Reading a file in IDLE 3 on Mac-Lion

Discussion in 'Python' started by Franck Ditter, Sep 21, 2012.

  1. Hello,
    I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion).
    It runs fine and creates the disk file, visible with
    TextWrangler or another.
    But I can't open it with IDLE (its name is greyed).
    IDLE is supposed to read utf-8 files, no ?
    This works on Windows-7.
    Thanks for the tip,

    franck
     
    Franck Ditter, Sep 21, 2012
    #1
    1. Advertising

  2. Franck Ditter

    Hans Mulder Guest

    On 21/09/12 16:29:55, Franck Ditter wrote:
    > I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion).
    > It runs fine and creates the disk file, visible with
    > TextWrangler or another.
    > But I can't open it with IDLE (its name is greyed).
    > IDLE is supposed to read utf-8 files, no ?
    > This works on Windows-7.


    There's a little pop-menu below the list of files.

    It allows you to choose which kind of files you want to open.
    By default, it is set to "Python files", which greys out all
    files, except those with a '.py' or '.pyw' extension.
    Setting it to "Text files" should help, or else try "All files".

    Hope this helps

    -- HansM
     
    Hans Mulder, Sep 21, 2012
    #2
    1. Advertising

  3. In article <505ccdc5$0$6919$4all.nl>,
    Hans Mulder <> wrote:

    > On 21/09/12 16:29:55, Franck Ditter wrote:
    > > I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion).
    > > It runs fine and creates the disk file, visible with
    > > TextWrangler or another.
    > > But I can't open it with IDLE (its name is greyed).
    > > IDLE is supposed to read utf-8 files, no ?
    > > This works on Windows-7.

    >
    > There's a little pop-menu below the list of files.
    >
    > It allows you to choose which kind of files you want to open.
    > By default, it is set to "Python files", which greys out all
    > files, except those with a '.py' or '.pyw' extension.
    > Setting it to "Text files" should help, or else try "All files".
    >
    > Hope this helps
    >
    > -- HansM


    Alas this pop-up menu is for Windows only, I don't
    find it on MacOS-X. My files are xxx.dat files and not visible,
    even text only (numeric data).
    This can be filed as something to do !
    Thanks,

    franck
     
    Franck Ditter, Sep 22, 2012
    #3
  4. Franck Ditter

    Hans Mulder Guest

    On 22/09/12 09:30:57, Franck Ditter wrote:
    > In article <505ccdc5$0$6919$4all.nl>,
    > Hans Mulder <> wrote:
    >
    >> On 21/09/12 16:29:55, Franck Ditter wrote:
    >>> I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion).
    >>> It runs fine and creates the disk file, visible with
    >>> TextWrangler or another.
    >>> But I can't open it with IDLE (its name is greyed).
    >>> IDLE is supposed to read utf-8 files, no ?
    >>> This works on Windows-7.

    >>
    >> There's a little pop-menu below the list of files.
    >>
    >> It allows you to choose which kind of files you want to open.
    >> By default, it is set to "Python files", which greys out all
    >> files, except those with a '.py' or '.pyw' extension.
    >> Setting it to "Text files" should help, or else try "All files".
    >>
    >> Hope this helps
    >>
    >> -- HansM

    >
    > Alas this pop-up menu is for Windows only, I don't
    > find it on MacOS-X.


    It's there on my MacOS X 10.6.5 system.

    If your 10.7 system doesn't show it, that's definitely a bug.

    > My files are xxx.dat files and not visible,
    > even text only (numeric data).


    As a work-around, you could name the your file xxx.pyw.

    On Windows, there's a functional difference between .py
    and .pyw. On a Mac, there's no functional difference and
    Idle is willing to open both types of files, so you could
    use .py for code and .pyw for data.

    > This can be filed as something to do !


    If you're feeling adventurous, you could try solving it
    yourself. Idle is written in pure Python; that makes
    this sort of thing a lot easier than if it were in C.

    And bug reports with a patch are far more likely to be
    picked up by the dev team.

    Hope this helps,

    -- HansM
     
    Hans Mulder, Sep 22, 2012
    #4
  5. Franck Ditter

    Ned Deily Guest

    In article <505d9cc5$0$6846$4all.nl>,
    Hans Mulder <> wrote:
    > On 22/09/12 09:30:57, Franck Ditter wrote:
    > > In article <505ccdc5$0$6919$4all.nl>,
    > > Hans Mulder <> wrote:
    > >> On 21/09/12 16:29:55, Franck Ditter wrote:
    > >>> I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion).
    > >>> It runs fine and creates the disk file, visible with
    > >>> TextWrangler or another.
    > >>> But I can't open it with IDLE (its name is greyed).
    > >>> IDLE is supposed to read utf-8 files, no ?
    > >>> This works on Windows-7.
    > >>
    > >> There's a little pop-menu below the list of files.
    > >>
    > >> It allows you to choose which kind of files you want to open.
    > >> By default, it is set to "Python files", which greys out all
    > >> files, except those with a '.py' or '.pyw' extension.
    > >> Setting it to "Text files" should help, or else try "All files".

    > > Alas this pop-up menu is for Windows only, I don't
    > > find it on MacOS-X.

    >
    > It's there on my MacOS X 10.6.5 system.
    >
    > If your 10.7 system doesn't show it, that's definitely a bug.


    This appears to a difference in behavior between Carbon Tk 8.4 and Cocoa
    Tk 8.5 on OS X. The python.org 32-bit-only installers are built to link
    with the former and, with 8.4, the Open file dialog box does have the
    file-type filter menu as Hans describes. The python.org 64-/32-bit
    installers link with the newer Cocoa Tk 8.5 and, with it, the Open file
    dialog box does not have the filter menu. I'm not sure there is
    anything that IDLE or Tkinter can do about that; any change may need to
    be by the Tcl/Tk folks. But it would be good if you would open an issue
    at bugs.python.org so we can follow up on it.

    --
    Ned Deily,
     
    Ned Deily, Sep 23, 2012
    #5
  6. Franck Ditter

    Kevin Walzer Guest

    On 9/23/12 3:33 AM, Ned Deily wrote:
    > This appears to a difference in behavior between Carbon Tk 8.4 and Cocoa
    > Tk 8.5 on OS X. The python.org 32-bit-only installers are built to link
    > with the former and, with 8.4, the Open file dialog box does have the
    > file-type filter menu as Hans describes. The python.org 64-/32-bit
    > installers link with the newer Cocoa Tk 8.5 and, with it, the Open file
    > dialog box does not have the filter menu. I'm not sure there is
    > anything that IDLE or Tkinter can do about that; any change may need to
    > be by the Tcl/Tk folks. But it would be good if you would open an issue
    > at bugs.python.org so we can follow up on it.


    It's a function of NSOpenPanel, the underlying native dialog that
    supports the "open file" dialog on OS X. It doesn't have a "file filter"
    capability, and so it will only recognize hard-coded types that are
    passed to it, cf. py and txt files. "dat" isn't recognized, I tested it
    out. There's nothing to do here; it's an aspect of the native dialog.

    --
    Kevin Walzer
    Code by Kevin
    http://www.codebykevin.com
     
    Kevin Walzer, Sep 23, 2012
    #6
  7. Franck Ditter

    Kevin Walzer Guest

    On 9/23/12 8:45 AM, Kevin Walzer wrote:
    > There's nothing to do here; it's an aspect of the native dialog.


    To clarify: there's nothing to do at the C level, which is where the
    native dialog is invoked. IDLE can probably be patched to accept other
    file types, such as "dat."

    --
    Kevin Walzer
    Code by Kevin
    http://www.codebykevin.com
     
    Kevin Walzer, Sep 23, 2012
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JKPeck
    Replies:
    3
    Views:
    849
    Benjamin Kaplan
    Mar 13, 2012
  2. Tim Johnson

    MySQLdb on Mac Lion

    Tim Johnson, Oct 13, 2011, in forum: Python
    Replies:
    0
    Views:
    217
    Tim Johnson
    Oct 13, 2011
  3. Franck Ditter
    Replies:
    4
    Views:
    597
    Ned Deily
    Mar 5, 2012
  4. Une Bévue
    Replies:
    0
    Views:
    801
    Une Bévue
    Mar 22, 2012
  5. Trudge

    Odd behaviour on Mac OS X Lion

    Trudge, Jun 11, 2012, in forum: Perl Misc
    Replies:
    11
    Views:
    831
    Tim McDaniel
    Jun 13, 2012
Loading...

Share This Page