Re: how to join array of integers?

2007-09-15 Thread Arnau Sanchez
js escribió: >> On 9/15/07, Summercool <[EMAIL PROTECTED]> wrote: >> in Python... is the method to use ",".join() ? but then it must take >> a list of strings... not integers... >> >> any fast method? > print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension inste

Re: Modul (%) in python not like in C?

2007-09-09 Thread Arnau Sanchez
J. Cliff Dyer escribió: > Dotan Cohen wrote: >> FIrst of all, how is the % symbol (as in 70%6=4) called in English? >> >> Second, in Turbo C -111%10=-1 however in python -111%10=9. Is one or >> the other in error? Is this a known gotcha? I tried to google the >> subject however one cannot google

Re: Text processing and file creation

2007-09-06 Thread Arnau Sanchez
[EMAIL PROTECTED] escribió: > I am still wondering how to do this efficiently in Python (being kind > of new to it... and it's not for homework). You should post some code anyway, it would be easier to give useful advice (it would also demonstrate that you put some effort on it). Anyway, here i

Re: Text processing and file creation

2007-09-05 Thread Arnau Sanchez
[EMAIL PROTECTED] escribió: > I have a text source file of about 20.000 lines. >>From this file, I like to write the first 5 lines to a new file. Close > that file, grab the next 5 lines write these to a new file... grabbing > 5 lines and creating new files until processing of all 20.000 lines is

Re: sys.argv is munging my command line options

2007-08-29 Thread Arnau Sanchez
Chris Allen escribió: > action key=value key=value... > > Where action is a required string (ie. 'backup', 'init', 'restore', > etc) and the program can accept one or more key value pairs. I know > this syntax isn't standard, but I think it works great for my program > as each key can override a

Re: How do I get the current path of my python file that is currently running.

2007-08-23 Thread Arnau Sanchez
Lamonte Harris escribió: > Say I start i click on a python file on my desktop, how could I return > the path of the current python file thats running? http://docs.python.org/lib/module-sys.html -- http://mail.python.org/mailman/listinfo/python-list

Re: sort dictionary by specific values

2007-08-18 Thread Arnau Sanchez
dorje tarap escribió: >2. > {8: (99, 99), 9: [(55, 67), (77, 66), (67, 88)], 4: [(45, 78), > (56, 78), (99, 78)], 5: (67, 77)} > > > I want to sort the entire dictionary based on the last values in each > line. First for [-1][0] and then[-1][0] Each "line" means each value in t

Re: how to get command output using python

2007-08-09 Thread Arnau Sanchez
[EMAIL PROTECTED] escribió: >> Any non cross-platform module should be avoided unless absolutely necessary. >> >> Subprocess is the right module to use. >> >> arnau > > You forgot to mention that subprocess replaces commands, so in effect, > commands is deprecated anyway. It was implicit :-) An

Re: how to get command output using python

2007-08-09 Thread Arnau Sanchez
Steven Harms escribió: > In python it is quite easy: > > import commands > status, output = commands.getstatusoutput("my command") Uhm, this module has a big issue: (http://docs.python.org/lib/module-commands.html) 8.17 commands -- Utilities for running commands Availability: Unix.

Re: Launch file from Python

2007-08-08 Thread Arnau Sanchez
[EMAIL PROTECTED] escribió: > That's just the exit status or run status, if I recall correctly. I > think 0 (i.e. False) means it didn't run properly and anything else is > True, or ok. Something like that. The other way: 0 means "ok" while everything else means error (at least in UNIX). The re

Re: What is the "functional" way of doing this?

2007-08-05 Thread Arnau Sanchez
> On Jul 30, 5:48 pm, beginner wrote: > >> def f(n): >> l=[] >> while n>0: >> l.append(n%26) >> n /=26 >> return l >> >> I am wondering what is the 'functional' way to do the same. >> > I see. It is interesting (and not surprisingly) that recursion or > yield ar