[Tutor] when is a generator "smart?"
Oscar Benjamin
oscar.j.benjamin at gmail.com
Mon Jun 3 23:41:28 CEST 2013
On 3 June 2013 21:36, Jim Mooney <cybervigilante at gmail.com> wrote:
> So to clarify, the module names are the same on 2.7 and 3.3. Does that
> mean the module writers set the module so it will only install on the
> proper Py version, failing if it can't find it, so I don't have to
> think about that?
Maybe or maybe not. When you run 'python setup.py install' (this
happens implicitly when using pip), Python will try to run the
setup.py script. At this point the script can do anything that its
author likes. It could check for versions, it could just install and
be broken, it could delete random files or damage your system in a
malicious way. The author may have written the package at a time when
Python 3 didn't exist so they didn't see the need to check for Python
version and wrote code that wouldn't work in Python 3.
There is progress on improving this situation by formalising the
metadata that is supplied with Python packages so that it can be used
more effectively by tools such as pip. The current (unaccepted) PEP
for this is here (see the environment markers section):
http://www.python.org/dev/peps/pep-0426/
> Incidentally, for those nutty enough to run two Pys on Win, with Wing
> 101, I realized you can get Wing 101 to run either, without having to
> reconfigure it all the time, by setting up a Guest account in Windows,
> and configuring the second Wing for Py 3.3, run as Guest, with the
> primary as 2.7. This is helpful since some online sources I read are
> for one Py and some are for another.
If you have py.exe (which you should if you've installed Python 3.3 on
Windows) then you can run any installed Python version as 'py -2.7
myscript.py' or 'py -3.3 myscript.py' to choose the version of Python
that will run myscript.py. I find it easier and clearer to do that
explicitly on the command line when I want to test different versions.
Oscar
More information about the Tutor
mailing list