python cook book

Python Cook Book Written by Sebastian

Author: Sebastian

Python Cook Book Index

Download Book Now

CSV Reader / Writer Example 1
1.1 The Basics . 1
1.2 Reading and writing dictionaries . 5
1.3 Download the Code Project . . . . 6
2 Decorator Tutorial 7
2.1 Understanding Functions . . . . . 7
2.2 Jumping into decorators 8
2.3 The Practice 9
2.4 Download the Code Project . . . . 14
3 Threading / Concurrency Example 15
3.1 Python _thread module 15
3.2 Python threading module . . . . . 16
3.2.1 Extending Thread . . . . . 16
3.2.2 Getting Current Thread Information . 17
3.2.3 Daemon Threads . . . . . 18
3.2.4 Joining Threads 20
3.2.5 Time Threads . 22
3.2.6 Events: Communication Between Threads . . . . 23
3.2.7 Locking Resources . . . . 24
3.2.8 Limiting Concurrent Access to Resources . . . . 29
3.2.9 Thread-Specific Data . . . 29
4 Logging Example 31
4.1 The Theory 31
4.1.1 Log Levels . . 31
4.1.2 Handlers . . . 32
4.1.3 Format . . . . 32
4.2 The Practice 33
4.3 Download the Code Project . . . . 39

Python Programming Cookbook iii
5 Django Tutorial 40
5.1 Creating the project . . 40
5.2 Creating our application . . . . . 40
5.3 Database Setup . . . . 41
5.4 The Public Page . . . . 45
5.5 Style Sheets 47
5.6 Download the Code Project . . . . 49
6 Dictionary Example 50
6.1 Define . . . 50
6.2 Read . . . . 50
6.3 Write . . . 52
6.4 Useful operations . . . 52
6.4.1 In (keyword) . 53
6.4.2 Len (built-in function) . . 53
6.4.3 keys() and values() . . . . 54
6.4.4 items() . . . . 55
6.4.5 update() . . . . 56
6.4.6 copy() . . . . . 56
6.5 Download the Code Project . . . . 57
7 Sockets Example 58
7.1 Creating a Socket . . . 58
7.2 Using a Socket . . . . 59
7.3 Disconnecting . . . . . 60
7.4 A Little Example Here 60
7.5 Non-blocking Sockets . 62
7.6 Download the Code Project . . . . 63
8 Map Example 64
8.1 Map Implementation . 64
8.2 Python’s Map . . . . . 65
8.3 Map Object 68
8.4 Download the Code Project . . . . 69
9 Subprocess Example 70
9.1 Convenience Functions 70
9.1.1 subprocess.call 70
9.1.2 subprocess.check_call . . 71
9.1.3 subprocess.check_output . 72
9.2 Popen . . . 72
9.3 Download the Code Project . . . . 74

Python Programming Cookbook iv
10 Send Email Example 75
10.1 The Basics of smtplib . 75
10.2 SSL and Authentication 76
10.3 Sending HTML . . . . 77
10.4 Sending Attachments . 78
10.5 Download the Code Project . . . . 80

Download Book Now

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s