Weak Type Ability for Python

2QdxY4RzWzUUiLuE at potatochowder.com 2QdxY4RzWzUUiLuE at potatochowder.com
Thu Apr 13 13:47:17 EDT 2023


On 2023-04-12 at 22:47:17 -0400,
Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:

> 	REXX -- where everything is considered a string until it needs to be
> something else.

I see your REXX, and raise you an awk,¹ except that awk won't add a
string to a number, or a number to string, but it will concatenate in
both cases:

    $ echo 1 a | awk '{print $1 $2}{print $1 + $2}'
    1a
    1

    $ echo 1 a | awk '{print $2 $1}{print $2 + $1}'
    a1
    1

    $ echo 1 2 | awk '{print $1 $2}{print $2 + $1}'
    12
    3

¹ GNU Awk 5.2.1, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.0, GNU MP 6.2.1)

Dan


More information about the Python-list mailing list