Re: Splitting device addresses into parts

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, 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

Re: Splitting device addresses into parts

2006-09-26 Thread Virgil Dupras
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 Steine

Re: Splitting device addresses into parts

2006-09-26 Thread Fabian Steiner
[EMAIL PROTECTED] wrote: > This may be a rare case where regular expressions are not a horrible, > self-defeating idea. Something like: > > delimiter = re.compile("[:\.]") > delimiter.split("PCI:2:3.0") > ...and then ignore the first entry, and map int the rest. > Alternatively, if the delimiters

Re: Splitting device addresses into parts

2006-09-26 Thread Bruno Desthuilliers
Fabian Steiner a écrit : > 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

Re: Splitting device addresses into parts

2006-09-26 Thread Steve Holden
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

Re: Splitting device addresses into parts

2006-09-26 Thread Paddy
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

Re: Splitting device addresses into parts

2006-09-26 Thread johnzenger
This may be a rare case where regular expressions are not a horrible, self-defeating idea. Something like: delimiter = re.compile("[:\.]") delimiter.split("PCI:2:3.0") ...and then ignore the first entry, and map int the rest. Alternatively, if the delimiters can really be anything, and if there a

Re: Splitting device addresses into parts

2006-09-26 Thread Fabian Steiner
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

Re: Splitting device addresses into parts

2006-09-26 Thread Bruno Desthuilliers
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", "PC