On Tue, 5 Mar 2002 00:08:48 -0500 "Fred L. Drake, Jr." <fdrake@acm.org> wrote: > > Has anyone tried setting class attributes on a new-style > class in C? > The file sandbox/datetime/datetime.py has code that does > this: > > class datetime(basetime): > ... > > datetime.min = datetime(...) > datetime.max = datetime(...) Funny you should ask. Guido and I were just chatting about this problem this morning. I think we concluded that the cleanest way to add attributes to an extension type is to create a subclass in Python: import _datetime class datetime(_datetime): pass datetime.min = datetime(...) You can add attributes to the Python class in Python. If you really want to do it in C, take a look at Zope3's Persistence.cPersistence. After it calls PyType_Ready(), it adds items to the type's tp_dict slot. Jeremy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4