Determining if a filename is greater than X characters

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sun Aug 3 14:23:06 CEST 2003


Cy Edmunds wrote:

> filename = "abcdefgh"
> if len(filename) > 6:
>     filename = filename[:6]
> print filename
> abcdef

The if is not necessary, just use

filename=filename[:6]

--Irmen







More information about the Python-list mailing list