Re: Partition Recursive

2010-12-27 Thread DevPlayer
# parse_url11.py # devpla...@gmail.com # 2010-12 (Dec)-27 # A brute force ugly hack from a novice programmer. # You're welcome to use the code, clean it up, make positive suggestions # for improvement. """ Parse a url string into a list using a generator. """ #special_itemMeaning = ";?:@=&#."

Re: Partition Recursive

2010-12-24 Thread macm
Thanks all In [11]: reps = 5 In [12]: t = Timer("url = 'http://docs.python.org/dev/library/ stdtypes.html? highlight=partition#str.partition' ;sp = re.compile('(//?|[;?:@=&#.])'); filter(len, sp.split(url))", 'import re') In [13]: print sum(t.repeat(repeat=reps, number=1)) / reps 4.94003295898e-0

Re: Partition Recursive

2010-12-23 Thread Ian Kelly
On 12/23/2010 10:03 PM, kj wrote: import re # sorry sp = re.compile('(//?|[;?:@=&#.])') filter(len, sp.split(url)) Perhaps I'm being overly pedantic, but I would likely have written that as "filter(None, sp.split(url))" for the same reason that "if string:" is generally preferred to "if len(s

Re: Partition Recursive

2010-12-23 Thread kj
In macm writes: >url = >'http://docs.python.org/dev/library/stdtypes.html?highlight=partition#str.partition' >So I want convert to >myList = >['http',':','//','docs','.','python','.','org','/','dev','/','library','/','stdtypes','.','html','?','highlight','=','partition','#','str','.','partit

Re: Partition Recursive

2010-12-23 Thread Rhodri James
Please don't top-post, it makes everything harder to read. (Re-ordering to make sense...) On Thu, 23 Dec 2010 18:05:39 -, macm wrote: On Dec 23, 3:57 pm, Jon Clements wrote: I would use urlparse.urlsplit, then split further, if required. >>> urlsplit(url) SplitResult(scheme='http', n

Re: Partition Recursive

2010-12-23 Thread macm
Hi urlparse isnt a option. My reasult must be: myList = ['http',':','//','docs','.','python','.','org','/','dev','/','library','/', 'stdtypes','.','html','?','highlight','=','partition','#','str','.','partition'] re module is slow. Even I make a loop in urlparse.urlsplit I can lost specialMean

Re: Partition Recursive

2010-12-23 Thread Jon Clements
On Dec 23, 5:26 pm, macm wrote: > Hi Folks > > I have this: > > url = 'http://docs.python.org/dev/library/stdtypes.html? > highlight=partition#str.partition' > > So I want convert to > > myList = > ['http',':','//','docs','.','python','.','org','/','dev','/','library','/','stdtypes','.','html','?'

Re: Partition Recursive

2010-12-23 Thread MRAB
On 23/12/2010 17:26, macm wrote: Hi Folks I have this: url = 'http://docs.python.org/dev/library/stdtypes.html? highlight=partition#str.partition' So I want convert to myList = ['http',':','//','docs','.','python','.','org','/','dev','/','library','/','stdtypes','.','html','?','highlight','='

Partition Recursive

2010-12-23 Thread macm
Hi Folks I have this: url = 'http://docs.python.org/dev/library/stdtypes.html? highlight=partition#str.partition' So I want convert to myList = ['http',':','//','docs','.','python','.','org','/','dev','/','library','/','stdtypes','.','html','?','highlight','=','partition','#','str','.','partiti