[ python-Bugs-1739107 ] Bug assigning list comprehension to __slots__ in python 2.5
SourceForge.net
noreply at sourceforge.net
Mon Jun 18 17:21:57 CEST 2007
Bugs item #1739107, was opened at 2007-06-18 14:32
Message generated for change (Comment added) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Private: No
Submitted By: François Desloges (fdesloges)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug assigning list comprehension to __slots__ in python 2.5
Initial Comment:
I use the package 2.5-4.1mdv2007.1.i586 in mandriva.
I don't know if this has already been reported elsewhere but the following code:
a= ['C','D']
class A(object):
__slots__ = a + ['__'+name for name in a]
def __init(self, c, d):
self.__C = c
self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
a = A()
results is an a.name attribute with value 'D'.
But using :
b= tuple('C','D')
class B(object):
__slots__ = b + tuple('__'+name for name in b)
def __init(self, c, d):
self.__C = c
self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
b = B()
b appropriately do not have a b.name attribute.
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-18 15:21
Message:
Logged In: YES
user_id=849994
Originator: NO
Ah, strike my last comment.
This is not a bug, or at least not fixable, since list comprehensions do
leak their iteration
variable into the enclosing scope, while generator expressions don't.
They will stop doing this in Py3k.
----------------------------------------------------------------------
Comment By: Georg Brandl (gbrandl)
Date: 2007-06-18 15:20
Message:
Logged In: YES
user_id=849994
Originator: NO
Sorry, I can't follow you. Why should b have a "name" attribute?
Also, is it intentional that your __init is not named __init__?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470
More information about the Python-bugs-list
mailing list