argparse and filetypes
Alex Willmer
alex at moreati.org.uk
Tue Mar 22 11:52:37 EDT 2011
On Mar 22, 2:06 pm, Bradley Hintze <bradle... at aggiemail.usu.edu>
wrote:
> Hi,
>
> I just started with argparse. I want to simply check the extension of
> the file that the user passes to the program. I get a ''file' object
> has no attribute 'rfind'' error when I use
> os.path.splitext(args.infile).
Addendum, some file objects have a name attribute (which I hadn't
noticed until today):
file.name
If the file object was created using open(), the name of the file.
Otherwise, some string that indicates the source of the file object,
of the form <...>. This is a read-only attribute and may not be
present on all file-like objects.
http://docs.python.org/library/stdtypes.html#file-objects
More information about the Python-list
mailing list