Bugs item #1539847, was opened at 2006-08-14 07:47 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1539847&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.4 >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: W Barnes (w_barnes) Assigned to: Nobody/Anonymous (nobody) Summary: Identifiers begining with __ renamed Initial Comment: Identifiers used in a class function that start with __ are renamed to _classname__identifer even if the identifier is owned by some other object. Code snippet: size = len(Data.__entry_dates) Here I'm trying to access the identifier __entry_dates in the module Data from the function DataTestCase.testEntryDates() but I get the following: Traceback (most recent call last): File "DataTest.py", line 247, in testEntryDates size = len(Data.__entry_dates) AttributeError: 'module' object has no attribute '_DataTestCase__entry_dates' I'm using Python 2.4.3 on Windows XP sp2 Thanks, Walter ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2006-08-14 08:07 Message: Logged In: YES user_id=849994 This is exactly how __ name mangling is supposed to work. These are meant to be private, and thus shouldn't be accessed from another class. If the attribute was in another class, you could do the mangling (with the correct class name!) yourself, as it's on a module in this case, use __dict__: size = len(Data.__dict__['__entry_dates']) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1539847&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com