Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Side by Side Diff: Doc/library/enum.rst

Issue 18758: Fix internal references in the documentation
Patch Set: Created 6 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/difflib.rst ('k') | Doc/library/exceptions.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`enum` --- Support for enumerations 1 :mod:`enum` --- Support for enumerations
2 ======================================== 2 ========================================
3 3
4 .. module:: enum 4 .. module:: enum
5 :synopsis: Implementation of an enumeration class. 5 :synopsis: Implementation of an enumeration class.
6 6
7 .. :moduleauthor:: Ethan Furman <ethan@stoneleaf.us> 7 .. :moduleauthor:: Ethan Furman <ethan@stoneleaf.us>
8 .. :sectionauthor:: Barry Warsaw <barry@python.org>, 8 .. :sectionauthor:: Barry Warsaw <barry@python.org>,
9 .. :sectionauthor:: Eli Bendersky <eliben@gmail.com>, 9 .. :sectionauthor:: Eli Bendersky <eliben@gmail.com>,
10 .. :sectionauthor:: Ethan Furman <ethan@stoneleaf.us> 10 .. :sectionauthor:: Ethan Furman <ethan@stoneleaf.us>
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 >>> Animal = Enum('Animal', 'ant bee cat dog') 364 >>> Animal = Enum('Animal', 'ant bee cat dog')
365 >>> Animal 365 >>> Animal
366 <enum 'Animal'> 366 <enum 'Animal'>
367 >>> Animal.ant 367 >>> Animal.ant
368 <Animal.ant: 1> 368 <Animal.ant: 1>
369 >>> Animal.ant.value 369 >>> Animal.ant.value
370 1 370 1
371 >>> list(Animal) 371 >>> list(Animal)
372 [<Animal.ant: 1>, <Animal.bee: 2>, <Animal.cat: 3>, <Animal.dog: 4>] 372 [<Animal.ant: 1>, <Animal.bee: 2>, <Animal.cat: 3>, <Animal.dog: 4>]
373 373
374 The semantics of this API resemble :class:`namedtuple`. The first argument 374 The semantics of this API resemble :class:`~collections.namedtuple`. The first a rgument
375 of the call to :class:`Enum` is the name of the enumeration. 375 of the call to :class:`Enum` is the name of the enumeration.
376 376
377 The second argument is the *source* of enumeration member names. It can be a 377 The second argument is the *source* of enumeration member names. It can be a
378 whitespace-separated string of names, a sequence of names, a sequence of 378 whitespace-separated string of names, a sequence of names, a sequence of
379 2-tuples with key/value pairs, or a mapping (e.g. dictionary) of names to 379 2-tuples with key/value pairs, or a mapping (e.g. dictionary) of names to
380 values. The last two options enable assigning arbitrary values to 380 values. The last two options enable assigning arbitrary values to
381 enumerations; the others auto-assign increasing integers starting with 1. A 381 enumerations; the others auto-assign increasing integers starting with 1. A
382 new class derived from :class:`Enum` is returned. In other words, the above 382 new class derived from :class:`Enum` is returned. In other words, the above
383 assignment to :class:`Animal` is equivalent to:: 383 assignment to :class:`Animal` is equivalent to::
384 384
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 679
680 >>> dir(Planet) 680 >>> dir(Planet)
681 ['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENU S', '__class__', '__doc__', '__members__', '__module__'] 681 ['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENU S', '__class__', '__doc__', '__members__', '__module__']
682 >>> dir(Planet.EARTH) 682 >>> dir(Planet.EARTH)
683 ['__class__', '__doc__', '__module__', 'name', 'surface_gravity', 'value'] 683 ['__class__', '__doc__', '__module__', 'name', 'surface_gravity', 'value']
684 684
685 A :meth:`__new__` method will only be used for the creation of the 685 A :meth:`__new__` method will only be used for the creation of the
686 :class:`Enum` members -- after that it is replaced. This means if you wish to 686 :class:`Enum` members -- after that it is replaced. This means if you wish to
687 change how :class:`Enum` members are looked up you either have to write a 687 change how :class:`Enum` members are looked up you either have to write a
688 helper function or a :func:`classmethod`. 688 helper function or a :func:`classmethod`.
OLDNEW
« no previous file with comments | « Doc/library/difflib.rst ('k') | Doc/library/exceptions.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+