Learning Python
Jan. 5th, 2006 09:04 pmI’ve decided to not read LJ for a week and instead use that time to learn the Python programming language. If there is something you specifically want me to see, please email it.
I may be posting little “oh my god that’s so cool” kind of ramblings. Here’s an example:
Rather than having to bother with sprintf like in C and perl, they have a freakin’ brilliant idea to overload an operators to mean “format this with printf-style formatting rules”. So if you do:
And having infinite precision integers (if the value is larger than 32-bits, it starts using a “big int” library to manage the values) as a first-class citizen is just so cool.
I may be posting little “oh my god that’s so cool” kind of ramblings. Here’s an example:
Rather than having to bother with sprintf like in C and perl, they have a freakin’ brilliant idea to overload an operators to mean “format this with printf-style formatting rules”. So if you do:
print “%4.2f” % 3.1412
it formats as if you had done this in perl:print sprintf( “%4.2f”, 3.1412)
(Obviously you could use “printf” instead, but this is just a demo).And having infinite precision integers (if the value is larger than 32-bits, it starts using a “big int” library to manage the values) as a first-class citizen is just so cool.
no subject
Date: 2006-01-06 02:24 am (UTC)How so?
Because I, and my co-workers, waste less time trying to figure out what the heck the person who wrote an automation tool was thinking, even (or especially) when the person reading the code was the original author.
(That's in addition to all the usual "automate away the annoying stuff" advantages: user creation, host database management, and many backup tasks are now handled in Python scripts.)
no subject
Date: 2006-01-06 03:32 am (UTC)no subject
Date: 2006-01-06 04:07 am (UTC)Doesn't perl also automatically switch to big ints if integer values get too large, on architectures that support big ints?
no subject
Date: 2006-01-06 11:45 am (UTC)Yeah. You'll also have "OMFG why did they do *that*!?" moments. My learning experience (http://krabbe.livejournal.com/11684.html) was certainly littered with them (http://krabbe.livejournal.com/12994.html).