lint appeasement (was: @staticmethod or def function()?)

2018-10-31 Thread Cameron Simpson
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

Re: @staticmethod or def function()?

2018-10-31 Thread Marko Rauhamaa
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

Re: @staticmethod or def function()?

2018-10-31 Thread Rob Gaddi
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

Re: @staticmethod or def function()?

2018-10-31 Thread Peter Otten
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

Re: @staticmethod or def function()?

2018-10-31 Thread Santiago Basulto
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

Re: customer compare in assertEqual

2018-10-31 Thread Stone Zhong
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

@staticmethod or def function()?

2018-10-31 Thread Tobiah
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