Partition Recursive

macm moura.mario at gmail.com
Thu Dec 23 13:05:39 EST 2010


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 specialMeaning
order.

Seen easy but best aproach will be recursive.

Regards

Mario




On Dec 23, 3:57 pm, Jon Clements <jon... at googlemail.com> wrote:
> On Dec 23, 5:26 pm, macm <moura.ma... at gmail.com> 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','#','str','.','partit ion']
>
> > The reserved char are:
>
> > specialMeaning = ["//",";","/", "?", ":", "@", "=" , "&","#"]
>
> > Regards
>
> > Mario
>
> I would use urlparse.urlsplit, then split further, if required.
>
> >>> urlsplit(url)
>
> SplitResult(scheme='http', netloc='docs.python.org', path='/dev/
> library/stdtypes.html', query='highlight=partition',
> fragment='str.partition')
>
> Jon.




More information about the Python-list mailing list