[Pythonmac-SIG] Strange ?
Larry Meyn
lmeyn@mail.arc.nasa.gov
Sun, 3 Feb 2002 10:16:33 -0800
Note, len('HD:Dev:stats usenet:Classement') = 30
Try:
print sys.argv[1:]
files = sys.argv[1:]
for file in files:
out = file.split(':')[-1]
if len(out)>30: out = out[:30] + ' '
print out
At 6:16 PM +0100 2/3/02, Francois Granger wrote:
>I did a simple script to work info inside some files. It gave me
>strange results, so I have reduced it to the bare script needed to
>show the behaviour.
>Config: MacOS 9.1, Python 2.2
>
>Make this script an applet and drop the filenames showed in the list.
>All filenames are different. I expect it to return the full filename
>plus a space unless the filename is longer than 30 char. In this
>case, it should return the first 30 char plus a space. But it return
>only the first word of the name plus a space.
>
>I did test with
>files = os.listdir(os.getcwd())
>and I did not get the same behaviour.
>
># python
>
>import sys, re, os
>
>print sys.argv[1:]
>files = sys.argv[1:]
>for file in files:
> out = file[:30] + ' '
> print out
>
>output of the script below.
>====================================================
>['HD:Dev:stats usenet:Classement hebdo020118', 'HD:Dev:stats
>usenet:Classement hebdo020125', 'HD:Dev:stats usenet:Classement
>hebdo020201', 'HD:Dev:stats usenet:Classement mensuel 0201',
>'HD:Dev:stats usenet:Classement hebdo020111']
>HD:Dev:stats usenet:Classement
>HD:Dev:stats usenet:Classement
>HD:Dev:stats usenet:Classement
>HD:Dev:stats usenet:Classement
>HD:Dev:stats usenet:Classement
>====================================================
>
>_______________________________________________
>Pythonmac-SIG maillist - Pythonmac-SIG@python.org
>http://mail.python.org/mailman/listinfo/pythonmac-sig
--
----------------------------------------------------------------------
Larry Meyn
Aerospace Operations Modeling Office
M/S 210-10 Phone: (650) 604-5038
NASA Ames Research Center FAX: (650) 604-0222
Moffett Field, CA 94035-1000 email: lmeyn@mail.arc.nasa.gov
E-FAX: (425) 944-5526 sent via e-mail
----------------------------------------------------------------------