Re: [Tutor] why gtk.Entry does not give me right answers?

2012-04-23 Thread Lion Chen
于 2012年04月23日 23:08, Steven D'Aprano 写道: Lion Chen wrote: Hi, All, i am trying write a calculator, now normal calculation works ok. but if i enter long numbers, for example 33 + 7, it gives me "12". there are 18 "3"s, if the length is more than 17, the calcu

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Gerhardus Geldenhuis
nters would be > appreciated. > >>> > >>> Regards > >>> > >>> -- > >>> Gerhardus Geldenhuis > >>> > >>> ___ > >>> Tutor maillist - Tutor@python.org > >>>

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Don Jennings
utor maillist - Tutor@python.org >>> To unsubscribe or change subscription options: >>> http://mail.python.org/mailman/listinfo/tutor >>> >> >> So you want to take 'column1' and get back 1?, 'column10' and get back 10? >> >> s = 

Re: [Tutor] why gtk.Entry does not give me right answers?

2012-04-23 Thread Russel Winder
On Tue, 2012-04-24 at 01:08 +1000, Steven D'Aprano wrote: [...] > > * Use the decimal module instead of floats. You still have finite precision, > but you can choose how many *decimal* places to store instead of having a > fixed number of *binary* places. (But decimal is much slower.) Alterna

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Joel Goldstick
On Mon, Apr 23, 2012 at 11:08 AM, Gerhardus Geldenhuis wrote: > Hi > Here is my solution: > > def readcsvfile(filename,headerstring): >   headers = headerstring.split(',') > >   f = open(filename, 'ro') >   csvdata = csv.DictReader(f) >   for row in csvdata: >     for column in headers[0:-1]: >  

Re: [Tutor] why gtk.Entry does not give me right answers?

2012-04-23 Thread Steven D'Aprano
Lion Chen wrote: > Hi, All, > > i am trying write a calculator, now normal calculation works ok. but if > i enter long numbers, for example 33 + 7, it gives me > "12". > > there are 18 "3"s, if the length is more than 17, the calculation will > be wrong on Wind

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Gerhardus Geldenhuis
Hi Here is my solution: def readcsvfile(filename,headerstring): headers = headerstring.split(',') f = open(filename, 'ro') csvdata = csv.DictReader(f) for row in csvdata: for column in headers[0:-1]: print row[column]+',', print row[headers[-1]] Regards On 23 April 2012 15

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Gerhardus Geldenhuis
Hi Thanks for all the replies, I will try a the suggestions and post my solution back. Regards -- Gerhardus Geldenhuis ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Joel Goldstick
On Mon, Apr 23, 2012 at 10:18 AM, nehal dattani wrote: > Hi, > >> >> Unfortunately I am not, this needs to happen in python. >> >> > > Please see if following helps. > > http://stackoverflow.com/questions/5863999/python-cut-example > > Regards, > Nehal Dattani > > > ___

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread nehal dattani
Hi, > Unfortunately I am not, this needs to happen in python. > > > Please see if following helps. http://stackoverflow.com/questions/5863999/python-cut-example Regards, Nehal Dattani ___ Tutor maillist - Tutor@python.org To unsubscribe or change su

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Christian Witts
On 2012/04/23 03:46 PM, Gerhardus Geldenhuis wrote: Not quite, I have csvfile1: column1, column2, column3, ... column200 That is my raw data but I want to use only 5 columns for example in a specific application. I thus want a file with the following: column33,column1,column5 I then want to

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Gerhardus Geldenhuis
Yip, Unfortunately I am not, this needs to happen in python. Regards On 23 April 2012 14:59, Christian Witts wrote: > On 2012/04/23 03:46 PM, Gerhardus Geldenhuis wrote: > > Not quite, > > I have csvfile1: > column1, column2, column3, ... column200 > > That is my raw data but I want to use o

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Gerhardus Geldenhuis
Not quite, I have csvfile1: column1, column2, column3, ... column200 That is my raw data but I want to use only 5 columns for example in a specific application. I thus want a file with the following: column33,column1,column5 I then want to read the original csv file and write a new csv file with

Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Joel Goldstick
On Mon, Apr 23, 2012 at 8:56 AM, Gerhardus Geldenhuis wrote: > Hi > Appologies about the subject I could not think of a better description. > > I have this very simple function: > > def readcsvfile(filename): >   f = open(filename, 'ro') >   csvdata = csv.DictReader(f) >   for row in csvdata: >  

[Tutor] Converting a string into dictionary references

2012-04-23 Thread Gerhardus Geldenhuis
Hi Appologies about the subject I could not think of a better description. I have this very simple function: def readcsvfile(filename): f = open(filename, 'ro') csvdata = csv.DictReader(f) for row in csvdata: print row["column3"]+','+row["column1"] I have another inputfile that will be

[Tutor] why gtk.Entry does not give me right answers?

2012-04-23 Thread Lion Chen
Hi, All, i am trying write a calculator, now normal calculation works ok. but if i enter long numbers, for example 33 + 7, it gives me "12". there are 18 "3"s, if the length is more than 17, the calculation will be wrong on Windows and Ubuntu. the following is