Determining if a filename is greater than X characters

Sean 'Shaleh' Perry shalehperry at
Sun Aug 3 08:40:15 CEST 2003

On Saturday 02 August 2003 19:15, hokiegal99 wrote:
> How would I determine if a filename is greater than a certain number
> of characters and then truncate it to that number? For example a file
> named XXXXXXXXX.txt would become XXXXXX
> 	fname = files
> 	if fname[0] > 6
> 	   print fname[0]
> Thanks!!!

look at the os.path module and also the len() builtin.  The two of those 
should give you everything you need.

More information about the Python-list mailing list