I hope this question is considered appropriate for stackoverflow. If not, I’ll remove the question right away.
I’ve just wrote my very first python program. The idea is that you can issue a command, and it’s gets sent to several servers in parallel.
This is just for personal educational purposes. The program works! I really want to get better at python and therefore I’d like to ask the following questions:
- My style looks messy compared to PHP (what I’m used to). Do you have any suggestions around style improvements.
- Am I using the correct libraries? Am I using them correctly?
- Am I using the correct datatypes? Am I using them correctly?
I have a good programming background, but it took me quite a while to develope a decent style for PHP (PEAR-coding standards, knowing what tools to use and when).
The source (one file, 92 lines of code)
Usually is preferred that what follows after the end of sentence
:is in a separate line (also don’t add a space before it)instead of
You don’t need to check the len of a list if you are going to iterate over it
is redundant, a more ‘readable’ is (python is smart enough to not iterate over an empty list):
Also a more ‘pythonistic’ is to use list’s comprehensions (but certainly is a debatable opinion)
can be shortened to