Re: [Tutor] map one file and print it out following the sequence

2011-10-12 Thread Andreas Perstinger
On 2011-10-12 05:31, lina wrote: I tried to write one (not working one) as below, so many problems here. Just some quick remarks: #!/usr/bin/python3 import os.path LINESTOSKIP=0 CHAINID=CDEFGHI INFILENAME=pdbone.pdb DICTIONARYFILE=itpone.itp mapping={} valuefromdict={} def sortfile():

Re: [Tutor] Keyboard Module

2011-10-12 Thread Alan Gauld
On 12/10/11 02:32, Ryan Strunk wrote: The keyboard module I currently have access to is a wrapper for the wx keyboard handler, which is fine, but it prevents me from holding one key and pressing another. So use raw wx key events. They include key down,up and press events. I thought of using

Re: [Tutor] map one file and print it out following the sequence

2011-10-12 Thread lina
On Wed, Oct 12, 2011 at 3:29 PM, Andreas Perstinger andreas.perstin...@gmx.net wrote: On 2011-10-12 05:31, lina wrote: I tried to write one (not working one) as below, so many problems here. Just some quick remarks: Thanks, Now the newly-improved one as following: but still the sort

Re: [Tutor] map one file and print it out following the sequence

2011-10-12 Thread Andreas Perstinger
On 2011-10-12 10:27, lina wrote: $ python3 map-to-itp.py {'O4': '2', 'C19': '3', 'C21': '1'} {'C': '3'} {'C': '2'} {'C': '1'} for print(mapping) part, {'O4': '2', 'C19': '3', 'C21': '1'} the value doesn't keep the 1, 2, 3 order any more. That's fine, because mapping is a dictionary which

[Tutor] Parsing /etc/passwd

2011-10-12 Thread Gerhardus Geldenhuis
Hi I wrote the following code: f = open('/etc/passwd', 'r') users = f.read() userelements = re.findall(r'(\w+):(\w+):(\w+):(\w+):(\w+):(\w+):(\w+)', users) print userelements for user in userelements: (username, encrypwd, uid, gid, gecos, homedir, usershell) = user # unpack the

Re: [Tutor] Parsing /etc/passwd

2011-10-12 Thread Hugo Arts
On Wed, Oct 12, 2011 at 3:41 PM, Gerhardus Geldenhuis gerhardus.geldenh...@gmail.com wrote: Hi I wrote the following code:   f = open('/etc/passwd', 'r')   users = f.read()   userelements = re.findall(r'(\w+):(\w+):(\w+):(\w+):(\w+):(\w+):(\w+)', users)   print userelements   for user in

Re: [Tutor] Parsing /etc/passwd

2011-10-12 Thread Gerhardus Geldenhuis
Fantastic, Thanks Hugo that makes 100% sense now! Testing both regex for including / and doing split and when done throwing both away and using the default module. Regards On Wed, Oct 12, 2011 at 2:49 PM, Hugo Arts hugo.yo...@gmail.com wrote: On Wed, Oct 12, 2011 at 3:41 PM, Gerhardus

Re: [Tutor] map one file and print it out following the sequence

2011-10-12 Thread lina
On Wed, Oct 12, 2011 at 8:50 PM, Andreas Perstinger andreas.perstin...@gmx.net wrote: On 2011-10-12 10:27, lina wrote: $ python3 map-to-itp.py {'O4': '2', 'C19': '3', 'C21': '1'} {'C': '3'} {'C': '2'} {'C': '1'} for print(mapping) part, {'O4': '2', 'C19': '3', 'C21': '1'} the value

Re: [Tutor] Parsing /etc/passwd

2011-10-12 Thread Peter Otten
Hugo Arts wrote: f = open('/etc/passwd', 'r') users = f.readlines() for user in users: ... You can iterate over the file directly: for user in f: ... The version using readlines() reads the whole file into a list of lines where the alternative just has to remember the current

Re: [Tutor] map one file and print it out following the sequence

2011-10-12 Thread Dave Angel
On 10/12/2011 09:57 AM, lina wrote: I do have problems to write each blocks (differentiated by chainID) back one by one, but this will leave it at the end. at present I still have following problems Q1: why the D E F G H I stopped being processed. In what sense do you mean stopped? There are

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-12 Thread Prasad, Ramit
for item in list: print item Or you could do this inline with: print ' '.join( myList ) # Change ' ' to be the separator you desire if you want something other than a space between elements? Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main

[Tutor] extract specific column

2011-10-12 Thread Anna Olofsson
Hi, I'm a beginner at python and I'm trying to extract a specific column from a txt file ( see attached file). In the attached file I want to extract the entire column pph2_prob (i.e. column 16). But I want to get all the values from

[Tutor] extract specific column

2011-10-12 Thread Anna Olofsson
Hi, I'm a beginner at python and I'm trying to extract a specific column from a txt file ( see attached file). In the attached file I want to extract the entire column pph2_prob (i.e. column 16). But I want to get all the values from

Re: [Tutor] extract specific column

2011-10-12 Thread Wayne Werner
On Wed, Oct 12, 2011 at 12:21 PM, Anna Olofsson olofsson_anna...@hotmail.com wrote: Hi, I'm a beginner at python and I'm trying to extract a specific column from a txt file ( see attached file). In the attached file I want to extract the entire column* pph2_prob *(i.e. column 16). But I

Re: [Tutor] extract specific column

2011-10-12 Thread Matt Williams
On 12/10/2011 18:21, Anna Olofsson wrote: Hi, I'm a beginner at python and I'm trying to extract a specific column from a txt file ( see attached file). In the attached file I want to extract the entire column/pph2_prob /(i.e. column 16). But I want to get all the values from that column

[Tutor] extract specific column

2011-10-12 Thread Anna Olofsson
From: olofsson_anna...@hotmail.com To: tutor@python.org Subject: FW: [Tutor] extract specific column Date: Wed, 12 Oct 2011 21:59:34 +0200 The thing is, I don't know where to start. I know how to open the attached file, but I don't know how to work inside the file. Is this a csv file?

[Tutor] FW: extract specific column

2011-10-12 Thread Anna Olofsson
The thing is, I don't know where to start. I know how to open the attached file, but I don't know how to work inside the file. Is this a csv file? Do I need to use a split function? In what way should I look at the file? As a string? As lines? Best, Anna From: waynejwer...@gmail.com Date:

Re: [Tutor] extract specific column

2011-10-12 Thread Dave Angel
On 10/12/2011 03:59 PM, Anna Olofsson wrote: (PLEASE don't top-post. And don't start multiple similar threads a couple of hours apart. Send your message as text without tons of blank lines, and don't assume the attachments will make it. In my case, I haven't a clue to what the file looks

Re: [Tutor] FW: extract specific column

2011-10-12 Thread Steven D'Aprano
Anna Olofsson wrote: The thing is, I don't know where to start. I know how to open the attached file, but I don't know how to work inside the file. Is this a csv file? Do I need to use a split function? In what way should I look at the file? As a string? As lines? It looks like a CSV file.

[Tutor] Retrieve data from log file

2011-10-12 Thread Abe Miranda
Hi there, I'm sorry to ask this, I tried and example that was posted in 2009 but I couldn't make it work. I'm trying to parse a log file and retrieve what I just need. Hope you can help me with this, this is part of the log file: [2011-10-11 20:43:54:307] INFO [QuoteCompareDaoWSImpl: 24]

[Tutor] Generic For Loop

2011-10-12 Thread Max S.
I've been doing some research into C++, and I've noticed the for loops. Is there a way to use the C++ version of the loops instead of the Python one? For example, I believe that the Python syntax would be: for a=1, a 11, a += 1: print(a) print(Loop ended.) if the 'for' keyword did it's

Re: [Tutor] Generic For Loop

2011-10-12 Thread bob gailer
On 10/12/2011 8:41 PM, Max S. wrote: I've been doing some research into C++, and I've noticed the for loops. Is there a way to use the C++ version of the loops instead of the Python one? For example, I believe that the Python syntax would be: for a=1, a 11, a += 1: print(a) print(Loop

Re: [Tutor] Generic For Loop

2011-10-12 Thread Max S.
Thanks! On Wed, Oct 12, 2011 at 8:56 PM, bob gailer bgai...@gmail.com wrote: On 10/12/2011 8:41 PM, Max S. wrote: I've been doing some research into C++, and I've noticed the for loops. Is there a way to use the C++ version of the loops instead of the Python one? For example, I believe

Re: [Tutor] Generic For Loop

2011-10-12 Thread Alan Gauld
On 13/10/11 01:41, Max S. wrote: I've been doing some research into C++, and I've noticed the for loops. If you are trying to program in Python you should probably research Python rather than C++. Any tutorial will provide information about for loops... Is there a way to use the C++