Skip to content

Instantly share code, notes, and snippets.

@mhermans
Last active March 20, 2017 04:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mhermans/6a7e6da16c1b15c8bd95 to your computer and use it in GitHub Desktop.
Save mhermans/6a7e6da16c1b15c8bd95 to your computer and use it in GitHub Desktop.
A very opinionated Python getting-started guide

A very opinionated Python getting-started guide

Setup your Python packages environment

  • Install globally pip, package manager for Python packages.
  • Install globally, using pip , virtualenv and virtualenvwrapper, tools that create & help manage seperate virtual environments so you can try out Python packages without screwing existing configurations, have per-project sets of Python packages, etc.
  • After that, create a virtual environment per project, and install required Python packages using pip per-virtual environment.

Setup your development environment

  • For learning a new language, starting out simple, e.g. running scripts without an IDE is probably better.
  • Definitely install IPython. So instead of running small scripts on the command line, you can start out using IPython to learn by adapting/running small snippets (and then move to more extensive use of the notebooks if wanted, see below).
  • After scripts & snippets, pick an IDE for more extensive development.
    • I gradually added extra plugins that made my editor-of-choice (vim) into a light-weight Python IDE (is console-based, adds the vim-learning curve to it).
    • Other option is the Pycharm IDE, heard good things about it, and I'm considering switching to it myself, as refactoring etc. larger projects is proving to be difficult (is GUI-based).

Try out the things that are included

Python has a "batteries included" philosophy, i.e. you should be able to cover most cases with the libraries included and install advanced/specialist libraries if needed.

  • Scroll through the Python standard library, and try out some example snippets that you will likely use.
  • For specific library modules that you are sure you will need in to future, look at the Python Module of the Week. This site dives into each module in the standard library.
  • For some things, the standard library will likely be all you need, e.g. for file operations and basic OS-interaction when running scripts. For other things it depents on your use. For instance, likely the built-in datetime functionality is sufficient, and it is not worth it to add extra dependencies on other libraries. In other cases, you will fast feel the limites of the standard library, for instance in the case of HTTP-handeling, where external libraries are much better.

In any case, you can trust the standard library to be high-quality, standards-compliant and well-supported/built-in, so knowing what is in there is handy.

Get to know the supporting programming standards

Look at well-designed libraries or interesting projects

  • A big list of popular libraries
  • Libraries with well-designed API's are IMHO for example requests
  • For datascience: pandas and scikit-learn
  • IPython notebooks are used to share projects & explorations in datavisualisation, cf. gallery of examples
  • The Python bindings to the OpenCV computer vision library are fun to play with.
  • Somewhat generally useful libraries I use frequently are requests, the lxml library for XML/HTML-processing, tablib for reading/writing tabular data, flask for getting a fast website/REST-interface running.
  • I also really like the Redis-database and its Python-bindings for persistance when logging/scraping/datamanipulating. Alternatives are the build-in shelve library and an SQL ORM such as SQLAlchemy.
  • Perhaps writing a plugin for an active, modular audio-related project is a good excercise? For instance I use beets as music-organiser, and modipy is a hackable music server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment