use this if you want to take a hammer to crack a nut :D
import os
url = 'http://this/is/my/url/to/parse'
os.path.basename(url) #gives "parse"
os.path.dirname(url) #gives 'http://this/is/my/url/to'
___
Tutor maillist - Tutor@python.org
http://mail.pytho
On Sun, Feb 15, 2009 at 5:09 AM, Jay Jesus Amorin wrote:
> Hi,
>
> Can you please help my how to parse.
>
> url = http://this/is/my/url/to/parse
>
> how do i parse url to print "http://this/is/my/url/to";
>
> i want to remove the last part of my url with is "parse". I would like to
> remove the la
Thanks this is much more simple and is what i need.
On Sun, Feb 15, 2009 at 9:29 PM, Lie Ryan wrote:
> On Sun, 15 Feb 2009 14:22:09 +0100, Andre Engels wrote:
> > What is 'new' in your solution? Apart from that, the following looks
> > simpler:
> >
> url = "http://this/is/my/url/to/parse";
On Sun, 15 Feb 2009 14:22:09 +0100, Andre Engels wrote:
> What is 'new' in your solution? Apart from that, the following looks
> simpler:
>
url = "http://this/is/my/url/to/parse"; parts = url.split('/')
sol = '/'.join(parts[:-1])
sol
> 'http://this/is/my/url/to'
do you want somethi
On Sun, Feb 15, 2009 at 1:37 PM, Emad Nawfal (عماد نوفل)
wrote:
> I'm not sure this is the best strategy, but it seems to work:
>
url ="http://this/is/my/url/to/parse";
m = url.replace("//", '/').split("/")
n = m[0]+"//"+"/".join(new[1:])
n
> 'http://this/is/my/url/to'
What i
On Sun, Feb 15, 2009 at 7:37 AM, Emad Nawfal (عماد نوفل) <
emadnaw...@gmail.com> wrote:
>
>
> On Sun, Feb 15, 2009 at 5:09 AM, Jay Jesus Amorin wrote:
>
>> Hi,
>>
>> Can you please help my how to parse.
>>
>> url = http://this/is/my/url/to/parse
>>
>> how do i parse url to print "http://this/is/my
On Sun, Feb 15, 2009 at 5:09 AM, Jay Jesus Amorin wrote:
> Hi,
>
> Can you please help my how to parse.
>
> url = http://this/is/my/url/to/parse
>
> how do i parse url to print "http://this/is/my/url/to";
>
> i want to remove the last part of my url with is "parse". I would like to
> remove the la
Hi,
Can you please help my how to parse.
url = http://this/is/my/url/to/parse
how do i parse url to print "http://this/is/my/url/to";
i want to remove the last part of my url with is "parse". I would like to
remove the last string of my url.
i have try split, but i think it wont work as i dont