On Fri, Dec 2, 2011 at 11:28 AM, 8 Dihedral
wrote:
> On Monday, November 28, 2011 7:45:57 PM UTC+8, Andrea Crotti wrote:
>> I'm happily using the ast module to analyze some code,
>> but my scripts need also to run unfortunately on python 2.5
>>
>> The _ast was there already, but the ast helper
On Monday, November 28, 2011 7:45:57 PM UTC+8, Andrea Crotti wrote:
> I'm happily using the ast module to analyze some code,
> but my scripts need also to run unfortunately on python 2.5
>
> The _ast was there already, but the ast helpers not yet.
> Is it ok if I just copy over the source from the
And on a related topic, how can I actually detect other types of
imports, for example
__import__
Doing a dump I get this:
In [113]: ast.dump(ast.parse('__import__("module")'))
Out[113]: "Module(body=[Expr(value=Call(func=Name(id='__import__',
ctx=Load()), args=[Str(s='module')], keywords=[], s
On 12/02/2011 03:18 PM, DevPlayer wrote:
There was another topic in these forums recently about "un-importing"
modules (and how you can not do that reliably without restarting
python). There was various ways mentioned of keeping track of what was
imported. And there was mentioned reasonable ways
On Nov 30, 1:03 pm, Andrea Crotti wrote:
> Another thing about the AST, I am having fun trying to for example list
> out all
> the unused imports.
>
> I have already a visitor which works quite nicely I think, but now I
> would like
> to get a way to find all the unused imports, so I need more vis
Another thing about the AST, I am having fun trying to for example list
out all
the unused imports.
I have already a visitor which works quite nicely I think, but now I
would like
to get a way to find all the unused imports, so I need more visitors that
find out all the used names.
I didn't f
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 ImportErr
On Tue, 29 Nov 2011 09:51:24 +, Andrea Crotti wrote:
> On 11/29/2011 03:55 AM, Dave Angel wrote:
>>
>> But don't forget to tag it as version specific, so it gets removed when
>> the later version of the library is available. There are various ways
>> of doing that, but the easiest is probably
On 29 November 2011 09:51, Andrea Crotti wrote:
> from sys import version_info
>
> if version_info[1] == 5:
> from psi.devsonly.ast import parse, NodeVisitor
> else:
> from ast import parse, NodeVisitor
Why don't you just:
try:
from ast import parse, NodeVisitor
except ImportError:
On 11/29/2011 03:55 AM, Dave Angel wrote:
But don't forget to tag it as version specific, so it gets removed
when the later version of the library is available. There are various
ways of doing that, but the easiest is probably to put a test in the
acceptance suite that fails if this code is
On 11/28/2011 03:08 PM, Terry Reedy wrote:
On 11/28/2011 6:45 AM, Andrea Crotti wrote:
I'm happily using the ast module to analyze some code,
but my scripts need also to run unfortunately on python 2.5
The _ast was there already, but the ast helpers not yet.
Is it ok if I just copy over the sou
On 11/28/2011 6:45 AM, Andrea Crotti wrote:
I'm happily using the ast module to analyze some code,
but my scripts need also to run unfortunately on python 2.5
The _ast was there already, but the ast helpers not yet.
Is it ok if I just copy over the source from the ast helpers in my code
base
T
I'm happily using the ast module to analyze some code,
but my scripts need also to run unfortunately on python 2.5
The _ast was there already, but the ast helpers not yet.
Is it ok if I just copy over the source from the ast helpers in my code base
or is there a smarter way?
(I don't even need al
13 matches
Mail list logo