[Python-Dev] PEP: __source__ proposal
sxanth at ceid.upatras.gr
Sat Dec 4 10:02:26 CET 2004
> I'm opposed to this idea. It creates overhead in
> the size of .pyc files,
No it doesn't.
> for no additional value that couldn't be obtained otherwise.
I know it is possible to do all this with existing
python facilities. I did write such a dynamic code
framework in python. Specifically I used a function
'deyndef(code)' which was exactly like 'def' but also
stored the source string in a dictionary.
The key point is that I think think should be the
job of the parser and the functionality provided
at the interactive prompt w/o the user having to
write 'dyndef' or store the code of exec's or request
from himself to use specific commands to create
functions. It should be transparent built into python.
> A file is precisely the level of granularity that is
> burnt into the Python language. A module is *always* a file, executed
> from top to bottom. It is not possible to recreate the source code
> of a module if you have only the source code of all functions, and
> all classes.
That's exactly the rationale for NOT combining __source__
with import. It's in the PEP.
It appears that there are the 'module people' who
find this feature irrelevant. Indeed. If we are interested
in distributing modules and increasing the number of
people who use python programs,then __source__ is redundant.
OTOH, programming python is easy and fun and I think
the proposed feature will make it even more fun and it
aims in increasing the number of people who program
python for their every day tasks. It'd be interesting to
hear if the developers of IDLE/ipython/etc could use this.
Oh well. I guess I'm ahead of my time again:)
More information about the Python-Dev