tuple methods: documentation missing

Discussion in 'Python' started by Alan G Isaac, Jan 16, 2009.

  1. Alan G Isaac

    Alan G Isaac Guest

    Alan G Isaac, Jan 16, 2009
    #1
    1. Advertising

  2. Alan G Isaac

    Terry Reedy Guest

    Terry Reedy, Jan 16, 2009
    #2
    1. Advertising

  3. Alan G Isaac

    Alan G Isaac Guest

    > Alan G Isaac wrote:
    >> http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range
    >>
    >> I see no mention of the tuple methods?
    >>
    >> Right after the paragraph
    >> "Most sequence types support the following operations."
    >> it seems appropriate to have one stating
    >> "Most sequence types support the following methods: index() and count()."




    On 1/16/2009 6:44 PM Terry Reedy apparently wrote:
    > I addressed this and related issues in
    > http://bugs.python.org/issue4966



    Excellent!

    Alan Isaac
    Alan G Isaac, Jan 17, 2009
    #3
  4. Alan G Isaac

    Alan G Isaac Guest

    On 1/16/2009 6:44 PM Terry Reedy apparently wrote:
    > http://bugs.python.org/issue4966



    Is this another lacuna or am I overlooking it?
    I cannot find the 3.0 documentation of string
    formatting with the ``%`` operator.

    Thanks,
    Alan Isaac
    Alan G Isaac, Jan 17, 2009
    #4
  5. Alan G Isaac

    Ned Deily Guest

    Ned Deily, Jan 17, 2009
    #5
  6. Alan G Isaac

    Alan G Isaac Guest

    Re: string formatting documentation

    On 1/17/2009 3:59 PM Ned Deily apparently wrote:
    > <http://docs.python.org/3.0/library/stdtypes.html#old-string-formatting-operations>



    Ah, so the rumors are true:
    we are supposed to prefer
    '{0:>10}'.format('wtf?')
    to
    '%10s' % 'wtf?'
    and
    '{{0}}{0}'.format('wtf?').format('wtf?')
    to
    '%%s%s' % 'wtf?' % 'wtf?'

    According to PEP 4,
    "obsolete" means "deprecated".
    So the compact, simple, and useful
    old string formatting is really deprecated?
    Ouch.

    Thanks,
    Alan Isaac
    Alan G Isaac, Jan 19, 2009
    #6
  7. Re: string formatting documentation

    On Mon, 19 Jan 2009 14:44:01 +0000, Alan G Isaac wrote:

    > On 1/17/2009 3:59 PM Ned Deily apparently wrote:
    >> <http://docs.python.org/3.0/library/stdtypes.html#old-string-

    formatting-operations>
    >
    >
    > Ah, so the rumors are true:
    > we are supposed to prefer
    > '{0:>10}'.format('wtf?')
    > to
    > '%10s' % 'wtf?'
    > and
    > '{{0}}{0}'.format('wtf?').format('wtf?') to
    > '%%s%s' % 'wtf?' % 'wtf?'


    Well, that second example certainly is a WTF.

    I think we are supposed to prefer:

    '{0}{0}'.format('wtf?')
    to
    '%%s%s' % 'wtf?' % 'wtf?'

    And frankly, I do.


    > According to PEP 4,
    > "obsolete" means "deprecated".
    > So the compact, simple, and useful
    > old string formatting is really deprecated? Ouch.


    PEP 4 applies to *modules*. String formatting is not a module. Old string
    formatting is obsolete but not yet deprecated. Why don't you raise the
    issue on python-dev, where it may do some good?



    --
    Steven
    Steven D'Aprano, Jan 19, 2009
    #7
  8. Alan G Isaac

    Alan G Isaac Guest

    Re: string formatting documentation

    > On Mon, 19 Jan 2009 14:44:01 +0000, Alan G Isaac wrote:
    >> we are supposed to prefer '{0:>10}'.format('wtf?')
    >> to
    >> '%10s' % 'wtf?'
    >> and
    >> '{{0}}{0}'.format('wtf?').format('wtf?') to
    >> '%%s%s' % 'wtf?' % 'wtf?'


    On 1/19/2009 10:01 AM Steven D'Aprano apparently wrote:
    > Well, that second example certainly is a WTF.
    > I think we are supposed to prefer:


    > '{0}{0}'.format('wtf?')
    > to
    > '%%s%s' % 'wtf?' % 'wtf?'



    But your replacement misses the point of the example,
    which is that sequential formatting is often needed.
    That is, you need to generate a format string from
    a format string. More explicitly:

    '{{0}} {0}'.format('earlyinfo').format('lateinfo')

    '%%s %s' % 'earlyinfo' % 'lateinfo'

    But of more interest: you claim PEP 4 is not relevant,
    and that old string formatting is NOT deprecated.
    I would like assurance that it is not deprecated.
    Can you back that?

    Thanks,
    Alan Isaac
    Alan G Isaac, Jan 19, 2009
    #8
  9. Alan G Isaac

    John Machin Guest

    Re: string formatting documentation

    On Jan 20, 2:38 am, Alan G Isaac <> wrote:
    > But of more interest: you claim PEP 4 is not relevant,
    > and that old string formatting is NOT deprecated.
    > I would like assurance that it is not deprecated.


    It is not deprecated YET; see this:

    http://docs.python.org/3.0/whatsnew/3.0.html#changes-already-present-in-python-2-6

    PEP 3101: Advanced String Formatting. Note: the 2.6 description
    mentions the format() method for both 8-bit and Unicode strings. In
    3.0, only the str type (text strings with Unicode support) supports
    this method; the bytes type does not. The plan is to eventually make
    this the only API for string formatting, and to start deprecating the
    % operator in Python 3.1.
    John Machin, Jan 19, 2009
    #9
  10. Re: string formatting documentation

    On Mon, 19 Jan 2009 15:38:02 +0000, Alan G Isaac wrote:

    > But of more interest: you claim PEP 4 is not relevant, and that old
    > string formatting is NOT deprecated. I would like assurance that it is
    > not deprecated. Can you back that?


    If you want to know what python-dev have in mind, you have to ask them,
    not me.

    But as I see it, the earliest % formatting could be removed would be
    Python 3.2: Python 3.1 to get a formal deprecation warning, with
    removal no earlier than 3.2. So you've got about a year to change their
    mind about deprecating the old style, or alternatively, a year to get
    used to the new style, followed by another year for % to go away
    completely.




    --
    Steven
    Steven D'Aprano, Jan 19, 2009
    #10
  11. Alan G Isaac

    Terry Reedy Guest

    Re: string formatting documentation

    Alan G Isaac wrote:
    >> On Mon, 19 Jan 2009 14:44:01 +0000, Alan G Isaac wrote:
    >>> we are supposed to prefer


    No, no 'supposed to's. You are not even 'supposed to' like or use
    Python. (Unless, I supposed, an employer demands it. But that is
    another story.) Certainly, one is not 'supposed to' prefer the new to
    the carefully picked best use example of the old. Guido and some
    developers prefer the totality of uses cases and possibilities of
    ..format to the same for % formatting.

    > On 1/19/2009 10:01 AM Steven D'Aprano apparently wrote:
    >> Well, that second example certainly is a WTF. I think we are supposed
    >> to prefer:

    >
    >> '{0}{0}'.format('wtf?')
    >> to '%%s%s' % 'wtf?' % 'wtf?'

    >
    > But your replacement misses the point of the example,


    I read it the same way and has the same thought as Steven.
    Perhaps all the obviously angry 'wtf?'s distracted me.

    > which is that sequential formatting is often needed.
    > That is, you need to generate a format string from
    > a format string. More explicitly:
    >
    > '{{0}} {0}'.format('earlyinfo').format('lateinfo')
    >
    > '%%s %s' % 'earlyinfo' % 'lateinfo'


    This is what you should have written. Having never seen or done this, I
    first missed the doubled '%%' and read it as a syntax error.

    > I would like assurance that it is not deprecated.
    > Can you back that?


    If you claim something exists, you have the burden of proof.
    I have not seen 3.0 emit a % deprecation warning. Have you?

    Last I read, Guido *plans* to deprecate % formatting 'sometime'.

    Terry Jan Reedy
    Terry Reedy, Jan 19, 2009
    #11
  12. Alan G Isaac

    Alan G Isaac Guest

    Re: string formatting documentation

    On 1/19/2009 3:03 PM John Machin apparently wrote:
    > It is not deprecated YET; see this:
    >
    > http://docs.python.org/3.0/whatsnew/3.0.html#changes-already-present-in-python-2-6
    >
    > PEP 3101: Advanced String Formatting. Note: the 2.6 description
    > mentions the format() method for both 8-bit and Unicode strings. In
    > 3.0, only the str type (text strings with Unicode support) supports
    > this method; the bytes type does not. The plan is to eventually make
    > this the only API for string formatting, and to start deprecating the
    > % operator in Python 3.1.



    Thanks!
    Alan Isaac
    Alan G Isaac, Jan 20, 2009
    #12
  13. Alan G Isaac

    Alan G Isaac Guest

    Re: string formatting documentation

    On 1/19/2009 5:03 PM Terry Reedy apparently wrote:
    > I have not seen 3.0 emit a % deprecation warning.



    Point taken.

    But the vocabulary of PEP 4 suggests that
    "obsolete" and "deprecated" are synonyms,
    and PEP 4 lists obsolete modules without
    deprecation warnings.

    Alan Isaac
    Alan G Isaac, Jan 20, 2009
    #13
    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. Michal Mikolajczyk
    Replies:
    1
    Views:
    792
    Larry Bates
    Apr 20, 2004
  2. Jeff Epler
    Replies:
    0
    Views:
    923
    Jeff Epler
    Apr 20, 2004
  3. Bill Scherer
    Replies:
    0
    Views:
    602
    Bill Scherer
    Apr 20, 2004
  4. Gregor Horvath

    Why tuple with one item is no tuple

    Gregor Horvath, Mar 15, 2005, in forum: Python
    Replies:
    37
    Views:
    793
    Antoon Pardon
    Mar 30, 2005
  5. Steve
    Replies:
    1
    Views:
    945
    Fredrik Lundh
    Dec 13, 2005
Loading...

Share This Page