A few observations on Python while I made my first steps into it
Posted by jpluimers on 2018/11/28
A while back, I made my first steps into Python.
Coming from a mixed language back-ground (including Pascal, Delphi, C#, SQL, batch files, PowerShell, bash, C, Java) it was an interesting experience.
A few observations:
- It’s a [WayBack] line oriented language.
- I secretly think that’s the reason there are no multi-line comments in Python, but Guido never gave a reason, just that you can use multi-line “”” or ”’ strings for them: [WayBack] Why doesn’t Python have multiline comments? – Stack Overflow
- Multi-line strings can end up in generated documentation or mess with your indenting. So putting a comment # octothorp in front of each line is recommended. [WayBack] Comment out a Python code block – Stack Overflow
- Most code editors have a shortcut for multi-line comments. Atom.io has Ctrl-/ for it. [WayBack] Commenting out code blocks in Atom – Stack Overflow
- The
pass
statement is your [WayBack] no-op friend (via [WayBack] What’s a standard way to do a no-op in python? – Stack Overflow). - Though Python supports the subclass-the-Thread class for multi-threading [WayBack] multithreading – Stopping a python thread running an Infinite Loop – Stack Overflow
- The idiom however seems to wrap the thread into a function instead of [WayBack] multithreading – Overriding python threading.Thread.run() – Stack Overflow
- Though the built-in data type
bool
is lower-case, theFalse
andTrue
built-in constants start with a capital [WayBack] 4. Built-in Constants — Python 2.7.13 documentation - Lots of idioms are centered around key/value or name/value pairs.
- It has two ways of formatting/aligning strings, which is OK as I hate re-inventing wheels [WayBack] Python spacing and aligning strings – Stack Overflow and [WayBack] 5. Built-in Types — String Formatting Operations
- There is a huge number of [WayBack] Python standard libraries.
More observations likely to follow.
–jeroen
Leave a Reply