Wanted: a python24 package for Python 2.3

J

Jonathan Fine

Hello

My problem is that I want a Python 2.4 module on
a server that is running Python 2.3. I definitely
want to use the 2.4 module, and I don't want to
require the server to move to Python 2.4.

More exactly, I am using subprocess, which is
new in Python 2.4. What I am writing is something
like
===
from subprocess import Popen
===

This will fail in Python 2.3, in which case I
would like to write something like
===
try:
from subprocess import Popen
else ImportError:
from somewhere_else import Popen
===

Put this way, it is clear (to me) that somewhere_else
should be python24.

In other words, I'm asking for a python24 package that
contains all (or most) of the modules that are new to
Python 2.4.

I've looked around a bit, and it seems that this
formulation of the solution is new. I wonder if
anyone else has encountered this problem, or has
comments on my solution.
 
K

kyosohma

Hello

My problem is that I want a Python 2.4 module on
a server that is running Python 2.3. I definitely
want to use the 2.4 module, and I don't want to
require the server to move to Python 2.4.

More exactly, I am using subprocess, which is
new in Python 2.4. What I am writing is something
like
===
from subprocess import Popen
===

This will fail in Python 2.3, in which case I
would like to write something like
===
try:
from subprocess import Popen
else ImportError:
from somewhere_else import Popen
===

Put this way, it is clear (to me) that somewhere_else
should be python24.

In other words, I'm asking for a python24 package that
contains all (or most) of the modules that are new to
Python 2.4.

I've looked around a bit, and it seems that this
formulation of the solution is new. I wonder if
anyone else has encountered this problem, or has
comments on my solution.

You might be able to use the "from future import SomeModule" syntax to
accomplish this, but I am not sure. Other than that, I would just
recommend using the os.popen calls that are native to 2.3

Mike
 
G

Gerald Klix

Hi,
You can't import subproces from future, only syntactic and semantic
changes that will become standard feature in future python version can
be activated that way.

You can copy the subprocess module from python 2.4 somewhere where it
will be found from python 2.3. At least subporcess is importable after that:

--- snip ---
klix@vesuv6:~/ttt> cp -av /usr/local/lib/python2.4/subprocess.py .
»/usr/local/lib/python2.4/subprocess.py« -> »./subprocess.py«
klix@vesuv6:~/ttt> python2.3
Python 2.3.3 (#1, Jun 29 2004, 14:43:40)
[GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.--- snip ---

HTH,
Gerald
 
J

Jonathan Fine

You might be able to use the "from future import SomeModule" syntax to
accomplish this, but I am not sure. Other than that, I would just
recommend using the os.popen calls that are native to 2.3

I've already made my mind up. I want to use subprocess on
both 2.3 and 2.4. To do this, 2.3 sites have to have a copy
of the subprocess module.

My question (snipped) is how best to package this up.

best regards


Jonathan
 
J

Jonathan Fine

Alex said:
For subprocess specifically, see
<http://www.lysator.liu.se/~astrand/popen5/> .

Thanks for the URL.
I don't think anybody's
ever packaged up ALL the new stuff as you require.

Actually, all I require (for now) is subprocess. So
I went and made a python24 module. I'll change this
if people think something else would be better. (It's
easy to ask for forgiveness than ask for permission.)

I can show you what I've done:
http://texd.cvs.sourceforge.net/texd/py/python24/
http://texd.cvs.sourceforge.net/texd/py/tex/util.py?revision=1.4&view=markup

My idea is that python24 should contain the Python 2.4
modules that those who are still on Python 2.3 might
want to use.

Similarly, python26 would be modules that are new
for Python 2.6 (which has not been released next).

I doubt that I'm the only one with this problem, and
this is my suggestion for making it easier to solve.
 
D

Dennis Lee Bieber

J

Jonathan Fine

Gerald said:
Hi,
You can't import subproces from future, only syntactic and semantic
changes that will become standard feature in future python version can
be activated that way.

You can copy the subprocess module from python 2.4 somewhere where it
will be found from python 2.3. At least subporcess is importable after
that:

--- snip ---
klix@vesuv6:~/ttt> cp -av /usr/local/lib/python2.4/subprocess.py .
»/usr/local/lib/python2.4/subprocess.py« -> »./subprocess.py«
klix@vesuv6:~/ttt> python2.3
Python 2.3.3 (#1, Jun 29 2004, 14:43:40)
[GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

You're quite right about the use of __future__. I decided to
put subprocess in a package, so that my system can choose
which one to find, whether running Python 2.3 or 2.4.

(Well, in 2.3 there's no choice, but in 2.4 I don't want
the "just for 2.3" module to hide the real 2.4 module.)

The responses I've had indicate that my approach might
be a good idea, and might be useful to others. For me,
that's enough for now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top