[Python-Dev] Py2.6 ideas (original) (raw)
Josiah Carlson jcarlson at uci.edu
Wed Feb 21 05:20:52 CET 2007
- Previous message: [Python-Dev] A "record" type (was Re: Py2.6 ideas)
- Next message: [Python-Dev] Py2.6 ideas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Larry Hastings <larry at hastings.org> wrote:
For new code, I can't think of a single place I'd want to use a "NamedTuple" where a "record" wouldn't be arguably more suitable. The "NamedTuple" makes sense only for "fixing" old APIs like os.stat.
I disagree.
def add(v1, v2)
return Vector(i+j for i,j in izip(v1,v2))
x,y,z = point
And more are examples where not having a defined ordering (as would be the case with a 'static dict') would reduce its usefulness. Having a defined ordering (as is the case of lists and tuples) implies indexability (I want the ith item in this sequence!). It also allows one to use a NamedTuple without change otherwise anywhere you would have previously used a tuple (except for doctests, which would need to be changed). This was all discussed earlier.
- Josiah
- Previous message: [Python-Dev] A "record" type (was Re: Py2.6 ideas)
- Next message: [Python-Dev] Py2.6 ideas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]