New submission from Stubz:

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')

----------
assignee: docs@python
components: Documentation
messages: 262223
nosy: docs@python, stubzpub
priority: normal
severity: normal
status: open
title: Descriptor HowTo Guide - Typo
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26613>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to