Intro To Python
Intro To Python
What is Python?
• General Purpose High Level Language
• Beginner Friendly
• Emphasis on readability
• Do a lot with a few lines of code
• Less verbose than C++ or Java
• Indentation replaces brackets
• Automatic memory management
• Dynamic types
• Interpreted / Interactive
• Completely Object Oriented
• In Python everything is an object
Why Python?
• No memory management
• Memory management is automated.
• So are pointers.
• High Level native data types
• Bool, Int, Float, String (only one of each!)
• Lists, dictionaries, file objects
• DataFrames (pandas), arrays (numpy)
• Easy Integration
• C, C++, Java, R
• JSON, XML, HTML, RDBMS
• Simpler code gets written faster.
When to use Python?
• Prototyping
• Great for building the first draft of a program
• before moving to C/C++, Java
• DevOPS
• Talk to multiple OS’s, network protocols & databases
• from the same process
• for embedded configuration, extension scripts
• Data Analysis
• Easy processing of multiple data formats
• Markup languages (HTML, XML), Excel, Databases, Text
• Many analysis and visualization tools
How to install?
• Anaconda – Continuum Analytics
• Makes windows installation easy
• 1 step process
• Included IDE’s
• Spyder – Matlab like environment
• iPython Notebook – build interactive documents
Libraries - Ecosystem
• Numpy – Scientific Computing
• Pandas – Data Analysis Library
• MatPlotLib – Graphics and plotting
• Vincent – Data visualization
• Cython – C/C++ integration
• pyspark - Apache SPARK API – for big data processing.
• Scikit-learn – Machine Learning and AI.
• Processing – parallel - multicore or clusters
• libXML – XML parsing and manipulation
IDE’s
• Spyder
• A powerfull interactive environment
• Editing, testing, debugging & Introspection tools.
• Numerical computing environment
• Includes Ipython, Numpy, Scipy and Matplotlib
• -> based on MATLab
• Visual Studio
• Integrated with VS features
• Free and open source -> Hosted on GitHub
• Install from VS custom install.
• You need to install the python backend (anaconda) first
libXML
• etree
• A data structure for accessing and manipulating XML’s
• Allows queries using XPATH.
• XPATH is a query language for XML & HTML documents.
• Defined by W3C
xml_compare.py
• Get the xml tree, applications branch
• Using xpath to navigate the XML.
• Go over the leafs in each branch
• Compare the settings of new and old
• Store records with results & details of each test
• Calculate statistics