Confessions of a Python fanboy
masklinn at masklinn.net
Thu Jul 30 19:56:07 CEST 2009
On 30 Jul 2009, at 19:37 , Jean-Michel Pichavant wrote:
> r wrote:
>> On Jul 30, 11:31 am, Falcolas <garri... at gmail.com> wrote:
>>> On Jul 29, 9:06 pm, r <rt8... at gmail.com> wrote:
>>>> 1.) No need to use "()" to call a function with no arguments.
>>>> Python --> "obj.m2().m3()" --ugly
>>>> Ruby --> "obj.m1.m2.m3" -- sweeet!
>>>> Man, i must admit i really like this, and your code will look so
>>> I personally would not prefer this, and would likely continue to use
>>> (), precisely for code clarity - let me explain:
>>> Which of the calls above referenced instance variables, and which
>>> called functions which changed the internal state of foo? I would
>>> trouble saying, just based on the calls above. I would have to go
>>> to the definition or documentation of foo to identify which is doing
>>> what. On the other hand, the following gives a better clue as to
>>> is happening (granted not perfect, but better):
>> I held your exact same view before i learned the Ruby language. And
>> your veiw makes some good points, however, naming conventions with
>> eliminate this problem all together. All "method names" should use
>> underscore to separate words, "variable names" should use camelCase,
>> "constants" in all caps, and "class defs" in titlecase.
>> def go_and_do_this_for_me_now(self, *args)
>> THISISACONSTANT -or- THIS_IS_A_CONSTANT
>> in your example i would have used the following
>> good naming conventions will make your life (and everybody else's)
>> much easier when debugging code.
> How do I know if foo.value is an attribute or if it is a method that
> returns the foo value ?
It cannot be an attribute. Ruby doesn't give access to attributes,
they're always solely private (as in Smalltalk). Also you shouldn't
reply to r, he has no idea about what he's talking about.
More information about the Python-list