On 31Oct2018 21:23, Marko Rauhamaa wrote:
Peter Otten <__pete...@web.de>:
Do not make changes to your code only to apeace a linter.
Precisely. Don't let a tool drive a show.
While this is sound for semantic changes (and a function versus a
@staticmethod is verging on that), I would point o
Peter Otten <__pete...@web.de>:
> Do not make changes to your code only to apeace a linter.
Precisely. Don't let a tool drive a show.
> Regarding more the general question, should I use an instance method,
> a class method, a static method, or a function? -- that is hard to
> answer without an i
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
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
> t
I usually recommend my students to use @classmethod. It's a consistent API
with a regular instance method, and receiving the class as first parameter
(usually `cls`) is useful if you have to extend your classes.
About separating a staticmethod in a regular function, it's mostly a matter
of taste a
On Monday, October 29, 2018 at 5:29:11 PM UTC-7, Stone Zhong wrote:
> Hi There,
>
> Now I want to make sure my code calls a function foo with an object t,
> however, foo.assert_called_once_with(t) does not work, since t is a model
> object and the code may load a different copy of t, so what I r
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 unl