Eric V. Smith added the comment:
Also: you're statement that bar was initialized to "some value" isn't true: you
didn't use attr1 in your __init__ method, so "some value" was never used.
If you're confused, I suggest you ask on the python-list or tutor mailing
lists. More info here: https://
Eric V. Smith added the comment:
This isn't a bug, it's how the language works. You're not forced to use the
parameters to a function (in this case __init__), and you can reference any
variable, including a global.
--
components: -asyncio
nosy: +eric.smith
_
New submission from Sebastian Bevc :
Hello,
This is my first bug report. While doing some homework i came to realize that
the __init__ of a class was taking out of context variables.
class Foo(object):
def __init__(self, attr1):
self.out_of_context = out_of_context
# Raises NameError