FAQ
I mean to get the man page for '[' like in the following code.

x=[1,2,3]


But help('[') doesn't seem to give the above usage.

###########
Mutable Sequence Types
**********************

List objects support additional operations that allow in-place
modification of the object. Other mutable sequence types (when added
to the language) should also support these operations. Strings and
tuples are immutable sequence types: such objects cannot be modified
once created. The following operations are defined on mutable sequence
types (where *x* is an arbitrary object):
...
##########

I then checked help('LISTLITERALS'), which gives some description that
is available from the language reference. So '[' in "x=[1,2,3]" is
considered as a language feature rather than a function or an
operator?

############
List displays
*************

A list display is a possibly empty series of expressions enclosed in
square brackets:

list_display ::= "[" [expression_list | list_comprehension] "]"
list_comprehension ::= expression list_for
list_for ::= "for" target_list "in" old_expression_list
[list_iter]
old_expression_list ::= old_expression [("," old_expression)+ [","]]
list_iter ::= list_for | list_if
list_if ::= "if" old_expression [list_iter]
.....
###########
--
Regards,
Peng

Search Discussions

  • Robert Kern at Jul 16, 2010 at 5:41 pm

    On 7/16/10 12:01 PM, Peng Yu wrote:

    I then checked help('LISTLITERALS'), which gives some description that
    is available from the language reference. So '[' in "x=[1,2,3]" is
    considered as a language feature rather than a function or an
    operator?
    Yes. It is part of the list literal syntax of the Python language.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
  • Terry Reedy at Jul 16, 2010 at 10:42 pm

    On 7/16/2010 1:01 PM, Peng Yu wrote:
    I mean to get the man page for '[' like in the following code.

    x=[1,2,3]
    You might find my Python symbol glossary useful.
    https://code.google.com/p/xploro/downloads/detail?name=PySymbols.html
  • Peng Yu at Jul 17, 2010 at 1:42 am

    On Fri, Jul 16, 2010 at 5:42 PM, Terry Reedy wrote:
    On 7/16/2010 1:01 PM, Peng Yu wrote:

    I mean to get the man page for '[' like in the following code.

    x=[1,2,3]
    You might find my Python symbol glossary useful.
    https://code.google.com/p/xploro/downloads/detail?name=PySymbols.html
    This is for Python 3. Is there one for Python 2.x?

    --
    Regards,
    Peng
  • MRAB at Jul 17, 2010 at 2:08 am

    Peng Yu wrote:
    On Fri, Jul 16, 2010 at 5:42 PM, Terry Reedy wrote:
    On 7/16/2010 1:01 PM, Peng Yu wrote:
    I mean to get the man page for '[' like in the following code.

    x=[1,2,3]
    You might find my Python symbol glossary useful.
    https://code.google.com/p/xploro/downloads/detail?name=PySymbols.html
    This is for Python 3. Is there one for Python 2.x?
    Is anyone /still/ using Python 2.x? ;-)
  • Tim Chase at Jul 17, 2010 at 2:23 am

    On 07/16/2010 09:08 PM, MRAB wrote:
    Peng Yu wrote:
    You might find my Python symbol glossary useful.
    https://code.google.com/p/xploro/downloads/detail?name=PySymbols.html
    This is for Python 3. Is there one for Python 2.x?
    Is anyone /still/ using Python 2.x? ;-)
    2.x?! You were lucky. We lived for three months with Python 1.x
    in a septic tank. We used to have to get up at six in the
    morning, write our 1.x code using ed, eat a crust of stale bread,
    go to work down in machine language, fourteen hours a day,
    week-in week-out, for sixpence a week, and when we got home our
    Dad would thrash us to sleep wi' his belt...

    -tkc
  • Python at Jul 17, 2010 at 2:59 am
    Tim,
    2.x?! You were lucky. We lived for three months with Python 1.x in a septic tank. We used to have to get up at six in the morning, write our 1.x code using ed, eat a crust of stale bread, go to work down in machine language, fourteen hours a day,
    week-in week-out, for sixpence a week, and when we got home our Dad
    would thrash us to sleep wi' his belt...

    Luxury. Our computers only had 256 bytes[1] of RAM and We had to enter
    our code, in the dark, using loose binary toggle switches with poor
    connections. We used to have to get out of the lake at three o'clock in
    the morning, clean the lake, eat a handful of hot gravel, go to work at
    the mill every day for tuppence a month, come home, and Dad would beat
    us around the head and neck with a broken bottle, if we were LUCKY!

    Cheers,
    Malcolm

    [1] http://incolor.inebraska.com/bill_r/elf/html/elf-1-33.htm
  • Mark Lawrence at Jul 17, 2010 at 8:57 am

    On 17/07/2010 03:59, python at bdurham.com wrote:
    Tim,
    2.x?! You were lucky. We lived for three months with Python 1.x in a septic tank. We used to have to get up at six in the morning, write our 1.x code using ed, eat a crust of stale bread, go to work down in machine language, fourteen hours a day,
    week-in week-out, for sixpence a week, and when we got home our Dad
    would thrash us to sleep wi' his belt...

    Luxury. Our computers only had 256 bytes[1] of RAM and We had to enter
    our code, in the dark, using loose binary toggle switches with poor
    connections. We used to have to get out of the lake at three o'clock in
    the morning, clean the lake, eat a handful of hot gravel, go to work at
    the mill every day for tuppence a month, come home, and Dad would beat
    us around the head and neck with a broken bottle, if we were LUCKY!

    Cheers,
    Malcolm

    [1] http://incolor.inebraska.com/bill_r/elf/html/elf-1-33.htm
    I'm just envisaging a "Paper Tape Repairman" sketch.

    Kindest regards.

    Mark Lawrence.
  • Thomas Jollans at Jul 18, 2010 at 10:55 am

    On 07/17/2010 04:59 AM, python at bdurham.com wrote:
    Tim,
    2.x?! You were lucky. We lived for three months with Python 1.x in a septic tank. We used to have to get up at six in the morning, write our 1.x code using ed, eat a crust of stale bread, go to work down in machine language, fourteen hours a day,
    week-in week-out, for sixpence a week, and when we got home our Dad
    would thrash us to sleep wi' his belt...

    Luxury. Our computers only had 256 bytes[1] of RAM and We had to enter
    our code, in the dark, using loose binary toggle switches with poor
    connections. We used to have to get out of the lake at three o'clock in
    the morning, clean the lake, eat a handful of hot gravel, go to work at
    the mill every day for tuppence a month, come home, and Dad would beat
    us around the head and neck with a broken bottle, if we were LUCKY!

    [1] http://incolor.inebraska.com/bill_r/elf/html/elf-1-33.htm
    In slightly related news, I just stumbled upon this:

    http://catb.org/esr/jargon/html/story-of-mel.html

    Now of course, he had it tough.
  • Python at Jul 18, 2010 at 4:45 pm
    Thomas,
    In slightly related news, I just stumbled upon this:
    http://catb.org/esr/jargon/html/story-of-mel.html

    Now of course, he had it tough.
    Tough???

    Well we had it tough. Our computers[1][2] had 0 bytes of RAM and 0 bytes
    of ROM. We had to hand wire our logic and physically push data through
    logic gates without the benefit of transistors. We used to have to get
    up out of the shoebox at twelve o'clock at night, and LICK the road
    clean with our tongues. We had half a handful of freezing cold gravel,
    worked twenty-four hours a day at the mill for fourpence every six
    years, and when we got home, our Dad would slice us in two with a bread
    knife.

    Malcolm

    [1] http://totallytrygve.com/computer.php?item8&picture=0

    [2] I learned about computers through one of these kits. When I first
    stumbled across assembly language (6502), my first thought was, "wow,
    this is so much easier than what I've been doing"!


    <snipped>
    2.x?! You were lucky. We lived for three months with Python 1.x in a septic tank. We used to have to get up at six in the morning, write our 1.x code using ed, eat a crust of stale bread, go to work down in machine language, fourteen hours a day,
    week-in week-out, for sixpence a week, and when we got home our Dad
    would thrash us to sleep wi' his belt...

    Luxury. Our computers only had 256 bytes[1] of RAM and We had to enter
    our code, in the dark, using loose binary toggle switches with poor
    connections. We used to have to get out of the lake at three o'clock in
    the morning, clean the lake, eat a handful of hot gravel, go to work at
    the mill every day for tuppence a month, come home, and Dad would beat
    us around the head and neck with a broken bottle, if we were LUCKY!

    [1] http://incolor.inebraska.com/bill_r/elf/html/elf-1-33.htm
    In slightly related news, I just stumbled upon this:

    http://catb.org/esr/jargon/html/story-of-mel.html

    Now of course, he had it tough.
    </snipped>
  • Steven D'Aprano at Jul 17, 2010 at 8:03 am

    On Fri, 16 Jul 2010 21:23:09 -0500, Tim Chase wrote:

    Is anyone /still/ using Python 2.x? ;-)
    2.x?! You were lucky. We lived for three months with Python 1.x in a
    septic tank. We used to have to get up at six in the morning, write our
    1.x code using ed,
    You got to use ed? Oh, we *dreamed* of using an editor! We had to edit
    the sectors on disk directly with a magnetised needle. A rusty, blunt
    needle.



    --
    Steven
  • Geremy condra at Jul 17, 2010 at 8:17 am

    On Sat, Jul 17, 2010 at 1:03 AM, Steven D'Aprano wrote:
    On Fri, 16 Jul 2010 21:23:09 -0500, Tim Chase wrote:

    Is anyone /still/ using Python 2.x? ;-)
    2.x?! ?You were lucky. We lived for three months with Python 1.x in a
    septic tank. We used to have to get up at six in the morning, write our
    1.x code using ed,
    You got to use ed? Oh, we *dreamed* of using an editor! We had to edit
    the sectors on disk directly with a magnetised needle. A rusty, blunt
    needle.
    Real programmers use butterflies.

    http://xkcd.com/378/

    Geremy Condra
  • Thomas Jollans at Jul 17, 2010 at 10:39 am

    On 07/17/2010 10:03 AM, Steven D'Aprano wrote:
    On Fri, 16 Jul 2010 21:23:09 -0500, Tim Chase wrote:

    Is anyone /still/ using Python 2.x? ;-)
    2.x?! You were lucky. We lived for three months with Python 1.x in a
    septic tank. We used to have to get up at six in the morning, write our
    1.x code using ed,
    You got to use ed? Oh, we *dreamed* of using an editor! We had to edit
    the sectors on disk directly with a magnetised needle. A rusty, blunt
    needle.
    You try and tell the young people of today that, and they won't believe
    you.
  • Gary Herron at Jul 17, 2010 at 4:38 pm

    On 07/17/2010 01:03 AM, Steven D'Aprano wrote:
    On Fri, 16 Jul 2010 21:23:09 -0500, Tim Chase wrote:

    Is anyone /still/ using Python 2.x? ;-)
    2.x?! You were lucky. We lived for three months with Python 1.x in a
    septic tank. We used to have to get up at six in the morning, write our
    1.x code using ed,
    You got to use ed? Oh, we *dreamed* of using an editor! We had to edit
    the sectors on disk directly with a magnetised needle. A rusty, blunt
    needle.
    Along those lines, there's this -- one of my favorite comics:

    http://xkcd.com/378/

    and unrelated to the thread but still about python:

    http://xkcd.com/353/

    Gary Herron
  • Thomas Jollans at Jul 17, 2010 at 5:16 pm

    On 07/17/2010 06:38 PM, Gary Herron wrote:
    On 07/17/2010 01:03 AM, Steven D'Aprano wrote:
    On Fri, 16 Jul 2010 21:23:09 -0500, Tim Chase wrote:

    Is anyone /still/ using Python 2.x? ;-)
    http://xkcd.com/353/
    There we have the most important difference between Python 2 and 3: in
    the latter, "import antigravity" actually works.
  • Emile van Sebille at Jul 17, 2010 at 5:27 pm
    On 7/17/2010 9:38 AM Gary Herron said...
    and unrelated to the thread but still about python:

    http://xkcd.com/353/
    ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
    Python 2.6.1 (r261:67515, Dec 5 2008, 13:58:38) [MSC v.1500 32 bit
    (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    import antigravity
    Nothing happens.
    >>>

    Emile
  • Benjamin Kaplan at Jul 17, 2010 at 5:57 pm

    On Sat, Jul 17, 2010 at 10:27 AM, Emile van Sebille wrote:

    On 7/17/2010 9:38 AM Gary Herron said...

    and unrelated to the thread but still about python:
    ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
    Python 2.6.1 (r261:67515, Dec 5 2008, 13:58:38) [MSC v.1500 32 bit
    (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    import antigravity
    Nothing happens.
    Emile
    Try it in Python 3.
  • Emile van Sebille at Jul 17, 2010 at 6:37 pm
    On 7/17/2010 10:57 AM Benjamin Kaplan said...
    Try it in Python 3.
    Cool. :)

    Although I wouldn't have been surprised had my monitor levitated. :)

    Emile
  • Emile van Sebille at Jul 17, 2010 at 5:28 pm
    On 7/16/2010 7:08 PM MRAB said...
    Peng Yu wrote:
    On Fri, Jul 16, 2010 at 5:42 PM, Terry Reedy wrote:
    On 7/16/2010 1:01 PM, Peng Yu wrote:
    I mean to get the man page for '[' like in the following code.

    x=[1,2,3]
    You might find my Python symbol glossary useful.
    https://code.google.com/p/xploro/downloads/detail?name=PySymbols.html
    This is for Python 3. Is there one for Python 2.x?
    Is anyone /still/ using Python 2.x? ;-)
    Is anyone /actually/ using Python 3.x ;-)

    Emile
  • Terry Reedy at Jul 17, 2010 at 3:12 am

    On 7/16/2010 9:42 PM, Peng Yu wrote:
    On Fri, Jul 16, 2010 at 5:42 PM, Terry Reedywrote:
    On 7/16/2010 1:01 PM, Peng Yu wrote:

    I mean to get the man page for '[' like in the following code.

    x=[1,2,3]
    You might find my Python symbol glossary useful.
    https://code.google.com/p/xploro/downloads/detail?name=PySymbols.html
    This is for Python 3. Is there one for Python 2.x?
    They are close to 100% the same. I intentionally worded the entries so
    one could look in the manuals for details.


    --
    Terry Jan Reedy
  • Paul McGuire at Jul 17, 2010 at 1:57 pm

    On Jul 16, 12:01?pm, Peng Yu wrote:
    I mean to get the man page for '[' like in the following code.

    x=[1,2,3]

    But help('[') doesn't seem to give the above usage.

    ###########
    Mutable Sequence Types
    **********************

    List objects support additional operations that allow in-place
    modification of the object. Other mutable sequence types (when added
    to the language) should also support these operations. Strings and
    tuples are immutable sequence types: such objects cannot be modified
    once created. The following operations are defined on mutable sequence
    types (where *x* is an arbitrary object):
    ...
    ##########

    I then checked help('LISTLITERALS'), which gives some description that
    is available from the language reference. So '[' in "x=[1,2,3]" is
    considered as a language feature rather than a function or an
    operator?

    ############
    List displays
    *************

    A list display is a possibly empty series of expressions enclosed in
    square brackets:

    ? ?list_display ? ? ? ?::= "[" [expression_list | list_comprehension] "]"
    ? ?list_comprehension ?::= expression list_for
    ? ?list_for ? ? ? ? ? ?::= "for" target_list "in" old_expression_list
    [list_iter]
    ? ?old_expression_list ::= old_expression [("," old_expression)+ [","]]
    ? ?list_iter ? ? ? ? ? ::= list_for | list_if
    ? ?list_if ? ? ? ? ? ? ::= "if" old_expression [list_iter]
    .....
    ###########
    --
    Regards,
    Peng
    Also look for __getitem__ and __setitem__, these methods defined on
    your own container classes will allow you to write "myobject['x']" and
    have your own custom lookup code get run.

    -- Paul

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 16, '10 at 5:01p
activeJul 18, '10 at 4:45p
posts21
users14
websitepython.org

People

Translate

site design / logo © 2022 Grokbase