Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44963
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-05-08 13:14 -0700 |
| References | <ab1feb45-0397-4411-bab1-898c95f57b05@googlegroups.com> <mailman.1419.1367963622.3114.python-list@python.org> |
| Message-ID | <f41664f6-9f02-473c-bcd9-5f88980aab63@googlegroups.com> (permalink) |
| Subject | Re: Get filename using filefialog.askfilename |
| From | cheirasacan@gmail.com |
El martes, 7 de mayo de 2013 23:53:32 UTC+2, Terry Jan Reedy escribió:
> On 5/7/2013 4:27 PM, cheirasacan@gmail.com wrote:
>
>
>
> > file = filedialog.askopenfile ( mode....... )
>
>
>
> askopenfile is a convenience function that creates an Open dialog
>
> object, shows it, gets the name returned by the dialog, opens the file
>
> with that name, and returns an appropriate normal file object
>
>
>
> > to open a file with an open dialog box, OK. Made it.
>
> >
>
> > How i get the name of the opened file?
>
>
>
> file.name, (at least in 3.3), which in your example below is "file.doc"
>
>
>
> > print(file)
>
> >
>
> > the output is: <......name="file.doc"...mode=......encoding.......... >
>
>
>
> This is the standard string representation of a file object. It is
>
> created from the various attributes of the file instance, including
>
> file.name.
>
>
>
> > How can i get the second member of 'file'?
>
>
>
> Strings do not have fields. The second 'member', would be the second
>
> character, file[1], which is not what you want.
>
>
>
> > And i am unable to find a detailed reference to this object in the i.net
>
>
>
> Use the Fine Manual. The entry for builtin open() function, which you
>
> should read to understand the 'open' part of askopenfile, directs you to
>
> the Glossary entry 'file object' which says "There are actually three
>
> categories of file objects: raw binary files, buffered binary files and
>
> text files. Their interfaces are defined in the io module. The canonical
>
> way to create a file object is by using the open() function." The kind
>
> of file object you get is determined by the mode ('b' present or not),
>
> buffer arg, and maybe something else. You can look in the io chapter or
>
> use dir() and help() as John G. suggested.
>
>
>
> Python programmers should really learn to use dir(), help(), and the
>
> manuls, including the index and module index.
>
>
>
> --
>
> Terry Jan Reedy
Yeah. This is an answer. A lot of thanks.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Get filename using filefialog.askfilename cheirasacan@gmail.com - 2013-05-07 13:27 -0700
Re: Get filename using filefialog.askfilename John Gordon <gordon@panix.com> - 2013-05-07 20:37 +0000
Re: Get filename using filefialog.askfilename Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-07 17:53 -0400
Re: Get filename using filefialog.askfilename cheirasacan@gmail.com - 2013-05-08 13:14 -0700
Re: Get filename using filefialog.askfilename Dave Angel <davea@davea.name> - 2013-05-08 18:52 -0400
csiph-web