When answering a recent question I repeated my assumption that one reason for using @staticmethod was to save ram, since a static method was only ever instantised once. This assertion can be found fairly easily online, (e.g. here) and I don’t know where I first encountered it. My reasoning was based on two assumptions, one false: a. that python instantised
Tag: static-methods
Python: Make class iterable
I have inherited a project with many large classes constituent of nothing but class objects (integers, strings, etc). I’d like to be able to check if an attribute is present without needed to define a list of attributes manually. Is it possible to make a python class iterable itself using the standard syntax? That is, I’d like to be able