4

Aside from learning the Python language itself, I have to learn on the go during daily business how to solve real-life problems with Python and share solutions with other colleagues.

Therefore I want while starting my projects from scratch, bootstrap them already with an advanced level for good readability1 and unit testing and have a more or less convenient efficient environment (besides what is the matter of taste, error-prone and well-readable code is here in focus).

Here is what I have found so far - what else would you add?

  • Install not Python itself but the Anaconda distro
  • Organize project in a comprehensive well-explained structure:
  • If you are coming from an object-oriented language, consider Python object and classes
  • Control code quality:
  • Consider to add a Dockerfile will required dependencies to demo how your tests run through in a given operating system environment

There is also a useful info on what modules' __init__.py file could contain.

Answers welcome also pointing out what are Python specific but tool-neutral aspects to consider while integrating with a DevOps toolchain i.e. source control, continuous integration and binary package management.

1 I've noticed that the tag clean code and related are leading to opinionated discussions; so I have decided to follow where possible recommendations available from Google, PEP, and pylint.

Open Food Broker
  • 1,095
  • 1
  • 8
  • 31
  • 2
    You sound like someone with coding experience already, so perhaps you don't need more general non-python coding advice, but if not, worth familiarising yourself with good practise around source control too. Will depend on what system you're using but https://www.git-tower.com/blog/version-control-best-practices/ has some good general tips around good practise. – Andrew McDowell Sep 20 '18 at 08:55
  • we use git; is there something Python-specific to consider? or better, what is Pythonic-specific to consider regarding source control? - thanks for linking to the git-tower! – Open Food Broker Sep 20 '18 at 08:56
  • 2
    Those links are good enough for you to get started. For source control, I suggest https://www.fullstackpython.com/source-control.html – shiv_90 Sep 20 '18 at 09:02
  • I can't think of anything python specific I would consider vital for a broad overview. If you're using Jupyter notebooks, it's worth being aware that any uncleared output will be present in the file when you commit. This can be helpful in some cases, but can cause problems too if people don't realise they're submitting sensitive data into a repository others can access. – Andrew McDowell Sep 20 '18 at 09:04
  • 2
    I recommend checking out "Fluent Python". It is not in the other Stackoverflow post you linked to but it will help you get up to speed on the better Python practices. Also, I personally like to use [type annotation](https://docs.python.org/3/library/typing.html). This can help autocompletion and static analysis tools. Tools like [cookiecutter](https://github.com/audreyr/cookiecutter) also helps in creating a basic project skeleton. You can customize it to your liking. – lightalchemist Sep 20 '18 at 09:08
  • 2
    Regarding your footnote on clean code. Since you are part of a team, make sure to agree on common conventions and rules regarding coding style and structure within your team. In my experience it is much more important to follow a common standard within the team than to enforce people to code by the book (or Google, PEP and pylint). That being said, there's nothing wrong with introducing standards that follow the recommendations of the sources you mention, _if the team agrees_. :) – shmee Sep 20 '18 at 09:13

0 Answers0