1

As in the title I want to know how to have a self instance in a staticmethod in python.

8
  • 1
    use global keyword I suppose, but I do no think you want to do what your asking...there is a better way Commented Apr 20, 2011 at 20:33
  • Why don't you tell us what the problem you're trying to solve is (with code) and we'll suggest something better than using static methods, which are rarely a good idea in Python. Commented Apr 20, 2011 at 20:34
  • can you guys see the second answer on this question stackoverflow.com/questions/5642500/… Commented Apr 20, 2011 at 20:36
  • because updating variables in a function as a side effect leads to bugs. Unless you have to like in C where your dealing directly with memory Commented Apr 20, 2011 at 20:39
  • 1
    I put an answer on your bounty Commented Apr 20, 2011 at 21:05

1 Answer 1

6

By definition, a static method does not have a self parameter. That's what makes it static. If it did have a self parameter, it would be a regular method and not a static method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.