Python

From Robowaifu Institute of Technology
Jump to navigation Jump to search
This page requires expansion!
This page needs to be beginner friendly, giving an idea what Python is capable of and how to start using it.

Python is an interpreted, high-level, general-purpose programming language. Python's object-oriented design emphasizes code readability and aims to help programmers write clear, logical code for small and large-scale projects.

Get Started

Generally the only really necessary component in your setup is a Python installation on your computer. Python has a small IDE integrated which is really barebones and not recommended to use. It's not wrong or something, it just lacks a lot of features you would expect from a proper modern IDE.

There is Python 2 and Python 3, use Python 3. The support for Python 2 was dropped some years ago. So if you come across some package/tutorial using Python 2 a general advice is to look somewhere else.

Recommendations for IDEs:

  • VisualStudioCode: search for python setups, you will probably want to install some plugins. do not confuse with VisualStudio(violet), VisualStudioCode is blue
  • PyCharm: this is a really good IDE for Python development. you have to search for the community edition on the website, it is a little bit hidden. this is a very convenient way to program in python, especially the module management/version stuff is really a breeze in there

Modules and Versions

You will notice really fast that there are a lot of python versions available. This leads sometimes to compatibility issues. As most modules are freely available and opensource the updates to the newest python version isn't always guaranteed. If you use pip for installing, this can cause some headache.

This is where PyCharm is really really convenient. It creates environments with specific python versions you want to use for your project. No more installing and reinstalling different Python versions and mapping them in your system variables.

Considerations

Python's ease of use comes at a cost of generally running 75 times slower than C and 50 times slower than C++. Compiling Python code with Cython can generally achieve up to a fifth of the speed of C++, but it cannot be optimized the same way as C++ unless the generated C code is modified.

This problem can be mitigated by refactoring computation heavy code in C/C++ and exposing it to Python. This ways you can use the best of both, ease of use (scripting) and speed (compiled languages). So if you want to start programming just go for it in python. You always will be able to get into the nitty gritties of C/C++ later.

External links