background preloader

Python

Facebook Twitter

Nullege: A Search Engine for Python source code. Learning Python ( For the Complete Noob ) Tutorial. Python en:Table of Contents. You have seen how you can reuse code in your program by defining functions once. What if you wanted to reuse a number of functions in other programs that you write? As you might have guessed, the answer is modules. There are various methods of writing modules, but the simplest way is to create a file with a .py extension that contains functions and variables. Another method is to write the modules in the native language in which the Python interpreter itself was written.

For example, you can write modules in the C programming language and when compiled, they can be used from your Python code when using the standard Python interpreter. A module can be imported by another program to make use of its functionality. This is how we can use the Python standard library as well. Example (save as module_using_sys.py): import sys print('The command line arguments are:')for i in sys.argv: print i print '\n\nThe PYTHONPATH is', sys.path, '\n' How It Works 11.1. 11.2. 11.3. 11.4. 11.5. 11.6. 11.7. Non-Programmer's Tutorial for Python 2.6. Non-Programmer's Tutorial for Python 2.6 From Wikibooks, open books for an open world Jump to: navigation, search For Python 3, see Non-Programmer's Tutorial for Python 3.

Contents[edit] Authors Contributors to this book Front matter Initial remarks Intro Installing and using Python – where to get help Hello, World The famous first program – screen output – numbers and calculations Who Goes There? Interactive input – strings Count to 10 while loops Decisions if statements Debugging Finding out what goes wrong Defining Functions Structuring programs with the use of functions Advanced Functions Example (Almost) mind-blowing example of how programmers can think Lists Variables containing more than one value For Loops A second kind of loop Boolean Expressions Computer logic – true and false – and and or – not Dictionaries Variables containing key/value pairs Using Modules Extensions to the standard set of functionality More on Lists Using elements or parts of lists Revenge of the Strings Advanced text manipulation File IO Views.

Learn Python The Hard Way, 2nd Edition — Learn Python The Hard Way, 2nd Edition.