Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16391
| Date | 2011-11-29 13:51 +0000 |
|---|---|
| From | Andrea Crotti <andrea.crotti.0@gmail.com> |
| Subject | Re: python 2.5 and ast |
| References | <4ED37475.3050709@gmail.com> <jb0pnp$a7i$1@dough.gmane.org> <4ED457C5.2020407@davea.name> <mailman.3121.1322560291.27778.python-list@python.org> <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3124.1322574694.27778.python-list@python.org> (permalink) |
On 11/29/2011 11:32 AM, Steven D'Aprano wrote: > > I prefer to check against sys.version. > > import sys > if sys.version<= '2.5': > from psi.devsonly.ast import parse, NodeVisitor > else: > from ast import parse, NodeVisitor > > > > Or even: > > > try: > from ast import parse, NodeVisitor > except ImportError: > from ast import parse, NodeVisitor > > > The try/except is probably the nicest... I've seen in other places using sys.version <=, but is it a good idea to rely on the fact that the <= on strings has the right semantic? After all that's just a string, version_info looks more correct to me..
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: python 2.5 and ast Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-11-29 09:51 +0000
Re: python 2.5 and ast Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-29 11:32 +0000
Re: python 2.5 and ast Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-11-29 13:51 +0000
Re: python 2.5 and ast Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-11-30 18:03 +0000
Re: python 2.5 and ast DevPlayer <devplayer@gmail.com> - 2011-12-02 07:18 -0800
Re: python 2.5 and ast Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-02 16:54 +0000
Re: python 2.5 and ast Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-02 17:01 +0000
csiph-web