Python examples (example source code) Organized by topic





GUI Tk /

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

Event /

Key Action 15Mouse Action 23Mouse Draw 3

GUI Pmw /

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

2D /

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

List /

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

Tuple /

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

Dictionary /

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

String /

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

Class /

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

Function /

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

Buildin Function /

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

Data Type /

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

Data Structure /

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

Database /

DBM 3MySQL 3ODBC 1Pickle 5
shelve 3

File /

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

Development /

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

Language Basics /

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

Exception /

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

Math /

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

Network /

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

Thread /

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

System /

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

XML /

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

Utility /

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

Application /

Calculator 2