[ python-Feature Requests-1324261 ] __name__ available during class dictionary build
SourceForge.net
noreply at sourceforge.net
Wed Oct 12 00:15:09 CEST 2005
Feature Requests item #1324261, was opened at 2005-10-12 01:15
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1324261&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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Adal Chiriliuc (adalx)
Assigned to: Nobody/Anonymous (nobody)
Summary: __name__ available during class dictionary build
Initial Comment:
It would be nice if __name__ would be defined in the
class block during it's construction. I have a code
generator which generates C-structure wrappers and this
would make it cleaner.
> class Test(object):
> print __name__
> #print locals()["__name__"] - this should also work
It should print "Test" and not the name of the current
module (global __main__).
I looked through the source code to see how this could
be implemented, but I don't understand exactly what's
going on and I'm afraid I'll broke something since the
class name is stored in a slot.
Here's some sample code I'm using. I could get rid of
the extra "MSG" parameter if this is implemented.
> from Structure import Structure
> from px.Structure.POINT import POINT
>
> # WinUser.h
> class MSG(object):
>
> _members = (
> ("HWND", "hwnd"),
> ("UINT", "message"),
> ("WPARAM", "wParam"),
> ("LPARAM", "lParam"),
> ("DWORD", "time"),
> (POINT, "pt"))
>
> Structure(globals(), locals(), "MSG")
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1324261&group_id=5470
More information about the Python-bugs-list
mailing list