dictionary/hash and '1' versus 1

Paddy paddy3118 at googlemail.com
Mon Jan 7 18:51:58 CET 2008


On Jan 7, 5:09 pm, "Reedick, Andrew" <jr9... at ATT.COM> wrote:

> Bingo.  Perl has specific operators to establish intent:
>         > Perl -e "'1' + 1"
>         > 2
>         > Perl -e "'1' . 1"
>         > 11
> '+' is the operator for addition
> '.' is the operator for string concatenation
>
> int and string comparisons also have specific operators:
>         $a == $b  # compare as integers:  ==,  >,  <, <=, >=
>         $a eq $b  # compare as strings:   eq, gt, lt, le, ge
>
> Which now morphs the conversation into the issue of how too much
> operator overloading creates confusion and/or ambiguity.
>
Or how using different operators for similar operations on different
types causes confusion.
i.e. == versus eq; > versus gt
If Perl had, for example, a complex number 'base' type would that need
yet another set of operators?

Well enough Perl vs Python. The thing is, that when writing in another
programming language you have to use its idioms or you end up fighting
the language in attempt to make it work like another language you are
more familiar with. In Python strings won't ever automatically change
to numbers.

- Paddy.



More information about the Python-list mailing list