Skip to main content
13 events
when toggle format what by license comment
Jan 23 at 22:33 comment added JimmyJames @chepner I assume you are talking about calling one classes method but with an object of a different class. The functional-style examples are fine, right?
Jan 23 at 22:30 comment added JimmyJames @chepner I added a strong warning to the first sentence. Better?
Jan 23 at 22:29 history edited JimmyJames CC BY-SA 4.0
added 32 characters in body
Jan 23 at 22:26 comment added chepner @JimmyJames You may not have suggested it, but I'm sure someone will try to do it anyway :) My comment is directed towards them.
Jan 23 at 22:23 comment added JimmyJames @chepner I'm pretty sure I did not suggest anyone should do this. Doing things like this is like cave diving. Not for amateurs.
Jan 23 at 21:48 comment added chepner The fact that you can do this in no way suggest you should. As to why it's possible requires an understanding of the descriptor protocol in Python and how it implements foo.set_a(1) as Foo.set_a(foo, 1) (via an intermediate call to Foo.set_a.__get__(foo, Foo)).
Nov 10, 2023 at 8:34 comment added User051209 I agree with you and in the future I will use this approach to programming with the Python language. The code write in the past will remain as it is, but I think the use of Python class will decrease in my next new programs.
Nov 9, 2023 at 18:45 history edited JimmyJames CC BY-SA 4.0
added 164 characters in body
Nov 9, 2023 at 18:44 comment added JimmyJames @frankfalse I consider this to be intermediate to advanced Python knowledge. The fact that you are even asking suggests you may be underestimating yourself. My opinion is that with Python, you should use module level code as long as it meets your needs and isn't becoming spaghetti code and only introduce classes when they provide a clear benefit.
Nov 9, 2023 at 18:39 history edited JimmyJames CC BY-SA 4.0
added 164 characters in body
Nov 9, 2023 at 18:22 comment added User051209 My real difficult concern on the fact that sometimes I have to avoid to create class in Python and use module because classes are not so needed as for example in Java.
Nov 9, 2023 at 18:20 comment added User051209 Thank you very much. Your answer with the anwser of Caleth have added much to my my poor knowledge of Python. I agree with you that the use of attribute reference is inside framework or other special cases.
Nov 9, 2023 at 18:10 history answered JimmyJames CC BY-SA 4.0