Re: [Tutor] string to integer

2006-01-06 Thread Alan Gauld
>> nums = [ch for ch in aString if ch in string.digits] > I'd spell that > > nums = [ch for ch in aString if ch.isdigit()] Now I had a look for a digit() method but never notoced the isdigit() one. Thanks Brian. Alan G. ___ Tutor maillist - Tutor@

Re: [Tutor] string to integer

2006-01-05 Thread Brian van den Broek
Alan Gauld said unto the world upon 05/01/06 04:16 PM: >>Here is how it should work: >>val(7) = 7 >>val(bbab7) = 7 >>val(aa7aa) = 7 >>val( 7) = 7 > > > There is no direct equivalent for val() as shpwn above the > nearest is int() or float() but that will only work with the first > and last e

Re: [Tutor] string to integer

2006-01-05 Thread Boyan R.
Thank you both I think I'll manage to continue with my program :) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] string to integer

2006-01-05 Thread Alan Gauld
> Here is how it should work: > val(7) = 7 > val(bbab7) = 7 > val(aa7aa) = 7 > val( 7) = 7 There is no direct equivalent for val() as shpwn above the nearest is int() or float() but that will only work with the first and last examples. (It is a pretty arbitrary functionn to convert aa7aa to

Re: [Tutor] string to integer

2006-01-05 Thread bob
At 12:40 PM 1/5/2006, Boyan R. wrote: >I need program to convert my string in integer. >I remember in BASIC I used val(string) command >Is there a Python equivalent ? > >Here is how it should work: >val(7) = 7 >val(bbab7) = 7 >val(aa7aa) = 7 >val( 7) = 7 > >This last is most important, currently

Re: [Tutor] string to integer

2006-01-05 Thread Danny Yoo
On Thu, 5 Jan 2006, Boyan R. wrote: > I need program to convert my string in integer. > I remember in BASIC I used val(string) command > Is there a Python equivalent ? > > Here is how it should work: > val(7) = 7 > val(bbab7) = 7 > val(aa7aa) = 7 > val( 7) = 7 Hi Boyan, Python has a functi

[Tutor] string to integer

2006-01-05 Thread Boyan R.
I need program to convert my string in integer. I remember in BASIC I used val(string) command Is there a Python equivalent ? Here is how it should work: val(7) = 7 val(bbab7) = 7 val(aa7aa) = 7 val( 7) = 7 This last is most important, currently I don't know how to convert string " 7" to