Skip to content

jonculloty/python-cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 

Repository files navigation

python-cheatsheet

Everything related to syntax, tips and tricks and stuff

Data Types

List

Define a List

["a", 1, "b", "c"]

To check presence of an element:

array1 = ["a", "b", "c"]

"a" in array1 # True

array.index("b") # returns 1 - returns index of an element
array.index("f") # raises exception

To remove an element:

array2 = ["a", "b", "c"]
array2.remove("c")
#or 
array.pop() # removes last element

Dictionary

Create and access Dict

userid = {'john': 51, 'paul': 53}
print "paul usedid: ",userid['paul']

Tuple

Object Oriented

Introspection

  • dir()

Documenting Code

Available Documentation Libraries

Using Sphinx

Example project documented with Sphinx: http://packages.python.org/an_example_pypi_project/sphinx.html

About

Everything related to syntax, tips and tricks and stuff

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors