Splitting device addresses into parts

Virgil Dupras hardcoded.software at gmail.com
Tue Sep 26 22:19:10 CEST 2006


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 ...
>
> Regards,
> Fabian Steiner

I would personally go for regex, but what about a quick and dirty:

s.replace('.',':').split(':')[1:]




More information about the Python-list mailing list