Extracting values from text file

Preben Randhol randhol+valid_for_reply_from_news at pvv.org
Sun Jun 18 07:34:59 EDT 2006


On Sun, 18 Jun 2006 10:54:01 +0200
Mirco Wahab <wahab at chemie.uni-halle.de> wrote:


> 
> For the other issue I stumbled upon:
> 
> - no DWIM-ism (do what I mean) on 'value' addition
> 
>     a  = '1'
>     a += '1.1111'
>     print a
> 
>  will print
>     11.1111
> 
> and not 2.1111, as in 'dynamically typed', 'operator based' languages.
> (maybe the lack of a simple string-concatenation operator is the
> reason?)

But you don't add two values. you add two strings. If you want numbers
you must convert the strings. 

> How could one approach these things without needing to
> get too explicitly about 'type conversions'
> (Python is supposed to be 'dynamically typed'?).

Yes, but how can Python know that you want to add to numbers and not
concate two strings? 



More information about the Python-list mailing list