Python examples (example source code) Organized by topic





GUI Tk /

Alarm 1Animation 3
Back Fore ground 1Beeper 1
Border 7Button 32
Canvas 8CheckBox 7
Common Dialog 9Cursor 1
Dialog 14Editor 1
Event 9Exception Dialog 1
Focus 1Frame 23
Label 16Layout 40
LED 1ListBox 7
Menu Checkbox 1Menu RadioButton 1
Menu 18MenuButton 1
Message Box 1OptionMenu 1
Pack 4Popup Menu 1
RadioButton 9Scale 8
ScrollBar 2StatusBar MessageField 2
Table Grid 5Text 11
TextArea 4TextField Entry 12
Timer 2Tk option database 1
TK Root Window 3ToolBar 2
Top Level 1UI Class 15
UI Event 1

Event /

Key Action 15Mouse Action 23
Mouse Draw 3

GUI Pmw /

Pmw AboutDialog 2Pmw Blt Tabset 1
Pmw Border 1Pmw ButtonBox 5
Pmw Color 2Pmw ComboBox 7
Pmw ComboBoxDialog 2Pmw Counter 9
Pmw CounterDialog 2Pmw Dialog 8
Pmw EntryField 15Pmw Error Handler 2
Pmw Gauge 1Pmw Grid 2
Pmw Group 8Pmw HistoryText 1
Pmw Key Action 1Pmw LabeledWidget 2
Pmw LogicalFont 1Pmw MegaWidget 4
Pmw MenuBar 2Pmw MessageBar 2
Pmw MessageDialog 7Pmw Multi line label 2
Pmw OptionMenu 4Pmw Password 1
Pmw Performance 1Pmw PromptDialog 1
Pmw RadioSelect 5Pmw ScrolledCanvas 4
Pmw ScrolledField 1Pmw ScrolledFrame 1
Pmw ScrolledListBox 5Pmw ScrolledText 4
Pmw SelectionDialog 2Pmw Splitpane 3
Pmw StatusBar 1Pmw Tab NoteBook 4
Pmw TextDialog 2Pmw TimeCounter 2
Pmw Tooltips 2Pmw Toplevel Megawidget 1
Pmw Validation Field 9Subclassing Pmw 3

2D /

Arc 2Bitmap 2
Circle 1Color 2
Curve 1Font 7
Gif 1Image 1
Line 5Oval 3
Polygon 1Rectangle 2
Shape Border 2

List /

List Append 4List Assign 5
List Cancatenation 5List Compare 3
List Comprehensive 6List Count 1
List Declaration 1List Element Insert 1
List Element Remove 1List Element Replace 1
List Element 4List Empty 1
List Extend 3List Filter 1
List In 3List Index 2
List Indexing 7List Insert 2
List Intersect 2List Length 2
List Loop 6List Pop 3
List Remove 5List Repitition 1
List Reverse 2List Sliced 7
List Sort 3List Two Dimension 2
Nested List 3Return List 1
Variables in List 1

Tuple /

Nested Tuple 1Tuple Concatination 2
Tuple Condition 1Tuple Creation 6
Tuple Declaration 4Tuple Display 1
Tuple Element 1Tuple Immutable 1
Tuple In 3Tuple Index 4
Tuple Length 2Tuple Loop 3
Tuple Range 1Tuple Repitition 1
Tuple Returned 1Tuple Slice 2
Tuple toList 2Tuple Zip 1

Dictionary /

Dictionary Assignment 4Dictionary Clear 1
Dictionary Copy 3Dictionary Declaration 3
Dictionary Del 1Dictionary Fetch 1
Dictionary get 3Dictionary has Key 4
Dictionary items 2Dictionary iteritems 1
Dictionary Key 6Dictionary List 1
Dictionary Loop 3Dictionary Output 1
Dictionary popitem 1Dictionary Print 1
Dictionary setdefault 1Dictionary Tuple 3
Dictionary update 2Dictionary values 2

String /

Append 1Format 1
Loop 2String Case 2
String Cast 5String center 1
String Compare 1String Concatenation 3
String count 1String cross Line 1
String Declaration 3String Ends 1
String endsWith 1String Escape 4
String find 2String In 3
String Index 4String join 6
String Length 6String ljust 1
String Output 2String Quotation 3
String R 1String Repitition 2
String Replace 5String rfind 1
String rindex 1String rjust 1
String Slice 6String Special Char 1
String Split 4String startsWith 1
String strip 1String toTitle 1
String Variables 2zfill 1

Class /

Class abstract 1Class add 1
Class call 1Class Constructor 5
Class Define 2Class Definition 8
Class del 1Class Dict 2
Class fields 10Class getattr 2
Class getitem 2Class getslice 1
Class Inheritance 12Class Instance 1
Class instantiation 1Class iter 1
Class len 1Class list 1
Class metaclass 1Class Method 5
Class mul 1Class Operator Add 1
Class Private 1Class radd 1
Class repr 1Class self 1
Class setattr 1Class str 3
Class sub 1Class Virtual 6
Static 1

Function /

Apply 2Function as Parameters 3
Function as Return 2Function Default Argument 10
Function Define 7Function Dictionary Parameters 4
Function Inner 4Function Keyword Arguments 3
Function Parameters 5Function Recursive 3
Function Return 5Function Tuple Parameters 6
Function type vars 1Functional Programming 5
lambda function 5Return 3

Buildin Function /

chr 1Del 1
dict 1Dir 3
enumerate 1Eval 1
filter 4Float Function 1
Generator Function 3Generator 3
id 1in 3
int cast 2Iterable Object 1
Iterator Behavior 1Iterators 1
len 3list 4
map 6next 2
ord 2range 8
reduce 4repr 6
reversed 1sorted 1
str 4zfill 1
zip 7

Data Type /

Array 1Bigger Number 1
Bit 3Boolean 3
Complex Numbers 6Decimal 1
Float 2Hex Function 1
Hex Type 1Int 11
Long 1maxint 2
Oct Function 1octal Type 1
True 2Type Conversion 2

Data Structure /

bisect 1Deque 1
Queue 1Set Declaration 2
Set In 1Set 3
Stack 2

Database /

DBM 3MySQL 3
ODBC 1Pickle 5
shelve 3

File /

Dircetories 4File Binary 1
File Close 3File IO Exception 1
File Object 1File Open 1
File Pointer 1File Read 9
File Readline 3File seek 2
File Tell 1File Text 2
File Utilities 1File Utility 2
File Write 6File Zip 4
IO Error 3Text File Read Write 2
Text File Read 8Text File Write 4

Development /

Command Line 3Compress 1
Console Read 4Date Time 6
Doc String 6Encode File 2
Environment 2Help 2
isinstance 1Logging 1
Output Format 25Path 1
Random 10Reflection 1
Standard Read 5Standard Redirect 5
Standard Vars 1stdout stderr 6
Test 1Timer 1
User Input 2

Language Basics /

And Or 7Break 4
Buildin Error 2Catch Exceptions 3
Comments 3Continue 3
def 1Divide 4
For In 2For 5
Garbage Collector 1Global 5
If 10Import 3
Local Variables 2Locale 1
Logical Operator 1Module 15
Multiply 3Not 1
Operator 1Pass 1
Plus 1pprint 1
Print 3Raise 1
Statement 1Static Method 2
Subtract 1Text Encode 3
Try Else 2Try finally 1
Try 2Type 2
Unicode 9Variable Assign 3
Variable Declaration 2Variable Immutable 2
Variable Reference 1While 12

Exception /

Exception Class 3Exception finally 1
Exception Handle 6Exception Info 3
Exception Raise 2Exception Trace 1
Exception Type 1Value Error 1

Math /

cos 1E 1
Log 1Math Pow 1
Max 2Min 2
Mod 1Pi 1
Power 2Round 2
Sin 2sqrt 1

Network /

Address Info 3CGI 5
Email 8FTP 4
Gopher Client 5Host Info 3
HTML Parser 2HTTP POST 1
Internet Access 1IP Address 1
Proxy 1Remote File 1
Server UDP 2Socket Broadcast 1
Socket Client 3Socket Error Handle 3
Socket Info 1Socket Option 1
Socket Pocket 2Socket Server 6
TCP 5UDP 4
URL 7Web Client 6
Web Page 3Web Server 1

Thread /

Thread Exit 1Thread Sleep 1
Thread Start 1Thread Synchronize 3

System /

System Cmd Mount 3System Command 1
System Error 1System Exit 1
System fork 1System Info 1
System Path 4System pid 1
System Time 1System User 1
System Variables 3

XML /

Handler 2SAX 4
XML Children Node 5XML Element 4
XML Parse 7XML Transform 3

Utility /

API Helper 2Command Line 1
Command 2Exception 1
File Utility 16Network Utility 7
Programming 21Regular Expressions 1

Application /

Calculator 2