[Tutor] Beginner needs help with tkinter and images

2011-05-17 Thread Adam Westrum
I've got a basic program going right now, with 4 buttons. Forward backward right and left. Each button goes to an image of a colored circle. Problem i'm having is that when you click a button, the picture appears. When you click another button, a different picture appears, but the first picture rem

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread lina
On Wed, May 18, 2011 at 2:30 AM, Michiel Overtoom wrote: > On 2011-05-17 18:47, lina wrote: > >> A further question:  I don't know how can I get the final output is >> unique? > > Unique in what way? You mean that in file1 (confout.pdb?) there could be > more values for the same key? or should dup

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread lina
May I ask another question: where I can get some advanced, terse and powerful python tutorials. short but powerful and a bit hard to understand at first. Thanks again, On Wed, May 18, 2011 at 1:51 AM, Emile van Sebille wrote: > On 5/17/2011 9:47 AM lina said... >> >> A further question:  I don'

Re: [Tutor] Indexing a List of Strings

2011-05-17 Thread Alan Gauld
"Spyros Charonis" wrote for item in finalmotifs: for line in my_list: if item in line: print line.index(item) But this only returns a single number (e.g 119), which is the index at which my sequence begins. Is it possible to get a pair of indices that indicate beginnin

[Tutor] Indexing a List of Strings

2011-05-17 Thread Spyros Charonis
Greetings Python List, I have a motif sequence (a list of characters e.g. 'EAWLGHEYLHAMKGLLC') whose index I would like to return. The list contains 20 strings, each of which is close to 1000 characters long making it far too cumbersome to display an example. I would like to know if there is a way

Re: [Tutor] Looking for feedback on improving my code.

2011-05-17 Thread eire1130
Pretty cool how that site makes code formating wotk on my bb. The big thing I've noticed is, and I'm a total newbie btw, mind cap conventions. Use camel case and upper case and whatnot for class definitions. I think its a wothwhile habit to pick up. I keep thinking you're instantiating a class

Re: [Tutor] RuntimeError: file does not exist

2011-05-17 Thread Alan Gauld
"Susana Iraiis Delgado Rodriguez" wrote message which tells me the file I want to work with doesn't exist, but it does. I don't believe you! :-) Traceback (most recent call last):... lyr.datasource = mapnik.Shapefile(base=filepath, file=filepath) return CreateDatasource(keywords)

Re: [Tutor] how to convert list of lists to dict

2011-05-17 Thread Alan Gauld
"Brad Hudson" wrote > Given that you want more than one method I assume > this is a homwework assignment It's really more that I'm a newbie to python. Trying to translate from perl to python in my head... OK, Thats fine, it just seemed odd that you asked for 3 solutions to the problem rath

[Tutor] Looking for feedback on improving my code.

2011-05-17 Thread Glen Clark
Hello tutors, Have not posted in a while. Started learning python a while back but had to stop after a couple of weeks due to lack of time. Anyway pretty much forgotten most things but if anyone has time I would love some feedback on my application. My main aim to to learn python, as a hobby, and

Re: [Tutor] multiprocessing for nested function

2011-05-17 Thread tax botsis
I am trying to start multiple instances using a for statement but this is not working. Has anyone tried affinity module? Tax 2011/5/17 Emile van Sebille > On 5/17/2011 7:29 AM tax botsis said... > > Part of my code includes the following script, which both shows a >> progress bar (for as long

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread Prasad, Ramit
Start solving the problem by viewing the text around what is being returned. Look at the +- 10-100 characters from what is being returned. Where exactly on the page is the return coming from? Is this centered near where you expected it? If not, what could be causing that? If it is actually clos

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread Joel Goldstick
On Tue, May 17, 2011 at 12:54 PM, I. Dooba wrote: > Thanks, Joel Goldstick > > There is no error message. > But the program is returning incomplete or too many characters. For > example, instead of "Halal" it will return "l Hala" > or "nol" depending on the length of the word the user inputs. >

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Michiel Overtoom
On 2011-05-17 18:47, lina wrote: A further question: I don't know how can I get the final output is unique? Unique in what way? You mean that in file1 (confout.pdb?) there could be more values for the same key? or should duplicate lines in the output be condensed to one line? Maybe if you w

Re: [Tutor] RuntimeError: file does not exist

2011-05-17 Thread Susana Iraiis Delgado Rodriguez
Hello Emile! Well, I changed the values because if I assigned different values, anyways I got the next error: Traceback (most recent call last): File "", line 1, in File "imagen_shp.py", line 32, in lyr.datasource = mapnik.Shapefile(base=raiz, file=archivo[0]) File "C:\mapnik-0.7.1\pyt

Re: [Tutor] RuntimeError: file does not exist

2011-05-17 Thread Emile van Sebille
On 5/17/2011 10:10 AM Susana Iraiis Delgado Rodriguez said... Hello list!! I'm using a python dll to create images out from shapefiles. I import a python module and its functions, when I want to use this library, I get a message which tells me the file I want to work with doesn't exist, but it d

Re: [Tutor] reading very large files

2011-05-17 Thread Emile van Sebille
On 5/17/2011 10:20 AM Vikram K said... I wish to read a large data file (file size is around 1.8 MB) and manipulate the data in this file. Just reading and writing the first 500 lines of this file is causing a problem. I wrote: fin = open('gene-GS00471-DNA_B01_ 1101_37-ASM.tsv') count = 0 for i

Re: [Tutor] how to convert list of lists to dict

2011-05-17 Thread Emile van Sebille
On 5/17/2011 10:19 AM Brad Hudson said... Thanks for the quick response Emile! However, this only seems to solve part of the problem. Yes -- I figured that by understanding the one-liner I replied with you'd be able to construct the missing part. And then by restructuring to a loop you'd ge

Re: [Tutor] reading very large files

2011-05-17 Thread Jerry Hill
On Tue, May 17, 2011 at 1:20 PM, Vikram K wrote: > I wish to read a large data file (file size is around 1.8 MB) and manipulate > the data in this file. Just reading and writing the first 500 lines of this > file is causing a problem. I wrote: ... > > Traceback (most recent call last): >   File >

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Emile van Sebille
On 5/17/2011 9:47 AM lina said... A further question: I don't know how can I get the final output is unique? That'll require some rework. The mapping container replaces mapping[parts[0]] each time it encounters another parts[0]. You can test if you are about to add a new entry or replace an e

Re: [Tutor] reading very large files

2011-05-17 Thread Sander Sweers
On Tue, 17 May 2011, 19:20:42 CEST, Vikram K wrote: > I wish to read a large data file (file size is around 1.8 MB) and > manipulate the data in this file. Just reading and writing the first 500 > lines of this file is causing a problem. I wrote: Unless you are very constrained memory wise 1.8 M

Re: [Tutor] how to convert list of lists to dict

2011-05-17 Thread Brad Hudson
On Tue, May 17, 2011 at 12:10 PM, Alan Gauld wrote: > > Given that you want more than one method I assume > this is a homwework assignment rather than a practical > problem? If so we would prefer that you showed us what > you tried and we can then help you fix it rather than > just offer you solut

[Tutor] reading very large files

2011-05-17 Thread Vikram K
I wish to read a large data file (file size is around 1.8 MB) and manipulate the data in this file. Just reading and writing the first 500 lines of this file is causing a problem. I wrote: fin = open('gene-GS00471-DNA_B01_ 1101_37-ASM.tsv') count = 0 for i in fin.readlines(): print i count

Re: [Tutor] how to convert list of lists to dict

2011-05-17 Thread Brad Hudson
On Tue, May 17, 2011 at 11:30 AM, Emile van Sebille wrote: > On 5/17/2011 8:58 AM Brad Hudson said... > > I'm new to python and have a need to convert a 'list of lists' to a >> dictionary object. Can someone help me to convert data similar to the >> following using two different examples of a li

Re: [Tutor] how to convert list of lists to dict

2011-05-17 Thread Alan Gauld
"Brad Hudson" wrote dictionary object. Can someone help me to convert data similar to the following using two different examples of a list comprehension and a for loop? Given that you want more than one method I assume this is a homwework assignment rather than a practical problem? If so w

[Tutor] RuntimeError: file does not exist

2011-05-17 Thread Susana Iraiis Delgado Rodriguez
Hello list!! I'm using a python dll to create images out from shapefiles. I import a python module and its functions, when I want to use this library, I get a message which tells me the file I want to work with doesn't exist, but it does. I'm running the script from Windows. This is the code: impo

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread I. Dooba
Thanks, Joel Goldstick There is no error message. But the program is returning incomplete or too many characters. For example, instead of "Halal" it will return "l Hala" or "nol" depending on the length of the word the user inputs. Since I can't predict the words the user will search for, I'm fi

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread lina
A further question: I don't know how can I get the final output is unique? #!/bin/python mapping={} for line in open("confout.pdb").readlines(): parts=line.strip().split() if len(parts)>6: mapping[parts[1]]=parts[4]+parts[3] origs=open("dummy.atomID").read().split() print " ".joi

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread lina
Thanks, it works. On Tue, May 17, 2011 at 11:53 PM, Emile van Sebille wrote: > On 5/17/2011 8:31 AM lina said... >> >> Following Michiel's code (a little adjustment was done): >> > > Well. you're almost there.  The error you're getting > is likely due to splitting an empty line, then referencing

Re: [Tutor] how to convert list of lists to dict

2011-05-17 Thread Emile van Sebille
On 5/17/2011 8:58 AM Brad Hudson said... I'm new to python and have a need to convert a 'list of lists' to a dictionary object. Can someone help me to convert data similar to the following using two different examples of a list comprehension and a for loop? Data is similar to the following: [['n

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread Joel Goldstick
On Tue, May 17, 2011 at 11:20 AM, I. Dooba wrote: > I'm new to programming and have decided to start with Python following the > advice of experts including Eric S. Raymond. > So far I've learnt quite a lot from this list. > > However, I've the following problem. > > The program was designed (as

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread Andre Engels
I am not able to check your code (I get an error message about the usage of urllib, but that might be a difference in Python installations); however, my first guess is that you neglected to take case into account: The page contains the text "Water", not "water", so if you input "water", halal_haram

Re: [Tutor] multiprocessing for nested function

2011-05-17 Thread Emile van Sebille
On 5/17/2011 7:29 AM tax botsis said... Part of my code includes the following script, which both shows a progress bar (for as long as 'categorize_reports()' is executed) and prints the fileid and the output of the 'document' function; the latter is the one increasing the calculation time (please

[Tutor] how to convert list of lists to dict

2011-05-17 Thread Brad Hudson
I'm new to python and have a need to convert a 'list of lists' to a dictionary object. Can someone help me to convert data similar to the following using two different examples of a list comprehension and a for loop? Data is similar to the following: [['name=server1', 'state=active', 'ncpu=8', 'me

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Emile van Sebille
On 5/17/2011 8:31 AM lina said... Following Michiel's code (a little adjustment was done): Well. you're almost there. The error you're getting is likely due to splitting an empty line, then referencing the [1] and [4] elements. After you split the line into parts, test to confirm that the fi

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread Joel Goldstick
On Tue, May 17, 2011 at 11:20 AM, I. Dooba wrote: > I'm new to programming and have decided to start with Python following the > advice of experts including Eric S. Raymond. > So far I've learnt quite a lot from this list. > > However, I've the following problem. > > The program was designed (as

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread lina
I learn python on and off, tried some examples, I mean tutorial, step by step writing around 80 ones, but seems not a good way of learning. Those tutorials are good, just I am not good at learning. so what I learned can't handle the problem I met. On Tue, May 17, 2011 at 11:19 PM, lina wrote: >

[Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread I. Dooba
I'm new to programming and have decided to start with Python following the advice of experts including Eric S. Raymond. So far I've learnt quite a lot from this list. However, I've the following problem. The program was designed (as part of my practice with Head First Programming) to check whethe

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread lina
$ python atomToResidues.py Traceback (most recent call last): File "atomToResidues.py", line 6, in mapping[parts[1]]=parts[4] IndexError: list index out of range Following Michiel's code (a little adjustment was done): #!/bin/python mapping={} for line in open("confout.pdb").readlines():

[Tutor] multiprocessing for nested function

2011-05-17 Thread tax botsis
Part of my code includes the following script, which both shows a progress bar (for as long as 'categorize_reports()' is executed) and prints the fileid and the output of the 'document' function; the latter is the one increasing the calculation time (please see my comment). Any ideas on how to use

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Emile van Sebille
On 5/17/2011 6:42 AM lina said... Hi, For file1: 5007 O28 CHO 173 35.300 99.430 65.810 1.00 0.0 5008 H29 CHO 173 35.680 100.290 66.150 1.00 0.00 5009 C1 CHO 174 59.060 12.440 58.680 1.00 0.00 5010 C2 CHO 174 59.460 12.480 60.160 1.00

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Michiel Overtoom
On 2011-05-17 15:42, lina wrote: > I want to get the $4(column 4) value which has the $1 value. for > values in file2 Have you tried to write some code yourself already? Please show it. Anyway, I'd proceed with something like this: mapping={} for line in open("file1").readlines(): parts=

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Andre Engels
First read file1, and keep the result in a useful data structure (for this simple case it can be nothing more than a dictionary with the value in column 1 as key and the value in column 4 as value, but perhaps it's better to find something else if you want to do more with the data). Then go through

[Tutor] how to read two files and substitute

2011-05-17 Thread lina
Hi, For file1: 5007 O28 CHO 173 35.300 99.430 65.810 1.00 0.0 5008 H29 CHO 173 35.680 100.290 66.150 1.00 0.00 5009 C1 CHO 174 59.060 12.440 58.680 1.00 0.00 5010 C2 CHO 174 59.460 12.480 60.160 1.00 0.00 5011 C3 CHO 174 59.590

Re: [Tutor] String Processing Query

2011-05-17 Thread Alan Gauld
"Spyros Charonis" wrote I have a file with the following contents: from header1 abcdefghijkl mnopqrs tuvwxyz * from header2 poiuytrewq lkjhgfdsa mnbvcxz * My string processing code goes as follows: file1=open('/myfolder/testfile.txt') scan = file1.readlines() string1 = ' ' for line in

Re: [Tutor] String Processing Query

2011-05-17 Thread spawgi
This snipped also works - may be there is a better solution - ', '*'] >>> s = '' >>> for line in lines: line = line.rstrip('\n') if line.startswith('>from header'): continue elif line.startswith('*'): s = s + '\n' else: s = s + line >>> s 'abcdefghijklmnopqrstuvwxyz\npoiuytrewqlkjhgfdsamnbvcxz\