Splitting device addresses into parts
Steve Holden
steve at holdenweb.com
Tue Sep 26 14:53:50 EDT 2006
Fabian Steiner wrote:
> Bruno Desthuilliers wrote:
>
>>Fabian Steiner wrote:
>>
>>>I often have to deal with strings like "PCI:2:3.0" or "PCI:3.4:0" and
>>>need the single numbers as tuple (2, 3, 0) or (3, 4, 0). Is there any
>>>simple way to achieve this? So far I am using regular expressions but I
>>>would like to avoid them ...
>>
>>devices = ["PCI:2:3.0", "PCI:3.4:0"]
>>for d in device:
>> nums = tuple(map(int, d.split(':')[1:]))
>> print "for ", d, " : ", nums
>
>
> Unfortunately, this doesn't work (even if I correct your typos) since
> the delimeter isn't necessary a colon - that's exactly the difficulty I
> am trying to solve.
>
In which case you'd better redefine """like "PCI:2:3.0" or
"PCI:3.4:0"""" so we can understand the real problem :-)
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list