Skip to content
Advertisement

Tag: self

self in Python references to variable rather than the class [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 3 months ago. Improve this question

Extending dictionary with cascading methods

I am extending the dict class in python: I would like to be able to do: the problem I have here is that jmespath can return a list, so I cannot do: Next idea would be creating a prettyprint class that superDict would inherit from and could also be used in the return of search: But I can’t figure out

Confusion about scoping in python classes

I am currently reviewing the python tutorials of python.org. I come from C++ and in the Classes tutorial (https://docs.python.org/3/tutorial/classes.html) I see that the scoping is similar to that in C++. It says the following about scoping and nesting: “At any time during execution, there are at least three nested scopes whose namespaces are directly accessible: – the innermost scope, which

Python classes self.variables

I have started learning python classes some time ago, and there is something that I do not understand when it comes to usage of self.variables inside of a class. I googled, but couldn’t find the answer. I am not a programmer, just a python hobbyist. Here is an example of a simple class, with two ways of defining it: 1)first

When do you use ‘self’ in Python? [duplicate]

This question already has answers here: What is the purpose of the `self` parameter? Why is it needed? (26 answers) Closed 6 months ago. Are you supposed to use self when referencing a member function in Python (within the same module)? More generally, I was wondering when it is required to use self, not just for methods but for variables

Advertisement