Hi,
I want to convert a string to float value. The string contains
engineering symbols.
For example,
s = '12k'
I want some function which would return 12000
function(s)
=> 12000.0
I searched the web, but could not fi
Hi,
I have a string like,
s1 = '12e3'
s2 = 'junk'
Now before converting these values to float, I want to check if they
are valid numbers.
s1.isdigit returns False.
Is there any other function which would return True for s1 and False
for s2.
Than
Hi all,
Lets say I have an array:
from numarray import *
a = array([ 6, 7, 8, 9, 10, 11, 12])
I want to multiply out all the elements and get the result.
r = 1.0
for i in a:
r = r*i
Is there any faster, efficient
Exactly what I wanted.
It would be nice if the standard float function takes care of these.
regards,
Suresh
> how about:
>
> SI_prefixes = {
> 'Y':24, 'Z':21, 'E':18, 'P':15, 'T':12, 'G':9, 'M':6, 'k':3,
> 'h':2, 'd':-1, 'c':-2, 'm':-3, u'\xb5':-6, 'u':-6, 'n':-9, 'p':-12,
> 'f':-1
Hi,
a = '/home/suresh/doc/html/a1/'
b = '/home/suresh/doc/'
I am looking for a standard function which will return the location of b
relative to a i.e. '../..'
I have gone through the os and os.path modules, but could not find any
function of use. Should I write my own?
I have a list of sets in variable lsets .
Now I want to find the intersection of all the sets.
r = lsets[0]
for s in r[0:]:
r = r & s
Is there any other shorter way?
Thanks in advance,
Suresh
--
http://mail.python.org/mailman/listinfo/python-list
Given a string
s = 'a=1,b=2'
I want to create a dictionary {'a': '1', 'b': '2'}
I did,
dict(map(lambda k: k.split('='), s.split(',')))
Is it possible to get rid of the lambda here, without having to define
another function just for this.
Is this the easiest/straight-forward way to do this?
r
I got it:
dict([k.split('=') for k in s.split(',')])
regards,
Suresh
Suresh Jeevanandam wrote:
> Given a string
> s = 'a=1,b=2'
>
> I want to create a dictionary {'a': '1', 'b': '2'}
>
> I did,
>
>
Dear all,
I read in "Python in a Nutshell" that when we have multiple assignments
made on a single line, it is equivalent to have those many simple
assignments and that the right side is evaluated once for each
assignment. [The wordings are mine. I am not sure if this is what he
intende
Hi,
Is there any gain in performance because of augmented assignments.
x += 1 vs x = x+1
Or are both of them the same.
regards,
Suresh
--
http://mail.python.org/mailman/listinfo/python-list
Thanks Alex. I was not aware of mtimeit.
regards,
Suresh
Alex Martelli wrote:
> Suresh Jeevanandam <[EMAIL PROTECTED]> wrote:
>
>> Hi,
>> Is there any gain in performance because of augmented assignments.
>>
>> x += 1 vs x = x+1
>>
>>
# I am new to python.
In python all numbers are immutable. This means there is one object ( a
region in the memory ) created every time we do an numeric operation. I
hope there should have been some good reasons why it was designed this way.
But why not have mutable numbers also in the language
Alex Martelli wrote:
> Suresh Jeevanandam <[EMAIL PROTECTED]> wrote:
>
>> Dear all,
>> I read in "Python in a Nutshell" that when we have multiple assignments
>> made on a single line, it is equivalent to have those many simple
>> assignments
13 matches
Mail list logo