Re: path slashes cleaning
Am 04.09.2008, 15:27 Uhr, schrieb Mike Driscoll [EMAIL PROTECTED]: On Sep 4, 8:25 am, Mathieu Prevot [EMAIL PROTECTED] wrote: Hi, for scripts that take arguments, I would like to remove the trailing slash if it's present. Is there something else than: a='/usr/local/lib/' if a[-1] == '/': a = list(a) a.pop() ''.join(a) Thanks, Mathieu How about this: if a[-1] == '/': a = a[:-1] Mike Hi, how about a.rstrip('/') ? Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a Python Program/Tool That Will Add Line Numbers to a txt File
On Thu, 14 Feb 2008, W. Watson wrote: See Subject. It's a simple txt file, each line is a Python stmt, but I need up to four digits added to each line with a space between the number field and the text. Perhaps someone has already done this or there's a source on the web for it. I'm not yet into files with Python. A sudden need has burst upon me. I'm using Win XP. -- Wayne Watson (Nevada City, CA) Web Page: speckledwithStars.net Hi Wayne, sorry for that: Change OS, and type cat -n program.py numbered.py Just joking, Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use list as key of dictionary?
On Tue, 6 Nov 2007, Boris Borcic wrote: We know that list cannot be used as key of dictionary. Yeah, but do we know why ? I think, because lists are mutable and a key of a dictionary MUST be unmutable, not to crash the dictionary by accidently changing one of its keys! Mike -- http://mail.python.org/mailman/listinfo/python-list