@ -436,11 +464,11 @@ class <enum_name>(enum.Enum):
```
```python
<enum_name>.<name> # == <enum>
<enum_name>['<name>'] # == <enum>
<enum_name>(value) # == <enum>
<enum>.name # == <name>
<enum>.value # == <value>
<enum> = <enum_name>.<name>
<enum> = <enum_name>['<name>']
<enum> = <enum_name>(value)
<name> = <enum>.name
<value> = <enum>.value
```
```python
@ -587,6 +615,11 @@ while True:
break
```
#### Raise exception
```python
raise IOError("input/output error")
```
Threading
---------
```python
@ -647,8 +680,8 @@ from itertools import *
### Count
```python
>>> a = count(5, 2)
>>> next(a), next(a)
>>> i = count(5, 2)
>>> next(i), next(i)
(5, 7)
```
@ -689,7 +722,14 @@ Introspection and Metaprograming
* **Traverse the parent classes**
* **Change values in the class**
### Variables
```python
<list> = dir() # In scope variables.
<dict> = globals() # Global variables.
<dict> = locals() # Local variables.
```
### Attributes
```python
>>> class Z:
... def __init__(self):
@ -698,7 +738,6 @@ Introspection and Metaprograming
>>> z = Z()
```
### Getattr, Hasattr, Setattr
```python
>>> getattr(z, 'a') # Same as Z.__getattribute__(z, 'a')
'abcde'
@ -735,7 +774,7 @@ class MyMetaClass(type):
return type.__new__(klass, name, parents, attrs)
```
### Metaclass Attr
### Metaclass Attribute
**When class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined, and eventually comes to type:**