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.

Author Jonathan Hsu
Recipients Ethan Onstott, Jonathan Hsu, barry, docs@python, edd07, eli.bendersky, ethan.furman
Date 2020-03-21.21:45:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584827108.9.0.302452692651.issue40025@roundup.psfhosted.org>
In-reply-to
Content
While the current behavior may be initially unexpected, it does match the way that python normally behaves when defining class variables. For example, the following class will throw an exception because the function number_two() is called before it is defined:


class Numbers:
    one = 1
    two = number_two()

    def number_two():
        return 2

# NameError: name 'number_two' is not defined


However, this version is fine:


class Numbers:
    one = 1

    def number_two():
        return 2

    two = number_two()
History
Date User Action Args
2020-03-21 21:45:08Jonathan Hsusetrecipients: + Jonathan Hsu, barry, eli.bendersky, docs@python, ethan.furman, edd07, Ethan Onstott
2020-03-21 21:45:08Jonathan Hsusetmessageid: <1584827108.9.0.302452692651.issue40025@roundup.psfhosted.org>
2020-03-21 21:45:08Jonathan Hsulinkissue40025 messages
2020-03-21 21:45:08Jonathan Hsucreate