On Mon, Nov 29, 2010 at 11:21 PM, Michal Suchanek <hramrach / centrum.cz> wrote:
> On 29 November 2010 19:40, deepak <kannan.deepak / gmail.com> wrote:
>> hi,
>> saw this on twitter today:
>> http://guide.python-distribute.org/introduction.html#current-state-of-packaging
>> where he was making a point that "it sure is complicated for a
>> language having one way of doing things"
>>
>> It is good to have multiple options, find the best solution to a
>> problem by applying common sense and good taste, take feedback/
>> benchmark and iterate.
>>
>> Not really sure how the python zen works. Maybe having no choice in
>> indentation, multi-line lambdas etc are obvious. i dunno. If it comes
>> with experience and then it is no better than having options and
>> discovering the best option through experience, irc, mail-group,
>> benchmarks, awesome community, pretty ok docs and your own common
>> sense and good taste.
>
> The point is that there is no one right way, the right way depends on context.
>
> The python zen does not work for me at least. Take a small example:
>
> Python is supposedly an object oriented language but you don't have
>
> "string".len
>
> you only have
>
> len("string")

Ouch.

> supposedly for the case when an object does not implement len by
> itself but the length can still be determined (possibly to be 1 or or
> 0 on scalars).
>
> Sure, in Python you can't just monkey-patch a len to something that
> could have it determined but does not implement it so to have only one
> true way you need a procedural len() which goes against OO.

That sounds strange.

> In Ruby you have "string".length and you can always write procedural
> len() if it makes your code look nicer and you can also add length to
> any object you want (well, except for integers but you could use some
> voodoo if you really insisted).

It's not too difficult.  Just for the fun of it:

irb(main):001:0> class Numeric
irb(main):002:1> def length;size;end
irb(main):003:1> end
=> nil
irb(main):004:0> 123.length
=> 4
irb(main):005:0> (1<<100).length
=> 16

length is in bytes. :-)

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/