[Python-ideas] Namespace creation with syntax short form

Andrew Barnert abarnert at yahoo.com
Sat Feb 14 01:18:47 CET 2015


On Feb 13, 2015, at 15:51, random832 at fastmail.us wrote:

> On Fri, Feb 13, 2015, at 17:16, Andrew Barnert wrote:
>> OK, that makes this seem even _less_ useful for the stat case.
>> 
>> The reasons to use namedtuple/structseq in the first place for stat are
>> (a) so existing code written to the original tuple interface can continue
>> to treat the value as a tuple while newer code can access the new
>> attributes that don't fit;
> 
> What I'm getting is: the reason to want a simple namespace syntax is to
> get people to stop returning tuples for stuff like this in the first
> place, so that there is no original tuple interface. The horse has
> already bolted for the stat case.

But (as Greg Ewing said better than me), I don't think there really is a common use case for this at all.

Have you ever, say, designed a 2D graphics package and decided to pass around 2-tuples instead of point objects just because it was too hard to create a Point class?

And yes, I realize that particular example sucks. But my point is that every example I can think of sucks, and neither the OP nor anyone else has thought of one that doesn't.

(And stat, in particular, is not a good example. It was added to a much simpler and weaker language than today's Python, and it was coded in C, not Python, so the reasons for its design aren't likely to be relevant here in the first place.)


More information about the Python-ideas mailing list