RE: open is not obsolete (was Re: understanding self

Discussion in 'Python' started by Delaney, Timothy C (Timothy), Jul 8, 2004.

  1. Jeff Shannon wrote:

    > Okay, perhaps "legacy" is a better term than "obsolete". In either
    > case, it's recommended that it not be used in new code, even if there
    > is no current plan to remove it. Not that the specifics of this case
    > are particularly germane to the point I was making...


    As mentioned by Tony, this is not the case. From python-dev:

    >> Then should the following line in the reference be changed?
    >>
    >> "The file() constructor is new in Python 2.2. The previous spelling,
    >> open(), is retained for compatibility, and is an alias for file()."
    >>
    >> That *strongly* suggests that the preferred spelling is file(), and
    >> that open() shouldn't be used for new code.

    >
    > Oops, yes. I didn't write that, and it doesn't convey my feelings
    > about file() vs. open(). Here's a suggestion for better words:
    >
    > "The file class is new in Python 2.2. It represents the type (class)
    > of objects returned by the built-in open() function. Its constructor
    > is an alias for open(), but for future and backwards compatibility,
    > open() remains preferred."
    >
    > --Guido van Rossum (home page: http://www.python.org/~guido/)


    Tim Delaney
    Delaney, Timothy C (Timothy), Jul 8, 2004
    #1
    1. Advertising

  2. Delaney, Timothy C (Timothy) wrote:

    > Jeff Shannon wrote:
    >
    >
    >>Okay, perhaps "legacy" is a better term than "obsolete". In either
    >>case, it's recommended that it not be used in new code, even if there
    >>is no current plan to remove it. Not that the specifics of this case
    >>are particularly germane to the point I was making...

    >
    >
    > As mentioned by Tony, this is not the case. From python-dev:
    >
    >
    >>>Then should the following line in the reference be changed?
    >>>
    >>>"The file() constructor is new in Python 2.2. The previous spelling,
    >>>open(), is retained for compatibility, and is an alias for file()."
    >>>
    >>>That *strongly* suggests that the preferred spelling is file(), and
    >>>that open() shouldn't be used for new code.

    >>
    >>Oops, yes. I didn't write that, and it doesn't convey my feelings
    >>about file() vs. open(). Here's a suggestion for better words:
    >>
    >>"The file class is new in Python 2.2. It represents the type (class)
    >>of objects returned by the built-in open() function. Its constructor
    >>is an alias for open(), but for future and backwards compatibility,
    >>open() remains preferred."
    >>
    >>--Guido van Rossum (home page: http://www.python.org/~guido/)

    >
    >
    > Tim Delaney


    "file" is analogous to a class constructor, while "open" becomes a
    factory function for that class, with the same signature.

    This raises the question as to which is the better way of creating an
    instance of a class.

    It seems to me that the constructor is, for simple cass, the better way
    to go. It provides one way and avoids the question of "Should I use A
    or B when there are more than one ways of doing some task.

    What is the general view?

    Colin W.
    Colin J. Williams, Jul 8, 2004
    #2
    1. Advertising

  3. Delaney, Timothy C (Timothy)

    Paul Watson Guest

    "Colin J. Williams" <> wrote in message
    news:5OaHc.45662$...
    >
    >
    > Delaney, Timothy C (Timothy) wrote:
    >
    > > Jeff Shannon wrote:
    > >
    > >
    > >>Okay, perhaps "legacy" is a better term than "obsolete". In either
    > >>case, it's recommended that it not be used in new code, even if there
    > >>is no current plan to remove it. Not that the specifics of this case
    > >>are particularly germane to the point I was making...

    > >
    > >
    > > As mentioned by Tony, this is not the case. From python-dev:
    > >
    > >
    > >>>Then should the following line in the reference be changed?
    > >>>
    > >>>"The file() constructor is new in Python 2.2. The previous spelling,
    > >>>open(), is retained for compatibility, and is an alias for file()."
    > >>>
    > >>>That *strongly* suggests that the preferred spelling is file(), and
    > >>>that open() shouldn't be used for new code.
    > >>
    > >>Oops, yes. I didn't write that, and it doesn't convey my feelings
    > >>about file() vs. open(). Here's a suggestion for better words:
    > >>
    > >>"The file class is new in Python 2.2. It represents the type (class)
    > >>of objects returned by the built-in open() function. Its constructor
    > >>is an alias for open(), but for future and backwards compatibility,
    > >>open() remains preferred."
    > >>
    > >>--Guido van Rossum (home page: http://www.python.org/~guido/)

    > >
    > >
    > > Tim Delaney

    >
    > "file" is analogous to a class constructor, while "open" becomes a
    > factory function for that class, with the same signature.
    >
    > This raises the question as to which is the better way of creating an
    > instance of a class.
    >
    > It seems to me that the constructor is, for simple cass, the better way
    > to go. It provides one way and avoids the question of "Should I use A
    > or B when there are more than one ways of doing some task.
    >
    > What is the general view?
    >
    > Colin W.


    It would appear that the "General DBFL" view is to use open().
    Paul Watson, Jul 8, 2004
    #3
  4. Paul Watson wrote:
    > "Colin J. Williams" <> wrote in message
    > news:5OaHc.45662$...
    >
    >>
    >>Delaney, Timothy C (Timothy) wrote:
    >>
    >>
    >>>Jeff Shannon wrote:
    >>>
    >>>
    >>>
    >>>>Okay, perhaps "legacy" is a better term than "obsolete". In either
    >>>>case, it's recommended that it not be used in new code, even if there
    >>>>is no current plan to remove it. Not that the specifics of this case
    >>>>are particularly germane to the point I was making...
    >>>
    >>>
    >>>As mentioned by Tony, this is not the case. From python-dev:
    >>>
    >>>
    >>>
    >>>>>Then should the following line in the reference be changed?
    >>>>>
    >>>>>"The file() constructor is new in Python 2.2. The previous spelling,
    >>>>>open(), is retained for compatibility, and is an alias for file()."
    >>>>>
    >>>>>That *strongly* suggests that the preferred spelling is file(), and
    >>>>>that open() shouldn't be used for new code.
    >>>>
    >>>>Oops, yes. I didn't write that, and it doesn't convey my feelings
    >>>>about file() vs. open(). Here's a suggestion for better words:
    >>>>
    >>>>"The file class is new in Python 2.2. It represents the type (class)
    >>>>of objects returned by the built-in open() function. Its constructor
    >>>>is an alias for open(), but for future and backwards compatibility,
    >>>>open() remains preferred."
    >>>>
    >>>>--Guido van Rossum (home page: http://www.python.org/~guido/)
    >>>
    >>>
    >>>Tim Delaney

    >>
    >>"file" is analogous to a class constructor, while "open" becomes a
    >>factory function for that class, with the same signature.
    >>
    >>This raises the question as to which is the better way of creating an
    >>instance of a class.
    >>
    >>It seems to me that the constructor is, for simple cass, the better way
    >>to go. It provides one way and avoids the question of "Should I use A
    >>or B when there are more than one ways of doing some task.
    >>
    >>What is the general view?
    >>
    >>Colin W.

    >
    >
    > It would appear that the "General DBFL" view is to use open().
    >
    >

    I was seeking some ideas on the relative merits of factory functions vs
    constructors. We have the DBFL view on the specific case of open versus
    file.

    Colin W.
    Colin J. Williams, Jul 9, 2004
    #4
    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. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    561
    Lonnie Princehouse
    Jul 11, 2005
  2. Ralf W. Grosse-Kunstleve
    Replies:
    18
    Views:
    580
    Bengt Richter
    Jul 11, 2005
  3. Ralf W. Grosse-Kunstleve
    Replies:
    2
    Views:
    390
    Dan Sommers
    Jul 12, 2005
  4. falcon
    Replies:
    0
    Views:
    361
    falcon
    Jul 31, 2005
  5. Bart Kastermans
    Replies:
    6
    Views:
    386
    Bart Kastermans
    Jul 13, 2008
Loading...

Share This Page