Opened 14 years ago
Last modified 8 years ago
#9536 closed task
Remove Python 2.4 compatibility — at Version 3
Reported by: | Remy Blank | Owned by: | Remy Blank |
---|---|---|---|
Priority: | normal | Milestone: | 1.0 |
Component: | general | Version: | 0.13dev |
Severity: | normal | Keywords: | python25 |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
The goal of this task is to remove Python 2.4 compatibility code, and to start using Python 2.5-only features. See what's new in Python 2.5. This includes:
- Use context managers and the
with
statement for: database transactions, handling locks, handling files. - Use
... if ... else ...
expressions instead of the more error-prone... and ... or ...
. - Use
try: except: finally:
instead of nestedtry: finally:
andtry: except:
. - Use
except Exception:
instead ofexcept:
. - Remove our own implementations for functionality that was introduced in Python 2.5.
- Use generator expressions instead of list comprehensions where adequate.
- Use tuple arguments to
str.startswith()
andstr.endswith()
. - Use relative imports for parent, sibling and child modules?
Please add new items to this list as they pop up.
Change History (3)
comment:1 by , 14 years ago
Description: | modified (diff) |
---|---|
Keywords: | python25 added |
Version: | → 0.13dev |
comment:2 by , 14 years ago
- Use
... if ... else ...
expressions instead of the more error-prone... and ... or ...
.
Btw, Genshi supports this at least since the merge of the AST branch (see log:trunk/scripts/ast_generator.py) nearly 2 years ago, so we can also use that in templates (same thing for generator expressions).
comment:3 by , 14 years ago
Description: | modified (diff) |
---|
Copying items to the description, to get a nice overview. Keep 'em coming!
We should probably also start using except Exception:
instead of except:
.
What about using relative imports for parent, sibling and child modules (e.g. use from .api import ...
)? I wouldn't want to use relative imports for cross-package imports though.
The change concerning the context managers and the
with
statement mostly concerns the refactor transaction handling topic (#8751), as discussed in the googlegroups:trac-dev:4efe0b99b4e78d23 mail and follow-ups.But we could also use it for other things, like holding locks.
Slightly related, a few places could also benefit from the unification of try/except/finally.