[ Web Proxy ]
URL:
Viewing:
https://github-redirect.dependabot.com/python/python-docs-pl/blob/3.8/howto/descriptor.po
[Back]
[Original]
python-docs-pl/howto/descriptor.po at 3.8 python/python-docs-pl GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
[]
[]
GitHub
Repository hosting, code review, and collaboration
[]
[]
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
[]
[]
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
[]
[]
GitHub Universe
The event for developers, by developers talks, workshops, and whats next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
python
python-docs-pl
Repository navigation
Code
Issues
4
(4)
Pull requests
2
(2)
Actions
Security and quality
Insights
More
items
Files
Expand file tree
3.8
Breadcrumbs
python-docs-pl
/
howto
/
descriptor.po
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
394 lines (321 loc) 13.1 KB
3.8
Breadcrumbs
python-docs-pl
/
howto
/
descriptor.po
Copy path
Top
File metadata and controls
Code
Blame
394 lines (321 loc) 13.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#
SOME DESCRIPTIVE TITLE.
#
Copyright (C) 2001-2021, Python Software Foundation
#
This file is distributed under the same license as the Python package.
#
FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#
Translators:
#
Stefan Ocetkiewicz <stefan.ocetkiewicz@gmail.com>, 2020
#
Seweryn Pirkowski <seweryn.piorkowski@gmail.com>, 2020
#
Maciej Olko <maciej.olko@gmail.com>, 2021
#
#,
fuzzy
msgid ""
msgstr ""
"
Project-Id-Version
:
Python 3.8\n
"
"
Report-Msgid-Bugs-To
:
\n
"
"
POT-Creation-Date
:
2021-01-01 16:06+0000\n
"
"
PO-Revision-Date
:
2020-05-30 11:54+0000\n
"
"
Last-Translator
:
Maciej Olko <maciej.olko@gmail.com>, 2021\n
"
"
Language-Team
:
Polish (https://www.transifex.com/python-doc/teams/5390/pl/)\n
"
"
MIME-Version
:
1.0\n
"
"
Content-Type
:
text/plain; charset=UTF-8\n
"
"
Content-Transfer-Encoding
:
8bit\n
"
"
Language
:
pl\n
"
"
Plural-Forms
:
nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) &&
"
"
(n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 &&
"
"
n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n
"
msgid
"Descriptor HowTo Guide"
msgstr
""
msgid
"Author"
msgstr
"Autor"
msgid
"Raymond Hettinger"
msgstr
"Raymond Hettinger"
msgid
"Contact"
msgstr
""
msgid
"<python at rcn dot com>"
msgstr
""
msgid
"Contents"
msgstr
"Zawarto"
msgid
"Abstract"
msgstr
"Streszczenie"
msgid
""
"Defines descriptors, summarizes the protocol, and shows how descriptors are "
"called. Examines a custom descriptor and several built-in Python "
"descriptors including functions, properties, static methods, and class "
"methods. Shows how each works by giving a pure Python equivalent and a "
"sample application."
msgstr
""
msgid
""
"Learning about descriptors not only provides access to a larger toolset, it "
"creates a deeper understanding of how Python works and an appreciation for "
"the elegance of its design."
msgstr
""
msgid
"Definition and Introduction"
msgstr
""
msgid
""
"In general, a descriptor is an object attribute with
\"
binding behavior
\"
, "
"one whose attribute access has been overridden by methods in the descriptor "
"protocol. Those methods are :meth:`__get__`, :meth:`__set__`, and :meth:"
"`__delete__`. If any of those methods are defined for an object, it is said "
"to be a descriptor."
msgstr
""
msgid
""
"The default behavior for attribute access is to get, set, or delete the "
"attribute from an object's dictionary. For instance, ``a.x`` has a lookup "
"chain starting with ``a.__dict__['x']``, then ``type(a).__dict__['x']``, and "
"continuing through the base classes of ``type(a)`` excluding metaclasses. If "
"the looked-up value is an object defining one of the descriptor methods, "
"then Python may override the default behavior and invoke the descriptor "
"method instead. Where this occurs in the precedence chain depends on which "
"descriptor methods were defined."
msgstr
""
msgid
""
"Descriptors are a powerful, general purpose protocol. They are the "
"mechanism behind properties, methods, static methods, class methods, and :"
"func:`super()`. They are used throughout Python itself to implement the new "
"style classes introduced in version 2.2. Descriptors simplify the "
"underlying C-code and offer a flexible set of new tools for everyday Python "
"programs."
msgstr
""
msgid
"Descriptor Protocol"
msgstr
""
msgid
"``descr.__get__(self, obj, type=None) -> value``"
msgstr
""
msgid
"``descr.__set__(self, obj, value) -> None``"
msgstr
""
msgid
"``descr.__delete__(self, obj) -> None``"
msgstr
""
msgid
""
"That is all there is to it. Define any of these methods and an object is "
"considered a descriptor and can override default behavior upon being looked "
"up as an attribute."
msgstr
""
msgid
""
"If an object defines :meth:`__set__` or :meth:`__delete__`, it is considered "
"a data descriptor. Descriptors that only define :meth:`__get__` are called "
"non-data descriptors (they are typically used for methods but other uses are "
"possible)."
msgstr
""
msgid
""
"Data and non-data descriptors differ in how overrides are calculated with "
"respect to entries in an instance's dictionary. If an instance's dictionary "
"has an entry with the same name as a data descriptor, the data descriptor "
"takes precedence. If an instance's dictionary has an entry with the same "
"name as a non-data descriptor, the dictionary entry takes precedence."
msgstr
""
msgid
""
"To make a read-only data descriptor, define both :meth:`__get__` and :meth:"
"`__set__` with the :meth:`__set__` raising an :exc:`AttributeError` when "
"called. Defining the :meth:`__set__` method with an exception raising "
"placeholder is enough to make it a data descriptor."
msgstr
""
msgid
"Invoking Descriptors"
msgstr
""
msgid
""
"A descriptor can be called directly by its method name. For example, ``d."
"__get__(obj)``."
msgstr
""
msgid
""
"Alternatively, it is more common for a descriptor to be invoked "
"automatically upon attribute access. For example, ``obj.d`` looks up ``d`` "
"in the dictionary of ``obj``. If ``d`` defines the method :meth:`__get__`, "
"then ``d.__get__(obj)`` is invoked according to the precedence rules listed "
"below."
msgstr
""
msgid
""
"The details of invocation depend on whether ``obj`` is an object or a class."
msgstr
""
msgid
""
"For objects, the machinery is in :meth:`object.__getattribute__` which "
"transforms ``b.x`` into ``type(b).__dict__['x'].__get__(b, type(b))``. The "
"implementation works through a precedence chain that gives data descriptors "
"priority over instance variables, instance variables priority over non-data "
"descriptors, and assigns lowest priority to :meth:`__getattr__` if provided. "
"The full C implementation can be found in :c:func:"
"`PyObject_GenericGetAttr()` in :source:`Objects/object.c`."
msgstr
""
msgid
""
"For classes, the machinery is in :meth:`type.__getattribute__` which "
"transforms ``B.x`` into ``B.__dict__['x'].__get__(None, B)``. In pure "
"Python, it looks like::"
msgstr
""
msgid
"The important points to remember are:"
msgstr
""
msgid
"descriptors are invoked by the :meth:`__getattribute__` method"
msgstr
""
msgid
"overriding :meth:`__getattribute__` prevents automatic descriptor calls"
msgstr
""
msgid
""
":meth:`object.__getattribute__` and :meth:`type.__getattribute__` make "
"different calls to :meth:`__get__`."
msgstr
""
msgid
"data descriptors always override instance dictionaries."
msgstr
""
msgid
"non-data descriptors may be overridden by instance dictionaries."
msgstr
""
msgid
""
"The object returned by ``super()`` also has a custom :meth:"
"`__getattribute__` method for invoking descriptors. The attribute lookup "
"``super(B, obj).m`` searches ``obj.__class__.__mro__`` for the base class "
"``A`` immediately following ``B`` and then returns ``A.__dict__['m']."
"__get__(obj, B)``. If not a descriptor, ``m`` is returned unchanged. If "
"not in the dictionary, ``m`` reverts to a search using :meth:`object."
"__getattribute__`."
msgstr
""
msgid
""
"The implementation details are in :c:func:`super_getattro()` in :source:"
"`Objects/typeobject.c`. and a pure Python equivalent can be found in "
"`Guido's Tutorial`_."
msgstr
""
msgid
""
"The details above show that the mechanism for descriptors is embedded in "
"the :meth:`__getattribute__()` methods for :class:`object`, :class:`type`, "
"and :func:`super`. Classes inherit this machinery when they derive from :"
"class:`object` or if they have a meta-class providing similar functionality. "
"Likewise, classes can turn-off descriptor invocation by overriding :meth:"
"`__getattribute__()`."
msgstr
""
msgid
"Descriptor Example"
msgstr
""
msgid
""
"The following code creates a class whose objects are data descriptors which "
"print a message for each get or set. Overriding :meth:`__getattribute__` is "
"alternate approach that could do this for every attribute. However, this "
"descriptor is useful for monitoring just a few chosen attributes::"
msgstr
""
msgid
""
"The protocol is simple and offers exciting possibilities. Several use cases "
"are so common that they have been packaged into individual function calls. "
"Properties, bound methods, static methods, and class methods are all based "
"on the descriptor protocol."
msgstr
""
msgid
"Properties"
msgstr
""
msgid
""
"Calling :func:`property` is a succinct way of building a data descriptor "
"that triggers function calls upon access to an attribute. Its signature is::"
msgstr
""
msgid
""
"The documentation shows a typical use to define a managed attribute ``x``::"
msgstr
""
msgid
""
"To see how :func:`property` is implemented in terms of the descriptor "
"protocol, here is a pure Python equivalent::"
msgstr
""
msgid
""
"The :func:`property` builtin helps whenever a user interface has granted "
"attribute access and then subsequent changes require the intervention of a "
"method."
msgstr
""
msgid
""
"For instance, a spreadsheet class may grant access to a cell value through "
"``Cell('b10').value``. Subsequent improvements to the program require the "
"cell to be recalculated on every access; however, the programmer does not "
"want to affect existing client code accessing the attribute directly. The "
"solution is to wrap access to the value attribute in a property data "
"descriptor::"
msgstr
""
msgid
"Functions and Methods"
msgstr
""
msgid
""
"Python's object oriented features are built upon a function based "
"environment. Using non-data descriptors, the two are merged seamlessly."
msgstr
""
msgid
""
"Class dictionaries store methods as functions. In a class definition, "
"methods are written using :keyword:`def` or :keyword:`lambda`, the usual "
"tools for creating functions. Methods only differ from regular functions in "
"that the first argument is reserved for the object instance. By Python "
"convention, the instance reference is called *self* but may be called *this* "
"or any other variable name."
msgstr
""
msgid
""
"To support method calls, functions include the :meth:`__get__` method for "
"binding methods during attribute access. This means that all functions are "
"non-data descriptors which return bound methods when they are invoked from "
"an object. In pure Python, it works like this::"
msgstr
""
msgid
""
"Running the interpreter shows how the function descriptor works in practice::"
msgstr
""
msgid
"Static Methods and Class Methods"
msgstr
""
msgid
""
"Non-data descriptors provide a simple mechanism for variations on the usual "
"patterns of binding functions into methods."
msgstr
""
msgid
""
"To recap, functions have a :meth:`__get__` method so that they can be "
"converted to a method when accessed as attributes. The non-data descriptor "
"transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. Calling ``klass."
"f(*args)`` becomes ``f(*args)``."
msgstr
""
msgid
"This chart summarizes the binding and its two most useful variants:"
msgstr
""
msgid
"Transformation"
msgstr
""
msgid
"Called from an Object"
msgstr
""
msgid
"Called from a Class"
msgstr
""
msgid
"function"
msgstr
""
msgid
"f(obj,
\\
*args)"
msgstr
""
msgid
"f(
\\
*args)"
msgstr
""
msgid
"staticmethod"
msgstr
""
msgid
"classmethod"
msgstr
""
msgid
"f(type(obj),
\\
*args)"
msgstr
""
msgid
"f(klass,
\\
*args)"
msgstr
""
msgid
""
"Static methods return the underlying function without changes. Calling "
"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into ``object."
"__getattribute__(c,
\"
f
\"
)`` or ``object.__getattribute__(C,
\"
f
\"
)``. As a "
"result, the function becomes identically accessible from either an object or "
"a class."
msgstr
""
msgid
""
"Good candidates for static methods are methods that do not reference the "
"``self`` variable."
msgstr
""
msgid
""
"For instance, a statistics package may include a container class for "
"experimental data. The class provides normal methods for computing the "
"average, mean, median, and other descriptive statistics that depend on the "
"data. However, there may be useful functions which are conceptually related "
"but do not depend on the data. For instance, ``erf(x)`` is handy conversion "
"routine that comes up in statistical work but does not directly depend on a "
"particular dataset. It can be called either from an object or the class: "
"``s.erf(1.5) --> .9332`` or ``Sample.erf(1.5) --> .9332``."
msgstr
""
msgid
""
"Since staticmethods return the underlying function with no changes, the "
"example calls are unexciting::"
msgstr
""
msgid
""
"Using the non-data descriptor protocol, a pure Python version of :func:"
"`staticmethod` would look like this::"
msgstr
""
msgid
""
"Unlike static methods, class methods prepend the class reference to the "
"argument list before calling the function. This format is the same for "
"whether the caller is an object or a class::"
msgstr
""
msgid
""
"This behavior is useful whenever the function only needs to have a class "
"reference and does not care about any underlying data. One use for "
"classmethods is to create alternate class constructors. In Python 2.3, the "
"classmethod :func:`dict.fromkeys` creates a new dictionary from a list of "
"keys. The pure Python equivalent is::"
msgstr
""
msgid
"Now a new dictionary of unique keys can be constructed like this::"
msgstr
""
msgid
""
"Using the non-data descriptor protocol, a pure Python version of :func:"
"`classmethod` would look like this::"
msgstr
""
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
Manage cookies
Do not share my personal information
You cant perform that action at this time.
Web Proxy Viewer |
New URL
|
Original Page