Re: [Tutor] url parsing

2009-02-15 Thread Daniele
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

Re: [Tutor] url parsing

2009-02-15 Thread Kent Johnson
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

Re: [Tutor] url parsing

2009-02-15 Thread Jay Jesus Amorin
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";

Re: [Tutor] url parsing

2009-02-15 Thread Lie Ryan
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

Re: [Tutor] url parsing

2009-02-15 Thread Andre Engels
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

Re: [Tutor] url parsing

2009-02-15 Thread عماد نوفل
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

Re: [Tutor] url parsing

2009-02-15 Thread عماد نوفل
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

[Tutor] url parsing

2009-02-15 Thread Jay Jesus Amorin
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