On 10/31/18 8:53 AM, Tobiah wrote:
My IDE (pycharm) suggests that I mark my class methods
with @staticmethod when they don't use 'self'.  Sounds
good.  I did that then it suggested I had the option
to make a regular function instead, at the file level.
That's a possibility.  I was thinking that I'd leave
the method in the class unless it was ever also used
by another class.  What do you think?




It should be a staticmethod if the code is, while not linked to any instance in particular, still fundamentally inherent to the class itself and of little use outside the context of that class. It should be a stand-alone function if it provides stand-alone functionality. The decision is also almost certainly not worth the amount of thought you're giving it.

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to