Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'sys': 0.05; 'importerror:': 0.07; 'subject:python': 0.10; 'ast': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'header:In-Reply- To:1': 0.22; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'import': 0.27; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'cc:2**2': 0.34; 'try:': 0.34; 'except': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'why': 0.39; 'received:209': 0.40; '2011': 0.61; 'andrea': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=eKXuJDhHEGaMWKh1bM8YIq6ruph/8E1K95g9dYnc43I=; b=KwY2h126EXw3Aml+cW5hWH9HjN8sVClLCZGza7Fdh5zLDP+TpnMeVj5KBXRKOuvKR7 RBQ2fhndpjWI4B02uasMhfN4L1VTFUkoTA7Z4il+prWVI9eMUS3b10nFsytkyTbzPLQS tjO1brI5nz2xtPBkJmgHoWq0lbzpRs4n4XcHA= MIME-Version: 1.0 In-Reply-To: <4ED4AB1C.3080609@gmail.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ED4AB1C.3080609@gmail.com> Date: Tue, 29 Nov 2011 10:11:06 +0000 Subject: Re: python 2.5 and ast From: Arnaud Delobelle To: Andrea Crotti Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org, d@davea.name, Terry Reedy X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322561470 news.xs4all.nl 6971 [2001:888:2000:d::a6]:56216 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16386 On 29 November 2011 09:51, Andrea Crotti wrote: > from sys import version_info > > if version_info[1] =3D=3D 5: > =C2=A0 =C2=A0from psi.devsonly.ast import parse, NodeVisitor > else: > =C2=A0 =C2=A0from ast import parse, NodeVisitor Why don't you just: try: from ast import parse, NodeVisitor except ImportError: from psi.devsonly.ast import parse, NodeVisitor --=20 Arnaud