classification
Title: delete_me
Type: behavior Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: keyboardAnt, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2020-04-08 11:45 by keyboardAnt, last changed 2020-04-08 12:23 by ronaldoussoren. This issue is now closed.

Messages (2)
msg365977 - (view) Author: (keyboardAnt) Date: 2020-04-08 11:45
Executing the following code* raise a NameError**. Is it on purpose?
Attached minimal example to reproduce.

class C:
	val = C.sm()

	@staticmethod
	def sm():
		return 'val'

*With Python 3.8.2, on MacOS.
**"NameError: name 'C' is not defined"

Best regards
msg365982 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-04-08 12:23
This is expected behavior, the call to "C.sm()" happens before "C" is created.
History
Date User Action Args
2020-04-08 12:23:36ronaldoussorensetstatus: open -> closed
type: behavior
messages: + msg365982

resolution: not a bug
stage: resolved
2020-04-08 11:49:58keyboardAntsetversions: - Python 3.8
components: - macOS
title: Execute a @staticmethod (Python 3.8.2) -> delete_me
2020-04-08 11:49:19keyboardAntsetfiles: - example.py
2020-04-08 11:45:10keyboardAntcreate