Python

(Rick Simeone) #1

  • Quotation in Python

  • Comments in Python

  • Using Blank Lines

  • Waiting for the User

  • Multiple Statements on a Single Line

  • Multiple Statement Groups as Suites

  • Command Line Arguments

  • Accessing Command-Line Arguments

  • Parsing Command-Line Arguments

  • getopt.getopt method

  • Exception getopt.GetoptError



    1. PYTHON ─ VARIABLE TYPES



    • Assigning Values to Variables

    • Multiple Assignment

    • Standard Data Types

    • Python Numbers

    • Python Strings

    • Python Lists

    • Python Tuples

    • Python Dictionary

    • Data Type Conversion





    1. PYTHON ─ BASIC OPERATORS



    • Types of Operators

    • Python Arithmetic Operators

    • Python Comparison Operators

    • Python Assignment Operators

    • Python Bitwise Operators

    • Python Logical Operators

    • Python Membership Operators

    • Python Identity Operators...........................................................................................................................

    • Python Operators Precedence





    1. PYTHON ─ DECISION MAKING.................................................................................................



    • If Statement

    • If...else Statement

    • The elif Statement

    • Single Statement Suites





    1. PYTHON ─ LOOPS



    • While Loop

    • The Infinite Loop

    • Using else Statement with Loops

    • Single Statement Suites

    • For Loop

    • Iterating by Sequence Index

    • Using else Statement with Loops

    • Nested Loops

    • Loop Control Statements.............................................................................................................................

    • Break Statement

    • Continue Statement

    • Pass Statement





    1. PYTHON ─ NUMBERS



    • Number Type Conversion

    • Random Number Functions

    • Trigonometric Functions

    • Mathematical Constants





    1. PYTHON ─ STRINGS



    • Accessing Values in Strings

    • Updating Strings

    • Escape Characters

    • String Special Operators

    • String Formatting Operator

    • Triple Quotes

    • Unicode String

    • Built-in String Methods

    • capitalize() Method

    • center(width, fillchar) Method

    • count(str, beg= 0,end=len(string)) Method

    • decode(encoding='UTF-8',errors='strict') Method

    • encode(encoding='UTF-8',errors='strict') Method

    • endswith(suffix, beg=0, end=len(string)) Method

    • expandtabs(tabsize=8)

    • find(str, beg=0 end=len(string))

    • index(str, beg=0, end=len(string))

    • isalnum() Method

    • isalpha()



  • isdigit()

  • islower()

  • isnumeric()

  • isspace() Method.........................................................................................................................................

  • istitle().........................................................................................................................................................

  • isupper()

  • join(seq)

  • len(string)....................................................................................................................................................

  • ljust(width[, fillchar])

  • lower()

  • lstrip()

  • maketrans()

  • max(str)

  • min(str)

  • replace(old, new [, max])

  • rfind(str, beg=0,end=len(string))

  • rindex(str, beg=0, end=len(string))

  • rjust(width,[, fillchar])

  • rstrip()

  • split(str="", num=string.count(str))

  • splitlines(num=string.count('\n'))..............................................................................................................

  • startswith(str, beg=0,end=len(string))

  • strip([chars])

  • swapcase()

  • title()

  • translate(table, deletechars="")

    • upper()

    • zfill (width)

    • isdecimal()





    1. PYTHON ─ LISTS



    • Python Lists

    • Accessing Values in Lists

    • Updating Lists

    • Deleting List Elements

    • Basic List Operations

    • Indexing, Slicing, and Matrixes

    • Built-in List Functions and Methods

    • Cmp(list1, list2)

    • len(List)

    • max(list)

    • min(list)

    • List.append(obj)

    • list.count(obj)

    • list.extend(seq)

    • list.index(obj)

    • list.insert(index,obj)

    • list.pop(obj=list[-1])

    • List.remove(obj)

    • List.reverse()

    • list.sort([func])





    1. PYTHON ─ TUPLES



    • Accessing Values in Tuples

    • Updating Tuples

    • Deleting Tuple Elements

    • Basic Tuples Operations

    • Indexing, Slicing, and Matrixes

    • No Enclosing Delimiters.............................................................................................................................

    • Built-in Tuple Functions

    • Cmp(tuple1, tuple2)

    • Len(tuple)

    • Max(tuple)

    • Min(tuple)

    • Tuple(seg)





    1. PYTHON ─ DICTIONARY.........................................................................................................



    • Accessing Values in Dictionary

    • Updating Dictionary

    • Delete Dictionary Elements

    • Properties of Dictionary Keys

    • Built-in Dictionary Functions and Methods

    • Cmp(dict1, dict2)

    • len(dict)

    • str(dict)

    • type()

    • dict.clear()

    • Dict.copy()

    • Dict.fromkeys()

    • Dict.get(key,default=none)

    • Dict.has_key(key)

    • Dict.items()

    • Dict.keys()

    • dict.setdefault(key, default=None)

    • dict.update(dict2)......................................................................................................................................

    • dict.values()





    1. PYTHON ─ DATE AND TIME



    • What is Tick?

    • What is TimeTuple?

    • Getting Current Time.................................................................................................................................

    • Getting Formatted Time

    • Getting Calendar for a Month

    • The time Module

    • time.altzone

    • time.actime([tupletime])...........................................................................................................................

    • time.clock( )

    • time.ctime([secs])

    • time.gmtime([secs])

    • time.localtime([secs])................................................................................................................................

    • time.mktime(tupletime)............................................................................................................................

    • time.sleep(secs)

    • time.strftime(fmt[,tupletime])

    • time.strptime(str,fmt='%a %b %d %H:%M:%S %Y')

    • time.time( )

    • time.tzset()

    • The calendar Module

    • Other Modules and Functions





    1. PYTHON ─ FUNCTIONS



    • Defining a Function

    • Calling a Function

    • Passing by Reference Versus Passing by Value

    • Function Arguments

    • Required Arguments

    • Keyword Arguments..................................................................................................................................

    • Default Arguments

    • Variable Length Arguments

    • The Anonymous Functions

    • The return Statement

    • Scope of Variables

    • Global vs. Local variables





    1. PYTHON ─ MODULES



    • The import Statement

    • The from...import Statement

    • The from...import * Statement:

    • Locating Modules:

    • The PYTHONPATH Variable

    • Namespaces and Scoping

    • The dir( ) Function

    • The globals() and locals() Functions

    • The reload() Function

    • Packages in Python





    1. PYTHON ─ FILES I/O



    • Printing to the Screen

    • Reading Keyboard Input

    • The raw_input Function

    • The input Function

    • Opening and Closing Files

    • The open Function

    • The file Object Attributes

    • The close() Method

    • Reading and Writing Files

    • The write() Method

    • The read() Method

    • File Positions

    • Renaming and Deleting Files

    • The rename() Method

    • The remove() Method

    • Directories in Python

    • The mkdir() Method

    • The chdir() Method

    • The getcwd() Method

    • The rmdir() Method...................................................................................................................................

    • File and Directory Related Methods

    • file.close()

    • File.flush()

    • File.fileno()

    • File.isatty()

    • File.next()

    • File.read([size])

    • File.readline([size])

    • file.readline([sizehint])

    • file.seek(offset[,whence])

    • file.tell()

    • file.truncate([size])

    • file.write(str)

    • file.writelines(sequence)

    • OS Object Methods





    1. PYTHON ─ EXCEPTIONS



    • Assertions in Python

    • The assert Statement

    • What is Exception?

    • Handling an Exception

    • The except Clause with No Exceptions

    • The except Clause with Multiple Exceptions

    • The try-finally Clause

    • Argument of an Exception

    • Raising an Exception

    • User-Defined Exceptions





    1. PYTHON ─ CLASSES AND OBJECTS



    • Overview of OOP Terminology

    • Creating Classes

    • Creating Instance Objects

    • Accessing Attributes

    • Built-In Class Attributes

    • Destroying Objects (Garbage Collection)

    • Class Inheritance

    • Overriding Methods

    • Base Overloading Methods

    • Overloading Operators

    • Data Hiding





    1. PYTHON ─ REGULAR EXPRESSIONS



    • The match Function

    • The search Function

    • Matching Versus Searching

    • Search and Replace

    • Regular-Expression Modifiers: Option Flags

    • Regular-Expression Patterns

    • Regular-Expression Examples

    • Grouping with Parentheses

    • Backreferences





    1. PYTHON ─ CGI PROGRAMMING



    • What is CGI?

    • Web Browsing

    • CGI Architecture

    • Web Server Support and Configuration

    • First CGI Program

    • HTTP Header

    • CGI Environment Variables

    • GET and POST Methods

    • Passing Information using GET method:

    • Simple URL Example : Get Method

    • Simple FORM Example: GET Method

    • Passing Information Using POST Method

    • Passing Checkbox Data to CGI Program

    • Passing Radio Button Data to CGI Program

    • Passing Text Area Data to CGI Program

    • Passing Drop Down Box Data to CGI Program

    • Using Cookies in CGI

    • How It Works?...........................................................................................................................................

    • Setting up Cookies

    • Retrieving Cookies.....................................................................................................................................

    • File Upload Example

    • How To Raise a "File Download" Dialog Box?





    1. PYTHON ─ DATABASE ACCESS



    • What is MySQLdb?

    • How do I Install MySQLdb?

    • Database Connection

    • Creating Database Table

    • INSERT Operation

    • READ Operation

    • Update Operation

    • DELETE Operation

    • Performing Transactions

    • COMMIT Operation

    • ROLLBACK Operation

    • Disconnecting Database

    • Handling Errors





    1. PYTHON ─ NETWORK PROGRAMMING



    • What is Sockets?

    • The socket Module

    • Server Socket Methods

    • Client Socket Methods

    • General Socket Methods

    • A Simple Server

    • A Simple Client

    • Python Internet modules

    • Further Readings





    1. PYTHON ─ SENDING EMAIL



    • Sending an HTML e-mail using Python

    • Sending Attachments as an E-mail





    1. PYTHON ─ MULTITHREADING



    • Starting a New Thread

    • The Threading Module

    • Creating Thread Using Threading Module:

    • Synchronizing Threads

    • Multithreaded Priority Queue





    1. PYTHON ─ XML PROCESSING



    • What is XML?

    • XML Parser Architectures and APIs:

    • Parsing XML with SAX APIs

    • The make_parser Method

    • The parse Method

    • The parseString Method

    • Parsing XML with DOM APIs





    1. PYTHON ─ GUI PROGRAMMING



    • Tkinter Programming

    • Tkinter Widgets

    • Button

    • Canvas

    • Checkbutton

    • Entry

    • Frame

    • Label

    • Listbox.......................................................................................................................................................

    • MenuButton

    • Menu

    • Message

    • Radiobutton

    • Scale

    • Scrollbar

    • Text

    • TopLevel

    • SpinBox

    • PanelWindow

    • LabelFrame

    • tkMessageBox

    • Standard Attributes

    • Dimensions

    • Colors

    • Fonts

    • Anchors

    • Relief styles

    • Bitmaps

    • Cursors

    • Geometry Management

    • Python Tkinter pack() Method

    • Python Tkinter grid() Method

    • Python Tkinter place() Method





    1. PYTHON ─ FURTHER EXTENSIONS



    • Pre-Requisites for Writing Extensions

    • First Look at a Python Extension

    • The Header File Python.h

    • The C Functions



  • The Method Mapping Table

  • The Initialization Function

  • Building and Installing Extensions

  • Importing Extensions

  • Passing Function Parameters

  • The PyArg_ParseTuple Function

  • Returning Values

  • The Py_BuildValue Function

Free download pdf