Re: Better way to sift parts of URL . . .

2006-04-19 Thread Ben Wilson
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 =

Re: Better way to sift parts of URL . . .

2006-04-19 Thread Ben Wilson
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. --

Better way to sift parts of URL . . .

2006-04-18 Thread Ben Wilson
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

Re: Better way to sift parts of URL . . .

2006-04-18 Thread Ben Wilson
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('/')

Re: Better way to sift parts of URL . . .

2006-04-18 Thread Ben Wilson
? Skip -- Ben Wilson Mundus vult decipi, ergo decipiatur -- http://mail.python.org/mailman/listinfo/python-list

Re: editor for Python on Linux

2006-02-24 Thread Ben Wilson
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

Trolling for New Web Host . . .

2006-02-24 Thread Ben Wilson
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/mailman/listinfo/python

Re: editor for Python on Linux

2006-02-20 Thread Ben Wilson
He said IDE. That means vim -- http://mail.python.org/mailman/listinfo/python-list

Re: - Copy dictionary entries to attributes

2006-02-18 Thread Ben Wilson
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

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Ben Wilson
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

Re: Newbie Q: dynamically assigning object attribute

2006-02-10 Thread Ben Wilson
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

Newbie Q: dynamically assigning object attribute

2006-02-09 Thread Ben Wilson
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

Re: Newbie Q: dynamically assigning object attribute

2006-02-09 Thread Ben Wilson
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

Re: Another try at Python's selfishness

2006-02-08 Thread Ben Wilson
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 is

Ternary Operator Now?

2006-02-08 Thread Ben Wilson
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 --