Re: [Python-Dev] Assignment to None

2008-06-12 Thread Curt Hagenlocher
On Thu, Jun 12, 2008 at 8:06 PM, Frank Wierzbicki <[EMAIL PROTECTED]> wrote: > > On Wed, Jun 11, 2008 at 5:27 PM, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > > If I recall correctly, Jython handles this by appending a trailing > > underscore to the imported name and there's no reason why we could

Re: [Python-Dev] Assignment to None

2008-06-12 Thread Frank Wierzbicki
On Wed, Jun 11, 2008 at 5:27 PM, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > If I recall correctly, Jython handles this by appending a trailing > underscore to the imported name and there's no reason why we couldn't > do something similar. In truth the current implementation of Jython allows keyw

Re: [Python-Dev] Assignment to None

2008-06-12 Thread Leif Walsh
On Thu, Jun 12, 2008 at 10:28 AM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > That makes about as much sense as wanting to support a.42 = b since > a[42] = b works. :-) Well don't I feel silly now. -- Cheers, Leif ___ Python-Dev mailing list Python-D

Re: [Python-Dev] Assignment to None

2008-06-12 Thread Guido van Rossum
On Thu, Jun 12, 2008 at 10:13 AM, Leif Walsh <[EMAIL PROTECTED]> wrote: > I haven't been following this thread very closely, so I'm not sure > what the status is, but I'd just like to point out that yesterday I > used the fact that a[None] = b works, when I used the @memoize > decorator from the wi

Re: [Python-Dev] Assignment to None

2008-06-12 Thread Leif Walsh
I haven't been following this thread very closely, so I'm not sure what the status is, but I'd just like to point out that yesterday I used the fact that a[None] = b works, when I used the @memoize decorator from the wiki. This seems to provide an argument that, for symmetry's sake, we might want

Re: [Python-Dev] Assignment to None

2008-06-12 Thread Nick Coghlan
Curt Hagenlocher wrote: If I recall correctly, Jython handles this by appending a trailing underscore to the imported name and there's no reason why we couldn't do something similar. It also has the virtue of being the common convention for attribute names that shadow keywords even in CPython

Re: [Python-Dev] Assignment to None

2008-06-11 Thread Curt Hagenlocher
On Sun, Jun 8, 2008 at 10:19 PM, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > > So, it's okay to setattr the attribute name "None" but not okay to set > > it directly? Is this deliberate or is it an unintentional side effect > > of parser changes to prevent assignment to None? > > It's deliber

Re: [Python-Dev] Assignment to None

2008-06-11 Thread Nick Coghlan
Thomas Lee wrote: Martin v. Löwis wrote: In Python 3, None, True, and False are keywords, so clearly, the intended semantics is also the implemented one (and the language description for 2.x needs to be updated/clarified). Interestingly enough, the semantics of True, False and None are diff

Re: [Python-Dev] Assignment to None

2008-06-10 Thread Georg Brandl
Thomas Lee schrieb: What happened in 3k? Were the constants in xmlrpclib renamed/removed? They were removed, as there is no way they can be accessed as attributes of a module now. Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.

Re: [Python-Dev] Assignment to None

2008-06-10 Thread Thomas Lee
Martin v. Löwis wrote: The question is, what is the specification for Python. Now, that's a more interesting question than the question originally asked (which I interpreted as "why does it work the way it works"). The only indication in the specification of that feature I could find was:

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Terry Reedy
""Martin v. Löwis"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |> At the global level, the subversion does not work: | | I think you are misinterpreting what you are seeing. No, you didn't understand the code I posted which explicitely demonstrated the same point you repeated.

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Martin v. Löwis
> The question is, what is the specification for Python. Now, that's a more interesting question than the question originally asked (which I interpreted as "why does it work the way it works"). The only indication in the specification of that feature I could find was: http://docs.python.org/dev/

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Martin v. Löwis
> At the global level, the subversion does not work: I think you are misinterpreting what you are seeing. When you refer to the global identifier None, the compiler just knows that it must be the NoneType singleton, and returns it as a constant, without doing any name lookup. So it isn't that assi

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Terry Reedy
"Tony Nelson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | At 4:46 PM +0100 6/9/08, Michael Foord wrote: | Or perhaps CPython should just stop trying to detect this at compile time. | Note that while assignment to ".None" is not allowed, setattr(foo, "None", | 1) then referenci

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Gisle Aas
On Jun 9, 2008, at 17:12, Alex Martelli wrote: The problem is more general: what if a member (of some external object we're proxying one way or another) is named print (in Python < 3), or class, or...? To allow foo.print or bar.class would require pretty big changes to Python's parser I simp

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Thomas Lee
Tony Nelson wrote: At 4:46 PM +0100 6/9/08, Michael Foord wrote: Alex Martelli wrote: The problem is more general: what if a member (of some external object we're proxying one way or another) is named print (in Python < 3), or class, or...? To allow foo.print or bar.class would requir

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Tony Nelson
At 4:46 PM +0100 6/9/08, Michael Foord wrote: >Alex Martelli wrote: >> The problem is more general: what if a member (of some external >> object we're proxying one way or another) is named print (in Python < >> 3), or class, or...? To allow foo.print or bar.class would require >> pretty big chang

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Michael Foord
Alex Martelli wrote: The problem is more general: what if a member (of some external object we're proxying one way or another) is named print (in Python < 3), or class, or...? To allow foo.print or bar.class would require pretty big changes to Python's parser -- I have vague memories that the i

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Alex Martelli
The problem is more general: what if a member (of some external object we're proxying one way or another) is named print (in Python < 3), or class, or...? To allow foo.print or bar.class would require pretty big changes to Python's parser -- I have vague memories that the issue was discussed ages

Re: [Python-Dev] Assignment to None

2008-06-09 Thread Michael Foord
Steven D'Aprano wrote: On Mon, 9 Jun 2008 12:24:55 pm Curt Hagenlocher wrote: So, it's okay to setattr the attribute name "None" but not okay to set it directly? I suspect this is off-topic for python-dev, and would be better on comp.lang.python or similar, but for what it's worth,

Re: [Python-Dev] Assignment to None

2008-06-08 Thread Martin v. Löwis
> So, it's okay to setattr the attribute name "None" but not okay to set > it directly? Is this deliberate or is it an unintentional side effect > of parser changes to prevent assignment to None? It's deliberate. setattr(o, "foo bar", "baz") also works, even though "foo bar" is not an identifier.

Re: [Python-Dev] Assignment to None

2008-06-08 Thread Steven D'Aprano
On Mon, 9 Jun 2008 12:24:55 pm Curt Hagenlocher wrote: > So, it's okay to setattr the attribute name "None" but not okay to > set it directly?   I suspect this is off-topic for python-dev, and would be better on comp.lang.python or similar, but for what it's worth, I consider having an attribu

Re: [Python-Dev] Assignment to None

2008-06-08 Thread Benjamin Peterson
On Sun, Jun 8, 2008 at 9:24 PM, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > My apologies if this is one of those "dead horse" issues. The > following seems a little inconsistent to me: > c = C() c.None > Traceback (most recent call last): > File "", line 1, in > AttributeError: C ins

[Python-Dev] Assignment to None

2008-06-08 Thread Curt Hagenlocher
My apologies if this is one of those "dead horse" issues. The following seems a little inconsistent to me: >>> c = C() >>> c.None Traceback (most recent call last): File "", line 1, in AttributeError: C instance has no attribute 'None' >>> c.None = 'foo' File "", line 1 SyntaxError: assignme