Message188748
| Author |
eli.bendersky |
| Recipients |
eli.bendersky, ncoghlan |
| Date |
2013年05月09日.03:46:55 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1368071216.78.0.0822877752405.issue17941@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
[this came up as part of the Enum discussions. Full details in this thread: http://mail.python.org/pipermail/python-dev/2013-May/126076.html]
namedtuple currently uses this code to obtain the __module__ for the class it creates dynamically so that pickling works:
result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')
This may not work correctly on all Python implementations, for example IronPython.
To support some way to pickle on all implementations, namedtuple should support a fully qualified name for the class:
Point = namedtuple('mymodule.Point', ['x', 'y'])
If the name is a qualified dotted name, it will be split and the first part becomes the __module__. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2013年05月09日 03:46:56 | eli.bendersky | set | recipients:
+ eli.bendersky, ncoghlan |
| 2013年05月09日 03:46:56 | eli.bendersky | set | messageid: <1368071216.78.0.0822877752405.issue17941@psf.upfronthosting.co.za> |
| 2013年05月09日 03:46:56 | eli.bendersky | link | issue17941 messages |
| 2013年05月09日 03:46:55 | eli.bendersky | create |
|