Re: [Tutor] Really miss the C preprocessor!!

2010-03-06 Thread Steven D'Aprano
On Sat, 6 Mar 2010 07:17:43 pm you wrote: > I thought about suggesting using decorators for this, since I've done > something similar (not exactly exponential backoff, but retrying a > few times on exception). However, as I started writing the example, I > got stuck at expressing a generic way to

Re: [Tutor] Instantiating a list of strings into a list of classes

2010-03-06 Thread spir
On Fri, 5 Mar 2010 17:38:08 -0800 Daryl V wrote: > I have a csv list of data, of the form: > plot, utmN83_X, utmN83_Y, plot_radius_m > Spring1,348545,3589235,13.2 > etc. [...] > What I want to do is use the first entry in that row (row[0]) as the > variable name for the instantiated class. Ther

Re: [Tutor] Encoding

2010-03-06 Thread Giorgio
2010/3/5 Dave Angel I'm not angry, and I'm sorry if I seemed angry. Tone of voice is hard to > convey in a text message. Ok, sorry. I've misunderstood your mail :D > I'm still not sure whether your confusion is to what the rules are, or why > the rules were made that way. WHY the rules are

Re: [Tutor] Process list elements as consecutive pairs

2010-03-06 Thread Hugo Arts
On Fri, Mar 5, 2010 at 10:48 PM, Hugo Arts wrote: > > Except the OP requested pairs (1, 2), (3, 4), i.e. with no duplicate > elements. Here is a generator that does what you need: > > def pairs(seq): >    it = iter(seq) >    try: >        while True: >            yield it.next(), it.next() >    ex

Re: [Tutor] Instantiating a list of strings into a list of classes

2010-03-06 Thread Alan Gauld
"Daryl V" wrote What I want to do is use the first entry in that row (row[0]) as the variable name for the instantiated class. Thats usually a very bad idea. Not least because all the code that comes after it would somehow, magically, have to know about this brand new variable that has appear

Re: [Tutor] Process list elements as consecutive pairs

2010-03-06 Thread Peter Otten
Rüdiger Wolf wrote: > I am trying to Process list elements as consecutive pairs into > consecutive pairs. > Any pythonic suggestions? > > listin = [1,2,3,4,5,6,7,8,9,10] > I want to process as consecutive pairs > 1,2 > 3,4 > 5,6 > 7,8 > 9,10 >>> listin = [1,2,3,4,5,6,7,8,9,10] >>> it = iter(lis