Re: [regex] How to check for non-space character?

2009-03-22 Thread Gilles Ganault
On Sat, 21 Mar 2009 08:53:10 -0500, Tim Chase wrote: >It looks like it's these periods that are throwing you off. Just >remove them. For a 3rd syntax: > >(\S)(\d{5}) > >the \S (capital, instead of "\s") is "any NON-white-space character" Thanks guys for the tips. -- http://mail.python.org/

Re: default shelve on linux corrupts, does different DB system help?

2009-03-22 Thread Paul Sijben
Thanks very much for a clear and concise explanation of the problem and the solution! I am implementing it now in my system. Luckily we caught this one during testing so no important data has been lost. Unfortunately windows does not seem to support gdbm. But in our case, everything that is on th

Re: [ANN] lxml 2.2 released

2009-03-22 Thread Francesco Guerrieri
On Sat, Mar 21, 2009 at 5:22 PM, Stefan Behnel wrote: > Hi all, > > I'm proud to announce the release of lxml 2.2 final. > > http://codespeak.net/lxml/ > http://pypi.python.org/pypi/lxml/2.2 > > Changelog: > http://codespeak.net/lxml/changes-2.2.html > Great news! I have relied on lxml in many o

Re: simplejson: alternate encoder not called enought

2009-03-22 Thread Chris Rebert
On Sat, Mar 21, 2009 at 2:11 PM, Pierre Hanser wrote: > hello > > I'm trying to use simplejson to encode some > python objects using simplejson dumps method. > > The dumps method accept a cls parameter to specify > an alternate encoder. But it seems that this alternate > encoder is called only as

Re: Async serial communication/threads sharing data

2009-03-22 Thread Nick Timkovich
On Mar 21, 9:19 pm, Jean-Paul Calderone wrote: > On Sat, 21 Mar 2009 13:52:21 -0700 (PDT), Nick Timkovich > wrote: > >I've been working on a program that will talk to an embedded device > >over the serial port, using some basic binary communications with > >messages 4-10 bytes long or so.  Most

Re: Safe to call Py_Initialize() frequently?

2009-03-22 Thread Graham Dumpleton
On Mar 21, 2:35 pm, roschler wrote: > On Mar 20, 7:27 pm, Mark Hammond wrote: > > > On 21/03/2009 4:20 AM, roschler wrote: > > > Calling Py_Initialize() multiple times has no effect.  Calling > > Py_Initialize and Py_Finalize multiple times does leak (Python 3 has > > mechanisms so this need to a

Re: __init__ vs. __del__

2009-03-22 Thread David Stanek
2009/3/21 Randy Turner : > There are a number of use-cases for object "cleanup" that are not covered by > a generic garbage collector... > > For instance, if an object is "caching" data that needs to be flushed to > some persistent resource, then the GC has > no idea about this. > > It seems to be

Re: script files with python (instead of tcsh/bash)?

2009-03-22 Thread Nick Craig-Wood
Esmail wrote: > I am wondering if anyone is using python to write script files? Yes! > Right now I have a bigg'ish bash/tcsh script that contain some grep/awk > command plus various files are processed and created, renamed and > moved to specific directories. I also write out some gnuplot sc

Generator

2009-03-22 Thread mattia
Can you explain me this behaviour: >>> s = [1,2,3,4,5] >>> g = (x for x in s) >>> next(g) 1 >>> s [1, 2, 3, 4, 5] >>> del s[0] >>> s [2, 3, 4, 5] >>> next(g) 3 >>> Why next(g) doesn't give me 2? -- http://mail.python.org/mailman/listinfo/python-list

Re: Async serial communication/threads sharing data

2009-03-22 Thread Jean-Paul Calderone
On Sun, 22 Mar 2009 03:13:36 -0700 (PDT), Nick Timkovich wrote: On Mar 21, 9:19 pm, Jean-Paul Calderone wrote: On Sat, 21 Mar 2009 13:52:21 -0700 (PDT), Nick Timkovich wrote: >I've been working on a program that will talk to an embedded device >over the serial port, using some basic binary

Re: script files with python (instead of tcsh/bash)?

2009-03-22 Thread Esmail
Nick Craig-Wood wrote: Esmail wrote: I am wondering if anyone is using python to write script files? Yes! <..> Almost any script that contains a loop I convert into python. In any case, the scripts are starting to look pretty hairy and I was wondering if it would make sense to re-wri

Re: Generator

2009-03-22 Thread MRAB
mattia wrote: Can you explain me this behaviour: s = [1,2,3,4,5] g = (x for x in s) next(g) 1 s [1, 2, 3, 4, 5] del s[0] s [2, 3, 4, 5] next(g) 3 Why next(g) doesn't give me 2? First it yields s[0] (which is 1), then you delete s[1], then it yields s[1] (which is now 3). It doesn't yi

Re: script files with python (instead of tcsh/bash)?

2009-03-22 Thread MRAB
Esmail wrote: Nick Craig-Wood wrote: Esmail wrote: I am wondering if anyone is using python to write script files? Yes! <..> Almost any script that contains a loop I convert into python. In any case, the scripts are starting to look pretty hairy and I was wondering if it would make

Re: default shelve on linux corrupts, does different DB system help?

2009-03-22 Thread skip
Paul> Unfortunately windows does not seem to support gdbm. That is a known issue, but one that can be solved I think by getting rid of the old 1.85 version of BerkDB and using something more modern. I believe the current bsddb module in recent Python versions supports BerkDB 3.x and 4.x. Sl

Using python 3 for scripting?

2009-03-22 Thread Timo Myyrä
Hi, I'll have to do some scripting in the near future and I was thinking on using the Python for it. I would like to know which version of Python to use? Is the Python 3 ready for use or should I stick with older releases? Timo -- http://mail.python.org/mailman/listinfo/python-list

Re: garbage collection / cyclic references

2009-03-22 Thread Aaron Brady
On Mar 21, 11:59 am, "andrew cooke" wrote: > Aaron Brady wrote: > > My point is, that garbage collection is able to detect when there are > > no program-reachable references to an object.  Why not notify the > > programmer (the programmer's objects) when that happens?  If the > > object does still

Re: Tkinter book on current versions

2009-03-22 Thread Mike Driscoll
Hi, On Fri, Mar 20, 2009 at 10:14 PM, Paul Watson wrote: > Has anyone tried the Grayson book, "Python and Tkinter Programming," > with a recent version of Python? > > The first example code (calculator) generates a single row of buttons. > Perhaps I have not applied the errata correctly.  Has any

How Get Name Of Working File

2009-03-22 Thread Victor Subervi
Hi; If I am writing a script that generates HTML, how do I grab the name of the actual file in which I am working? For example, let us say I am working in test.py. I can have the following code: import os dir = os.getcwd() and that will give me the working dir. But what about "test.py"? TIA, Vict

Re: How Get Name Of Working File

2009-03-22 Thread Christian Heimes
Victor Subervi schrieb: > Hi; > If I am writing a script that generates HTML, how do I grab the name of the > actual file in which I am working? For example, let us say I am working in > test.py. I can have the following code: > > import os > dir = os.getcwd() > > and that will give me the workin

Script for a project inside own directory

2009-03-22 Thread Filip Gruszczyński
I am having a project built like this: project module1.py module2.py packages1/ module3.py etc. I have script that uses objects from those modules/packages. If I keep this script inside project directory it's ok and it works. But I would like to move it to own scripts directory and

Re: Script for a project inside own directory

2009-03-22 Thread Maxim Khitrov
2009/3/22 Filip Gruszczyński : > I am having a project built like this: > > project >   module1.py >   module2.py >   packages1/ >     module3.py > > etc. > > I have script that uses objects from those modules/packages. If I keep > this script inside project directory it's ok and it works. But I wo

Re: How Get Name Of Working File

2009-03-22 Thread Maxim Khitrov
On Sun, Mar 22, 2009 at 10:58 AM, Christian Heimes wrote: > Victor Subervi schrieb: >> Hi; >> If I am writing a script that generates HTML, how do I grab the name of the >> actual file in which I am working? For example, let us say I am working in >> test.py. I can have the following code: >> >> i

3.0 - bsddb removed

2009-03-22 Thread Sean
Anyone got any thoughts about what to use as a replacement. I need something (like bsddb) which uses dictionary syntax to read and write an underlying (fast!) btree or similar. Thanks. Sean -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python 3 for scripting?

2009-03-22 Thread mahesh
python 2.5 is prefered; On Mar 22, 7:22 pm, timo.my...@gmail.com (Timo Myyrä) wrote: > Hi, > > I'll have to do some scripting in the near future and I was > thinking on using the Python for it. I would like to know which > version of Python to use? Is the Python 3 ready for use or should > I stic

Re: 3.0 - bsddb removed

2009-03-22 Thread Albert Hopkins
On Sun, 2009-03-22 at 15:55 +, Sean wrote: > Anyone got any thoughts about what to use as a replacement. I need > something (like bsddb) which uses dictionary syntax to read and write an > underlying (fast!) btree or similar. > gdbm -- http://mail.python.org/mailman/listinfo/python-list

Script for a project inside own directory

2009-03-22 Thread R. David Murray
=?UTF-8?Q?Filip_Gruszczy=C5=84ski?= wrote: > I am having a project built like this: > > project >module1.py >module2.py >packages1/ > module3.py > > etc. > > I have script that uses objects from those modules/packages. If I keep > this script inside project directory it's ok an

Re: 3.0 - bsddb removed

2009-03-22 Thread Benjamin Peterson
Sean att.net> writes: > > Anyone got any thoughts about what to use as a replacement. I need > something (like bsddb) which uses dictionary syntax to read and write an > underlying (fast!) btree or similar. pybsddb is just not included in the core. It's still distributed separately. http://w

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sat, 21 Mar 2009 23:58:07 -0300, escribió: ''' A python 3 question. Presume this code is in file p.py. The program fails. $ python3 p.py ... ValueError: I/O operation on closed file. Removing the comment character to increase the stream reference

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Fri, 20 Mar 2009 23:16:00 -0300, alex goretoy escribió: i looks at lambdas as unbound functions(or super function), in the case above we create the functions in a list places it in memory unboud, once binding a call to the memory address space it returns the value it is basically same as do

Re: Script for a project inside own directory

2009-03-22 Thread Benjamin Peterson
Filip Gruszczyński gmail.com> writes: > I would like to ask if there is any workaround? Use the runpy module. -- http://mail.python.org/mailman/listinfo/python-list

Using python 3 for scripting?

2009-03-22 Thread R. David Murray
timo.my...@gmail.com (Timo =?utf-8?Q?Myyr=C3=A4?=) wrote: > Hi, > > I'll have to do some scripting in the near future and I was > thinking on using the Python for it. I would like to know which > version of Python to use? Is the Python 3 ready for use or should > I stick with older releases? I

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
corning.com> writes: > Please, what is a better way to write the class with > regard to this issue? Set the original TextIOWrapper's buffer to None. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python 3 for scripting?

2009-03-22 Thread Chris Rebert
2009/3/22 Timo Myyrä : > Hi, > > I'll have to do some scripting in the near future and I was thinking on using > the Python for it. I would like to know which version of Python to use? Is > the Python 3 ready for use or should I stick with older releases? 2.6.1, the latest non-3.x release is pro

Re: script files with python (instead of tcsh/bash)?

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 11:05:22 -0300, MRAB escribió: Esmail wrote: Nick Craig-Wood wrote: Esmail wrote: I am wondering if anyone is using python to write script files? Two quick questions: As a replacement for grep I would use the re module and its methods? Perhaps; but strings have m

regular expressions, stack and nesting

2009-03-22 Thread Aaron Brady
Hi, Every so often the group gets a request for parsing an expression. I think it would be significantly easier to do if regular expressions could modify a stack. However, since you might nearly as well write Python, maybe there is a compromise. Could the Secret Labs' regular expression engine

Re: Script for a project inside own directory

2009-03-22 Thread Filip Gruszczyński
Works great. Thanks a lot. 2009/3/22 Maxim Khitrov : > 2009/3/22 Filip Gruszczyński : >> I am having a project built like this: >> >> project >>   module1.py >>   module2.py >>   packages1/ >>     module3.py >> >> etc. >> >> I have script that uses objects from those modules/packages. If I keep >>

Generator

2009-03-22 Thread R. David Murray
mattia wrote: > Can you explain me this behaviour: > > >>> s = [1,2,3,4,5] > >>> g = (x for x in s) > >>> next(g) > 1 > >>> s > [1, 2, 3, 4, 5] > >>> del s[0] > >>> s > [2, 3, 4, 5] > >>> next(g) > 3 > >>> > > Why next(g) doesn't give me 2? Think of it this way: the generator is exactly equiva

Re: Using python 3 for scripting?

2009-03-22 Thread Timo Myyrä
Ok, I think I'll stick with the 2.6 then. I recall it gave warnings about things that are deprecated in 3.0 so it will make porting the scripts to 3.0 easier. I might try 3.0 once I know what kind of scripts are needed. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-22 Thread rzed
Raymond Hettinger wrote in news:e35271b9-7623-4845-bcb9-d8c33971f...@w24g2000prd.googlegroups.c om: > If anyone here is interested, here is a proposal I posted on the > python-ideas list. > > The idea is to make numbering formatting a little easier with the > new format() builtin > in Py2.6 and

Re: regular expressions, stack and nesting

2009-03-22 Thread Chris Rebert
2009/3/22 Aaron Brady : > Hi, > > Every so often the group gets a request for parsing an expression.  I > think it would be significantly easier to do if regular expressions > could modify a stack.  However, since you might nearly as well write > Python, maybe there is a compromise. If you need to

Re: RSS feed issues, or how to read each item exactly once

2009-03-22 Thread Gabriel Genellina
En Sat, 21 Mar 2009 17:12:45 -0300, John Nagle escribió: I've been using the "feedparser" module, and it turns out that some RSS feeds don't quite do RSS right. [...] It's something that "feedparser" should perhaps do. Better to ask the author than post here, I think. And even if feedpa

Re: 3.0 - bsddb removed

2009-03-22 Thread Nick Craig-Wood
Sean wrote: > Anyone got any thoughts about what to use as a replacement. I need > something (like bsddb) which uses dictionary syntax to read and write an > underlying (fast!) btree or similar. sqlite. bsddb gave me no end of trouble with threads, but sqlite worked brilliantly. You would

Re: script files with python (instead of tcsh/bash)?

2009-03-22 Thread Nick Craig-Wood
Esmail wrote: > thanks for including the script, that really helps. Nice way of > finding files. Python has lots of useful stuff like that! > Two quick questions: > > As a replacement for grep I would use the re module and its > methods? The re module works on strings not files, but basic

Re: Async serial communication/threads sharing data

2009-03-22 Thread Nick Craig-Wood
Jean-Paul Calderone wrote: > It's true that the serial port support in Twisted isn't the most used > feature. :) These days, serial ports are on the way out, I think. That > said, much of the way a serial port is used in Twisted is the same as the > way a TCP connection is used. This means

Re: regular expressions, stack and nesting

2009-03-22 Thread Aaron Brady
On Mar 22, 12:18 pm, Chris Rebert wrote: > 2009/3/22 Aaron Brady : > > > Hi, > > > Every so often the group gets a request for parsing an expression.  I > > think it would be significantly easier to do if regular expressions > > could modify a stack.  However, since you might nearly as well write

Re: python php/html file upload issue

2009-03-22 Thread Gabriel Genellina
En Sat, 21 Mar 2009 11:47:36 -0300, S.Selvam Siva escribió: I want to upload a file from python to php/html form using urllib2,and my code is below See the Python Cookbook: http://code.activestate.com/recipes/langs/python/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/py

Re: Using python 3 for scripting?

2009-03-22 Thread andrew cooke
mahesh wrote: > python 2.5 is prefered; no it is not. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python 3 for scripting?

2009-03-22 Thread R. David Murray
timo.my...@gmail.com (Timo =?utf-8?Q?Myyr=C3=A4?=) wrote: > Ok, I think I'll stick with the 2.6 then. I recall it gave > warnings about things that are deprecated in 3.0 so it will make > porting the scripts to 3.0 easier. > > I might try 3.0 once I know what kind of scripts are needed. In cas

loading program's global variables in ipython

2009-03-22 Thread per
hi all, i have a file that declares some global variables, e.g. myglobal1 = 'string' myglobal2 = 5 and then some functions. i run it using ipython as follows: [1] %run myfile.py i notice then that myglobal1 and myglobal2 are not imported into python's interactive namespace. i'd like them too -

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > > import re > > import io > > > > class file(io.TextIOWrapper): > > > > ''' > > Enhance TextIO. Streams have many sources, > > a file name is insufficient. > > ''' > > > > def __init__(self,s

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Scott David Daniels
lamber...@corning.com wrote: ... Removing the comment character to increase the stream reference count fixes the program, at the expense of an extra TextIOWrapper object. But you do create that extra TextIOWrapper, so there should be no crying about its existence. If you rely on the d

Re: pyconfig on 64-bit machines with distutils vs 32-bit legacy code

2009-03-22 Thread Rob Clewley
Thanks for replying, Martin. I got my colleague (Nils) to run exactly the gcc call you described in your post (see below for what he ran) but it only returns the following: /home/nwagner/svn/PyDSTool/PyDSTool/tests/dopri853_temp/dop853_HHnet_vf_wrap.c:124:20: error: Python.h: Datei oder Verzeichn

Re: pyconfig on 64-bit machines with distutils vs 32-bit legacy code

2009-03-22 Thread Martin v. Löwis
Rob Clewley wrote: > I got my colleague (Nils) to run exactly the gcc call you described in > your post (see below for what he ran) but it only returns the > following: Sehr seltsam. Welche gcc-Version ist das denn? (gcc -v) > /home/nwagner/svn/PyDSTool/PyDSTool/tests/dopri853_temp/dop853_HHnet_v

Re: Using python 3 for scripting?

2009-03-22 Thread Timo Myyrä
I might get summer job in doing some 2nd tier support and doing some scripting besides that in Solaris environment. I gotta see what kind of scripts are needed but I'd guess the 2.6 would be the safest option. Timo -- http://mail.python.org/mailman/listinfo/python-list

Re: loading program's global variables in ipython

2009-03-22 Thread Peter Otten
per wrote: > i have a file that declares some global variables, e.g. > > myglobal1 = 'string' > myglobal2 = 5 These aren't declarations, this is exectutable code. > and then some functions. i run it using ipython as follows: > > [1] %run myfile.py > > i notice then that myglobal1 and mygloba

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray escribió: "Gabriel Genellina" wrote: En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > > class file(io.TextIOWrapper): > > ''' > Enhance TextIO. Streams have many sources, > a file name is insufficient. > ''' > >

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina yahoo.com.ar> writes: > > There is another alternative that relies on undocumented behaviour: use > open to create a *binary* file and wrap the resulting BufferedReader > object in your own TextIOWrapper. How is that undocumented behavior? TextIOWrapper can wrap any buffer

what features would you like to see in 2to3?

2009-03-22 Thread Benjamin Peterson
It's GSoC time again, and I've had lots of interested students asking about doing on project on improving 2to3. What kinds of improvements and features would you like to see in it which student programmers could accomplish? -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda forms and scoping

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Fri, 20 Mar 2009 23:16:00 -0300, alex goretoy > escribió: > > > i looks at lambdas as unbound functions(or super function), in the case > > above we create the functions in a list places it in memory unboud, once > > binding a call to the memory address space it r

Re: Generator

2009-03-22 Thread mattia
Il Sun, 22 Mar 2009 16:52:02 +, R. David Murray ha scritto: > mattia wrote: >> Can you explain me this behaviour: >> >> >>> s = [1,2,3,4,5] >> >>> g = (x for x in s) >> >>> next(g) >> 1 >> >>> s >> [1, 2, 3, 4, 5] >> >>> del s[0] >> >>> s >> [2, 3, 4, 5] >> >>> next(g) >> 3 >> >>> >> >>> >>

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray > escribió: > > "Gabriel Genellina" wrote: > >> En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > >> > > >> > class file(io.TextIOWrapper): > >> > > >> > ''' > >> > Enhance TextIO. Streams have many so

loading program's global variables in ipython

2009-03-22 Thread R. David Murray
per wrote: > hi all, > > i have a file that declares some global variables, e.g. > > myglobal1 = 'string' > myglobal2 = 5 > > and then some functions. i run it using ipython as follows: > > [1] %run myfile.py > > i notice then that myglobal1 and myglobal2 are not imported into > python's inte

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 16:37:31 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: There is another alternative that relies on undocumented behaviour: use open to create a *binary* file and wrap the resulting BufferedReader object in your own TextIOWrapper. How is that

Re: what features would you like to see in 2to3?

2009-03-22 Thread Daniel Fetchinson
> It's GSoC time again, and I've had lots of interested students asking about > doing on project on improving 2to3. What kinds of improvements and features > would you like to see in it which student programmers could accomplish? Last time I used 2to3 (maybe not the latest version) it didn't know

Re: Generator

2009-03-22 Thread R. David Murray
mattia wrote: > Il Sun, 22 Mar 2009 16:52:02 +, R. David Murray ha scritto: > > > mattia wrote: > >> Can you explain me this behaviour: > >> > >> >>> s = [1,2,3,4,5] > >> >>> g = (x for x in s) > >> >>> next(g) > >> 1 > >> >>> s > >> [1, 2, 3, 4, 5] > >> >>> del s[0] > >> >>> s > >> [2, 3,

Re: what features would you like to see in 2to3?

2009-03-22 Thread Benjamin Kaplan
On Sun, Mar 22, 2009 at 4:49 PM, Daniel Fetchinson < fetchin...@googlemail.com> wrote: > > It's GSoC time again, and I've had lots of interested students asking > about > > doing on project on improving 2to3. What kinds of improvements and > features > > would you like to see in it which student p

Re: Tkinter book on current versions

2009-03-22 Thread Paul Watson
On Sat, 2009-03-21 at 08:10 -0700, W. eWatson wrote: > Paul Watson wrote: > > Has anyone tried the Grayson book, "Python and Tkinter Programming," > > with a recent version of Python? > > > > The first example code (calculator) generates a single row of buttons. > > Perhaps I have not applied the

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina yahoo.com.ar> writes: > > The undocumented behavior is relying on the open() builtin to return a > BufferedReader for a binary file. I don't see the problem. open() will return some BufferedIOBase implmentor, and that's all that TextIOWrapper needs. -- http://mail.python.

Re: Using python 3 for scripting?

2009-03-22 Thread Paul Watson
On Sun, 2009-03-22 at 17:00 +, Timo Myyrä wrote: > Ok, I think I'll stick with the 2.6 then. I recall it gave > warnings about things that are deprecated in 3.0 so it will make > porting the scripts to 3.0 easier. > > I might try 3.0 once I know what kind of scripts are needed. Yes. Devel

Re: what features would you like to see in 2to3?

2009-03-22 Thread Daniel Fetchinson
>> > It's GSoC time again, and I've had lots of interested students asking >> about >> > doing on project on improving 2to3. What kinds of improvements and >> features >> > would you like to see in it which student programmers could accomplish? >> >> Last time I used 2to3 (maybe not the latest vers

safely rename a method with a decorator

2009-03-22 Thread Daniel Fetchinson
I'd like to implement a decorator that would rename the method which it decorates. Since it's a tricky thing in general involving all sorts of __magic__ I thought I would ask around first before writing something buggy :) It should work something like this: class myclass( object ): @rename( '

Re: Another of those "is" issues.

2009-03-22 Thread Emanuele D'Arrigo
Thank you all for the replies! Manu -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: The undocumented behavior is relying on the open() builtin to return a BufferedReader for a binary file. I don't see the problem. open() will return some BufferedIOBase implmentor, and

Re: safely rename a method with a decorator

2009-03-22 Thread MRAB
Daniel Fetchinson wrote: I'd like to implement a decorator that would rename the method which it decorates. Since it's a tricky thing in general involving all sorts of __magic__ I thought I would ask around first before writing something buggy :) It should work something like this: class myclas

Re: Lambda forms and scoping

2009-03-22 Thread alex goretoy
Sorry to have confused yall. What I meant was that you can do something like this, where the fucntion isn't called until it is bount to () with the right params >>> def a(): ... print "inside a" ... >>> def b(): ... print "inside b" ... >>> def c(a,b): ... a() ... b() ... >>> d={c:

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina yahoo.com.ar> schrieb: > > How do you know? AFAIK, the return value of open() is completely > undocumented: > http://docs.python.org/3.0/library/functions.html#open > And if you open the file in text mode, the return value isn't a > BufferedIOBase. Oh, I see. I should chan

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread lambertdw
Return value of open undocumented? The return value of open() is a "stream", according to http://docs.python.org/dev/py3k/library/io.html#module-io Seems like time for a bug report. -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Scott David Daniels
Gabriel Genellina wrote: En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: The undocumented behavior is relying on the open() builtin to return a BufferedReader for a binary file. I don't see the problem. open() will return some Buffered

Re: safely rename a method with a decorator

2009-03-22 Thread Daniel Fetchinson
>> I'd like to implement a decorator that would rename the method which >> it decorates. Since it's a tricky thing in general involving all sorts >> of __magic__ I thought I would ask around first before writing >> something buggy :) >> >> It should work something like this: >> >> class myclass( ob

Re: Lambda forms and scoping

2009-03-22 Thread andrew cooke
alex goretoy wrote: > Sorry to have confused yall. What I meant was that you can do something > like > this, where the fucntion isn't called until it is bount to () with the > right > params > def a(): > ... print "inside a" > ... def b(): > ... print "inside b" > ... def c(a

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 21:03:38 -0300, Scott David Daniels escribió: Gabriel Genellina wrote: En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: The undocumented behavior is relying on the open() builtin to return a BufferedReader for a bi

Re: Safe to call Py_Initialize() frequently?

2009-03-22 Thread Graham Dumpleton
On Mar 21, 10:27 am, Mark Hammond wrote: > Calling > Py_Initialize and Py_Finalize multiple times does leak (Python 3 has > mechanisms so this need to always be true in the future, but it is true > now for non-trivial apps. Mark, can you please clarify this statement you are making. The grammar u

Re: safely rename a method with a decorator

2009-03-22 Thread R. David Murray
Daniel Fetchinson wrote: > >> I'd like to implement a decorator that would rename the method which > >> it decorates. Since it's a tricky thing in general involving all sorts > >> of __magic__ I thought I would ask around first before writing > >> something buggy :) > >> > >> It should work someth

Re: Lambda forms and scoping

2009-03-22 Thread alex goretoy
I'm talking about in function c, where we bind the function call, kinda same thing with lambdas too, exactly same def func1(a): return a def func2(a="",b=0): return "%s has %d apples"%(a,b) def c(f1,f2,**kwargs): print f2(kwargs['name'], f1(kwargs['apple'])) #bind call to function 1 an

Re: safely rename a method with a decorator

2009-03-22 Thread andrew cooke
there was discussion related to this same problem earlier in the week. http://groups.google.com/group/comp.lang.python/browse_thread/thread/ad08eb9eb83a4e61/d1906cbc26e16d15?q=Mangle+function+name+with+decorator%3F andrew Daniel Fetchinson wrote: > I'd like to implement a decorator that would

Re: Generator

2009-03-22 Thread John Posner
[snip] > > If you want next(g) to yield 3, you'd have to do something like: > > > > g = (x for x in s[:]) > > > > where s[:] makes a copy of s that is then iterated over. BTW, this simpler statement works, too: g = iter(s[:]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Async serial communication/threads sharing data

2009-03-22 Thread Jean-Paul Calderone
On Sun, 22 Mar 2009 12:30:04 -0500, Nick Craig-Wood wrote: [snip] I wrote a serial port to TCP proxy (with logging) with twisted. The problem I had was that twisted serial ports didn't seem to have any back pressure. By that I mean I could pump data into a 9600 baud serial port at 10 Mbit/s.

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 20:43:02 -0300, alex goretoy escribió: Sorry to have confused yall. What I meant was that you can do something like this, where the fucntion isn't called until it is bount to () with the right params def a(): ... print "inside a" ... def b(): ... print "in

Re: Lambda forms and scoping

2009-03-22 Thread alex goretoy
> > Ah, so this is a terminology issue. I'd say that a and b are *called* in > function c, not *bound*. I've never seen "bind" used in this sense before, > but as Humpty Dumpty said to Alice: i use the word expressively -Alex Goretoy http://www.goretoy.com -- http://mail.python.org/mailman/listi

Re: Lambda forms and scoping

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 16:42:21 -0300, R. David Murray escribió: "Gabriel Genellina" wrote: And if you imply that *where* you call a function does matter, it does not. A function carries its own local namespace, its own closure, and its global namespace. At call time, no additional "binding

splitting a large dictionary into smaller ones

2009-03-22 Thread per
hi all, i have a very large dictionary object that is built from a text file that is about 800 MB -- it contains several million keys. ideally i would like to pickle this object so that i wouldnt have to parse this large file to compute the dictionary every time i run my program. however currentl

Re: splitting a large dictionary into smaller ones

2009-03-22 Thread Paul Rubin
per writes: > i would like to split the dictionary into smaller ones, containing > only hundreds of thousands of keys, and then try to pickle them. That already sounds like the wrong approach. You want a database. -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting a large dictionary into smaller ones

2009-03-22 Thread odeits
On Mar 22, 7:32 pm, per wrote: > hi all, > > i have a very large dictionary object that is built from a text file > that is about 800 MB -- it contains several million keys.  ideally i > would like to pickle this object so that i wouldnt have to parse this > large file to compute the dictionary ev

Re: splitting a large dictionary into smaller ones

2009-03-22 Thread per
On Mar 22, 10:51 pm, Paul Rubin wrote: > per writes: > > i would like to split the dictionary into smaller ones, containing > > only hundreds of thousands of keys, and then try to pickle them. > > That already sounds like the wrong approach.  You want a database. fa

Re: splitting a large dictionary into smaller ones

2009-03-22 Thread Armin
On Monday 23 March 2009 00:01:40 per wrote: > On Mar 22, 10:51 pm, Paul Rubin wrote: > > per writes: > > > i would like to split the dictionary into smaller ones, containing > > > only hundreds of thousands of keys, and then try to pickle them. > > > > That already s

Re: splitting a large dictionary into smaller ones

2009-03-22 Thread Paul Rubin
per writes: > fair enough - what native python database would you recommend? i > prefer not to install anything commercial or anything other than > python modules I think sqlite is the preferred one these days. -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting a large dictionary into smaller ones

2009-03-22 Thread Terry Reedy
per wrote: hi all, i have a very large dictionary object that is built from a text file that is about 800 MB -- it contains several million keys. ideally i would like to pickle this object so that i wouldnt have to parse this large file to compute the dictionary every time i run my program. how

Re: Obtaining the attributes and properties of a folder recursively.

2009-03-22 Thread venutaurus...@gmail.com
On Mar 21, 3:05 pm, Tim Golden wrote: > venutaurus...@gmail.com wrote: > > Thank you Sir for your reply. It is working for me. But is failing if > > I have Unicode characters in my path. I tried giving a 'u' in front of > > the path but still it fails at f.createdat. Does it support Unicode > > Ch

Re: safely rename a method with a decorator

2009-03-22 Thread Daniel Fetchinson
> there was discussion related to this same problem earlier in the week. > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/ad08eb9eb83a4e61/d1906cbc26e16d15?q=Mangle+function+name+with+decorator%3F > Thanks this was very helpful! >> I'd like to implement a decorator that w

Re: what features would you like to see in 2to3?

2009-03-22 Thread Kay Schluehr
On 22 Mrz., 20:39, Benjamin Peterson wrote: > It's GSoC time again, and I've had lots of interested students asking about > doing on project on improving 2to3. What kinds of improvements and features > would you like to see in it which student programmers could accomplish? It would suffice to wri

  1   2   >