# 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 = ";?:@=."
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
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
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
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
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
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','?'
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','='
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