====== Best Practices (Python) ====== ===== Check if dictionary contains key, if not return default value ===== # not so good if 'owner' in roledict: owner = roledict['owner'] else: owner = admin # just slightly better, still not good try: owner = roledict['owner'] except KeyError: owner = admin # better owner = roledict.get('owner', admin) ===== Invoking subprocesses ===== In order to spawn new processes like you would do in a shell, use the [[http://docs.python.org/library/subprocess.html|subprocess]] module of the Python standard library. It should be used instead of the ''os.system'' module. ===== Object Oriented Programming ===== **SOLID** design princibles: https://www.youtube.com/watch?v=pTB30aXS77U * **S**ingle responsibility * **O**pen/Closed * **L**iskov substitution * **I**nterface segregation * **D**ependency inversion {{tag>"python" "best practices"}}