Skip to content

Commit 9a3b94e

Browse files
committed
updates
1 parent e5595d0 commit 9a3b94e

35 files changed

Lines changed: 738 additions & 382 deletions

source/docs/bool/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Constructors
88
------------
99
`bool()`_
1010
Returns an expression converted into a Boolean.
11-
`Literal Syntax`_
12-
11+
`literal syntax`_
12+
Initializes a new instance of the **bool** type.
1313

1414
.. _literal syntax: literals.html
1515
.. _bool(): ../functions/bool.html

source/docs/complex/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Constructors
1010
====
1111
`complex()`_
1212
Returns an expression converted into a complex number.
13-
`Literal Syntax`_
13+
`literal syntax`_
14+
Initializes a new instance of the **complex** type.
1415

1516
Properties
1617
====

source/docs/dict/index.rst

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,7 @@ Constructors
1313
`{} dict comprehension`_
1414
Returns a dictionary based on existing iterables.
1515
`literal syntax`_
16-
17-
Misc
18-
====
19-
`[] (key lookup)`_
20-
Returns the value associated with the given key.
21-
22-
Functions
23-
====
24-
`len`_
25-
Returns an int type specifying number of elements in the collection.
26-
`min`_
27-
Returns the smallest item from a collection.
28-
`max`_
29-
Returns the largest item in an iterable or the largest of two or more arguments.
30-
`sum`_
31-
Returns a total of the items contained in the iterable object.
32-
`sorted`_
33-
Returns a sorted list from the iterable.
34-
`reversed`_
35-
Returns a reverse iterator over a sequence.
36-
`all`_
37-
Returns a Boolean value that indicates whether the collection contains only values that evaluate to True.
38-
`any`_
39-
Returns a Boolean value that indicates whether the collection contains any values that evaluate to True.
40-
`enumerate`_
41-
Returns an enumerate object.
42-
`zip`_
43-
Returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
16+
Initializes a new instance of the **dict** type.
4417

4518
Methods
4619
====
@@ -110,6 +83,34 @@ Dictionary Views Operators
11083
`| (union)`_
11184
Returns all the elements that appear in the dictview and the specified iterable.
11285

86+
Functions
87+
====
88+
`len`_
89+
Returns an int type specifying number of elements in the collection.
90+
`min`_
91+
Returns the smallest item from a collection.
92+
`max`_
93+
Returns the largest item in an iterable or the largest of two or more arguments.
94+
`sum`_
95+
Returns a total of the items contained in the iterable object.
96+
`sorted`_
97+
Returns a sorted list from the iterable.
98+
`reversed`_
99+
Returns a reverse iterator over a sequence.
100+
`all`_
101+
Returns a Boolean value that indicates whether the collection contains only values that evaluate to True.
102+
`any`_
103+
Returns a Boolean value that indicates whether the collection contains any values that evaluate to True.
104+
`enumerate`_
105+
Returns an enumerate object.
106+
`zip`_
107+
Returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
108+
109+
Misc
110+
====
111+
`[] (key lookup)`_
112+
Returns the value associated with the given key.
113+
113114
.. _dict(): ../functions/dict.html
114115
.. _[] (key lookup): ../brackets/key_lookup.html
115116
.. _{} dict comprehension: ../comprehensions/dict_comprehension.html
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
====
2-
Double Underscore Methods and Variables
2+
Direct Attribute Access
33
====
44

5-
Direct Atribute Access
5+
The following methods can be defined to customize the meaning of attribute access (use of, assignment to, or deletion of x.name) for class instances.
6+
7+
Methods
68
====
79
`\__getattribute__`_
810
Called unconditionally to implement attribute accesses for instances of the class.
@@ -13,31 +15,8 @@ Direct Atribute Access
1315
`\__delattr__`_
1416
Called when an attribute deletion is attempted.
1517

16-
Descriptor Protocol
17-
====
18-
Used to create object attributes overriding attribute access for class instances.
19-
20-
Comparisons
21-
================
22-
23-
Containers
24-
==========
25-
26-
Context Managers
27-
================
28-
29-
Numeric Methods
30-
===============
31-
32-
Object Attributes
33-
=================
34-
35-
Pickle Protocol
36-
===============
37-
3818
.. _\__getattribute__: ./getattribute.html
3919
.. _\__getattr__: ./getattr.html
4020
.. _\__setattr__: ./setattr.html
4121
.. _\__delattr__: ./delattr.html
42-
43-
.. _Descriptor ProtocolTODO: ./dscrpt.html
22+
File renamed without changes.

source/docs/dunderdsc/delete.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
====
2+
__delete__
3+
====
4+
5+
Description
6+
====
7+
Called to delete the attribute on an instance instance of the owner class.
8+
9+
Syntax
10+
====
11+
**object**. *__delete__(self, instance)*
12+
13+
*self*
14+
Required. Instance of the class, passed automatically on call.
15+
*instance*
16+
Required. Instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.
17+
18+
Remarks
19+
====
20+
The following method only apply to new-style classes.
21+
22+
The following methods only apply when an instance of the class containing the method (a so-called descriptor class) appears in an owner class (the descriptor must be in either the owner’s class dictionary or in the class dictionary for one of its parents).
23+
24+
This method should delete attribute value if found or raise an AttributeError exception otherwise.
25+
26+
Example
27+
====
28+
::
29+
30+
# this is our descriptor object
31+
class Bar(object):
32+
def __init__(self):
33+
self.value = ''
34+
def __get__(self, instance, owner):
35+
print "returned from descriptor object"
36+
return self.value
37+
def __set__(self, instance, value):
38+
print "set in descriptor object"
39+
self.value = value
40+
def __delete__(self, instance):
41+
print "deleted in descriptor object"
42+
del self.value
43+
44+
class Foo(object):
45+
bar = Bar()
46+
47+
f = Foo()
48+
f.bar = 10
49+
print f.bar
50+
del f.bar
51+
52+
set in descriptor object
53+
returned from descriptor object
54+
10
55+
deleted in descriptor object

source/docs/dunderdsc/get.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
====
2+
__get__
3+
====
4+
5+
Description
6+
====
7+
Called to get the attribute of the owner class (class attribute access) or of an instance of that class (instance attribute access).
8+
9+
Syntax
10+
====
11+
**object**. *__get__(self, instance, owner)*
12+
13+
*self*
14+
Required. Instance of the class, passed automatically on call.
15+
*instance*
16+
Required. Instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.
17+
*owner*
18+
Required. Owner is always the owner class.
19+
20+
Remarks
21+
====
22+
The following method only applies to new-style classes.
23+
24+
The following methods only apply when an instance of the class containing the method (a so-called descriptor class) appears in an owner class (the descriptor must be in either the owner’s class dictionary or in the class dictionary for one of its parents).
25+
26+
This method should return the (computed) attribute value or raise an AttributeError exception.
27+
28+
Example
29+
====
30+
::
31+
32+
# this is our descriptor object
33+
class Bar(object):
34+
def __init__(self):
35+
self.value = ''
36+
def __get__(self, instance, owner):
37+
print "returned from descriptor object"
38+
return self.value
39+
def __set__(self, instance, value):
40+
print "set in descriptor object"
41+
self.value = value
42+
def __delete__(self, instance):
43+
print "deleted in descriptor object"
44+
del self.value
45+
46+
class Foo(object):
47+
bar = Bar()
48+
49+
f = Foo()
50+
f.bar = 10
51+
print f.bar
52+
del f.bar
53+
54+
set in descriptor object
55+
returned from descriptor object
56+
10
57+
deleted in descriptor object

0 commit comments

Comments
 (0)