Zubin Mithra | 6 Nov 2010 16:34
Picon

"compiler" module in Python3k

Hello everyone!

I am currently working on porting a library over to Py3k and I am required to replace the compiler module as it does not exist in 3.1. I tried replacing the compiler module with the ast module, however that does not meet my requirements.

I need an analogue for compiler.parse.getChildren in Python3k. Any ideas? Thanks a lot.

Cheers!
Zubin
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Zubin Mithra | 6 Nov 2010 16:41
Picon

A few observations

Hello,


I have been reading a few blog posts here and there about various Arch users having problems with the recent Py3k transition. The good news is that quite a few of them have found a way to fix the problem and have been kind enough to blog about this.

I was wondering if we could have an aggregation of such posts(at least temporarily) for documenting such information so that we can help make the Python3 transition for a certain class of users easier.

Zubin
_______________________________________________
Python-porting mailing list
Python-porting@...
http://mail.python.org/mailman/listinfo/python-porting
Martin v. Löwis | 6 Nov 2010 16:55
Picon
Gravatar

Re: "compiler" module in Python3k

> I am currently working on porting a library over to Py3k and I am
> required to replace the compiler module as it does not exist in 3.1. I
> tried replacing the compiler module with the ast module, however that
> does not meet my requirements.
> 
> I need an analogue for compiler.parse.getChildren in Python3k. Any
> ideas? Thanks a lot.

Can you please generalize a little more what this code is trying to
achieve? Most likely, the _ast module will help, perhaps also lib2to3.

Regards,
Martin
Martin v. Löwis | 6 Nov 2010 16:57
Picon
Gravatar

Re: A few observations

> I have been reading a few blog posts here and there about various Arch
> users having problems with the recent Py3k transition. The good news is
> that quite a few of them have found a way to fix the problem and have
> been kind enough to blog about this.
> 
> I was wondering if we could have an aggregation of such posts(at least
> temporarily) for documenting such information so that we can help make
> the Python3 transition for a certain class of users easier.

In general, the answer to the question "do we have all information bits
on porting collected in one place" is "no".

>From time to time, motivated people have collected stuff in wiki pages,
but most certainly not about Arch.

Regards,
Martin
Georg Brandl | 6 Nov 2010 19:02
Picon
Gravatar

Re: "compiler" module in Python3k

Am 06.11.2010 16:34, schrieb Zubin Mithra:
> Hello everyone!
> 
> I am currently working on porting a library over to Py3k and I am required to
> replace the compiler module as it does not exist in 3.1. I tried replacing the
> compiler module with the ast module, however that does not meet my requirements.
> 
> I need an analogue for compiler.parse.getChildren in Python3k. Any ideas? Thanks
> a lot.

ast.iter_child_nodes together with ast.iter_fields seems to do what you need.

Georg

--

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
Lennart Regebro | 18 Nov 2010 12:49
Picon
Gravatar

Pattern help!?

I can't find a pattern that will match:
    foo
But not
    bar.foo

Any hints?

//Lennart
M.-A. Lemburg | 18 Nov 2010 13:48
Favicon

Re: Pattern help!?

Lennart Regebro wrote:
> I can't find a pattern that will match:
>     foo
> But not
>     bar.foo
> 
> Any hints?

Hi Lennart,

you can use a negative lookahead:

(?!bar\.)foo

--

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 18 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
Lennart Regebro | 18 Nov 2010 14:29
Picon
Gravatar

Re: Pattern help!?

On Thu, Nov 18, 2010 at 13:48, M.-A. Lemburg <mal@...> wrote:
> (?!bar\.)foo

Ah, sorry for wasting peoples time by not including enough context. My bad.

I'm looking for a patterns for making a fixer, not a regexp. :-)
Benjamin Peterson | 18 Nov 2010 15:00
Favicon
Gravatar

Re: Pattern help!?

2010/11/18 Lennart Regebro <regebro <at> gmail.com>:
> I can't find a pattern that will match:
>    foo
> But not
>    bar.foo
>
> Any hints?

It's usually best to do something like "is_probably_builtin" in
lib2to3/fixer_utils.py.

--

-- 
Regards,
Benjamin
_______________________________________________
Python-porting mailing list
Python-porting <at> python.org
http://mail.python.org/mailman/listinfo/python-porting
Lennart Regebro | 18 Nov 2010 15:03
Picon
Gravatar

Re: Pattern help!?

On Thu, Nov 18, 2010 at 15:00, Benjamin Peterson <benjamin@...> wrote:
> 2010/11/18 Lennart Regebro <regebro@...>:
>> I can't find a pattern that will match:
>>    foo
>> But not
>>    bar.foo
>>
>> Any hints?
>
> It's usually best to do something like "is_probably_builtin" in
> lib2to3/fixer_utils.py.

Ah, thanks! That's similar to what I did already, but I missed out on
this helper (as it's slightly weirdly named), and this one catches
several cases I didn't think of.

//Lennart

Gmane