In practice, I had to change this:
if len(query) > 0 and query[-1] == query[-1].capitalize(): group =
query.pop()
to this:
if len(query) > 0 and query[-1][0] == query[-1].capitalize()[0]:
group = query.pop()
This is because I only wanted to test the case of the first letter of
the string.
--
This is what I ended up with. Slightly different approach:
import urlparse
def sUrl(s):
page = group = ''
bits = urlparse.urlsplit(s)
url = '//'.join([bits[0],bits[1]]) + '/'
query = bits[2].split('/')
if '' in query: query.remove('')
if len(query) > 1: page = quer
mention having tried
> the urlparse module, so I thought I should ask: have you tried using
> urlparse?
>
> Skip
>
--
Ben Wilson
" Mundus vult decipi, ergo decipiatur"
--
http://mail.python.org/mailman/listinfo/python-list
Here is what I came up with:
def siftUrl(s):
s = s.split('//')[1]
bits = s.split('/')
if '' in bits: bits.remove('')
if len(bits) > 1:
group = bits[-2]
page = bits[-1]
group.strip('/')
page.strip('/')
else
I am working on a script that splits a URL into a page and a url. The
examples below are the conditions I expect a user to pass to the
script. In all cases, "http://www.example.org/test/"; is the URL, and
the page comprises parts that have upper case letters (note, 5 & 6 are
the same as earlier exa
Thanks for your suggestions. I've Python on both my Win32 and Linux
partitions of my laptop. Although, I suppose I should develop my CGI on
the laptop (running Apache) first.
Thanks,
Ben
--
http://mail.python.org/mailman/listinfo/python-list
way I can run a python script is by using the .cgi extension. I'm
not sure if I want to stick with my host and just call my apps
index.cgi, or if I should move to a new server. If I were to move to a
new server, which would you recomend, and why?
Regards,
Ben Wilson
--
http://mail.python.org/mai
You know, I have that for Perl, but seem never to have set up folding
for Python. I must remedy this tonight.
Ben
--
http://mail.python.org/mailman/listinfo/python-list
He said "IDE." That means "vim"
--
http://mail.python.org/mailman/listinfo/python-list
Perhaps:
def dictionary_make_attributes(self, settings):
for k,v in settings:
setattr(self, k, v)
http://ftp.python.org/doc/lib/built-in-funcs.html#l2h-64
--
http://mail.python.org/mailman/listinfo/python-list
Yeah, I was going to say it's "I-66," not "Route 66," which has been
replaced in pertainent parts by I-40.
tuh-ple.
--
http://mail.python.org/mailman/listinfo/python-list
Well, my Perl way of doing it would be to have all attributes in a dict
(hash), then create the accessor vi a dynamic function. I knew Python
would have a right way to do it for Python, but when I went looking I
neglected to look at the core of the language. I suppose I'm just too
accustomed to the
That's it. I should spend more time R-ingTFM. I kept looking for some
class-based solution and there was a built in. Perfectly logical.
Thanks,
Ben
--
http://mail.python.org/mailman/listinfo/python-list
I would like to dynamically assign object attributes:
dict = {
a : 1,
b : 2,
}
for key,val in dict :
obj.key = val
To get:
print obj.a
1
I've googled to no effect, or maybe I'm needing to be hit with the
appropriately sized clue-by-four. Any assistance would be appreciated.
Regards,
Ben
I read somewhere else that Python was getting a ternary operator (e.g.
x = (true/false) ? y : z). I read the PEP about it and that the PEP had
been approved this past Fall. Has this been released into the wild yet?
IIRC, the operator is like:
x = y if C : else z
--
http://mail.python.org/mailma
"But the point is, the current situation is not newbie-friendly (I can
tell, I am a newbie)"
I will agree to that, as I consider myself still new. _But_, it's a
stumbling stone only briefly. Get enough nagging error messages, and
you learn and move on. I agree with the grandparent poster that it i
16 matches
Mail list logo