M
markotaht
Is there a way to give a class extra functions whidout editing the .py file where the class is located?
Is there a way to give a class extra functions whidout editing the .py
file where the class is located?
Is there a way to give a class extra functions whidout editing the .py file where the class is located?
esmaspäev, 30. september 2013 11:43.19 UTC+3 kirjutas (e-mail address removed):
But does it have all the variables that the main class have?
under variables, i mean, the int's and lists and strings and floats that
the parent class uses. IF in parent class there is variable called
location, then can i use the same variable in my sub class.
Please show us some code. Thankyou.
under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class.
under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class.
Why does this meme persist!? Of course Python has variables, they just
don't work like C variables do. If you'd like to know the details:
http://nedbatchelder.com/text/names.html
Why does this meme persist!? Of course Python has variables, they just don't work like C variables do. If you'd like
to know the details: http://nedbatchelder.com/text/names.html
Names are Python's variables: they refer to values, and
those values can change (vary) over the course of your
program.
Because Python's model is different enough that it usually makes
thinking about it simpler to stay away from the word 'variable'; in
every other language I have used a variable is a box, but in Python
it's a label for a box.
From your blog:
This is partially incorrect. If the value referred to by the name is
immutable, then it cannot change; perhaps you meant to say that which
object the name points to can vary over time?
Why does this meme persist!? Of course Python has variables, they just
don't work like C variables do. If you'd like to know the details:
http://nedbatchelder.com/text/names.html
I agree. Names are not Python's variables.Ethan Furman said:From [Ned Batchelder]'s blog:This is partially incorrect. If the value referred to by the name isNames are Python's variables: they refer to values, and
those values can change (vary) over the course of your
program.
immutable, then it cannot change; perhaps you meant to say that which
object the name points to can vary over time?
If anything in Python is a “variable†as generally understood, it is not
a name. It is a *binding*, from a reference (a name, or some other
reference like a list item) to a value.
It is the binding which can change over the course of the program, so
that is the variable.
under variables, i mean, the int's and lists and strings and floats that
the parent class uses. IF in parent class there is variable called
location, then can i use the same variable in my sub class.
I can't speak for others, but in my own experience, I never *quite*
understood the semantic differences between Python name bindings and
Pascal variables until I came across the meme "Python has no variables".
True, but no one calls the binding the variable. Here is a program:I agree. Names are not Python's variables.Ethan Furman said:From [Ned Batchelder]'s blog:
Names are Python's variables: they refer to values, and
those values can change (vary) over the course of your program.
This is partially incorrect. If the value referred to by the name is
immutable, then it cannot change; perhaps you meant to say that which
object the name points to can vary over time?
If anything in Python is a “variable†as generally understood, it is
not a name. It is a *binding*, from a reference (a name, or some other
reference like a list item) to a value.
It is the binding which can change over the course of the program, so
that is the variable.
x = 4
Every one of us is perfectly comfortable talking about the variable x.
Don't get hung up on implementation pedantry. The name x here refers to
4. Later it could refer to "four". The value associated with the name
x changed. x is a variable.
Your statement is ambiguous -- do you mean the *association* betweenTrue, but no one calls the binding the variable. Here is a program:From [Ned Batchelder]'s blog:
Names are Python's variables: they refer to values, and
those values can change (vary) over the course of your program.
This is partially incorrect. If the value referred to by the name is
immutable, then it cannot change; perhaps you meant to say that which
object the name points to can vary over time?
I agree. Names are not Python's variables.
If anything in Python is a “variable†as generally understood, it is
not a name. It is a *binding*, from a reference (a name, or some other
reference like a list item) to a value.
It is the binding which can change over the course of the program, so
that is the variable.
x = 4
Every one of us is perfectly comfortable talking about the variable x.
Don't get hung up on implementation pedantry. The name x here refers to
4. Later it could refer to "four". The value associated with the name
x changed. x is a variable.
value (object) and name changed, or the value which is associated with
the name changed?
Python doesn't actually have variables, but the things it documents as
variables are local names within a method. Those are not visible
outside of the method, regardless of whether you're in a class or a
subclass.
But perhaps you mean attributes. There are both class attributes and
instance attributes, and the behavior is quite different. Roughly
speaking a class attribute occurs only once per class, and all code can
read its value with either Class.my_attrib or instance.my_attrib. It
can be written with Class.my_attrib.
On the other hand, instance attributes are usable by
instance.my_attrib, regardless of whether the instance is a base class
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.