Re: Nested List question

2016-02-24 Thread grsmith
Park Avenue None -Original Message- From: Erik Sent: Wednesday, February 24, 2016 4:28 PM To: grsm...@atlanticbb.net ; python-list Subject: Re: Nested List question On 24/02/16 20:59, grsm...@atlanticbb.net wrote: Can you have a phython list like: ['George', 'Soros'

Re: Nested List question

2016-02-24 Thread Mark Lawrence
On 24/02/2016 20:59, grsm...@atlanticbb.net wrote: All, Can you have a phython list like: ['George', 'Soros', ['99 First Street', '33 Broadway Avenue', ['Apt 303'], '1 Park Avenue'], 'New York', 'NY'] In other words how do you correctly nest the ['Apt 303'] so it goes with 33 Broadway

Re: Nested List question

2016-02-24 Thread Erik
On 24/02/16 20:59, grsm...@atlanticbb.net wrote: Can you have a phython list like: ['George', 'Soros', ['99 First Street', '33 Broadway Avenue', ['Apt 303'], '1 Park Avenue'], 'New York', 'NY'] In other words how do you correctly nest the ['Apt 303'] so it goes with 33 Broadway Avenue.

Re: Nested List question

2016-02-24 Thread Andrew Farrell
you can indeed have a nested list. One way you could do that looks like donor = [ 'George', 'Soros', [ #<- 2nd element of outermost list '99 First Street', [ #<- 1st element of middling list '33 Broadway Av

Re: Nested List question

2016-02-24 Thread Grant Edwards
On 2016-02-24, wrote: > All, > > Can you have a phython list like: > ['George', > 'Soros', > ['99 First Street', > '33 Broadway Avenue', ['Apt 303'], > '1 Park Avenue'], > 'New York', 'NY'] Sure: $ python3 Python 3.4.3 (default, Feb 12 2016, 15:58:12) [GCC 4.9.3] on linux Type "help", "c

Nested List question

2016-02-24 Thread grsmith
All, Can you have a phython list like: ['George', 'Soros', ['99 First Street', '33 Broadway Avenue', ['Apt 303'], '1 Park Avenue'], 'New York', 'NY'] In other words how do you correctly nest the ['Apt 303'] so it goes with 33 Broadway Avenue. Also, I tried several ways and could not figure

RE: Ordered list question

2011-07-18 Thread jyoung79
>> Can you share a website that goes into more detail on this good variable >> naming? > I'd Google that one. You'll find more articles than you can read in a > lifetime... Very true! :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordered list question

2011-07-18 Thread Chris Angelico
On Mon, Jul 18, 2011 at 2:12 PM, wrote: > Can you share a website that goes into more detail on this good variable > naming? I'd Google that one. You'll find more articles than you can read in a lifetime... ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Ordered list question

2011-07-17 Thread jyoung79
Thank you Chris, Dan and Thomas for your replies. I really appreciate your insight, and I will look into the information you have given me. Dan, I've never heard of a "treap" or "red-black tree", so I'll be interested to research these. Thomas, Thanks very much for giving me further knowledg

Re: Ordered list question

2011-07-17 Thread Dan Stromberg
If you need "read everything, then sort once", then a dictionary (or collections.defaultdict if you require undefined's) and a single sort at the end is probably the way to go. If you truly need an ordered datastructure (because you're reading one element, using things sorted, reading another elem

Re: Ordered list question

2011-07-17 Thread Thomas 'PointedEars' Lahn
jyoun...@kc.rr.com wrote: ^^ Something is missing there. > I'm currently working on a project where I'm looping through xml elements, > pulling the 'id' attribute (which will be coerced to a number) No, usually it won't. > as well as the element tag. That's element _type name_.

Re: Ordered list question

2011-07-17 Thread Chris Angelico
On Mon, Jul 18, 2011 at 2:28 AM, wrote: > My question is, does python have a similar way to do something like this? > I'm assuming the best way is to create a dictionary and then sort it by > the keys? > That would be one way to do it. If you know beforehand what the highest ID is, you could cre

Ordered list question

2011-07-17 Thread jyoung79
I'm currently working on a project where I'm looping through xml elements, pulling the 'id' attribute (which will be coerced to a number) as well as the element tag. I'm needing these elements in numerical order (from the id). Example xml might look like: There will be cases where element

Re: String to List Question

2009-07-02 Thread Rhodri James
On Thu, 02 Jul 2009 23:05:46 +0100, Hanna Michelsen wrote: Hi, I am brand new to python and I love it, but I've been having some trouble with a file parser that I've been working on. It contains lines that start with a name and then continue with names, nicknames and phone numbers of peop

Re: String to List Question

2009-07-02 Thread Philip Semanchuk
On Jul 2, 2009, at 6:05 PM, Hanna Michelsen wrote: Hi, I am brand new to python and I love it, but I've been having some trouble with a file parser that I've been working on. It contains lines that start with a name and then continue with names, nicknames and phone numbers of people asso

String to List Question

2009-07-02 Thread Hanna Michelsen
Hi, I am brand new to python and I love it, but I've been having some trouble with a file parser that I've been working on. It contains lines that start with a name and then continue with names, nicknames and phone numbers of people associated with that name. I need to create a list of the names o

Re: list question... unique values in all possible unique spots

2008-08-11 Thread ToshiBoy
Thank you for all your responses. I've tried the permutations road (thank you to all those of you who have suggested it) and it takes %*& %^ long :-) As expected. I've solved it a different way, which runs through the 26 spots by just adding one at a time if available. Still takes a long time, but

Re: list question... unique values in all possible unique spots

2008-08-11 Thread Mensanator
On Aug 11, 7:34 pm, [EMAIL PROTECTED] wrote: > Mensanator: > > > Ever tried to iterate 403 septillion times? > > The OP is talking about formulas, like: > X + Y * Z = W > Where X, Y, Z, W distinct and in [1, 26], so you have C(26, 4) > combinations that's way less than 26! > > >>> binomial(26, 4) >

Re: list question... unique values in all possible unique spots

2008-08-11 Thread bearophileHUGS
Mensanator: > Ever tried to iterate 403 septillion times? The OP is talking about formulas, like: X + Y * Z = W Where X, Y, Z, W distinct and in [1, 26], so you have C(26, 4) combinations that's way less than 26! >>> binomial(26, 4) 14950 So this can be solved with a xcombinations() generator.

Re: list question... unique values in all possible unique spots

2008-08-11 Thread Mensanator
On Aug 11, 3:53 pm, Tobiah <[EMAIL PROTECTED]> wrote: > On Mon, 11 Aug 2008 13:46:10 -0700, Tobiah wrote: > > On Sat, 09 Aug 2008 08:07:26 -0700, Mensanator wrote: > > >> 40329146112660563558400 > > > I think it's only 4 septillion. > > I meant to say 403. Whatever. Ever tried to iterate 403

Re: list question... unique values in all possible unique spots

2008-08-11 Thread Tobiah
On Mon, 11 Aug 2008 13:46:10 -0700, Tobiah wrote: > On Sat, 09 Aug 2008 08:07:26 -0700, Mensanator wrote: > >> 40329146112660563558400 > > I think it's only 4 septillion. I meant to say 403. ** Posted from http://www.teranews.com ** -- http://mail.python.org/mailman/listinfo/python-list

Re: list question... unique values in all possible unique spots

2008-08-11 Thread Tobiah
On Mon, 11 Aug 2008 13:46:10 -0700, Tobiah wrote: > On Sat, 09 Aug 2008 08:07:26 -0700, Mensanator wrote: > >> 40329146112660563558400 > > I think it's only 4 septillion. I meant 403. ** Posted from http://www.teranews.com ** -- http://mail.python.org/mailman/listinfo/python-list

Re: list question... unique values in all possible unique spots

2008-08-11 Thread Tobiah
On Sat, 09 Aug 2008 08:07:26 -0700, Mensanator wrote: > 40329146112660563558400 I think it's only 4 septillion. Perfectly manageable. ** Posted from http://www.teranews.com ** -- http://mail.python.org/mailman/listinfo/python-list

Re: list question... unique values in all possible unique spots

2008-08-09 Thread Mensanator
On Aug 9, 8:05�am, ToshiBoy <[EMAIL PROTECTED]> wrote: > I'm wondering how to do this the most elegant way: I found this quiz > in some magazine. I've already solved it on paper, but want to write a > python program to solve it. It comes down to being able to represent > range(1,27) through a numbe

Re: list question... unique values in all possible unique spots

2008-08-09 Thread George Sakkis
On Aug 9, 9:05 am, ToshiBoy <[EMAIL PROTECTED]> wrote: > I'm wondering how to do this the most elegant way: I found this quiz > in some magazine. I've already solved it on paper, but want to write a > python program to solve it. It comes down to being able to represent > range(1,27) through a numb

list question... unique values in all possible unique spots

2008-08-09 Thread ToshiBoy
I'm wondering how to do this the most elegant way: I found this quiz in some magazine. I've already solved it on paper, but want to write a python program to solve it. It comes down to being able to represent range(1,27) through a number of formulas. How do I write a loop that will loop through thi

Re: Mailing list question

2008-04-16 Thread Gary Herron
python newbie wrote: > Hello, > Just curious; can I post a basic programming question to this mailing > list? You just did. :-) (Real answer: Yes. We're pretty newbie friendly here.) Gary Herron > > Thanks in advance. > > Pete > > ---

Mailing list question

2008-04-16 Thread python newbie
Hello, Just curious; can I post a basic programming question to this mailing list? Thanks in advance. Pete - Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.-- http://mail.python.org/mailman/listinfo/python-list

Re: List question

2008-03-23 Thread Steven D'Aprano
On Sun, 23 Mar 2008 15:55:43 -0700, John Machin wrote: > On Mar 24, 12:19 am, Dustan <[EMAIL PROTECTED]> wrote: >> On Mar 21, 3:57 pm, Paul Rubin wrote: >> >> > [EMAIL PROTECTED] writes: >> > >if 'one' and 'two' in f: >> > >alist.append(f) >> >> > Use: >>

Re: List question

2008-03-23 Thread John Machin
On Mar 24, 12:19 am, Dustan <[EMAIL PROTECTED]> wrote: > On Mar 21, 3:57 pm, Paul Rubin wrote: > > > [EMAIL PROTECTED] writes: > > >if 'one' and 'two' in f: > > >alist.append(f) > > > Use: > > if 'one' in f and 'two' in f: ... > > Personally, I would

Re: List question

2008-03-23 Thread Dustan
On Mar 21, 3:57 pm, Paul Rubin wrote: > [EMAIL PROTECTED] writes: > >if 'one' and 'two' in f: > >alist.append(f) > > Use: > if 'one' in f and 'two' in f: ... Personally, I would put parentheses around to be clearer: if ('one' in f) and ('two' in f

Re: List question

2008-03-22 Thread Mensanator
On Mar 22, 8:40�pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sat, 22 Mar 2008 14:55:39 -0700 (PDT), Zentrader > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > is funny and not mean. �In the words of whoever it was in "Gone With > > The Wind", frankly I don't give a

Re: List question

2008-03-22 Thread Steven D'Aprano
On Sat, 22 Mar 2008 14:55:39 -0700, Zentrader wrote: >> No one meant to laugh at you. Your naivete was not obvious. FWIW, a >> sense of humor is a valuable possession in most Python-related >> conversations. > > Perhaps someone can explain how telling something like this to the OP, > who thinks

Re: List question

2008-03-22 Thread Steven D'Aprano
On Sat, 22 Mar 2008 16:16:03 -0700, bearophileHUGS wrote: > bearophile: >> A more computer-friendly (and Pythonic) syntax may be ('are' is a >> keyword): > > Sorry for causing confusion, I was just thinking aloud. English isn't my > first language, and sometimes I slip a bit. There is nothing w

Re: List question

2008-03-22 Thread bearophileHUGS
bearophile: > A more computer-friendly (and Pythonic) syntax may be ('are' is a keyword): Sorry for causing confusion, I was just thinking aloud. English isn't my first language, and sometimes I slip a bit. Replace that with: > A more computer-friendly (and Pythonic) syntax may be ('are' is meant

Re: List question

2008-03-22 Thread Michael Wieher
If you can't laugh at your own stupidity, being a programmer will lead directly to insanity. =) 2008/3/22, Zentrader <[EMAIL PROTECTED]>: > > > No one meant to laugh at you. Your naivete was not obvious. FWIW, a > > sense of humor is a valuable possession in most Python-related > > conversations

Re: List question

2008-03-22 Thread Zentrader
> No one meant to laugh at you. Your naivete was not obvious. FWIW, a > sense of humor is a valuable possession in most Python-related > conversations. Perhaps someone can explain how telling something like this to the OP, who thinks this statement will work if 'one' and 'two' in f: is funny and

Re: List question

2008-03-22 Thread Jeff Schwab
Zentrader wrote: > On Mar 22, 10:07 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> On Mar 22, 4:38 pm, Zentrader <[EMAIL PROTECTED]> wrote: >> if ('one', 'two') are in f: ... >>> "are" gives me an error in Python 2.5 with a "from future import *" >>> statement included. What version and p

Re: List question

2008-03-22 Thread Zentrader
On Mar 22, 10:07 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Mar 22, 4:38 pm, Zentrader <[EMAIL PROTECTED]> wrote: > > > > if ('one', 'two') are in f: ... > > > "are" gives me an error in Python 2.5 with a "from future import *" > > statement included. What version and platform are you ru

Re: List question

2008-03-22 Thread Arnaud Delobelle
On Mar 22, 4:38 pm, Zentrader <[EMAIL PROTECTED]> wrote: > > if ('one', 'two') are in f: ... > > "are" gives me an error in Python 2.5 with a "from future import *" > statement included.  What version and platform are you running.  Also, > the docs don't mention it.http://docs.python.org/ref/keywor

Re: List question

2008-03-22 Thread Zentrader
> if ('one', 'two') are in f: ... "are" gives me an error in Python 2.5 with a "from future import *" statement included. What version and platform are you running. Also, the docs don't mention it. http://docs.python.org/ref/keywords.html -- http://mail.python.org/mailman/listinfo/python-list

Re: List question

2008-03-21 Thread bearophileHUGS
Ricky Zhou: > Look at the this line: > if 'one' and 'two' in f: Very cute, it's the first time I see a bug like this. I think it's not a common enough pattern to justify a language change, but a bit smarter computer language may be able to do that too ;-) (it's not easy to tell the two meaning

Re: List question

2008-03-21 Thread Paul Rubin
[EMAIL PROTECTED] writes: > if 'one' and 'two' in f: > alist.append(f) Use: if 'one' in f and 'two' in f: ... -- http://mail.python.org/mailman/listinfo/python-list

Re: List question

2008-03-21 Thread Ricky Zhou
On 2008-03-21 05:16:41 PM, [EMAIL PROTECTED] wrote: > alist = [] > blist = [ 'one','two','one and two','one and four','five','one two'] > for f in blist: > if 'one' and 'two' in f: > alist.append(f) > > for i in alist: > print i > > two > one and two > one two > > >

List question

2008-03-21 Thread From
Hello, I am learning python and dont quuite understand why is this happening could someone explain? alist = [] blist = [ 'one','two','one and two','one and four','five','one two'] for f in blist: if 'one' and 'two' in f: alist.append(f) for i in alist: print i tw

Re: stupid/style/list question

2008-01-09 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > Duncan Booth: >> I tried to measure this with timeit, and it looks like the 'del' is >> actually quite a bit faster (which I find suprising). > > Yes, it was usually faster in my benchmarks too. Something similar is > true for dicts too. I think such timings are influen

Re: stupid/style/list question

2008-01-09 Thread bearophileHUGS
Duncan Booth: > I tried to measure this with timeit, and it looks like the 'del' is > actually quite a bit faster (which I find suprising). Yes, it was usually faster in my benchmarks too. Something similar is true for dicts too. I think such timings are influenced a lot by the garbage collector.

Re: stupid/style/list question

2008-01-09 Thread Duncan Booth
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Giampaolo Rodola' wrote: > >> To flush a list it is better doing "del mylist[:]" or "mylist = []"? >> Is there a preferred way? If yes, why? > > The latter creates a new list object, the former modifies an existing > list in place. > > The latter is s

Re: stupid/style/list question

2008-01-08 Thread Raymond Hettinger
On Jan 8, 7:34 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > I was wondering... > To flush a list it is better doing "del mylist[:]" or "mylist = []"? > Is there a preferred way? If yes, why? To empty an existing list without replacing it, the choices are "del mylist[:]" and "mylist[:] = [

Re: stupid/style/list question

2008-01-08 Thread Giampaolo Rodola'
On 8 Gen, 16:45, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Giampaolo Rodola' wrote: > > To flush a list it is better doing "del mylist[:]" or "mylist = []"? > > Is there a preferred way? If yes, why? > > The latter creates a new list object, the former modifies an existing > list in place. > > The

Re: stupid/style/list question

2008-01-08 Thread Tim Chase
> To flush a list it is better doing "del mylist[:]" or "mylist = []"? > Is there a preferred way? If yes, why? It depends on what you want. The former modifies the list in-place while the latter just reassigns the name "mylist" to point to a new list within the local scope as demonstrated by thi

Re: stupid/style/list question

2008-01-08 Thread Fredrik Lundh
Giampaolo Rodola' wrote: > To flush a list it is better doing "del mylist[:]" or "mylist = []"? > Is there a preferred way? If yes, why? The latter creates a new list object, the former modifies an existing list in place. The latter is shorter, reads better, and is probably a bit faster in mos

stupid/style/list question

2008-01-08 Thread Giampaolo Rodola'
I was wondering... To flush a list it is better doing "del mylist[:]" or "mylist = []"? Is there a preferred way? If yes, why? -- http://mail.python.org/mailman/listinfo/python-list

Re: List Question

2007-10-03 Thread Bjoern Schliessmann
Pablo Ziliani wrote: > > > I always use this full-featured, all-inclusive, rock-solid version > (see the try/except block): > > count = i = 0 > x = 1 > y = [1,2,3,4,5,1,2,3,4,1,2,1] > try: > while count < 3: > if y[i] == x: > count += 1 > i += 1 > except RuntimeE

Re: List Question

2007-10-03 Thread Paul Hankin
On Oct 2, 11:09 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Oct 2, 4:20 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > > On Oct 2, 10:06 pm, brad <[EMAIL PROTECTED]> wrote: > > > > How is this expressed in Python? > > > > If x is in y more than three times: > > > print x > > > > y is a Pyth

Re: List Question

2007-10-02 Thread Bruno Desthuilliers
brad a écrit : > How is this expressed in Python? > > If x is in y more than three times: > print x > > y is a Python list. if y.count(x) > 3: print x -- http://mail.python.org/mailman/listinfo/python-list

Re: List Question

2007-10-02 Thread Paul McGuire
On Oct 2, 4:58 pm, Pablo Ziliani <[EMAIL PROTECTED]> wrote: > Paul Hankin wrote: > > On Oct 2, 10:06 pm, brad <[EMAIL PROTECTED]> wrote: > > >> How is this expressed in Python? > > >> If x is in y more than three times: > >> print x > > >> y is a Python list. > > > Simple and readable: > > if

Re: List Question

2007-10-02 Thread Paul McGuire
On Oct 2, 4:20 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 2, 10:06 pm, brad <[EMAIL PROTECTED]> wrote: > > > How is this expressed in Python? > > > If x is in y more than three times: > > print x > > > y is a Python list. > > Simple and readable: > if len([a for a in y if x == a]) > 3

Re: List Question

2007-10-02 Thread Pablo Ziliani
Paul Hankin wrote: > On Oct 2, 10:06 pm, brad <[EMAIL PROTECTED]> wrote: > >> How is this expressed in Python? >> >> If x is in y more than three times: >> print x >> >> y is a Python list. >> > > Simple and readable: > if len([a for a in y if x == a]) > 3: > print x > > Or the sli

Re: List Question

2007-10-02 Thread Paul Hankin
On Oct 2, 10:20 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 2, 10:06 pm, brad <[EMAIL PROTECTED]> wrote: > > > How is this expressed in Python? > > > If x is in y more than three times: > > print x > > > y is a Python list. > > Simple and readable: > if len([a for a in y if x == a]) >

Re: List Question

2007-10-02 Thread Paul Hankin
On Oct 2, 10:06 pm, brad <[EMAIL PROTECTED]> wrote: > How is this expressed in Python? > > If x is in y more than three times: > print x > > y is a Python list. Simple and readable: if len([a for a in y if x == a]) > 3: print x Or the slightly-too-flashy version: if sum(1 for a in y if x

Re: List Question

2007-10-02 Thread Michael Bentley
On Oct 2, 2007, at 2:06 PM, brad wrote: > How is this expressed in Python? > > If x is in y more than three times: > print x > > y is a Python list. # Try using help -- help(list) or help(list.count) for instance... if y.count(x) > 3: print x -- http://mail.python.org/mailman/listinf

List Question

2007-10-02 Thread brad
How is this expressed in Python? If x is in y more than three times: print x y is a Python list. -- http://mail.python.org/mailman/listinfo/python-list

subclassing list question

2007-05-20 Thread manstey
test -- http://mail.python.org/mailman/listinfo/python-list

subclassing list question

2007-05-20 Thread manstey
Hi, I have a simple class that subclasses a list: class CaListOfObj(list): """ subclass of list """ def __init__(self, *args, **kwargs): list.__init__(self, *args, **kwargs) a= CaListOfObj([1,2,3]) Is it possible to have a method in the class that is called EVERY time a is modif

subclassing list question

2007-05-20 Thread manstey
Hi, I have a simple class that subclasses list: class CaListOfObj(list): """ subclass of list """ def __init__(self, *args, **kwargs): list.__init__(self, *args, **kwargs) a = CaListOfObj([1,2,3]) I want an instance method to be run EVERY time a is modified. Is this possible? T

Re: String constants (was "Looping over a list question")

2006-10-03 Thread Tim Chase
> I'd also love to see string constants implemented some day too > (like str.whitespace and str.ascii_letters). You mean like the "string" module provides? :) >>> import string >>> print '\n'.join(["%s -> %s" % (s, repr(eval('string.%s' % s))) for s in dir(string) if isinstance(eval('string.%s

Re: Looping over a list question

2006-10-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > My "print" line is actually a long 40 line block. and? if your editor isn't horribly broken, that shouldn't be much of a problem. (but you may want to refactor the code; if you have a processing block that large, it's probably better to move all or parts of it into a

Re: Looping over a list question

2006-10-03 Thread Leif K-Brooks
Tim Williams wrote: > Maybe > def myfunc(txt): > ... print txt > ... datafiles = ['1.txt','2.txt','3.txt','4.tst'] null = [myfunc(i) for i in datafiles if '.txt' in i] > 1.txt > 2.txt > 3.txt Ew. List comprehensions with side effects are very icky. -- http://mail.python.or

Re: Looping over a list question

2006-10-03 Thread stephen
Fredrik Lundh wrote: [snip] > probably. but unless your editor or keyboard is horribly broken, you > can of course press return at the right place instead: > >for i in datafiles: > if '.txt' in i: > print 'Processing datafile %s' % f > > (for this specific case, "endswi

Re: Looping over a list question

2006-10-03 Thread mdsteele
[EMAIL PROTECTED] wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: > print 'Processing datafile %s' % f > > Has there

Re: Looping over a list question

2006-10-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: > print 'Processing datafile %s' % f > > Has th

Re: Looping over a list question

2006-10-03 Thread Tim Williams
On 3 Oct 2006 10:50:04 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: >

Re: Looping over a list question

2006-10-03 Thread Christoph Haas
On Tuesday 03 October 2006 19:50, [EMAIL PROTECTED] wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: > print 'Processin

Looping over a list question

2006-10-03 Thread stephen
I found myself writing: for f in [i for i in datafiles if '.txt' in i]: print 'Processing datafile %s' % f but I was wishing that I could have instead written: for f in in datafiles if '.txt' in f: print 'Processing datafile %s' % f Has there ever been a proposal for this? Just wonderin

Re: python/mysql/list question...

2006-08-10 Thread John Machin
bruce wrote: > hi. > > i have the following sample code. i'm trying to figure out if there's a way > to use a 'list of lists' in a mysql execute... > > i've tried a variety of combinations but i get an error: > Error 1241: Operand should contain 1 column(s) > > the test code is: > > insertSQL = "

RE: python/mysql/list question...

2006-08-10 Thread bruce
never mind... doh!!! executemany as opposed to execute!!! thanks -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of bruce Sent: Thursday, August 10, 2006 6:37 PM To: python-list@python.org Subject: python/mysql/list question... hi. i have the following

python/mysql/list question...

2006-08-10 Thread bruce
hi. i have the following sample code. i'm trying to figure out if there's a way to use a 'list of lists' in a mysql execute... i've tried a variety of combinations but i get an error: Error 1241: Operand should contain 1 column(s) the test code is: insertSQL = """insert into appTBL

Re: A simple list question.

2005-12-22 Thread Tomasz Lisowski
KraftDiner wrote: > I am trying to implement a two dimensional array. > mylist = [[a,b,c],[d,e,f,c],[g,h,i]] > > So the array is of length 3 here... > So how do I initialize this array and then set each object? > At some point in my code I know there will be 3 lists in the list. > So how do I init

Re: A simple list question.

2005-12-22 Thread Kent Johnson
KraftDiner wrote: > I am trying to implement a two dimensional array. > mylist = [[a,b,c],[d,e,f,c],[g,h,i]] > > So the array is of length 3 here... > So how do I initialize this array and then set each object? > At some point in my code I know there will be 3 lists in the list. > So how do I init

Re: A simple list question.

2005-12-22 Thread KraftDiner
I am trying to implement a two dimensional array. mylist = [[a,b,c],[d,e,f,c],[g,h,i]] So the array is of length 3 here... So how do I initialize this array and then set each object? At some point in my code I know there will be 3 lists in the list. So how do I initialize this list such that I can

Re: A simple list question.

2005-12-22 Thread Tim Williams (gmail)
On 22/12/05, Tim Williams (gmail) <[EMAIL PROTECTED]> wrote: On 22 Dec 2005 10:14:10 -0800, KraftDiner < [EMAIL PROTECTED]> wrote: Is there a cleaner way to implement this code?if len(self.listOfObjects) == 0:self.listOfObjects.append(self.cur

Re: A simple list question.

2005-12-22 Thread Tim Williams (gmail)
On 22 Dec 2005 10:14:10 -0800, KraftDiner <[EMAIL PROTECTED]> wrote: Is there a cleaner way to implement this code?if len(self.listOfObjects) == 0:self.listOfObjects.append(self.currentObject)elif:  

Re: A simple list question.

2005-12-22 Thread Larry Bates
KraftDiner wrote: > Is there a cleaner way to implement this code? > > if len(self.listOfObjects) == 0: > self.listOfObjects.append(self.currentObject) > elif: > self.listOfObjects[self.currentS

A simple list question.

2005-12-22 Thread KraftDiner
Is there a cleaner way to implement this code? if len(self.listOfObjects) == 0: self.listOfObjects.append(self.currentObject) elif: self.listOfObjects[self.currentSlice] = self.currentO

Re: Pychecker Re: Nested List Question

2005-11-02 Thread Mike Meyer
Roman Suzi <[EMAIL PROTECTED]> writes: > On Thu, 3 Nov 2005, Chris McCoy wrote: >>> gridSystemId = [[None]*columns]*rows >> You've made gridSystemID a list of `rows` references to the SAME "inner" >> list, so the behavior you observe is the only possible one. >> If you want copies instead, ASK for

Re: Nested List Question

2005-11-02 Thread Fredrik Lundh
"Newsfeeds" <[EMAIL PROTECTED]> wrote: > Could anyone tell me why this code produces the output it does? http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list has the full story. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pychecker Re: Nested List Question

2005-11-02 Thread Chris McCoy
It may, but I haven't been using Pychecker yet. I'm still fairly new to Python. Thanks, Chris M. "Roman Suzi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Thu, 3 Nov 2005, Chris McCoy wrote: > >> Thank you! I've been banging my head against the wall! >> >> Chris M. > >>> g

Pychecker Re: Nested List Question

2005-11-02 Thread Roman Suzi
On Thu, 3 Nov 2005, Chris McCoy wrote: > Thank you! I've been banging my head against the wall! > > Chris M. >> gridSystemId = [[None]*columns]*rows > > You've made gridSystemID a list of `rows` references to the SAME "inner" > list, so the behavior you observe is the only possible one. > > If y

Re: Nested List Question

2005-11-02 Thread Chris McCoy
Thank you! I've been banging my head against the wall! Chris M. "Alex Martelli" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Newsfeeds <[EMAIL PROTECTED]> wrote: > >> Hello All, >> >> Could anyone tell me why this code produces the output it does? > ... >> gridSystemId = [[

Re: Nested List Question

2005-11-02 Thread Alex Martelli
Newsfeeds <[EMAIL PROTECTED]> wrote: > Hello All, > > Could anyone tell me why this code produces the output it does? ... > gridSystemId = [[None]*columns]*rows You've made gridSystemID a list of `rows` references to the SAME "inner" list, so the behavior you observe is the only possible on

Nested List Question

2005-11-02 Thread Newsfeeds
Hello All, Could anyone tell me why this code produces the output it does? noAdjacencies = 2 gridsPerAdj = 3 rows = 4 columns = 5 gridSystemId = [[None]*columns]*rows for row in range(rows): for column in range(columns): gridSystemId[row][column] = "%d-%d" % (row,column) print gr

Mailing list question

2005-07-28 Thread Paolino
Puzzling. I have subscribed this list with an address int the gmail.com domain, and I receive your postings there,but it seems I can send messages with THIS address ,and I don't receive my messages sent with the gmail account. I don't receive any "python.org mailing list memberships reminder" on