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: 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: 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: 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: 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: References: 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: References: 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: References: Message-ID: 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: 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: References: 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: <4CE52099.7070002@egenix.com> Message-ID: On Thu, Nov 18, 2010 at 13:48, M.-A. Lemburg 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: References: Message-ID: 2010/11/18 Lennart 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. -- 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: References: Message-ID: On Thu, Nov 18, 2010 at 15:00, Benjamin Peterson wrote: > 2010/11/18 Lennart 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 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: <4CE52099.7070002@egenix.com> Message-ID: On Thu, Nov 18, 2010 at 7:48 AM, M.-A. Lemburg wrote: > you can use a negative lookahead: > > (?!bar\.)foo This is normally called a negative lookbehind, though. ? -Fred -- Fred L. Drake, Jr.? ? "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: References: <4CE52099.7070002@egenix.com> Message-ID: Am 18.11.2010 15:08, schrieb Fred Drake: > On Thu, Nov 18, 2010 at 7:48 AM, M.-A. Lemburg 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: References: <4CE52099.7070002@egenix.com> Message-ID: On Thu, Nov 18, 2010 at 9:33 AM, Georg Brandl 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.? ? "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: References: <4CE52099.7070002@egenix.com> Message-ID: On Thu, Nov 18, 2010 at 15:53, Fred Drake wrote: > On Thu, Nov 18, 2010 at 9:33 AM, Georg Brandl 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