From zubin.mithra at gmail.com  Sat Nov  6 16:34:51 2010
From: zubin.mithra at gmail.com (Zubin Mithra)
Date: Sat, 6 Nov 2010 21:04:51 +0530
Subject: [Python-porting] "compiler" module in Python3k
Message-ID: <AANLkTimeDqHVmxxuCqHJeZ1jbt2zeGQq=a5YbuBXQSSj@mail.gmail.com>

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20101106/88836058/attachment.html>

From zubin.mithra at gmail.com  Sat Nov  6 16:41:29 2010
From: zubin.mithra at gmail.com (Zubin Mithra)
Date: Sat, 6 Nov 2010 21:11:29 +0530
Subject: [Python-porting] A few observations
Message-ID: <AANLkTi=MMw5Od7bmS2iO+1QDdgYspPpdqHALLLXufAD8@mail.gmail.com>

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20101106/cfcedd05/attachment.html>

From martin at v.loewis.de  Sat Nov  6 16:55:13 2010
From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=)
Date: Sat, 06 Nov 2010 16:55:13 +0100
Subject: [Python-porting] "compiler" module in Python3k
In-Reply-To: <AANLkTimeDqHVmxxuCqHJeZ1jbt2zeGQq=a5YbuBXQSSj@mail.gmail.com>
References: <AANLkTimeDqHVmxxuCqHJeZ1jbt2zeGQq=a5YbuBXQSSj@mail.gmail.com>
Message-ID: <4CD57A61.1000608@v.loewis.de>

> 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

From martin at v.loewis.de  Sat Nov  6 16:57:04 2010
From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=)
Date: Sat, 06 Nov 2010 16:57:04 +0100
Subject: [Python-porting] A few observations
In-Reply-To: <AANLkTi=MMw5Od7bmS2iO+1QDdgYspPpdqHALLLXufAD8@mail.gmail.com>
References: <AANLkTi=MMw5Od7bmS2iO+1QDdgYspPpdqHALLLXufAD8@mail.gmail.com>
Message-ID: <4CD57AD0.2080507@v.loewis.de>

> 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

From g.brandl at gmx.net  Sat Nov  6 19:02:56 2010
From: g.brandl at gmx.net (Georg Brandl)
Date: Sat, 06 Nov 2010 19:02:56 +0100
Subject: [Python-porting] "compiler" module in Python3k
In-Reply-To: <AANLkTimeDqHVmxxuCqHJeZ1jbt2zeGQq=a5YbuBXQSSj@mail.gmail.com>
References: <AANLkTimeDqHVmxxuCqHJeZ1jbt2zeGQq=a5YbuBXQSSj@mail.gmail.com>
Message-ID: <ib45aq$il9$1@dough.gmane.org>

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.


From regebro at gmail.com  Thu Nov 18 12:49:22 2010
From: regebro at gmail.com (Lennart Regebro)
Date: Thu, 18 Nov 2010 12:49:22 +0100
Subject: [Python-porting] Pattern help!?
Message-ID: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>

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

Any hints?

//Lennart

From mal at egenix.com  Thu Nov 18 13:48:25 2010
From: mal at egenix.com (M.-A. Lemburg)
Date: Thu, 18 Nov 2010 13:48:25 +0100
Subject: [Python-porting] Pattern help!?
In-Reply-To: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
Message-ID: <4CE52099.7070002@egenix.com>

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/

From regebro at gmail.com  Thu Nov 18 14:29:59 2010
From: regebro at gmail.com (Lennart Regebro)
Date: Thu, 18 Nov 2010 14:29:59 +0100
Subject: [Python-porting] Pattern help!?
In-Reply-To: <4CE52099.7070002@egenix.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
	<4CE52099.7070002@egenix.com>
Message-ID: <AANLkTinB97S-hvU5H3TfxsKTB33WzE6i=K4Zb_onxdd6@mail.gmail.com>

On Thu, Nov 18, 2010 at 13:48, M.-A. Lemburg <mal at egenix.com> 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. :-)

From benjamin at python.org  Thu Nov 18 15:00:21 2010
From: benjamin at python.org (Benjamin Peterson)
Date: Thu, 18 Nov 2010 08:00:21 -0600
Subject: [Python-porting] Pattern help!?
In-Reply-To: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
Message-ID: <AANLkTi=wq8bs6Uas50pqTQObwWb=r3ZEeTAiSG4aXEdo@mail.gmail.com>

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

From regebro at gmail.com  Thu Nov 18 15:03:21 2010
From: regebro at gmail.com (Lennart Regebro)
Date: Thu, 18 Nov 2010 15:03:21 +0100
Subject: [Python-porting] Pattern help!?
In-Reply-To: <AANLkTi=wq8bs6Uas50pqTQObwWb=r3ZEeTAiSG4aXEdo@mail.gmail.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
	<AANLkTi=wq8bs6Uas50pqTQObwWb=r3ZEeTAiSG4aXEdo@mail.gmail.com>
Message-ID: <AANLkTinMsBKH6N36QEfURee4t89K8ozcYutrefD-ThL7@mail.gmail.com>

On Thu, Nov 18, 2010 at 15:00, Benjamin Peterson <benjamin at python.org> wrote:
> 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.

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

From fdrake at acm.org  Thu Nov 18 15:08:24 2010
From: fdrake at acm.org (Fred Drake)
Date: Thu, 18 Nov 2010 09:08:24 -0500
Subject: [Python-porting] Pattern help!?
In-Reply-To: <4CE52099.7070002@egenix.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
	<4CE52099.7070002@egenix.com>
Message-ID: <AANLkTimmrxEnKLR9j_1nEtBThH-rtskF0qtUXiQ9B14M@mail.gmail.com>

On Thu, Nov 18, 2010 at 7:48 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> you can use a negative lookahead:
>
> (?!bar\.)foo

This is normally called a negative lookbehind, though.


? -Fred

--
Fred L. Drake, Jr.? ? <fdrake at acm.org>
"A storm broke loose in my mind."? --Albert Einstein

From g.brandl at gmx.net  Thu Nov 18 15:33:17 2010
From: g.brandl at gmx.net (Georg Brandl)
Date: Thu, 18 Nov 2010 15:33:17 +0100
Subject: [Python-porting] Pattern help!?
In-Reply-To: <AANLkTimmrxEnKLR9j_1nEtBThH-rtskF0qtUXiQ9B14M@mail.gmail.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>	<4CE52099.7070002@egenix.com>
	<AANLkTimmrxEnKLR9j_1nEtBThH-rtskF0qtUXiQ9B14M@mail.gmail.com>
Message-ID: <ic3did$9ip$1@dough.gmane.org>

Am 18.11.2010 15:08, schrieb Fred Drake:
> On Thu, Nov 18, 2010 at 7:48 AM, M.-A. Lemburg <mal at egenix.com> wrote:
>> you can use a negative lookahead:
>>
>> (?!bar\.)foo
> 
> This is normally called a negative lookbehind, though.

Both are slightly wrong: what Marc gave is a lookahead, but
ISTM he *should* have given a lookbehind :)

Georg


From fdrake at acm.org  Thu Nov 18 15:53:01 2010
From: fdrake at acm.org (Fred Drake)
Date: Thu, 18 Nov 2010 09:53:01 -0500
Subject: [Python-porting] Pattern help!?
In-Reply-To: <ic3did$9ip$1@dough.gmane.org>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
	<4CE52099.7070002@egenix.com>
	<AANLkTimmrxEnKLR9j_1nEtBThH-rtskF0qtUXiQ9B14M@mail.gmail.com>
	<ic3did$9ip$1@dough.gmane.org>
Message-ID: <AANLkTinsxYkD=RgMmNm5-XG7fG7_K2+o2uT+3KcqL1Zg@mail.gmail.com>

On Thu, Nov 18, 2010 at 9:33 AM, Georg Brandl <g.brandl at gmx.net> wrote:
> Both are slightly wrong: what Marc gave is a lookahead, but
> ISTM he *should* have given a lookbehind :)

Which shows how often I don't use either.  :-)  Sorry for the
misinformation, Lennart!


? -Fred

--
Fred L. Drake, Jr.? ? <fdrake at acm.org>
"A storm broke loose in my mind."? --Albert Einstein

From regebro at gmail.com  Thu Nov 18 17:29:30 2010
From: regebro at gmail.com (Lennart Regebro)
Date: Thu, 18 Nov 2010 17:29:30 +0100
Subject: [Python-porting] Pattern help!?
In-Reply-To: <AANLkTinsxYkD=RgMmNm5-XG7fG7_K2+o2uT+3KcqL1Zg@mail.gmail.com>
References: <AANLkTikJUZvbXJyLijAh3AJ8cS+kOs5f6DQbyKA5=emg@mail.gmail.com>
	<4CE52099.7070002@egenix.com>
	<AANLkTimmrxEnKLR9j_1nEtBThH-rtskF0qtUXiQ9B14M@mail.gmail.com>
	<ic3did$9ip$1@dough.gmane.org>
	<AANLkTinsxYkD=RgMmNm5-XG7fG7_K2+o2uT+3KcqL1Zg@mail.gmail.com>
Message-ID: <AANLkTi=GzMj=Xaue+OsvpdNPqbve3nOEGaSDaG0VPn65@mail.gmail.com>

On Thu, Nov 18, 2010 at 15:53, Fred Drake <fdrake at acm.org> wrote:
> On Thu, Nov 18, 2010 at 9:33 AM, Georg Brandl <g.brandl at gmx.net> wrote:
>> Both are slightly wrong: what Marc gave is a lookahead, but
>> ISTM he *should* have given a lookbehind :)
>
> Which shows how often I don't use either. ?:-) ?Sorry for the
> misinformation, Lennart!

This feels like a good example of why I avoid regexps. :-)

//Lennart