background preloader

Getting started with Python

Facebook Twitter

Auto formatters for Python □‍□□ – 3YOURMIND-Tech. As you can see in the recent Stack Overflow developer survey, Python is one of the most popular programming languages available.

Auto formatters for Python □‍□□ – 3YOURMIND-Tech

With the recent rise of good auto formatters for Code like gofmt for Golang or prettier for JavaScript, there is a good question to ask: Which auto formatter to use with Python Code? An auto formatter is a tool which will format your code in a way it complies to the tool or any other standard it set. First of all, we need to make sure that we know the reason automatic formatting tools exist. Prettier is an auto formatter for JavaScript code. It is used by many big companies like Facebook, Paypal, Algolia, Yelp, Discord and many others which you can find here. Those reasons are really good arguments for using auto formatters. For Python there are three solutions out there: autopep8 — GitHub autopep8 is an auto formatter built and open-sourced and made by several developers.

Yapf — GitHub black — GitHub. Keep This Python Cheat Sheet On Hand When Learning To Code. Python is one of the best programming languages to learn.

Keep This Python Cheat Sheet On Hand When Learning To Code

As you get started, this one-page reference sheet of variables, methods and formatting options could come in handy. Provided by Dave Child, the cheat sheet includes both built-in system and operating system variables, as well as standard methods for working with lists, files and strings. You can download it for free in PDF or PNG version or view it online at the link below. Python Distribution Free. Using .pth files for Python development. Python's site module is responsible for setting up the interpreter's environment upon startup.

Using .pth files for Python development

One of the things it does during startup is scan your site directories (typically just site-packages , but framework builds for Mac OS X have an additional undocumented default location) for .pth files. .pth files are used to add additional locations sys.path , and they are typically created by distutils setup scripts that use the (still undocumented) extra_path argument. .pth files are a great alternative to using the PYTHONPATH environment variable: You don't have to screw with your environment (which can be difficult on Mac OS X and Windows). The effect is localized to a particular Python installation. You can toggle their usage simply by moving them around on the filesystem. py2app.pth # /Users/bob/src/py2app is a svn checkout of: # # /Users/bob/src/py2app/src docutils.pth PyObjC.pth.

VirtualEnvironment. Try Python: Interactive Python Tutorial in the Browser. PythonMonk - Interactive Python tutorials. Python progression path - From apprentice to guru. [Resource] Learning Python. A lot of people who join this course might not be that familiar with Python, or not be familiar with Python at all.

[Resource] Learning Python

So for those students this is a list of places where they can learn a bit about Python. Udacity CS101 - I took it in February & trust me it's worth it, even if you know Python.Learn Python The Hard Way - The hard way is the right way, and in the long run the easy way. Free to browse on the internet.Invent Your Own Computer Games with Python - A good book, with the blog a good resource too.

Free to download.Dive into Python - Free to downloadHow to think like a computer scientist - This book is about more than just Python, but still a good resource to have.MIT 6.00 Introduction to Computer Programming - This is a youtube playlist for lecture videos from Fall 2008.

Python practice, practice, practice

Programming. Python Cheat Sheet. String String Methods Array Indexes and Slices a=[0,1,2,3,4,5] 6 len(a) 0 a[0] 5 a[5] 5 a[-1] 4 a[-2] [1,2,3,4,5] a[1:] [0,1,2,3,4] a[:5] [0,1,2,3] a[:-2] [1,2] a[1:3] [1,2,3,4] a[1:-1] Shallow copy of a b=a[:] Math Constants math.pi The mathematical constant π = 3.141592..., to available precision. math.e The mathematical constant e = 2.718281..., to available precision.

Python Cheat Sheet

Random Functions Sys. Python Epiphanies. The Python Grimoire - a hypertext tome pertaining to that most elegant of languages.

Picking a Python version

How to Configure Python. After you’ve installed Python, you may want to configure some system settings that impact the way Python runs your code.

How to Configure Python

(If you are just getting started with the language, you can probably skip this section completely; there is usually no need to specify any system settings for basic programs.) Generally speaking, parts of the Python interpreter’s behavior can be configured with environment variable settings and command-line options. In this section, we’ll take a brief look at both, but be sure to see other documentation sources for more details on the topics we introduce here. A Note on Python Paths. This time I decided to share some knowledge about Python paths which seemed a little bit confusing to me in the beginning of diving into Python.

A Note on Python Paths

I am working with Django in different platforms like Mac OS X, Windows, and Linux, therefore the common patterns how to activate new python modules in all of those environments should be familiar to me. Python modules are either *.py files or directories containing __init__.py .

Lang intro

Tutorials. 384 manually selected sites about Python Programming Language.