background preloader

Python in Action

Facebook Twitter

Episodes - [Talk Python To Me Podcast] Welcome to Pyke. Why Every Language Needs Its Underscore - Hackflow. (This is an adaptation of a talk I gave at PyCon and DevDay.

Why Every Language Needs Its Underscore - Hackflow

Slides and video are available in russian) Do you know what underscore is? In its most general it’s a JavaScript library that makes life better. For whoever writes in JavaScript. I mostly write Python and I also wanted my life better, so I went ahead and wrote a similar library for Python. The problem To answer this question we should look at problems this kind of libraries solve. A piece of entangled code This messy piece of code was taken from a real project and slightly simplified: There are several things entangled in here, but my point is that this could be written much shorter: If it seems hard at first, then it’s okay. Dirty dictionary But let’s go on and clean some dirty dictionary: Here we go through dictionary and clean its values by coercing them to int. And it’s entirely possible with funcy. Pairwise iteration This code checks if a sequence is ascending: And pairwise does exactly that.

Extracting abstractions Wrap-up P.S. Why should librarians learn python? (a better answer) Scalability at YouTube. Invent Your Own Computer Games with Python - Chapters. Chapter 1 Read online: Chapter 1 - Installing Python Videos: Chapter 2 Read online: Chapter 2 - The Interactive Shell Chapter 3 Read online: Chapter 3 - Strings Download source: hello.py Copy source to clipboard: Use the online diff tool to find typos in your code: hello.py Chapter 4 Read online: Chapter 4 - Guess the Number Download source: guess.py Use the online diff tool to find typos in your code: guess.py Chapter 5 Read online: Chapter 5 - Jokes Download source: jokes.py Use the online diff tool to find typos in your code: jokes.py Chapter 6 Read online: Chapter 6 - Dragon Realm Download source: dragon.py Use the online diff tool to find typos in your code: dragon.py Chapter 7 Read online: Chapter 7 - Using the Debugger Chapter 8 Read online: Chapter 8 - Flow Charts Chapter 9 Read online: Chapter 9 - Hangman Download source: hangman.py Use the online diff tool to find typos in your code: hangman.py Chapter 10 Read online: Chapter 10 - Tic Tac Toe Download source: tictactoe.py Chapter 11.

Invent Your Own Computer Games with Python - Chapters

PythonTurtle. 5. Embedding Python in Another Application. The previous chapters discussed how to extend Python, that is, how to extend the functionality of Python by attaching a library of C functions to it.

5. Embedding Python in Another Application

It is also possible to do it the other way around: enrich your C/C++ application by embedding Python in it. Embedding provides your application with the ability to implement some of the functionality of your application in Python rather than C or C++. This can be used for many purposes; one example would be to allow users to tailor the application to their needs by writing some scripts in Python. You can also use it yourself if some of the functionality can be written in Python more easily. Embedding Python is similar to extending it, but not quite.

So if you are embedding Python, you are providing your own main program. A simple demo of embedding Python can be found in the directory Demo/embed/ of the source distribution. See also Python/C API Reference Manual The details of Python’s C interface are given in this manual. 5.1. 5.2. 5.3.

Salt

PyMCU - The Python Controlled Microcontroller. WikidPad - wiki notebook for Windows/Linux/Mac OS. Ulipad - python editor based on wxPython.