Re: zero argument member functions versus properties

2013-11-04 Thread Peter Cacioppi
Ian said : "Since the compiler generally can't predict what the types of objects will be, the bytecode that it generates can't depend on those types." very nice, the py is strong with you. Thanks, Pete -- https://mail.python.org/mailman/listinfo/python-list

Re: zero argument member functions versus properties

2013-11-03 Thread Ian Kelly
On Sun, Nov 3, 2013 at 2:23 PM, Peter Cacioppi wrote: > Ian said : > > " Whereas in Python, an attribute access is just > compiled as an attribute access no matter what the underlying > implementation of that access may end up being at run-time. " > > Really? Very nice. Have a good link handy for

Re: zero argument member functions versus properties

2013-11-03 Thread Peter Cacioppi
Ian said : " Whereas in Python, an attribute access is just compiled as an attribute access no matter what the underlying implementation of that access may end up being at run-time. " Really? Very nice. Have a good link handy for that? I'm compiling a codex of "why py is better?". -- https://ma

Re: zero argument member functions versus properties

2013-11-03 Thread Ian Kelly
On Sun, Nov 3, 2013 at 1:06 AM, Peter Cacioppi wrote: > Actually C# is mature enough for this idiom. C# and Python both support > getter/setter methods that present as direct attribute access to client code, > and thus allow you to refactor the class without breaking backwards > compatibility.

Re: zero argument member functions versus properties

2013-11-03 Thread Peter Cacioppi
Steve said: "(This isn't Java or Ruby, where data-hiding is compulsory :-) " At the risk of striking a sessile equine, when the attribute shouldn't be modified directly by client code, then you hide it and use a property to allow client code access. It is the idiom of allowing client code to e

Re: zero argument member functions versus properties

2013-11-03 Thread Peter Cacioppi
Steve said: "(This isn't Java or Ruby, where data-hiding is compulsory :-) " (You could add C++ and C# to this list). This is golden nugget for me. The old synapses are pretty well grooved to think of data hiding as good hygiene. Even though I've read a fair bit of Python text I still need to

Re: zero argument member functions versus properties

2013-11-02 Thread Steven D'Aprano
On Sat, 02 Nov 2013 23:09:09 -0700, Peter Cacioppi wrote: > Python makes it very easy to turn a zero argument member function into a > property (hooray!) by simply adding the @property decorator. > > (Meme for well thought py feature - "Guido was here") It is well-thought out, but it's also quit

Re: zero argument member functions versus properties

2013-11-02 Thread Peter Cacioppi
I just said "1-> the zero argument function is sort of factory-like. It potentially has non-trivial run time, or it substitutes calling a class constructor when building certain objects. 2-> it simply retrieves a stored value (perhaps lazily evaluating it first) so 1 should clearly be a zero

zero argument member functions versus properties

2013-11-02 Thread Peter Cacioppi
Python makes it very easy to turn a zero argument member function into a property (hooray!) by simply adding the @property decorator. (Meme for well thought py feature - "Guido was here") But the ease with which you can do this makes the "zero argument member function or property" discussion t