Re: [Tutor] @property vs @classmethod

2017-07-09 Thread Steven D'Aprano
On Sat, Jul 08, 2017 at 07:56:10PM -0600, Mats Wichmann wrote: > From OO people, though, we get the sputtering But... But... what about > encapsulation, data hiding, etc? Regular attributes are still encapsulated. There's no difference in encapsulation between: obj.x # a standard attribute obj

Re: [Tutor] @property vs @classmethod

2017-07-09 Thread Alan Gauld via Tutor
On 09/07/17 02:56, Mats Wichmann wrote: > From OO people, though, we get the sputtering But... But... what about > encapsulation, data hiding, etc? Encapsulation isn't really an issue here since Pythons classes fully encapsulate their data and methods. They just make them both public. Data Hidin

Re: [Tutor] @property vs @classmethod

2017-07-08 Thread Cameron Simpson
On 08Jul2017 16:03, Evuraan wrote: I was hoping to learn when to use classmethod and when to use property. They both seem similar (to me at least..), what's the pythonic way to choose between them? The core distinction is the context that the function needs. Does it depend on the particular i

Re: [Tutor] @property vs @classmethod

2017-07-08 Thread Mats Wichmann
On 07/08/2017 06:56 PM, Steven D'Aprano wrote: > The pythonic way is not to use them at all. > > For experts only: you'll know when you need them. > > They really aren't even a little bit similar, if you thought they did > that just means that you haven't understood what they do. > > property

Re: [Tutor] @property vs @classmethod

2017-07-08 Thread Steven D'Aprano
On Sat, Jul 08, 2017 at 04:03:24PM -0700, Evuraan wrote: > Greetings! > > I was hoping to learn when to use classmethod and when to use property. > They both seem similar (to me at least..), what's the pythonic way to > choose between them? The pythonic way is not to use them at all. For experts

Re: [Tutor] @property vs @classmethod

2017-07-08 Thread Alan Gauld via Tutor
On 09/07/17 00:03, Evuraan wrote: > I was hoping to learn when to use classmethod and when to use property. > They both seem similar (to me at least..), what's the pythonic way to > choose between them? In fact they do completely different things. A property is a field of an object that you acce

[Tutor] @property vs @classmethod

2017-07-08 Thread Evuraan
Greetings! I was hoping to learn when to use classmethod and when to use property. They both seem similar (to me at least..), what's the pythonic way to choose between them? $ cat ./try.py #!/usr/bin/python3 class _someclass: _tag = "sometag" def __init__(self,_text): self._text