diff --git a/dictionaries/howto_enum.txt b/dictionaries/howto_enum.txt index 99fd071a97..38d5bffd2d 100644 --- a/dictionaries/howto_enum.txt +++ b/dictionaries/howto_enum.txt @@ -1,3 +1,17 @@ +coordinate +custom decapables -subclasificables +favorite +gravity +mass +members +mood multibit +pantone +planet +radius +subclasificables +surface +swatch +today +unknown diff --git a/howto/enum.po b/howto/enum.po index 1929a3235f..e22a399000 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -9,22 +9,22 @@ msgstr "" "Project-Id-Version: Python en Español 3.11\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-21 16:38-0300\n" -"PO-Revision-Date: 2023-11-13 00:32-0500\n" +"PO-Revision-Date: 2024-11-28 14:40-0600\n" "Last-Translator: \n" -"Language: es_US\n" "Language-Team: python-doc-es\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: es_US\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Generated-By: Babel 2.16.0\n" +"X-Generator: Poedit 3.4.2\n" #: ../Doc/howto/enum.rst:5 msgid "Enum HOWTO" msgstr "HOWTO - Enum" #: ../Doc/howto/enum.rst:11 -#, fuzzy msgid "" "An :class:`Enum` is a set of symbolic names bound to unique values. They " "are similar to global variables, but they offer a more useful :func:`repr`, " @@ -55,6 +55,15 @@ msgid "" "... SATURDAY = 6\n" "... SUNDAY = 7" msgstr "" +">>> from enum import Enum\n" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7" #: ../Doc/howto/enum.rst:28 msgid "Or perhaps the RGB primary colors::" @@ -68,6 +77,11 @@ msgid "" "... GREEN = 2\n" "... BLUE = 3" msgstr "" +">>> from enum import Enum\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3" #: ../Doc/howto/enum.rst:36 msgid "" @@ -109,6 +123,8 @@ msgid "" ">>> Weekday(3)\n" "" msgstr "" +">>> Weekday(3)\n" +"" #: ../Doc/howto/enum.rst:53 msgid "" @@ -125,6 +141,8 @@ msgid "" ">>> print(Weekday.THURSDAY)\n" "Weekday.THURSDAY" msgstr "" +">>> print(Weekday.THURSDAY)\n" +"Weekday.THURSDAY" #: ../Doc/howto/enum.rst:60 msgid "The *type* of an enumeration member is the enum it belongs to::" @@ -139,6 +157,10 @@ msgid "" ">>> isinstance(Weekday.FRIDAY, Weekday)\n" "True" msgstr "" +">>> type(Weekday.MONDAY)\n" +"\n" +">>> isinstance(Weekday.FRIDAY, Weekday)\n" +"True" #: ../Doc/howto/enum.rst:67 msgid "Enum members have an attribute that contains just their :attr:`name`::" @@ -151,6 +173,8 @@ msgid "" ">>> print(Weekday.TUESDAY.name)\n" "TUESDAY" msgstr "" +">>> print(Weekday.TUESDAY.name)\n" +"TUESDAY" #: ../Doc/howto/enum.rst:72 msgid "Likewise, they have an attribute for their :attr:`value`::" @@ -161,6 +185,8 @@ msgid "" ">>> Weekday.WEDNESDAY.value\n" "3" msgstr "" +">>> Weekday.WEDNESDAY.value\n" +"3" #: ../Doc/howto/enum.rst:78 msgid "" @@ -187,6 +213,9 @@ msgid "" "def from_date(cls, date):\n" " return cls(date.isoweekday())" msgstr "" +"@classmethod\n" +"def from_date(cls, date):\n" +" return cls(date.isoweekday())" #: ../Doc/howto/enum.rst:90 msgid "The complete :class:`Weekday` enum now looks like this::" @@ -207,6 +236,18 @@ msgid "" "... def from_date(cls, date):\n" "... return cls(date.isoweekday())" msgstr "" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7\n" +"... #\n" +"... @classmethod\n" +"... def from_date(cls, date):\n" +"... return cls(date.isoweekday())" #: ../Doc/howto/enum.rst:105 msgid "Now we can find out what today is! Observe::" @@ -218,6 +259,9 @@ msgid "" ">>> Weekday.from_date(date.today()) \n" "" msgstr "" +">>> from datetime import date\n" +">>> Weekday.from_date(date.today())\n" +"" #: ../Doc/howto/enum.rst:111 msgid "" @@ -250,6 +294,15 @@ msgid "" "... SATURDAY = 32\n" "... SUNDAY = 64" msgstr "" +">>> from enum import Flag\n" +">>> class Weekday(Flag):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 4\n" +"... THURSDAY = 8\n" +"... FRIDAY = 16\n" +"... SATURDAY = 32\n" +"... SUNDAY = 64" #: ../Doc/howto/enum.rst:128 msgid "" @@ -273,6 +326,9 @@ msgid "" ">>> first_week_day\n" "" msgstr "" +">>> first_week_day = Weekday.MONDAY\n" +">>> first_week_day\n" +"" #: ../Doc/howto/enum.rst:137 msgid "" @@ -288,6 +344,9 @@ msgid "" ">>> weekend\n" "" msgstr "" +">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n" +">>> weekend\n" +"" #: ../Doc/howto/enum.rst:144 msgid "You can even iterate over a :class:`Flag` variable::" @@ -300,6 +359,10 @@ msgid "" "Weekday.SATURDAY\n" "Weekday.SUNDAY" msgstr "" +">>> for day in weekend:\n" +"... print(day)\n" +"Weekday.SATURDAY\n" +"Weekday.SUNDAY" #: ../Doc/howto/enum.rst:151 msgid "Okay, let's get some chores set up::" @@ -314,6 +377,12 @@ msgid "" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" msgstr "" +">>> chores_for_ethan = {\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." +"FRIDAY,\n" +"... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" +"... 'answer SO questions': Weekday.SATURDAY,\n" +"... }" #: ../Doc/howto/enum.rst:159 msgid "And a function to display the chores for a given day::" @@ -329,9 +398,15 @@ msgid "" ">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" "answer SO questions" msgstr "" +">>> def show_chores(chores, day):\n" +"... for chore, days in chores.items():\n" +"... if day in days:\n" +"... print(chore)\n" +"...\n" +">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" +"answer SO questions" #: ../Doc/howto/enum.rst:169 -#, fuzzy msgid "" "In cases where the actual values of the members do not matter, you can save " "yourself some work and use :func:`auto` for the values::" @@ -352,6 +427,16 @@ msgid "" "... SUNDAY = auto()\n" "... WEEKEND = SATURDAY | SUNDAY" msgstr "" +">>> from enum import auto\n" +">>> class Weekday(Flag):\n" +"... MONDAY = auto()\n" +"... TUESDAY = auto()\n" +"... WEDNESDAY = auto()\n" +"... THURSDAY = auto()\n" +"... FRIDAY = auto()\n" +"... SATURDAY = auto()\n" +"... SUNDAY = auto()\n" +"... WEEKEND = SATURDAY | SUNDAY" #: ../Doc/howto/enum.rst:188 msgid "Programmatic access to enumeration members and their attributes" @@ -375,6 +460,10 @@ msgid "" ">>> Color(3)\n" "" msgstr "" +">>> Color(1)\n" +"\n" +">>> Color(3)\n" +"" #: ../Doc/howto/enum.rst:199 msgid "If you want to access enum members by *name*, use item access::" @@ -389,6 +478,10 @@ msgid "" ">>> Color['GREEN']\n" "" msgstr "" +">>> Color['RED']\n" +"\n" +">>> Color['GREEN']\n" +"" #: ../Doc/howto/enum.rst:206 msgid "If you have an enum member and need its :attr:`name` or :attr:`value`::" @@ -404,6 +497,11 @@ msgid "" ">>> member.value\n" "1" msgstr "" +">>> member = Color.RED\n" +">>> member.name\n" +"'RED'\n" +">>> member.value\n" +"1" #: ../Doc/howto/enum.rst:216 msgid "Duplicating enum members and values" @@ -423,6 +521,13 @@ msgid "" "...\n" "TypeError: 'SQUARE' already defined as 2" msgstr "" +">>> class Shape(Enum):\n" +"... SQUARE = 2\n" +"... SQUARE = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: 'SQUARE' already defined as 2" #: ../Doc/howto/enum.rst:228 msgid "" @@ -454,6 +559,18 @@ msgid "" ">>> Shape(2)\n" "" msgstr "" +">>> class Shape(Enum):\n" +"... SQUARE = 2\n" +"... DIAMOND = 1\n" +"... CIRCLE = 3\n" +"... ALIAS_FOR_SQUARE = 2\n" +"...\n" +">>> Shape.SQUARE\n" +"\n" +">>> Shape.ALIAS_FOR_SQUARE\n" +"\n" +">>> Shape(2)\n" +"" #: ../Doc/howto/enum.rst:249 msgid "" @@ -492,6 +609,17 @@ msgid "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" msgstr "" +">>> from enum import Enum, unique\n" +">>> @unique\n" +"... class Mistake(Enum):\n" +"... ONE = 1\n" +"... TWO = 2\n" +"... THREE = 3\n" +"... FOUR = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: duplicate values found in : FOUR -> THREE" #: ../Doc/howto/enum.rst:274 msgid "Using automatic values" @@ -512,6 +640,14 @@ msgid "" ">>> [member.value for member in Color]\n" "[1, 2, 3]" msgstr "" +">>> from enum import Enum, auto\n" +">>> class Color(Enum):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> [member.value for member in Color]\n" +"[1, 2, 3]" #: ../Doc/howto/enum.rst:287 msgid "" @@ -537,6 +673,19 @@ msgid "" ">>> [member.value for member in Ordinal]\n" "['NORTH', 'SOUTH', 'EAST', 'WEST']" msgstr "" +">>> class AutoName(Enum):\n" +"... @staticmethod\n" +"... def _generate_next_value_(name, start, count, last_values):\n" +"... return name\n" +"...\n" +">>> class Ordinal(AutoName):\n" +"... NORTH = auto()\n" +"... SOUTH = auto()\n" +"... EAST = auto()\n" +"... WEST = auto()\n" +"...\n" +">>> [member.value for member in Ordinal]\n" +"['NORTH', 'SOUTH', 'EAST', 'WEST']" #: ../Doc/howto/enum.rst:306 msgid "" @@ -562,6 +711,12 @@ msgid "" "THURSDAY: 8>, , , ]" msgstr "" +">>> list(Shape)\n" +"[, , ]\n" +">>> list(Weekday)\n" +"[, , , , , , ]" #: ../Doc/howto/enum.rst:318 msgid "" @@ -591,6 +746,13 @@ msgid "" "('CIRCLE', )\n" "('ALIAS_FOR_SQUARE', )" msgstr "" +">>> for name, member in Shape.__members__.items():\n" +"... name, member\n" +"...\n" +"('SQUARE', )\n" +"('DIAMOND', )\n" +"('CIRCLE', )\n" +"('ALIAS_FOR_SQUARE', )" #: ../Doc/howto/enum.rst:332 msgid "" @@ -607,6 +769,9 @@ msgid "" "name]\n" "['ALIAS_FOR_SQUARE']" msgstr "" +">>> [name for name, member in Shape.__members__.items() if member.name != " +"name]\n" +"['ALIAS_FOR_SQUARE']" #: ../Doc/howto/enum.rst:340 msgid "" @@ -633,6 +798,12 @@ msgid "" ">>> Color.RED is not Color.BLUE\n" "True" msgstr "" +">>> Color.RED is Color.RED\n" +"True\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED is not Color.BLUE\n" +"True" #: ../Doc/howto/enum.rst:356 msgid "" @@ -650,6 +821,10 @@ msgid "" " File \"\", line 1, in \n" "TypeError: '<' not supported between instances of 'Color' and 'Color'" msgstr "" +">>> Color.RED < Color.BLUE\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: '<' not supported between instances of 'Color' and 'Color'" #: ../Doc/howto/enum.rst:364 msgid "Equality comparisons are defined though::" @@ -664,6 +839,12 @@ msgid "" ">>> Color.BLUE == Color.BLUE\n" "True" msgstr "" +">>> Color.BLUE == Color.RED\n" +"False\n" +">>> Color.BLUE != Color.RED\n" +"True\n" +">>> Color.BLUE == Color.BLUE\n" +"True" #: ../Doc/howto/enum.rst:373 msgid "" @@ -680,6 +861,8 @@ msgid "" ">>> Color.BLUE == 2\n" "False" msgstr "" +">>> Color.BLUE == 2\n" +"False" #: ../Doc/howto/enum.rst:382 msgid "" @@ -737,6 +920,22 @@ msgid "" "... return cls.HAPPY\n" "..." msgstr "" +">>> class Mood(Enum):\n" +"... FUNKY = 1\n" +"... HAPPY = 3\n" +"...\n" +"... def describe(self):\n" +"... # self es el miembro aquí\n" +"... return self.name, self.value\n" +"...\n" +"... def __str__(self):\n" +"... return 'my custom str! {0}'.format(self.value)\n" +"...\n" +"... @classmethod\n" +"... def favorite_mood(cls):\n" +"... # cls es la enumeración aquí\n" +"... return cls.HAPPY\n" +"..." #: ../Doc/howto/enum.rst:415 msgid "Then::" @@ -751,6 +950,12 @@ msgid "" ">>> str(Mood.FUNKY)\n" "'my custom str! 1'" msgstr "" +">>> Mood.favorite_mood()\n" +"\n" +">>> Mood.HAPPY.describe()\n" +"('HAPPY', 3)\n" +">>> str(Mood.FUNKY)\n" +"'my custom str! 1'" #: ../Doc/howto/enum.rst:424 msgid "" @@ -810,6 +1015,8 @@ msgid "" "class EnumName([mix-in, ...,] [data-type,] base-enum):\n" " pass" msgstr "" +"class EnumName([mix-in, ...,] [data-type,] base-enum):\n" +" pass" #: ../Doc/howto/enum.rst:453 msgid "" @@ -828,6 +1035,12 @@ msgid "" "...\n" "TypeError: cannot extend " msgstr "" +">>> class MoreColor(Color):\n" +"... PINK = 17\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: cannot extend " #: ../Doc/howto/enum.rst:463 msgid "But this is allowed::" @@ -844,6 +1057,14 @@ msgid "" "... SAD = 2\n" "..." msgstr "" +">>> class Foo(Enum):\n" +"... def some_behavior(self):\n" +"... pass\n" +"...\n" +">>> class Bar(Foo):\n" +"... HAPPY = 1\n" +"... SAD = 2\n" +"..." #: ../Doc/howto/enum.rst:474 msgid "" @@ -886,15 +1107,27 @@ msgid "" ">>> Creature.DOG\n" "" msgstr "" +">>> from dataclasses import dataclass, field\n" +">>> @dataclass\n" +"... class CreatureDataMixin:\n" +"... size: str\n" +"... legs: int\n" +"... tail: bool = field(repr=False, default=True)\n" +"...\n" +">>> class Creature(CreatureDataMixin, Enum):\n" +"... BEETLE = 'small', 6\n" +"... DOG = 'medium', 4\n" +"...\n" +">>> Creature.DOG\n" +"" #: ../Doc/howto/enum.rst:502 -#, fuzzy msgid "" "Use the :func:`~dataclasses.dataclass` argument ``repr=False`` to use the " "standard :func:`repr`." msgstr "" -"Utilice el argumento ``repr=False`` de :func:`!dataclass` para utilizar el :" -"func:`repr` estándar." +"Utilice el argumento ``repr=False`` de :func:`~dataclasses.dataclass` para " +"utilizar el :func:`repr` estándar." #: ../Doc/howto/enum.rst:505 msgid "" @@ -911,6 +1144,10 @@ msgid "" "produce very strange results at runtime, such as members being equal to each " "other::" msgstr "" +"Añadir el decorador :func:`~dataclasses.dataclass` a :class:`Enum` y sus " +"subclases no está soportado. No lanzará ningún error, pero producirá " +"resultados bastante extraños en tiempo de ejecución, como miembros siendo " +"iguales a otros:" #: ../Doc/howto/enum.rst:516 msgid "" @@ -924,6 +1161,15 @@ msgid "" ">>> Color.RED == Color.BLUE # problem is here: they should not be equal\n" "True" msgstr "" +">>> @dataclass # no haga esto: no tiene ningún sentido\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... BLUE = 2\n" +"...\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED == Color.BLUE # problema aquí:: no deberían ser iguales\n" +"True" #: ../Doc/howto/enum.rst:528 msgid "Pickling" @@ -940,6 +1186,10 @@ msgid "" ">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" "True" msgstr "" +">>> from test.test_enum import Fruit\n" +">>> from pickle import dumps, loads\n" +">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" +"True" #: ../Doc/howto/enum.rst:537 msgid "" @@ -976,6 +1226,9 @@ msgid "" ">>> class MyEnum(enum.Enum):\n" "... __reduce_ex__ = enum.pickle_by_enum_name" msgstr "" +">>> import enum\n" +">>> class MyEnum(enum.Enum):\n" +"... __reduce_ex__ = enum.pickle_by_enum_name" #: ../Doc/howto/enum.rst:556 msgid "" @@ -1006,6 +1259,13 @@ msgid "" ">>> list(Animal)\n" "[, , , ]" msgstr "" +">>> Animal = Enum('Animal', 'ANT BEE CAT DOG')\n" +">>> Animal\n" +"\n" +">>> Animal.ANT\n" +"\n" +">>> list(Animal)\n" +"[, , , ]" #: ../Doc/howto/enum.rst:573 msgid "" @@ -1046,6 +1306,12 @@ msgid "" "... DOG = 4\n" "..." msgstr "" +">>> class Animal(Enum):\n" +"... ANT = 1\n" +"... BEE = 2\n" +"... CAT = 3\n" +"... DOG = 4\n" +"..." #: ../Doc/howto/enum.rst:592 msgid "" @@ -1074,7 +1340,7 @@ msgstr "" #: ../Doc/howto/enum.rst:602 msgid ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" -msgstr "" +msgstr ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" #: ../Doc/howto/enum.rst:606 msgid "" @@ -1087,7 +1353,6 @@ msgstr "" "errores más cerca de la fuente, se desactivará el decapado." #: ../Doc/howto/enum.rst:610 -#, fuzzy msgid "" "The new pickle protocol 4 also, in some circumstances, relies on :attr:" "`~type.__qualname__` being set to the location where pickle will be able to " @@ -1095,14 +1360,15 @@ msgid "" "SomeData in the global scope::" msgstr "" "El nuevo protocolo pickle 4 también, en algunas circunstancias, depende de " -"que :attr:`~definition.__qualname__` se establezca en la ubicación donde " -"pickle podrá encontrar la clase. Por ejemplo, si la clase estuvo disponible " -"en la clase SomeData en el ámbito global:" +"que :attr:`~type.__qualname__` se establezca en la ubicación donde pickle " +"podrá encontrar la clase. Por ejemplo, si la clase estuvo disponible en la " +"clase SomeData en el ámbito global:" #: ../Doc/howto/enum.rst:615 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" msgstr "" +">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" #: ../Doc/howto/enum.rst:617 msgid "The complete signature is::" @@ -1120,25 +1386,33 @@ msgid "" " start=1,\n" " )" msgstr "" +"Enum(\n" +" value='NewEnumName',\n" +" names=<...>,\n" +" *,\n" +" module='...',\n" +" qualname='...',\n" +" type=,\n" +" start=1,\n" +" )" #: ../Doc/howto/enum.rst:629 -#, fuzzy msgid "*value*: What the new enum class will record as its name." -msgstr "Lo que la nueva clase de enumeración registrará como su nombre." +msgstr "" +"*value*: Lo que la nueva clase de enumeración registrará como su nombre." #: ../Doc/howto/enum.rst:631 -#, fuzzy msgid "" "*names*: The enum members. This can be a whitespace- or comma-separated " "string (values will start at 1 unless otherwise specified)::" msgstr "" -"Los miembros de la enumeración. Puede ser una cadena separada por comas o " -"espacios en blanco (los valores comenzarán en 1 a menos que se especifique " -"lo contrario):" +"*names*: Los miembros de la enumeración. Puede ser una cadena separada por " +"comas o espacios en blanco (los valores comenzarán en 1 a menos que se " +"especifique lo contrario):" #: ../Doc/howto/enum.rst:634 msgid "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" -msgstr "" +msgstr "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" #: ../Doc/howto/enum.rst:636 msgid "or an iterator of names::" @@ -1146,7 +1420,7 @@ msgstr "o un iterador de nombres::" #: ../Doc/howto/enum.rst:638 msgid "['RED', 'GREEN', 'BLUE']" -msgstr "" +msgstr "['RED', 'GREEN', 'BLUE']" #: ../Doc/howto/enum.rst:640 msgid "or an iterator of (name, value) pairs::" @@ -1154,7 +1428,7 @@ msgstr "o un iterador de (nombre, valor) pares::" #: ../Doc/howto/enum.rst:642 msgid "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" -msgstr "" +msgstr "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" #: ../Doc/howto/enum.rst:644 msgid "or a mapping::" @@ -1162,28 +1436,27 @@ msgstr "o un mapeo::" #: ../Doc/howto/enum.rst:646 msgid "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" -msgstr "" +msgstr "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" #: ../Doc/howto/enum.rst:648 -#, fuzzy msgid "*module*: name of module where new enum class can be found." msgstr "" -"nombre del módulo donde se puede encontrar la nueva clase de enumeración." +"*module*: nombre del módulo donde se puede encontrar la nueva clase de " +"enumeración." #: ../Doc/howto/enum.rst:650 -#, fuzzy msgid "*qualname*: where in module new enum class can be found." -msgstr "donde en el módulo se puede encontrar la nueva clase de enumeración." +msgstr "" +"*qualname*: donde en el módulo se puede encontrar la nueva clase de " +"enumeración." #: ../Doc/howto/enum.rst:652 -#, fuzzy msgid "*type*: type to mix in to new enum class." -msgstr "tipo para mezclar en la nueva clase de enumeración." +msgstr "*type*: tipo para mezclar en la nueva clase de enumeración." #: ../Doc/howto/enum.rst:654 -#, fuzzy msgid "*start*: number to start counting at if only names are passed in." -msgstr "número para comenzar a contar si solo se pasan nombres." +msgstr "*start*: número para comenzar a contar si solo se pasan nombres." #: ../Doc/howto/enum.rst:656 msgid "The *start* parameter was added." @@ -1227,6 +1500,21 @@ msgid "" ">>> Shape.CIRCLE == Request.POST\n" "True" msgstr "" +">>> from enum import IntEnum\n" +">>> class Shape(IntEnum):\n" +"... CIRCLE = 1\n" +"... SQUARE = 2\n" +"...\n" +">>> class Request(IntEnum):\n" +"... POST = 1\n" +"... GET = 2\n" +"...\n" +">>> Shape == 1\n" +"False\n" +">>> Shape.CIRCLE == 1\n" +"True\n" +">>> Shape.CIRCLE == Request.POST\n" +"True" #: ../Doc/howto/enum.rst:687 msgid "" @@ -1249,6 +1537,16 @@ msgid "" ">>> Shape.CIRCLE == Color.RED\n" "False" msgstr "" +">>> class Shape(IntEnum):\n" +"... CIRCLE = 1\n" +"... SQUARE = 2\n" +"...\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"...\n" +">>> Shape.CIRCLE == Color.RED\n" +"False" #: ../Doc/howto/enum.rst:700 msgid "" @@ -1266,6 +1564,12 @@ msgid "" ">>> [i for i in range(Shape.SQUARE)]\n" "[0, 1]" msgstr "" +">>> int(Shape.CIRCLE)\n" +"1\n" +">>> ['a', 'b', 'c'][Shape.CIRCLE]\n" +"'b'\n" +">>> [i for i in range(Shape.SQUARE)]\n" +"[0, 1]" #: ../Doc/howto/enum.rst:711 msgid "StrEnum" @@ -1340,6 +1644,19 @@ msgid "" ">>> Perm.R in RW\n" "True" msgstr "" +">>> from enum import IntFlag\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> Perm.R | Perm.W\n" +"\n" +">>> Perm.R + Perm.W\n" +"6\n" +">>> RW = Perm.R | Perm.W\n" +">>> Perm.R in RW\n" +"True" #: ../Doc/howto/enum.rst:758 msgid "It is also possible to name the combinations::" @@ -1360,6 +1677,18 @@ msgid "" ">>> Perm(7)\n" "" msgstr "" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"... RWX = 7\n" +"...\n" +">>> Perm.RWX\n" +"\n" +">>> ~Perm.RWX\n" +"\n" +">>> Perm(7)\n" +"" #: ../Doc/howto/enum.rst:775 msgid "" @@ -1387,6 +1716,10 @@ msgid "" ">>> bool(Perm.R & Perm.X)\n" "False" msgstr "" +">>> Perm.R & Perm.X\n" +"\n" +">>> bool(Perm.R & Perm.X)\n" +"False" #: ../Doc/howto/enum.rst:788 msgid "" @@ -1405,6 +1738,11 @@ msgid "" ">>> Perm.X + 8\n" "9" msgstr "" +">>> Perm.X | 4\n" +"\n" +"\n" +">>> Perm.X + 8\n" +"9" #: ../Doc/howto/enum.rst:799 msgid "" @@ -1419,6 +1757,8 @@ msgid "" ">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" "True" msgstr "" +">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" +"True" #: ../Doc/howto/enum.rst:805 msgid ":class:`IntFlag` members can also be iterated over::" @@ -1429,6 +1769,8 @@ msgid "" ">>> list(RW)\n" "[, ]" msgstr "" +">>> list(RW)\n" +"[, ]" #: ../Doc/howto/enum.rst:814 msgid "Flag" @@ -1473,6 +1815,16 @@ msgid "" ">>> bool(Color.RED & Color.GREEN)\n" "False" msgstr "" +">>> from enum import Flag, auto\n" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.RED & Color.GREEN\n" +"\n" +">>> bool(Color.RED & Color.GREEN)\n" +"False" #: ../Doc/howto/enum.rst:839 msgid "" @@ -1493,6 +1845,14 @@ msgid "" ">>> Color.WHITE\n" "" msgstr "" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"... WHITE = RED | BLUE | GREEN\n" +"...\n" +">>> Color.WHITE\n" +"" #: ../Doc/howto/enum.rst:851 msgid "" @@ -1515,6 +1875,16 @@ msgid "" ">>> bool(Color.BLACK)\n" "False" msgstr "" +">>> class Color(Flag):\n" +"... BLACK = 0\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.BLACK\n" +"\n" +">>> bool(Color.BLACK)\n" +"False" #: ../Doc/howto/enum.rst:865 msgid ":class:`Flag` members can also be iterated over::" @@ -1526,6 +1896,9 @@ msgid "" ">>> list(purple)\n" "[, ]" msgstr "" +">>> purple = Color.RED | Color.BLUE\n" +">>> list(purple)\n" +"[, ]" #: ../Doc/howto/enum.rst:875 msgid "" @@ -1563,6 +1936,8 @@ msgid "" "class IntEnum(int, ReprEnum): # or Enum instead of ReprEnum\n" " pass" msgstr "" +"class IntEnum(int, ReprEnum): # o Enum en lugar de ReprEnum\n" +" pass" #: ../Doc/howto/enum.rst:893 msgid "" @@ -1579,7 +1954,6 @@ msgid "Some rules:" msgstr "Algunas reglas:" #: ../Doc/howto/enum.rst:898 -#, fuzzy msgid "" "When subclassing :class:`Enum`, mix-in types must appear before the :class:" "`Enum` class itself in the sequence of bases, as in the :class:`IntEnum` " @@ -1679,14 +2053,37 @@ msgid "" "For example, if you want to pass several items to the constructor, but only " "want one of them to be the value::" msgstr "" -"Por ejemplo, si desea pasar varios elementos al constructor, pero solo desea " -"que uno de ellos sea el valor:" - -#: ../Doc/howto/enum.rst:938 -msgid "" +"Por ejemplo, si desea pasar varios elementos al constructor, pero solo desea " +"que uno de ellos sea el valor:" + +#: ../Doc/howto/enum.rst:938 +msgid "" +">>> class Coordinate(bytes, Enum):\n" +"... \"\"\"\n" +"... Coordinate with binary codes that can be indexed by the int code.\n" +"... \"\"\"\n" +"... def __new__(cls, value, label, unit):\n" +"... obj = bytes.__new__(cls, [value])\n" +"... obj._value_ = value\n" +"... obj.label = label\n" +"... obj.unit = unit\n" +"... return obj\n" +"... PX = (0, 'P.X', 'km')\n" +"... PY = (1, 'P.Y', 'km')\n" +"... VX = (2, 'V.X', 'km/s')\n" +"... VY = (3, 'V.Y', 'km/s')\n" +"...\n" +"\n" +">>> print(Coordinate['PY'])\n" +"Coordinate.PY\n" +"\n" +">>> print(Coordinate(3))\n" +"Coordinate.VY" +msgstr "" ">>> class Coordinate(bytes, Enum):\n" "... \"\"\"\n" -"... Coordinate with binary codes that can be indexed by the int code.\n" +"... Coordenada con códigos binarios que pueden ser indexada por el " +"código entero\n" "... \"\"\"\n" "... def __new__(cls, value, label, unit):\n" "... obj = bytes.__new__(cls, [value])\n" @@ -1705,7 +2102,6 @@ msgid "" "\n" ">>> print(Coordinate(3))\n" "Coordinate.VY" -msgstr "" #: ../Doc/howto/enum.rst:962 msgid "" @@ -1747,80 +2143,79 @@ msgid "Supported ``_sunder_`` names" msgstr "Nombres ``_sunder_`` admitidos" #: ../Doc/howto/enum.rst:983 -#, fuzzy msgid ":attr:`~Enum._name_` -- name of the member" -msgstr "``_name_`` -- nombre del miembro" +msgstr ":attr:`~Enum._name_` -- nombre del miembro" #: ../Doc/howto/enum.rst:984 -#, fuzzy msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr "" -"``_value_`` -- valor del miembro; se puede configurar/modificar en " +":attr:`~Enum._value_` -- valor del miembro; se puede configurar/modificar en " "``__new__``" #: ../Doc/howto/enum.rst:985 -#, fuzzy msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" -"``_missing_``: una función de búsqueda utilizada cuando no se encuentra un " -"valor; puede ser anulado" +":meth:`~Enum._missing_` -- una función de búsqueda utilizada cuando no se " +"encuentra un valor; puede ser anulado" #: ../Doc/howto/enum.rst:987 -#, fuzzy msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " "from the final class" msgstr "" -"``_ignore_`` -- una lista de nombres, ya sea como :class:`list` o :class:" -"`str`, que no se transformarán en miembros y se eliminarán de la clase final" +":attr:`~Enum._ignore_` -- una lista de nombres, ya sea como :class:`list` o :" +"class:`str`, que no se transformarán en miembros y se eliminarán de la clase " +"final" #: ../Doc/howto/enum.rst:990 -#, fuzzy msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" -"``_generate_next_value_``: utilizado por `Functional API`_ y por :class:" -"`auto` para obtener un valor apropiado para un miembro de enumeración; puede " -"ser anulado" +":meth:`~Enum._generate_next_value_` -- utilizado para obtener un valor " +"apropiado para un miembro de enumeración; puede ser sobrescrito" #: ../Doc/howto/enum.rst:992 msgid "" ":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr "" +":meth:`~Enum._add_alias_` -- añade un nombre nuevo como alias a un miembro " +"existente." #: ../Doc/howto/enum.rst:994 msgid "" ":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member. See `MultiValueEnum`_ for an example." msgstr "" +":meth:`~Enum._add_value_alias_` -- añade un valor nuevo como alias a un " +"miembro existente. Vea `MultiValueEnum`_ para un ejemplo ." #: ../Doc/howto/enum.rst:999 -#, fuzzy msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "Para las clases :class:`Enum` estándar, el siguiente valor elegido es el " -"último valor visto incrementado en uno." +"valor más alto incrementado en uno." #: ../Doc/howto/enum.rst:1002 -#, fuzzy msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "Para las clases :class:`Flag`, el siguiente valor elegido será la siguiente " -"potencia de dos más alta, independientemente del último valor visto." +"potencia de dos más alta." #: ../Doc/howto/enum.rst:1005 msgid "" "Prior versions would use the last seen value instead of the highest value." msgstr "" +"Versiones anteriores usarían el último valor visto en lugar del valor más " +"alto." #: ../Doc/howto/enum.rst:1008 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" @@ -1832,7 +2227,7 @@ msgstr "``_ignore_``" #: ../Doc/howto/enum.rst:1010 msgid "``_add_alias_``, ``_add_value_alias_``" -msgstr "" +msgstr "``_add_alias_``, ``_add_value_alias_``" #: ../Doc/howto/enum.rst:1012 msgid "" @@ -1858,6 +2253,17 @@ msgid "" " ['RED', 'BLUE', 'GREEN']\n" " ['RED', 'GREEN', 'BLUE']" msgstr "" +">>> class Color(Enum):\n" +"... _order_ = 'RED GREEN BLUE'\n" +"... RED = 1\n" +"... BLUE = 3\n" +"... GREEN = 2\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: member order does not match _order_:\n" +" ['RED', 'BLUE', 'GREEN']\n" +" ['RED', 'GREEN', 'BLUE']" #: ../Doc/howto/enum.rst:1030 msgid "" @@ -1922,6 +2328,11 @@ msgid "" ">>> MyEnum.example.value # and hex(11) is...\n" "17" msgstr "" +">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" +"... example = '11', 16 # so x='11' and base=16\n" +"...\n" +">>> MyEnum.example.value # and hex(11) is...\n" +"17" #: ../Doc/howto/enum.rst:1071 msgid "Boolean value of ``Enum`` classes and members" @@ -1946,6 +2357,8 @@ msgid "" "def __bool__(self):\n" " return bool(self.value)" msgstr "" +"def __bool__(self):\n" +" return bool(self.value)" #: ../Doc/howto/enum.rst:1082 msgid "Plain :class:`Enum` classes always evaluate as :data:`True`." @@ -1974,6 +2387,12 @@ msgid "" "['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " "'surface_gravity', 'value']" msgstr "" +">>> dir(Planet)\n" +"['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " +"'VENUS', '__class__', '__doc__', '__members__', '__module__']\n" +">>> dir(Planet.EARTH)\n" +"['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " +"'surface_gravity', 'value']" #: ../Doc/howto/enum.rst:1099 msgid "Combining members of ``Flag``" @@ -2002,6 +2421,18 @@ msgid "" ">>> Color(7) # not named combination\n" "" msgstr "" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"... MAGENTA = RED | BLUE\n" +"... YELLOW = RED | GREEN\n" +"... CYAN = GREEN | BLUE\n" +"...\n" +">>> Color(3) #combinación con nombre\n" +"\n" +">>> Color(7) # combinación sin nombre\n" +"" #: ../Doc/howto/enum.rst:1119 msgid "``Flag`` and ``IntFlag`` minutia" @@ -2022,6 +2453,14 @@ msgid "" "... WHITE = RED | GREEN | BLUE\n" "..." msgstr "" +">>> class Color(IntFlag):\n" +"... BLACK = 0\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 4\n" +"... PURPLE = RED | BLUE\n" +"... WHITE = RED | GREEN | BLUE\n" +"..." #: ../Doc/howto/enum.rst:1132 msgid "the following are true:" @@ -2044,6 +2483,8 @@ msgid "" ">>> list(Color.WHITE)\n" "[, , ]" msgstr "" +">>> list(Color.WHITE)\n" +"[, , ]" #: ../Doc/howto/enum.rst:1141 msgid "" @@ -2061,6 +2502,11 @@ msgid "" ">>> ~Color.BLUE\n" "" msgstr "" +">>> Color.BLUE\n" +"\n" +"\n" +">>> ~Color.BLUE\n" +"" #: ../Doc/howto/enum.rst:1150 msgid "names of pseudo-flags are constructed from their members' names::" @@ -2081,6 +2527,16 @@ msgid "" ">>> (Perm.R & Perm.W).name is None # effectively Perm(0)\n" "True" msgstr "" +">>> (Color.RED | Color.GREEN).name\n" +"'RED|GREEN'\n" +"\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> (Perm.R & Perm.W).name is None # efectivamente Perm(0)\n" +"True" #: ../Doc/howto/enum.rst:1163 msgid "multi-bit flags, aka aliases, can be returned from operations::" @@ -2099,6 +2555,14 @@ msgid "" ">>> Color(0)\n" "" msgstr "" +">>> Color.RED | Color.BLUE\n" +"\n" +"\n" +">>> Color(7) # or Color(-1)\n" +"\n" +"\n" +">>> Color(0)\n" +"" #: ../Doc/howto/enum.rst:1174 msgid "" @@ -2113,6 +2577,8 @@ msgid "" ">>> Color.BLACK in Color.WHITE\n" "True" msgstr "" +">>> Color.BLACK in Color.WHITE\n" +"True" #: ../Doc/howto/enum.rst:1180 msgid "" @@ -2130,6 +2596,11 @@ msgid "" ">>> Color.GREEN in Color.PURPLE\n" "False" msgstr "" +">>> Color.PURPLE in Color.WHITE\n" +"True\n" +"\n" +">>> Color.GREEN in Color.PURPLE\n" +"False" #: ../Doc/howto/enum.rst:1189 msgid "" @@ -2269,6 +2740,8 @@ msgid "" ">>> list(Color)\n" "[, , ]" msgstr "" +">>> list(Color)\n" +"[, , ]" #: ../Doc/howto/enum.rst:1251 msgid "(Note that ``BLACK``, ``PURPLE``, and ``WHITE`` do not show up.)" @@ -2287,6 +2760,8 @@ msgid "" ">>> ~Color.RED\n" "" msgstr "" +">>> ~Color.RED\n" +"" #: ../Doc/howto/enum.rst:1259 msgid "" @@ -2301,6 +2776,8 @@ msgid "" ">>> len(Color.PURPLE)\n" "2" msgstr "" +">>> len(Color.PURPLE)\n" +"2" #: ../Doc/howto/enum.rst:1269 msgid "Enum Cookbook" @@ -2379,6 +2856,13 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class Color(Enum):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../Doc/howto/enum.rst:1310 msgid "Using :class:`object`" @@ -2398,6 +2882,13 @@ msgid "" ">>> Color.GREEN \n" ">" msgstr "" +">>> class Color(Enum):\n" +"... RED = object()\n" +"... GREEN = object()\n" +"... BLUE = object()\n" +"...\n" +">>> Color.GREEN\n" +">" #: ../Doc/howto/enum.rst:1322 msgid "" @@ -2420,6 +2911,15 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class Color(Enum):\n" +"... RED = object()\n" +"... GREEN = object()\n" +"... BLUE = object()\n" +"... def __repr__(self):\n" +"... return \"<%s.%s>\" % (self.__class__.__name__, self._name_)\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../Doc/howto/enum.rst:1338 msgid "Using a descriptive string" @@ -2439,6 +2939,13 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class Color(Enum):\n" +"... RED = 'stop'\n" +"... GREEN = 'go'\n" +"... BLUE = 'too fast!'\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../Doc/howto/enum.rst:1352 msgid "Using a custom :meth:`__new__`" @@ -2465,6 +2972,20 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls):\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"...\n" +">>> class Color(AutoNumber):\n" +"... RED = ()\n" +"... GREEN = ()\n" +"... BLUE = ()\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../Doc/howto/enum.rst:1371 msgid "" @@ -2484,6 +3005,14 @@ msgid "" "... return obj\n" "..." msgstr "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls, *args): # éste es el único cambio respecto a " +"lo anterior\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"..." #: ../Doc/howto/enum.rst:1381 msgid "" @@ -2509,6 +3038,19 @@ msgid "" ">>> Swatch.BLEACHED_CORAL.pantone\n" "'unknown'" msgstr "" +">>> class Swatch(AutoNumber):\n" +"... def __init__(self, pantone='unknown'):\n" +"... self.pantone = pantone\n" +"... AUBURN = '3497'\n" +"... SEA_GREEN = '1246'\n" +"... BLEACHED_CORAL = () # ¡Nuevo color, aún sin código Pantone!\n" +"...\n" +">>> Swatch.SEA_GREEN\n" +"\n" +">>> Swatch.SEA_GREEN.pantone\n" +"'1246'\n" +">>> Swatch.BLEACHED_CORAL.pantone\n" +"'unknown'" #: ../Doc/howto/enum.rst:1400 msgid "" @@ -2530,7 +3072,7 @@ msgstr "" #: ../Doc/howto/enum.rst:1409 msgid "obj = int.__new__(cls, value)" -msgstr "" +msgstr "obj = int.__new__(cls, value)" #: ../Doc/howto/enum.rst:1413 msgid "OrderedEnum" @@ -2576,6 +3118,33 @@ msgid "" ">>> Grade.C < Grade.A\n" "True" msgstr "" +">>> class OrderedEnum(Enum):\n" +"... def __ge__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value >= other.value\n" +"... return NotImplemented\n" +"... def __gt__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value > other.value\n" +"... return NotImplemented\n" +"... def __le__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value <= other.value\n" +"... return NotImplemented\n" +"... def __lt__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value < other.value\n" +"... return NotImplemented\n" +"...\n" +">>> class Grade(OrderedEnum):\n" +"... A = 5\n" +"... B = 4\n" +"... C = 3\n" +"... D = 2\n" +"... F = 1\n" +"...\n" +">>> Grade.C < Grade.A\n" +"True" #: ../Doc/howto/enum.rst:1449 msgid "DuplicateFreeEnum" @@ -2613,6 +3182,26 @@ msgid "" " ...\n" "ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" msgstr "" +">>> class DuplicateFreeEnum(Enum):\n" +"... def __init__(self, *args):\n" +"... cls = self.__class__\n" +"... if any(self.value == e.value for e in cls):\n" +"... a = self.name\n" +"... e = cls(self.value).name\n" +"... raise ValueError(\n" +"... \"aliases not allowed in DuplicateFreeEnum: %r --> " +"%r\"\n" +"... % (a, e))\n" +"...\n" +">>> class Color(DuplicateFreeEnum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"... GRENE = 2\n" +"...\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" #: ../Doc/howto/enum.rst:1476 msgid "" @@ -2626,11 +3215,11 @@ msgstr "" #: ../Doc/howto/enum.rst:1482 msgid "MultiValueEnum" -msgstr "" +msgstr "MultiValueEnum" #: ../Doc/howto/enum.rst:1484 msgid "Supports having more than one value per member::" -msgstr "" +msgstr "Soporta tener más de un valor por miembro:" #: ../Doc/howto/enum.rst:1486 msgid "" @@ -2651,6 +3240,22 @@ msgid "" ">>> DType(9)\n" "" msgstr "" +">>> class MultiValueEnum(Enum):\n" +"... def __new__(cls, value, *values):\n" +"... self = object.__new__(cls)\n" +"... self._value_ = value\n" +"... for v in values:\n" +"... self._add_value_alias_(v)\n" +"... return self\n" +"...\n" +">>> class DType(MultiValueEnum):\n" +"... float32 = 'f', 8\n" +"... double64 = 'd', 9\n" +"...\n" +">>> DType('f')\n" +"\n" +">>> DType(9)\n" +"" #: ../Doc/howto/enum.rst:1505 msgid "Planet" @@ -2689,6 +3294,28 @@ msgid "" ">>> Planet.EARTH.surface_gravity\n" "9.802652743337129" msgstr "" +">>> class Planet(Enum):\n" +"... MERCURY = (3.303e+23, 2.4397e6)\n" +"... VENUS = (4.869e+24, 6.0518e6)\n" +"... EARTH = (5.976e+24, 6.37814e6)\n" +"... MARS = (6.421e+23, 3.3972e6)\n" +"... JUPITER = (1.9e+27, 7.1492e7)\n" +"... SATURN = (5.688e+26, 6.0268e7)\n" +"... URANUS = (8.686e+25, 2.5559e7)\n" +"... NEPTUNE = (1.024e+26, 2.4746e7)\n" +"... def __init__(self, mass, radius):\n" +"... self.mass = mass # in kilograms\n" +"... self.radius = radius # in meters\n" +"... @property\n" +"... def surface_gravity(self):\n" +"... # universal gravitational constant (m3 kg-1 s-2)\n" +"... G = 6.67300E-11\n" +"... return G * self.mass / (self.radius * self.radius)\n" +"...\n" +">>> Planet.EARTH.value\n" +"(5.976e+24, 6378140.0)\n" +">>> Planet.EARTH.surface_gravity\n" +"9.802652743337129" #: ../Doc/howto/enum.rst:1536 msgid "TimePeriod" @@ -2716,6 +3343,20 @@ msgid "" "[, ]" msgstr "" +">>> from datetime import timedelta\n" +">>> class Period(timedelta, Enum):\n" +"... \"different lengths of time\"\n" +"... _ignore_ = 'Period i'\n" +"... Period = vars()\n" +"... for i in range(367):\n" +"... Period['day_%d' % i] = i\n" +"...\n" +">>> list(Period)[:2]\n" +"[, ]\n" +">>> list(Period)[-2:]\n" +"[, ]" #: ../Doc/howto/enum.rst:1557 msgid "Subclassing EnumType"