Partition Recursive

Jon Clements joncle at googlemail.com
Thu Dec 23 12:57:54 EST 2010


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','.','partition']
>
> 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