Example: bankruptcy

A Python Book: Beginning Python, Advanced Python, and ...

A Python BookA Python book : Beginning Python , AdvancedPython, and Python ExercisesAuthor:Dave 1A Python 15, 2013 CopyrightCopyright (c) 2009 Dave Kuhlman. All Rights Reserved. This document is subject to the provisions of the Open Source MIT License document is a self learning document for a course in Python programming . This course contains (1) a part for beginners, (2) a discussion of several Advanced topics that are of interest to Python programmers, and (3) a Python workbook with lots of 2A Python BookContents1 Part 1 Beginning Introductions A general description of Interactive Lexical Names and Blocks and Doc Program Also Code Statements and inspection Built in data Numeric Tuples and The new Unicode Other built in The None Boolean Sets and Functions and Classes A Assignment import print if: elif: else: for: while: 3A Python continue and break try: except: raise with: Writing a context Using the with.

This document is a self­learning document for a course in Python programming. This course contains (1) a part for beginners, (2) a discussion of several advanced topics that are of interest to Python programmers, and (3) a Python workbook with

Tags:

  Programming, Python, Beginning, Book, Advanced, Python programming, Python book, Beginning python, Advanced python

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of A Python Book: Beginning Python, Advanced Python, and ...

1 A Python BookA Python book : Beginning Python , AdvancedPython, and Python ExercisesAuthor:Dave 1A Python 15, 2013 CopyrightCopyright (c) 2009 Dave Kuhlman. All Rights Reserved. This document is subject to the provisions of the Open Source MIT License document is a self learning document for a course in Python programming . This course contains (1) a part for beginners, (2) a discussion of several Advanced topics that are of interest to Python programmers, and (3) a Python workbook with lots of 2A Python BookContents1 Part 1 Beginning Introductions A general description of Interactive Lexical Names and Blocks and Doc Program Also Code Statements and inspection Built in data Numeric Tuples and The new Unicode Other built in The None Boolean Sets and Functions and Classes A Assignment import print if: elif: else: for: while: 3A Python continue and break try: except: raise with: Writing a context Using the with.

2 Case Functions, Modules, Packages, and The def Returning Local Other things to know about Global variables and the global Doc strings for Decorators for Iterators and Doc strings for A simple Defining The Member Calling Adding Class Class methods and static New style Doc strings for Private Special Debugging 4A Python File input and Unit A simple Unit test Additional unittest Guidance on Unit The Python database Installing Python More Python Features and Part 2 Advanced Introduction Python 201 (Slightly) Advanced Python Regular Defining regular Compiling regular Using regular Using match objects to extract a Extracting multiple Replacing multiple Iterator Example A generator Example A class containing a generator Example An iterator Example An iterator class that uses Example A list Example A generator Unit Defining unit Create a test Extending and embedding Introduction and Extension SWIG vs.

3 Extension Extension Special purpose 5A Python Writing a recursive descent parser by Creating a lexer/tokenizer with A survey of existing Creating a parser with Creating a parser with Parsing comma delimited Parsing Parsing names, phone numbers, A more complex GUI A simple message dialog A simple text input dialog A file selection dialog A simple EasyGUI An EasyGUI file open dialog Guidance on Packages and Implementing Using Distributing and Installing End Acknowledgements and See Part 3 Python Lexical Variables and Line Indentation and program Execution Built in Data Literal representations of Operators for Methods on Literal representation of 6A Python Operators on Methods on List Operators on Methods on Raw Unicode Literal representation of Operators on Methods on A few miscellaneous data The booleans True and Assignment print if: statement for: statement while: statement break and continue Exceptions and the try:except.

4 And raise Optional arguments and default Passing functions as Extra args and keyword Order of arguments (positional, extra, and keyword args).. Functions and duck typing and Recursive Generators and Object oriented programming and The Inheritance Implementing a Classes and Recursive calls to Class variables, class methods, and static Decorators for classmethod and 7A Python Additional and Advanced Decorators and how to implement Decorators with Stacked More help with A few preliminaries on More help with Applications and XML SAX, minidom, ElementTree, Relational database CSV comma separated value YAML and Part 4 Generating Python Bindings for Generating the Using the generated code to parse and export an XML Some command line options you might want to The graphical front Adding application specific Implementing custom Using the generated "API" from your A combined Special situations and Generic.

5 Type independent Step 1 generate the Step 2 add application specific Step 3 write a test/driver Step 4 run the test Some Children defined with maxOccurs greater than Children defined with simple numeric The type of an element's character Constructors and their default 8A Python BookPrefaceThis book is a collection of materials that I've used when conducting Python training and also materials from my Web site that are intended for self may prefer a machine readable copy of this book . You can find it in various formats here: HTML PDF ODF/OpenOffice , let me thank the students in my Python classes. Their questions and suggestions were a great help in the preparation of these 9A Python Book1 Part 1 Beginning Introductions EtcIntroductionsPractical matters: restrooms, breakroom, lunch and break times, the Python interactive interpreter. Also, IPython and scriptsEditors Choose an editor which you can configure so that it indents with 4 spaces, not tab characters.

6 For a list of editors for Python , see: A few possible editors: SciTE MS Windows only (1) TextPad ; (2) UltraEdit Jed See Emacs See and jEdit Requires a bit of customization for Python See Vim Geany And many interpreters: Python ipython IdleIDEs Also see : PyWin MS Windows only. Available at: WingIDE See Eclipse There is a plug in that supports Python . Kdevelop Linux/KDE See Eric Linux KDE? See http://eric Emacs and SciTE will evaluate a Python buffer within the 10A Python ResourcesWhere else to get help: Python home page Python standard documentation will also find links to tutorials there. FAQs The Python Wiki The Python Package Index Lots of Python packages Special interest groups (SIGs) Other Python related mailing lists and lists for specific applications (for example, Zope, Twisted, etc). Try: Lots of projects. Search for " Python ".

7 USENET Can also be accessed through Gmane: The Python tutor email list documentation: On MS Windows, the Python documentation is installed with the standard installation. Install the standard Python documentation on your machine from pydoc. Example, on the command line, type: pydoc re. Import a module, then view its .__doc__ attribute. At the interactive prompt, use help(obj). You might need to import it first. Example:>>> import urllib>>> help(urllib) In IPython, the question mark operator gives help. Example:In [13]: open?Type: builtin_function_or_methodBase Class: <type 'builtin_function_or_method'>String Form: <built in function open>Namespace: Python builtinDocstring: open(name[, mode[, buffering]]) > file object Open a file using the file() type, returns a file Docstring: (..) initializes x; see for signaturePage 11A Python BookCallable: YesCall def: Calling definition not docstring: (.)

8 <==> x(..) A general description of PythonPython is a high level general purpose programming language: Because code is automatically compiled to byte code and executed, Python is suitable for use as a scripting language, Web application implementation language, etc. Because Python can be extended in C and C++, Python can provide the speed needed for even compute intensive tasks. Because of its strong structuring constructs (nested code blocks, functions, classes, modules, and packages) and its consistent use of objects and object oriented programming , Python enables us to write clear, logical applications for small and large features of Python : Built in high level data types: strings, lists, dictionaries, etc. The usual control structures: if, if else, if elif else, while, plus a powerful collection iterator (for). Multiple levels of organizational structure: functions, classes, modules, and packages. These assist in organizing code.

9 An excellent and large example is the Python standard library. Compile on the fly to byte code Source code is compiled to byte code without aseparate compile step. Source code modules can also be "pre compiled" to byte code files. Object oriented Python provides a consistent way to use objects: everything is an object. And, in Python it is easy to implement new object types (called classes in object oriented programming ). Extensions in C and C++ Extension modules and extension types can be writtenby hand. There are also tools that help with this, for example, SWIG, sip, Pyrex. Jython is a version of Python that "plays well with" Java. See: The Jython Project things you will need to know: Python uses indentation to show block structure. Indent one level to show the Beginning of a block. Out dent one level to show the end of a block. As an example, the following C style code:if (x){Page 12A Python book if (y) { f1() } f2()}in Python would be:if x: if y: f1() f2()And, the convention is to use four spaces (and no hard tabs) for each level of indentation.

10 Actually, it's more than a convention; it's practically a requirement. Following that "convention" will make it so much easier to merge your Python code with code from other overview of Python : A scripting language Python is suitable (1) for embedding, (2) for writing smallunstructured scripts, (3) for "quick and dirty" programs. Not a scripting language (1) Python scales. (2) Python encourages us to write code that is clear and well structured. Interpreted, but also compiled to byte code. Modules are automatically compiled (to .pyc) when imported, but may also be explicitly compiled. Provides an interactive command line and interpreter shell. In fact, there are several. Dynamic For example: Types are bound to values, not to variables. Function and method lookup is done at runtime. Values are inspect able. There is an interactive interpreter, more than one, in fact. You can list the methods supported by any given object.


Related search queries