160 likes | 535 Views
An Introduction to Python. By: Anthony Long. What is Python ?. Python is an interpreted, interactive, object-oriented programming language. Installing Python. http :// www.python.org /download/. Definitions. Functions
E N D
An Introduction to Python. By: Anthony Long
What is Python? • Python is an interpreted, interactive, object-oriented programming language.
Installing Python • http://www.python.org/download/
Definitions • Functions • Functions are reusable code snippets which carry out a specific piece of functionality. • Modules • A collection of objects that can be imported and used by other code • Objects • Any entity that can be manipulated by commands. • Everything in Python is an object. • Classes • Describe the rules by which objects behave
Definitions (con’t) • Boolean • logical data type having one of two values (true or false). • Dictionaries • Dictionaries are data structures that are like lists in that they contain any number of values that you access by the dictionary name and the index. • However, dictionaries offer the added functionality of letting you assign your own key, instead of the integer that lists automatically assign for you. This key is usually a string that you want to associate with the value. • Float • Short for floating point, is a fundamental type used to define numbers with fractional parts • String • A sequence of bytes. • Unicode is the type used for “text” strings. • Integer • A whole number that can be positive, negative or zero • List • An array which can hold arbitrary objects and can expand dynamically as new items are added • None • Value returned for functions without a return statement
Important Modules Pyccuracy Autonose Bpython Ipython Mechanize Mysqldba Pyflakes Selenium pdb
Pyccuracy • Pyccuracy is a Behavior Driven Development style tool written in Python that aims to make it easier to write automated acceptance tests. It improves the readability of those tests by using a structured natural language – and a simple mechanism to extend this language – so that both developers and customers can collaborate and understand what the tests do. • Download: http://pypi.python.org/pypi/Pyccuracy/
Autonose • Autonose is an autotest-like tool for python. • Download: http://pypi.python.org/pypi/autonose/
Bpython • Bpython is a fancy interface to the Python interpreter for Unix-like operating systems. • Download: http://pypi.python.org/pypi/bpython/
Ipython • Ipython is an interactive shell for the Python programming language that offers enhanced introspection, additional shell syntax, code highlighting, tab completion, string completion, and a rich history. • Download: http://pypi.python.org/pypi/ipython
Mechanize • Mechanize is a Python module for stateful programmatic web browsing, used for automating interaction with websites. • Download: http://pypi.python.org/pypi/mechanize/
Mysqldbda • Mysqldbda is an interface for connecting to a MySQL database server from Python. • Download: http://pypi.python.org/pypi/mysqldbda
Pyflakes • Pyflakes is program to analyze Python programs and detect various errors. • Download: http://www.divmod.org/trac/wiki/DivmodPyflakes
Selenium • Selenium is a functional testing framework which automates the browser to perform certain operations which in turn test the underlying actions of your code. • Download here: http://pypi.python.org/pypi/selenium/
pdb • Pdb is an interactive source code debugger for Python programs, supporting breakpoints and single stepping settings at the source level. • More info: http://docs.python.org/library/pdb.html
Now for the fun stuff from selenium import selenium import unittest SERVER_SETUP = [“localhost”, 4444, “*firefox”, “http://google.com/”] class (unittest.TestCase): def setUp(self): self.verificationErrors = [] self.selenium = selenium(*SERVER_SETUP) self.selenium.start() def tearDown(self): self.selenium.stop() def test_(self): """test_""" self.selenium.open("") if __name__ == "__main__": unittest.main()