Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16555

Re: python 2.5 and ast

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(using': 0.05; 'sys': 0.05; 'imports': 0.07; 'question:': 0.07; 'restarting': 0.07; 'python': 0.08; 'imported.': 0.09; 'parsing': 0.09; 'skip:\\ 20': 0.09; 'subject:python': 0.10; '2.7': 0.13; 'algorithm': 0.13; 'ast': 0.16; 'cache,': 0.16; 'pydoc': 0.16; 'cc:addr:python-list': 0.16; 'examples': 0.16; 'meant': 0.17; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'assume': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'says': 0.25; 'code': 0.25; 'helpful': 0.26; 'windows': 0.26; 'import': 0.27; '(and': 0.28; 'skip:" 30': 0.28; 'bit': 0.28; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'definition': 0.30; 'topic': 0.30; 'received:mail- bw0-f46.google.com': 0.30; 'typeerror:': 0.30; 'source': 0.31; "didn't": 0.31; 'actual': 0.32; 'received:209.85.214': 0.32; 'pretty': 0.32; 'message-id:@gmail.com': 0.33; 'header:User- Agent:1': 0.33; 'actually': 0.33; 'there': 0.33; 'object': 0.33; 'anything': 0.34; 'copied': 0.34; 'something': 0.35; 'google': 0.35; 'modules': 0.35; 'file': 0.36; 'opposed': 0.37; 'skip:" 10': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'received:10.0.0': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'tutorials': 0.39; 'finding': 0.39; 'ways': 0.39; 'talk': 0.39; "i'd": 0.39; 'help': 0.39; 'received:209': 0.40; 'computer.': 0.40; 'more': 0.61; 'your': 0.61; 'love': 0.62; 'forums': 0.77; '"all': 0.84; "'nonetype'": 0.84; 'node': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=9pffwz/HkMrktUcpKityU4H3Xks0GqHYVBNiiZlm7Lw=; b=ZXDGVmxqmIlvQIe5P/Dz2t3xv3puPzpOrFL0yqHywn1MXemXYBi/G8wbACCgu5l09K Ttka5x8TU5ihlm2TShN7OAjyn+Whe/v5/nf0VXB7rKUzY4jJ/Cuc6kXsz5RbtSsTXwhK tKBmp98d5syEsIuKo9950VPVq5fEGfcfVSvVI=
Date Fri, 02 Dec 2011 16:54:34 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111108 Thunderbird/8.0
MIME-Version 1.0
To DevPlayer <devplayer@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> <4ED4E35E.6090405@gmail.com> <mailman.3166.1322676221.27778.python-list@python.org> <4bbaa89c-55d2-40d1-91fb-cb00c3f2239a@s4g2000yqk.googlegroups.com>
In-Reply-To <4bbaa89c-55d2-40d1-91fb-cb00c3f2239a@s4g2000yqk.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3230.1322844878.27778.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1322844878 news.xs4all.nl 6879 [2001:888:2000:d::a6]:55717
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16555

Show key headers only | View raw


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 of finding all
> possible imports on a computer.
>
> By "unused imports" I assume you mean "all unused imports in the
> application's source code" as opposed to meaning "all unused modules/
> packages/libraries on that computer."
>
> Personally I'd love to see more tutorials on the AST module; An AST
> for Dummies. Pretty much the tutorials talk about parsing an
> expression like "1+2=3". But I'd like to see how blocks are compiled/
> managed by the indent/dedent tokens and how the complete algorithm for
> finding qouted strings is implimented (using really simple
> explanations).
>
> Some google buzzwords to help with your search for your question:  sys
> import cache, import hook, pydoc walkpackages().
>
> And I just found this little tool; never knew about it: C:\PythonXX
> \Tools\Scripts\pydocui.pyw
>

Yes I meant unused imports in each of the modules actually...
The problem for me is to actually understand what are all the possible
AST node that can involve the use of an actual import, and I didn't
find anything helpful aboupt that.

The ASDL definition says everything in theory but without some examples
is a bit hard.

I got something nice however:
http://stackoverflow.com/questions/8340567/python-ast-to-dot-graph/8342383#8342383

But on windows and Python 2.5 nothing is working :/, even if I blandly 
copied the
ast.py from the python 2.7 code file..

   File "h:\long\path\devsonly\ast.py", line 166, in iter_fields
     for field in node._fields:
TypeError: 'NoneType' object is not iterable

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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