This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Descriptor HowTo Guide - Typo
Type: behavior Stage:
Components: Documentation Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, rhettinger, stubzpub
Priority: normal Keywords:

Created on 2016-03-23 00:56 by stubzpub, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg262223 - (view) Author: Stubz (stubzpub) Date: 2016-03-23 00:56
The last line has a typo ... Dict.fromkeys -> dict.fromkeys

I am a newbie, but that was just a pain in the ass ...

Worked my way thru this How to and spent an hour+ trying to sort a circular argument error...

Was this intentional ¿
In as much as it was a pain in the ass, I think I got the concept sorted ...


https://docs.python.org/3.5/howto/descriptor.html

Static Methods and Class Methods

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 dict.fromkeys() creates a new dictionary from a list of keys. The pure Python equivalent is:

class Dict(object):
    . . .
    def fromkeys(klass, iterable, value=None):
        "Emulate dict_fromkeys() in Objects/dictobject.c"
        d = klass()
        for key in iterable:
            d[key] = value
        return d
    fromkeys = classmethod(fromkeys)

Now a new dictionary of unique keys can be constructed like this:

>>>
Dict.fromkeys('abracadabra')
msg262225 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-03-23 01:20
The last line is not a typo, it shows how to call the pure python version of the classmethod described above it.

FWIW, I'm working a revision to this how-to guide that it easier to read.  At the time it was written, it was the *only* documentation for the descriptors in that language and much of it was a direct translation from the underlying C code as an authoritative reference to that code.  It was not really a newbie document (descriptors aren't a newbie topic) and was moved to the how-to guides because it was so popular.

Since you're already "sorted", I'll close this tracker item.
msg262262 - (view) Author: Stubz (stubzpub) Date: 2016-03-23 13:17
Thanx mate, I am sorted ...

Q tho ...

It turns out my issue was with the class Dict and what I called a typo in the call to dict.fromkeys ...

In order to make it 'go', I had to use the lower case letter, how is that not a typo ¿

The part that hung me up was the naming of class Dict and the call to dict.fromkeys, with no variable assigned to it ... 

It makes better sense now, but ... a class Dict used as a example of dictobject, to demonstrate the descriptors use of the dictobject methods, from a call to Dictobject, that returns error object not iterable ...

I don't care what Lvl you are, that's just confusing ...
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70800
2016-03-23 13:17:19stubzpubsetmessages: + msg262262
2016-03-23 01:20:24rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg262225

assignee: docs@python -> rhettinger
resolution: not a bug
2016-03-23 00:56:24stubzpubcreate