Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Jacqueline Canales
composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] x = 'Antheil' s = 'Saint-Saens' h = 'Beethoven' y = 'Easdale' k = 'Nielsen' if s[0] == 'S' or s[0] == 's' == s[-1] == 'S' or s[-1] == 's': if y[0] == 'E' or y[0] == 'e' == y[-1] == 'E' or y[-1] == 'e': if k[0] ==

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread 罗彭
Maybe the length of each name matters, too. You should consider whether to skip null('') and single-character('a'). On Fri, Sep 27, 2013 at 3:57 PM, Dharmit Shah wrote: > Also, comparison is case sensitive. Meaning, 'A' and 'a' are not the same. > > Hope that helps. :) > > On Fri, Sep 27, 2013

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Steven D'Aprano
Hi Jacqueline, and welcome! Further information below... On Fri, Sep 27, 2013 at 12:48:26AM -0500, Jacqueline Canales wrote: > Write a program that lists all the composers on the list ['Antheil', > 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] whose name starts and > ends with the same lette

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Alan Gauld
On 27/09/13 06:48, Jacqueline Canales wrote: So I have been trying to do this program using ifs and or loops. I am having a hard time solving this question, If you could please assist me in the right direction. Happy to. We won't do the homework for you but we will ask leading questions and gi

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Dharmit Shah
Also, comparison is case sensitive. Meaning, 'A' and 'a' are not the same. Hope that helps. :) On Fri, Sep 27, 2013 at 1:14 PM, Amit Saha wrote: > On Fri, Sep 27, 2013 at 3:48 PM, Jacqueline Canales > wrote: >> So I have been trying to do this program using ifs and or loops. >> I am having a ha

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Amit Saha
On Fri, Sep 27, 2013 at 3:48 PM, Jacqueline Canales wrote: > So I have been trying to do this program using ifs and or loops. > I am having a hard time solving this question, If you could please assist me > in the right direction. > > Write a program that lists all the composers on the list ['Anth

[Tutor] List Python Question..Please help

2013-09-27 Thread Jacqueline Canales
So I have been trying to do this program using ifs and or loops. I am having a hard time solving this question, If you could please assist me in the right direction. Write a program that lists all the composers on the list ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] whose name st

Re: [Tutor] list of references to object properties

2013-01-19 Thread Oscar Benjamin
On 19 January 2013 15:47, Jose Amoreira wrote: > Thanks for the explanation, Alan > >> Is there a good reason to want to do such a thing? > > There is a reason, but maybe you won't consider it a good one... > > I was writing a small program to simulate the gravitational dynamics of a > system of m

Re: [Tutor] list of references to object properties

2013-01-19 Thread eryksun
On Sat, Jan 19, 2013 at 10:47 AM, Jose Amoreira wrote: > > I defined a class, CelestialBody, that describes objects that > represent planets in my simulation. These objects have three attributes: > position, velocity and mass (the first two are 3D-vectors; as such, the > number of attributes is ac

Re: [Tutor] list of references to object properties

2013-01-19 Thread DoanVietTrungAtGmail
Hi Jose, have you thought about shallow copying? I am learning Python too, so I can be wrong here. But I have just tried the idea and it worked for me: class celestialBody(object): def __init__(self, m, x, y, z): self.mass = m self.pos = [x, y, z] def __str__(self):

Re: [Tutor] list of references to object properties

2013-01-19 Thread Alan Gauld
On 19/01/13 15:47, Jose Amoreira wrote: motion. I defined a class, CelestialBody, that describes objects that represent planets in my simulation. These objects have three attributes: position, velocity and mass (the first two are 3D-vectors; as such, the number of attributes is actually 7). The

Re: [Tutor] list of references to object properties

2013-01-19 Thread Jose Amoreira
Thanks for the explanation, Alan > > Is there a good reason to want to do such a thing? There is a reason, but maybe you won't consider it a good one... I was writing a small program to simulate the gravitational dynamics of a system of many planets, using scipy's odeint to solve the equations

Re: [Tutor] list of references to object properties

2013-01-18 Thread Alan Gauld
On 18/01/13 11:11, Jose Amoreira wrote: Suppose I have a list l_obj of similar objects. Is there any way I can generate a list l_prp of references to a given property of those objects in such a way that, if change the value of one element in l_prp, the corresponding object in l_obj gets its prop

Re: [Tutor] list of references to object properties

2013-01-18 Thread Jose Amoreira
Thanks, Peter. I was trying to avoid the regenerate step for updating. But maybe I can restructure my code and objects to make this simpler. Before that I'll try this view approach. Thanks again Ze On Fri, Jan 18, 2013 at 11:37 AM, Peter Otten <__pete...@web.de> wrote: > Jose Amoreira wrote: > >

Re: [Tutor] list of references to object properties

2013-01-18 Thread Peter Otten
Jose Amoreira wrote: > Hello > Suppose I have a list l_obj of similar objects. Is there any way I can > generate a list l_prp of references to a given property of those objects > in such a way that, if change the value of one element in l_prp, the > corresponding object in l_obj gets its property

[Tutor] list of references to object properties

2013-01-18 Thread Jose Amoreira
Hello Suppose I have a list l_obj of similar objects. Is there any way I can generate a list l_prp of references to a given property of those objects in such a way that, if change the value of one element in l_prp, the corresponding object in l_obj gets its property updated, and vice-versa? Let giv

Re: [Tutor] List Comprehension Syntax

2012-12-23 Thread Malcolm Newsome
> Message: 4 > Date: Sun, 23 Dec 2012 02:48:42 -0500 > From: Mario Cacciatore > To: "tutor@python.org" > Subject: [Tutor] List Comprehension Syntax > Message-ID: <50d6b74d.031d650a.3497.a...@mx.google.com> > Content-Type: text/plain; charset="windows

Re: [Tutor] List Comprehension Syntax

2012-12-23 Thread Steven D'Aprano
On 23/12/12 18:48, Mario Cacciatore wrote: Hey everyone, I am having a very hard time understanding the list comprehension syntax. I've followed the docs and could use some guidance from the fine folks here to supplement my findings. If someone wouldn't mind replying back with an example or two,

Re: [Tutor] List Comprehension Syntax

2012-12-23 Thread Peter Otten
Mario Cacciatore wrote: > Hey everyone, > > I am having a very hard time understanding the list comprehension syntax. > I've followed the docs and could use some guidance from the fine folks > here to supplement my findings. If someone wouldn't mind replying back > with an example or two, with so

Re: [Tutor] List Comprehension Syntax

2012-12-23 Thread Alan Gauld
On 23/12/12 07:48, Mario Cacciatore wrote: I am having a very hard time understanding the list comprehension syntax. I've followed the docs and could use some guidance from the fine folks here to supplement my findings. If someone wouldn't mind replying back with an example or two, with some exp

Re: [Tutor] List Comprehension Syntax

2012-12-23 Thread Mitya Sirenef
On 12/23/2012 02:48 AM, Mario Cacciatore wrote: Hey everyone, > > I am having a very hard time understanding the list comprehension syntax. I've followed the docs and could use some guidance from the fine folks here to supplement my findings. If someone wouldn't mind replying back with an exa

[Tutor] List Comprehension Syntax

2012-12-22 Thread Mario Cacciatore
Hey everyone, I am having a very hard time understanding the list comprehension syntax. I've followed the docs and could use some guidance from the fine folks here to supplement my findings. If someone wouldn't mind replying back with an example or two, with some explanation of each part I'd ap

Re: [Tutor] list all links with certain extension in an html file python

2012-09-28 Thread Stefan Behnel
Santosh Kumar, 16.09.2012 09:20: > I want to extract (no I don't want to download) all links that end in > a certain extension. > > Suppose there is a webpage, and in the head of that webpage there are > 4 different CSS files linked to external server. Let the head look > like this: > > http:

Re: [Tutor] list all links with certain extension in an html file

2012-09-28 Thread M Hussain
On Fri, Sep 28, 2012 at 1:10 PM, wrote: > Date: Sun, 16 Sep 2012 12:50:09 +0530 > From: Santosh Kumar > To: tutor@python.org > Subject: [Tutor] list all links with certain extension in an html file > python > Message-ID: > < > cae7maqa53x8pav96q2ka

Re: [Tutor] list all links with certain extension in an html file python

2012-09-28 Thread Oscar Benjamin
On 16 September 2012 08:20, Santosh Kumar wrote: > I want to extract (no I don't want to download) all links that end in > a certain extension. > > Suppose there is a webpage, and in the head of that webpage there are > 4 different CSS files linked to external server. Let the head look > like thi

[Tutor] list all links with certain extension in an html file python

2012-09-28 Thread Santosh Kumar
I want to extract (no I don't want to download) all links that end in a certain extension. Suppose there is a webpage, and in the head of that webpage there are 4 different CSS files linked to external server. Let the head look like this: http://foo.bar/part1.css";> http://foo.bar/part2.c

Re: [Tutor] List all possible 10digit number

2012-09-01 Thread eryksun
On Sat, Sep 1, 2012 at 3:18 AM, Dave Angel wrote: > > Somehow i missed the point that xrange() is NOT necessarily limited to > Python int values. So it may be usable on your machine, if your Python > is 64bit. All I really know is that it works on mine (2.7 64bit, on > Linux). See the following qu

Re: [Tutor] List all possible 10digit number

2012-09-01 Thread Dave Angel
On 08/31/2012 09:08 PM, Scurvy Scott wrote: > First of all thank you guys for all your help. The manual is really no > substitute for having things explained in laymans terms as opposed to a > technical manual. > > My question is this- I've been trying for a month to generate a list of all > pos

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
I'm not sure what the point of any of that is; you're making a simple > problem complex. If you're wanting to accomplish the task without using > any of the itertools stuff, why not just: > > > current = 10**9 > lim = 10**10 > while current < lim: > print current #or write to file, or wha

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
I could comment this better. We have a function, iterToHighNum, that takes two parameters: increment and high_num. increment is how long the list of numbers being added to the old increment list of ints, to create a shorter int list that maintains the sequential count, looking for the high number

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 09/01/2012 01:46 AM, Dwight Hutto wrote: > Here's the better function fixed with a return statement I forgot, but > might not be as quick as the pre-built functions already shown: > > def iterToHighNum(increment,high_num): > end_point = 0 > a = [i for i in range(0,increment)] > while

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
Here's the better function fixed with a return statement I forgot, but might not be as quick as the pre-built functions already shown: def iterToHighNum(increment,high_num): end_point = 0 a = [i for i in range(0,increment)] while (end_point != high_num) == True: for integer in

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
It might be a little buggy, but I'm in a rush, so it has a flaw in it. But I think you get the point I'm trying to make. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
I mean line 7. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
You can also watch this happen by uncommenting print on line 8: def iterToHighNum(increment,high_ num): end_point = 0 a = [i for i in range(0,increment)] while (end_point != high_num) == True: for integer in a: if integer != high_num: print "no matc

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread eryksun
On Sat, Sep 1, 2012 at 12:29 AM, Scurvy Scott wrote: > > The while loop works for simply printing. Now I'm trying to save to a file > > I = 10 > Boogers = raw_input("file") > Baseball = open(Boogers) As ASCII, that's 11 bytes per number times 9 billion numbers. That's approximately 92 GiB

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dwight Hutto
Dear Scurvy, I don't know if this has been suggested yet, but I just broke the larger list of 10 digit nums into segments, and at the end of the loop, kept the previous last num in the segment as the beginning of the next range() that goes through the same amount of ints in each segmentation of

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 08/31/2012 10:38 PM, Scurvy Scott wrote: > Now I've got > > A = 10 > I = raw_input("file name> ") > TheFile = open(I, 'w') > > TheFile.truncate > def allten(a): > while a < 99: > a = + 1 > TheFile.write(a) > allten(a) > > The result is: > Open file 'file.t

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 08/31/2012 10:14 PM, Scurvy Scott wrote: > Thanks for the reply. This isn't an assignment per se as I'm just learning > python for my own sake- not in classes or school or what have you. As I said > I'm pretty new to python picking up whatever I can and generators are > something that I haven

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread eryksun
On Fri, Aug 31, 2012 at 9:08 PM, Scurvy Scott wrote: > > My question is this- I've been trying for a month to generate a list of > all possible 10 digit numbers. I've googled, looked on stackoverflow, > experimented with itertools, In itertools, look at count() and islice(). An alternative to isl

Re: [Tutor] List all possible 10digit number

2012-08-31 Thread Dave Angel
On 08/31/2012 09:08 PM, Scurvy Scott wrote: > First of all thank you guys for all your help. The manual is really no > substitute for having things explained in laymans terms as opposed to a > technical manual. > > My question is this- I've been trying for a month to generate a list of all > pos

[Tutor] List all possible 10digit number

2012-08-31 Thread Scurvy Scott
First of all thank you guys for all your help. The manual is really no substitute for having things explained in laymans terms as opposed to a technical manual. My question is this- I've been trying for a month to generate a list of all possible 10 digit numbers. I've googled, looked on stackov

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Peter Otten
Pete O'Connell wrote: > Hi, I have tried to simplify things and am running into a bit of trouble. > What i am really trying to do is: Keep all the lines starting with "v " > and then delete those lines whose modulus 5 don't equal zero > > I have written it like this which seems to take a really l

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Dave Angel
(you replied off-list, so I'm cc'ing the list here, to keep it public) On 08/23/2012 10:42 PM, Pete O'Connell wrote: > On Fri, Aug 24, 2012 at 1:39 PM, Dave Angel wrote: > >> On 08/23/2012 09:11 PM, Pete O'Connell wrote: >>> Hi, I have tried to simplify things and am running into a bit of troubl

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Dave Angel
On 08/23/2012 10:34 PM, eryksun wrote: > On Thu, Aug 23, 2012 at 9:39 PM, Dave Angel wrote: >> >>> theGoodLines = [line.strip("\n") for line in lines if "v " == >>> line[0:2]] >> >> Better to use startswith(), since short lines will cause the if >> expression above to blow up. > > A slice won

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread eryksun
On Thu, Aug 23, 2012 at 9:39 PM, Dave Angel wrote: > >> theGoodLines = [line.strip("\n") for line in lines if "v " == >> line[0:2]] > > Better to use startswith(), since short lines will cause the if > expression above to blow up. A slice won't blow up. At worst you get an empty string. But t

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Dave Angel
On 08/23/2012 09:11 PM, Pete O'Connell wrote: > Hi, I have tried to simplify things and am running into a bit of trouble. > What i am really trying to do is: Keep all the lines starting with "v " and > then delete those lines whose modulus 5 don't equal zero > > I have written it like this which se

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Pete O'Connell
Hi, I have tried to simplify things and am running into a bit of trouble. What i am really trying to do is: Keep all the lines starting with "v " and then delete those lines whose modulus 5 don't equal zero I have written it like this which seems to take a really long time (a couple of minutes wh

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Asokan Pichai
On Thu, Aug 23, 2012 at 2:57 AM, Pete O'Connell wrote: > On Thu, Aug 23, 2012 at 4:16 AM, Alan Gauld wrote: > >> theTextAsListNoVnOrVtOrEmptyLine = [x for x in theTextAsListStripped >> if "vn" not in x >>

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
Ok thanks for the advice everyone. Cheers Pete On Thu, Aug 23, 2012 at 10:58 AM, Jerry Hill wrote: > On Wed, Aug 22, 2012 at 5:23 PM, Pete O'Connell > wrote: >> OK maybe I am wrong about it being slow (I thought for loops were >> slower than lis comprehensions). But I do know I need it to be a

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Jerry Hill
On Wed, Aug 22, 2012 at 5:23 PM, Pete O'Connell wrote: > OK maybe I am wrong about it being slow (I thought for loops were > slower than lis comprehensions). But I do know I need it to be as fast > as possible if I need to run it on a thousand files each with hundreds > of thousands of lines You'

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Alan Gauld
On 22/08/12 22:23, Pete O'Connell wrote: What makes you say it is "terribly slow"? Perhaps it is as fast as it could be under the circumstances. (Maybe it takes a long time because you have a lot of data, not because it is slow.) OK maybe I am wrong about it being slow (I thought for loops wer

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread ALAN GAULD
of 'and' then you need to go back to a compound statement but multi-line layout still aids legibility. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ > > From: Pete O'Connell >To: Alan Gauld ; tutor@python.o

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Mark Lawrence
On 22/08/2012 22:23, Pete O'Connell wrote: On Thu, Aug 23, 2012 at 2:53 AM, Steven D'Aprano wrote: Further to Steven's sound advice take a look at this http://wiki.python.org/moin/PythonSpeed/PerformanceTips IMHO the part on profiling is particulary useful. -- Cheers. Mark Lawrence. ___

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
On Thu, Aug 23, 2012 at 4:16 AM, Alan Gauld wrote: > theTextAsListNoVnOrVtOrEmptyLine = [x for x in theTextAsListStripped > if "vn" not in x > if "vt" not in x >

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
On Thu, Aug 23, 2012 at 2:53 AM, Steven D'Aprano wrote: > On 22/08/12 20:28, Pete O'Connell wrote: >> >> Hi. The next step for me to parse the file as I want to is to change >> lines that look like this: >> f 21/21/21 22/22/22 24/24/23 23/23/24 >> into lines that look like this: >> f 21 22 23 24 >

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
Thanks eryksun, that is a very clear example. Cheers pete On Wed, Aug 22, 2012 at 11:16 PM, eryksun wrote: > On Wed, Aug 22, 2012 at 3:06 AM, Peter Otten <__pete...@web.de> wrote: >> >> wanted = [line.strip("\n") for line in lines >> if "vn" not in line and "vt" not in line a

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Alan Gauld
On 22/08/12 10:51, Pete O'Connell wrote: theTextAsListNoVnOrVtOrEmptyLine = [x for x in theTextAsListStripped if "vn" not in x and "vt" not in x and x!= ""] It works but what I don't understand about this line is why the ands are not ors Because 'or' would include x if any one of the condi

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Steven D'Aprano
On 22/08/12 20:28, Pete O'Connell wrote: Hi. The next step for me to parse the file as I want to is to change lines that look like this: f 21/21/21 22/22/22 24/24/23 23/23/24 into lines that look like this: f 21 22 23 24 In English, what is the rule you are applying here? My guess is: "Given t

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Peter Otten
Pete O'Connell wrote: [Please don't to-post. Clip all text of previous posts except the portion relevant to your question] > Hi. The next step for me to parse the file as I want to is to change > lines that look like this: > f 21/21/21 22/22/22 24/24/23 23/23/24 > into lines that look like this:

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread eryksun
On Wed, Aug 22, 2012 at 3:06 AM, Peter Otten <__pete...@web.de> wrote: > > wanted = [line.strip("\n") for line in lines > if "vn" not in line and "vt" not in line and line != "\n"] Here's an equivalent expression with the negation factored out: not ("vn" in line or "vt"

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
Hi. The next step for me to parse the file as I want to is to change lines that look like this: f 21/21/21 22/22/22 24/24/23 23/23/24 into lines that look like this: f 21 22 23 24 Below is my terribly slow loop for doing this. Any suggestions about how to make this code more efficient would be gre

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
Thanks Peter. This looks like what I need: with open(fileName) as lines: wanted = [line.strip("\n") for line in lines if "vn" not in line and "vt" not in line and line != "\n"] Cheers And in response to Allan's suggestion. I can see using a generator in a situation where the if statements we

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
What a great mailing list! Thanks for all the responses. I have a few questions, though, first in regards to Puneeth's code. He writes to use: >theTextAsListNoVnOrVtOrEmptyLine = [x for x in theTextAsListStripped if "vn" >not in x and "vt" not in x and x!= ""] It works but what I don't understa

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Mark Lawrence
On 22/08/2012 07:29, Johann Spies wrote: #start import re exclude = re.compile('vn|vt|^$|^#') fileName = '/tmp/x' theFileOpened = open(fileName,'r') theTextAsList = theFileOpened.readlines() theTextAsListStripped = [] for aLine in theTe

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Alan Gauld
On 22/08/12 08:06, Peter Otten wrote: You can even have multiple if clauses in one list-comp (but that is rarely used): with open(filename) as lines: wanted = [line.strip("\n") for line if "vn" not in line if "vt" not in x if line !=

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Peter Otten
Pete O'Connell wrote: > Hi I am trying to parse a text file and create a list of all the lines > that don't include: "vn", "vt" or are empty. I want to make this as > fast as possible because I will be parsing many files each containing > thousands of lines. I though I would give list comprehensio

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-21 Thread Johann Spies
#start import re exclude = re.compile('vn|vt|^$|^#') fileName = '/tmp/x' theFileOpened = open(fileName,'r') theTextAsList = theFileOpened.readlines() theTextAsListStripped = [] for aLine in theTextAsList: theTextAsListStripped.append

[Tutor] list comprehension, testing for multiple conditions

2012-08-21 Thread Pete O'Connell
Hi I am trying to parse a text file and create a list of all the lines that don't include: "vn", "vt" or are empty. I want to make this as fast as possible because I will be parsing many files each containing thousands of lines. I though I would give list comprehensions a try. The last 3 lines of t

Re: [Tutor] List Methods, String Slices and For loops

2012-06-25 Thread Walter Prins
Hi, Just one tangential comment: On 25 June 2012 14:33, Developer Ecofunds wrote: > I'm using python 2.5 because it's the one works with Google App Engine > GAE works with Python 2.7 also: https://developers.google.com/appeng

Re: [Tutor] List Methods, String Slices and For loops

2012-06-25 Thread Craig Cesareo
In case you didn't get my reply on the previous message... Try putting.[:] After "words" in the for loop line. What's happening is you're removing words from the list you are iterating through and it's messing with the loop. The empty indice I'm having you insert makes an in place copy

Re: [Tutor] List Methods, String Slices and For loops

2012-06-25 Thread Developer Ecofunds
Soory by the new message with same question. The goup said my subject was messy and the previous message was denied. Please ignore. 2012/6/25 Developer Ecofunds > Hello guys, > > I'd like to ask you a little question about a script I did and isn't > working properly. > It is one excercise from g

[Tutor] List Methods, String Slices and For loops

2012-06-25 Thread Developer Ecofunds
Hello guys, I'd like to ask you a little question about a script I did and isn't working properly. It is one excercise from googles python classes < http://code.google.com/edu/languages/google-python-class/set-up.html> I'm using python 2.5 because it's the one works with Google App Engine < https

Re: [Tutor] List Indexing Issue

2012-05-14 Thread Bala subramanian
Hi, I would suggest you to use the biopython package. It has a PDB parser with which you can extract any specific information like atom name, residue, chain etc as you wish. Bala On Wed, May 9, 2012 at 3:19 AM, Jerry Hill wrote: > On Tue, May 8, 2012 at 4:00 PM, Spyros Charonis > wrote: > > Hel

Re: [Tutor] List Indexing Issue

2012-05-08 Thread Jerry Hill
On Tue, May 8, 2012 at 4:00 PM, Spyros Charonis wrote: > Hello python community, > > I'm having a small issue with list indexing. I am extracting certain > information from a PDB (protein information) file and need certain fields of > the file to be copied into a list. The entries look like this:

Re: [Tutor] List Indexing Issue

2012-05-08 Thread Joel Goldstick
On Tue, May 8, 2012 at 4:00 PM, Spyros Charonis wrote: > Hello python community, > > I'm having a small issue with list indexing. I am extracting certain > information from a PDB (protein information) file and need certain fields of > the file to be copied into a list. The entries look like this:

[Tutor] List Indexing Issue

2012-05-08 Thread Spyros Charonis
Hello python community, I'm having a small issue with list indexing. I am extracting certain information from a PDB (protein information) file and need certain fields of the file to be copied into a list. The entries look like this: ATOM 1512 N VAL A 222 8.544 -7.133 25.697 1.00 48.

Re: [Tutor] list comprehension efficiency

2012-02-18 Thread Steven D'Aprano
Bill Allen wrote: Generally speaking, are list comprehensions more efficient that the equivalent for loop with interior conditionals for a given task? Do they compile down to the same Python byte code? It depends, and no. For-loops are more general, so there are loops that can't be written as

Re: [Tutor] list comprehension efficiency

2012-02-18 Thread Mark Lawrence
On 19/02/2012 01:31, Bill Allen wrote: Generally speaking, are list comprehensions more efficient that the equivalent for loop with interior conditionals for a given task? Do they compile down to the same Python byte code? Thanks, Bill Allen ___ T

[Tutor] list comprehension efficiency

2012-02-18 Thread Bill Allen
Generally speaking, are list comprehensions more efficient that the equivalent for loop with interior conditionals for a given task? Do they compile down to the same Python byte code? Thanks, Bill Allen ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] list mail formatting

2011-12-27 Thread Alexander
On Fri, Dec 23, 2011 at 5:24 AM, Steven D'Aprano wrote: > Alexander Etter wrote: > > Ah I know of what you mentioned. On an GNU Emacs mailing list I was >> advised to avoid anything but plaintext. It just seems so archaic. But I'm >> a novice and will learn why eventually. >> > > There's a number

Re: [Tutor] list mail formatting

2011-12-23 Thread Steven D'Aprano
Alexander Etter wrote: Ah I know of what you mentioned. On an GNU Emacs mailing list I was advised to avoid anything but plaintext. It just seems so archaic. But I'm a novice and will learn why eventually. There's a number of reasons. In no particular order, and in all cases "you" is generic

Re: [Tutor] list issue.. i think

2011-12-22 Thread Steven D'Aprano
bruce wrote: hi. got a test where i have multiple lists with key/values. trying to figure out how to do a join/multiply, or whatever python calls it, where i have a Whatever Python calls what? You need to explain what *you* mean by "a join/multiply" before we can tell what you are referring t

Re: [Tutor] list issue.. i think

2011-12-22 Thread Rich Lovely
On 23 December 2011 02:11, bruce wrote: > hi. > > got a test where i have multiple lists with key/values. trying to figure out > how to do a join/multiply, or whatever python calls it, where i have a > series of resulting lists/dicts that look like the following.. > > the number of lists/rows is d

[Tutor] list issue.. i think

2011-12-22 Thread bruce
hi. got a test where i have multiple lists with key/values. trying to figure out how to do a join/multiply, or whatever python calls it, where i have a series of resulting lists/dicts that look like the following.. the number of lists/rows is dynamic.. the size of the list/rows will also be dynam

Re: [Tutor] list mail formatting

2011-12-22 Thread Steven D'Aprano
prakash singh wrote: i am asking a code how to fill the column of username and password with letters and press enter after that anyone who can help me on that thanks for the replies ,please provide me so that i can automate the rest part of the router gui Everything you need to know to solve t

Re: [Tutor] list mail formatting

2011-12-22 Thread prakash singh
i am asking a code how to fill the column of username and password with letters and press enter after that anyone who can help me on that thanks for the replies ,please provide me so that i can automate the rest part of the router gui On Thu, Dec 22, 2011 at 3:23 PM, Alexander Etter wrote: > > O

Re: [Tutor] list mail formatting

2011-12-22 Thread Jamie Paul Griffin
On Thu, Dec 22, 2011 at 09:14:57AM +, Alan Gauld wrote: > On 22/12/11 08:59, Jamie Paul Griffin wrote: > > >I can understand that and it's a fair point. > > So, perhaps my suggestion of putting some filtering/reformatting > > software on the list server could help with this? > > Maybe, but I'

Re: [Tutor] list mail formatting

2011-12-22 Thread Alexander Etter
On Dec 22, 2011, at 4:10, Alan Gauld wrote: > On 22/12/11 03:34, Alexander wrote: > >>> We request, and advise where possible, on setting up email >>> in plain text, but we do not insist > >>> It's a frustration to most folks who were brought up on >>> plain-text email. >> >> I'm glad I came

Re: [Tutor] list mail formatting

2011-12-22 Thread Alan Gauld
On 22/12/11 08:59, Jamie Paul Griffin wrote: I can understand that and it's a fair point. > So, perhaps my suggestion of putting some filtering/reformatting > software on the list server could help with this? Maybe, but I'm a list moderator and I have absolutely no access to the list server in

Re: [Tutor] list mail formatting

2011-12-22 Thread Alan Gauld
On 22/12/11 03:34, Alexander wrote: We request, and advise where possible, on setting up email in plain text, but we do not insist It's a frustration to most folks who were brought up on plain-text email. I'm glad I came across this thread. I've been following a few posts here and there, a

Re: [Tutor] list mail formatting

2011-12-22 Thread Jamie Paul Griffin
On Wed, Dec 21, 2011 at 11:51:46PM +, Alan Gauld wrote: > On 21/12/11 11:49, Jamie Paul Griffin wrote: > >Is there not a requirement to use plain text as with > > most other technical mailing lists? > > No, because many of the users of this list are non technical > beginners who understand r

Re: [Tutor] list mail formatting

2011-12-21 Thread Alexander
On Wed, Dec 21, 2011 at 11:02 PM, prakash singh wrote: > hi everybody i jsut want to login into  the web page can anyone help > me please i will attach the page i just want to give username and > password using the pyhton code please help me on this.please look for > the attachment. __

Re: [Tutor] list mail formatting

2011-12-21 Thread Alexander
On Wed, Dec 21, 2011 at 6:51 PM, Alan Gauld wrote: > On 21/12/11 11:49, Jamie Paul Griffin wrote: >> >> Can I just ask why the majority of the mail on this list is in > >> multipart/alternative and/or html format. > > Because thats what the majority of email systems are set up to > send as default

Re: [Tutor] list mail formatting

2011-12-21 Thread Alan Gauld
On 21/12/11 11:49, Jamie Paul Griffin wrote: Can I just ask why the majority of the mail on this list is in > multipart/alternative and/or html format. Because thats what the majority of email systems are set up to send as default, and have been for the last 10 years or more. Is there not a r

Re: [Tutor] list mail formatting

2011-12-21 Thread Steven D'Aprano
Dave Angel wrote: On 12/21/2011 06:49 AM, Jamie Paul Griffin wrote: Can I just ask why the majority of the mail on this list is in multipart/alternative and/or html format. It's driving me nuts trying to read this on my console. ^^^ to which Dave replied: if you're u

Re: [Tutor] list mail formatting

2011-12-21 Thread Dave Angel
On 12/21/2011 08:29 AM, Jamie Paul Griffin wrote: On Wed, Dec 21, 2011 at 07:57:33AM -0500, Dave Angel wrote: On 12/21/2011 06:49 AM, Jamie Paul Griffin wrote: Can I just ask why the majority of the mail on this list is in multipart/alternative and/or html format. It's driving me nuts trying t

Re: [Tutor] list mail formatting

2011-12-21 Thread Jamie Paul Griffin
On Wed, Dec 21, 2011 at 07:57:33AM -0500, Dave Angel wrote: > On 12/21/2011 06:49 AM, Jamie Paul Griffin wrote: > >Can I just ask why the majority of the mail on this list is in > >multipart/alternative and/or html format. It's driving me nuts trying to > >read this on my console. Is there not a

Re: [Tutor] list mail formatting

2011-12-21 Thread Dave Angel
On 12/21/2011 06:49 AM, Jamie Paul Griffin wrote: Can I just ask why the majority of the mail on this list is in multipart/alternative and/or html format. It's driving me nuts trying to read this on my console. Is there not a requirement to use plain text as with most other technical mailing l

[Tutor] list mail formatting

2011-12-21 Thread Jamie Paul Griffin
Can I just ask why the majority of the mail on this list is in multipart/alternative and/or html format. It's driving me nuts trying to read this on my console. Is there not a requirement to use plain text as with most other technical mailing lists? I don't mean to moan and I know it's not a ma

<    1   2   3   4   5   6   7   8   >