SlideShare a Scribd company logo
https://xkcd.com/353/
A C# Dev’s Guide to Python
Presented by:
Sarah Dutkiewicz
Microsoft MVP, Visual Studio and
Development Technologies
Microsoft Developers HK
13 June, 2018
About the Presenter
• 9 time Microsoft Most Valuable
Professional – 2 years in Visual C#, 7 years
in Visual Studio and Development Tools
• Bachelor of Science in Computer Science &
Engineering Technology
• Published author of a PowerShell book
• Live coding stream guest on Fritz and
Friends and DevChatter
• Why Hong Kong? #ancestraltrip!
The Python Community
Python’s community is vast;
diverse & aims to grow;
Python is Open.
https://www.python.org/community/
Diversity in Python
The Python Software Foundation and the global Python
community welcome and encourage participation by
everyone. Our community is based on mutual respect,
tolerance, and encouragement, and we are working to help
each other live up to these principles. We want our
community to be more diverse: whoever you are, and
whatever your background, we welcome you.
https://www.python.org/community/diversity/
The Zen of Python,
by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
https://www.python.org/dev/peps/pep-0020
Areas Using Python
• Analysis
• Computation
• Math
• Science
• Statistics
• Engineering
• Deep Learning
• Artificial Intelligence
• Machine Learning
• Data Science
Weakness of Python
• The Great Python Schism
• Hard version split between 2.x and 3.x
• Some people are stuck on 2.x due to dependencies following the 2.x line
• Greatly opinionated
There should be one-- and preferably only one --obvious way to do it.
Why Python 3?
• Python 2 struggles with text and binary data
• ‘abcd’ is both a string consisting of letters (textual) and a string consisting of
bytes (binary)
• Goes against the “preferably one way” part of the Zen of Python
• Doesn’t do well with Unicode
• Python was out before Unicode was a standard
• Not all projects in Python 2 support Unicode equally
• Python 3
• unicode/str/bytes types
• Backwards-incompatible – but very much necessary, as Python is a language
of the world
Python Enhancement Proposals (PEPs)
• https://www.python.org/dev/peps/
• Purpose and Guidelines for PEPs
• Guidelines for Language Evolution
• Deprecation of Standard Modules
• Bug Fixes
• Style Guides
• Docstring Conventions
• API for crypto
• API for Python database
• Python release schedules
• … and more!
Other Terms…
• Benevolent Dictator for Life (BDFL) – Guido van
Rossum, father of Python
• Pythonista – Python developer
• Pythonic – code follows common guidelines, written
in idiomatic Python
• Pythoneer – pioneers of Python, leaders who create
change
• A Pythoneer can be a Pythonista, but not all
Pythonistas are Pythoneers.
Some Tools to Know
• Visual Studio with Python Tools
• Visual Studio Code
• Azure Notebooks
• Repl.it
• Jupyter Notebooks
• PyCharm
Package Management
• Think NuGet only for Python
• Pip (Pip Installs Packages)
• Python’s official package manager
• Virtualenv
• Install pip packages in an isolated manner
• Conda – conda.io
• Not Python-specific – a cross-platform option similar
to apt and yum
• Part of Miniconda
• Just conda and its dependencies
• Also part of Anaconda
• Conda, its dependencies, and many packages helpful in
data science applications
• More than one? Isn’t this anti-Zen? Yes,
but…
http://jakevdp.github.io/blog/2016/08/25/co
nda-myths-and-misconceptions/
Presentation Breakdown
• Simple Python demos in a Jupyter Notebook – to be shared in
an Azure Notebook
• Variables
• Conditional Structures
• Loops
• Functions
• Exception Handling
• Azure Notebook Library:
https://notebooks.azure.com/cletechconsulting/libraries/
introtopyforcsharpdevs
• More complex code using Visual Studio Community Edition
with the Python Tools and/or Visual Studio Code
• GitHub repo:
https://github.com/sadukie/IntroToPyForCSharpDevs
What version of Python am I running?
Location Command
Command-line python -V
Within a Python
environment
import sys
sys.version
Key Points from Python Style Guide (PEP 8)
• Indentation – 4 spaces
• Optional for continuation lines
• Make it readable and clearly identifiable
• If tabs are already in use, continue with tabs
• Do not mix tabs and spaces!
• Maximum line length should be 79 characters
• Easy for side-by-side files
• Works well for code review situations
• Docstrings and comments should be limited to 72 characters
• Imports on separate lines, always at the top
• Be consistent with quoting – single-quoted and double-quoted strings are the same.
• Read more at https://www.python.org/dev/peps/pep-0008/#imports
DEMO: Basics of Python
If Internet is present: Azure Notebooks
If Internet is not present: Jupyter Notebooks
Object-
Orientation
and Python
Classes, Methods, Dunders, and More!
Object Orientation
• Object oriented from the beginning
• Classes with:
• Data members (class variables and instance variables)
• Methods
• Class Variables vs Instance Variables
• Class variables are accessed for all instances of a class
• Within a class, outside of methods
• Not common
• Instance variables are managed by the instance
Inheritance
• Can inherit from multiple classes
• Can check relationships with isinstance() and issubclass()
• Parent class is accessed via super() method call
• Typical to call parent’s __init__() from within child’s __init__() before
moving on in the child’s initialization method
• Child knows about parents through its __bases__attribute
Interfaces
• Not necessary in Python
• No interface keyword in Python
• Try to invoke a method we expect
• Exception handling
• hasattr checking
• Duck typing
If it talks and walks like a duck, then it is a duck
Metaclasses
• Things typically defined in the language specification in other
languages
• Classes’ classes
• Class factories!
• Can be stored in a __metaclass__ attribute
• Can also be declared with metaclass= in the class declaration, following
parameters
• Most classes have the metaclass of type
• Traverse the __class__ tree enough, and you’ll end at type
Abstract Base Classes
• ABCs!
• abc module
• ABCMeta metaclass
• Use the pass keyword to not define the method’s body
• Must also use the @abc.abstractmethod decorator
• Can register classes as virtual subclasses of ABCs
• Only useful for categorization
• Does not know anything about its parent – nothing in __bases__
• Can throw errors if methods aren’t implemented
DEMO: Inheritance and ABCs
Magic Methods (Dunder
Methods)
Magic Methods
• Key concept to understand for OO Python
• Method names are surrounded by double underscores (“dunders”)
• Sometimes called dunder methods
• Object’s lifespan in magic methods
• __new__ - redefined rarely; used to create new instances; phase 1 of the
constructor
• __init__ - initializer for the class; passed the instance; most commonly used in
Python class definitions
• __del__ - the destructor; no guarantee that __del__ will be executed
Primary Uses for Magic Methods
• Constructors / Destructors
• Operator handling for Object types
• Comparison
• Unary Operators
• Extended Operators
More Magic Methods
• Comparison
• __eq__ - ==
• __ne__ - !=
• __lt__ - <
• __gt__ - >
• __le__ - <=
• __ge__ - >=
• Important keywords with these
• self – this instance
• other – instance to compare to
Other Applications of Python
Desktop Application Development
• Tkinter (“Tk
interface”) – Defacto
GUI creation in
Python for writing
desktop apps based
on Tcl/Tk
• PyQt – Python
package for writing
desktop apps based
on Qt
• If you prefer GTK:
• PyGObject
• pygtk
http://www.pygame.org
https://kivy.org
Web Frameworks
https://trypyramid.com/
https://www.djangoproject.com/
http://www.turbogears.org/
http://flask.pocoo.org
Testing
https://docs.pytest.org
https://pypi.org/project/behave/
http://lettuce.it/
Data Science
https://pandas.pydata.org/
https://matplotlib.org/
https://www.datacamp.com/
Taken from my Jupyter Notebook DataCamp notes…
SQL Server 2017 & Machine Learning
• Run Python in the server
• Brings computation to the data
• revoscalepy: https://docs.microsoft.com/en-us/machine-learning-
server/python-reference/revoscalepy/revoscalepy-package
Learn More!
• Seminar of Machine Learning in Python – Open Source Hong Kong –
led by Delon Yau, Software Engineer, Microsoft -
https://www.meetup.com/opensourcehk/events/251121245/
• Getting Started with Python in Visual Studio Code:
https://code.visualstudio.com/docs/python/python-tutorial
• Python Tools for Visual Studio:
https://www.visualstudio.com/vs/features/python/
• Python at Microsoft blog:
https://blogs.msdn.microsoft.com/pythonengineering/
Contact Information
• Twitter: @sadukie
• GitHub: sadukie
• LinkedIn:
https://linkedin.com/in/sadukie
• Email:
sarah@cletechconsulting.com

More Related Content

What's hot

Debugging Apache Spark - Scala & Python super happy fun times 2017
Debugging Apache Spark -   Scala & Python super happy fun times 2017Debugging Apache Spark -   Scala & Python super happy fun times 2017
Debugging Apache Spark - Scala & Python super happy fun times 2017
Holden Karau
 
Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Is there a SQL for NoSQL?
Is there a SQL for NoSQL?
Arthur Keen
 
scrazzl - A technical overview
scrazzl - A technical overviewscrazzl - A technical overview
scrazzl - A technical overviewscrazzl
 
Ncku csie talk about Spark
Ncku csie talk about SparkNcku csie talk about Spark
Ncku csie talk about Spark
Giivee The
 
Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!
ankitbhandari32
 
Big Data Processing with Apache Spark 2014
Big Data Processing with Apache Spark 2014Big Data Processing with Apache Spark 2014
Big Data Processing with Apache Spark 2014
mahchiev
 
Data Day Seattle 2015: Sarah Guido
Data Day Seattle 2015: Sarah GuidoData Day Seattle 2015: Sarah Guido
Data Day Seattle 2015: Sarah Guido
Bitly
 
Scala and Spark are Ideal for Big Data - Data Science Pop-up Seattle
Scala and Spark are Ideal for Big Data - Data Science Pop-up SeattleScala and Spark are Ideal for Big Data - Data Science Pop-up Seattle
Scala and Spark are Ideal for Big Data - Data Science Pop-up Seattle
Domino Data Lab
 
20160512 apache-spark-for-everyone
20160512 apache-spark-for-everyone20160512 apache-spark-for-everyone
20160512 apache-spark-for-everyone
Amanda Casari
 
Big data analysing genomics and the bdg project
Big data   analysing genomics and the bdg projectBig data   analysing genomics and the bdg project
Big data analysing genomics and the bdg project
sree navya
 
AnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsight
AnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsightAnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsight
AnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsight
Łukasz Grala
 
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Chris Fregly
 
Whirlpools in the Stream with Jayesh Lalwani
 Whirlpools in the Stream with Jayesh Lalwani Whirlpools in the Stream with Jayesh Lalwani
Whirlpools in the Stream with Jayesh Lalwani
Databricks
 
Fulfilling Apache Arrow's Promises: Pandas on JVM memory without a copy
Fulfilling Apache Arrow's Promises: Pandas on JVM memory without a copyFulfilling Apache Arrow's Promises: Pandas on JVM memory without a copy
Fulfilling Apache Arrow's Promises: Pandas on JVM memory without a copy
Uwe Korn
 
Real-time Analytics with Cassandra, Spark, and Shark
Real-time Analytics with Cassandra, Spark, and SharkReal-time Analytics with Cassandra, Spark, and Shark
Real-time Analytics with Cassandra, Spark, and Shark
Evan Chan
 
Intuitive & Scalable Hyperparameter Tuning with Apache Spark + Fugue
Intuitive & Scalable Hyperparameter Tuning with Apache Spark + FugueIntuitive & Scalable Hyperparameter Tuning with Apache Spark + Fugue
Intuitive & Scalable Hyperparameter Tuning with Apache Spark + Fugue
Databricks
 
Apache Arrow: Cross-language Development Platform for In-memory Data
Apache Arrow: Cross-language Development Platform for In-memory DataApache Arrow: Cross-language Development Platform for In-memory Data
Apache Arrow: Cross-language Development Platform for In-memory Data
Wes McKinney
 
Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...
Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...
Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...
Databricks
 
Skutil - H2O meets Sklearn - Taylor Smith
Skutil - H2O meets Sklearn - Taylor SmithSkutil - H2O meets Sklearn - Taylor Smith
Skutil - H2O meets Sklearn - Taylor Smith
Sri Ambati
 

What's hot (19)

Debugging Apache Spark - Scala & Python super happy fun times 2017
Debugging Apache Spark -   Scala & Python super happy fun times 2017Debugging Apache Spark -   Scala & Python super happy fun times 2017
Debugging Apache Spark - Scala & Python super happy fun times 2017
 
Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Is there a SQL for NoSQL?
Is there a SQL for NoSQL?
 
scrazzl - A technical overview
scrazzl - A technical overviewscrazzl - A technical overview
scrazzl - A technical overview
 
Ncku csie talk about Spark
Ncku csie talk about SparkNcku csie talk about Spark
Ncku csie talk about Spark
 
Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!
 
Big Data Processing with Apache Spark 2014
Big Data Processing with Apache Spark 2014Big Data Processing with Apache Spark 2014
Big Data Processing with Apache Spark 2014
 
Data Day Seattle 2015: Sarah Guido
Data Day Seattle 2015: Sarah GuidoData Day Seattle 2015: Sarah Guido
Data Day Seattle 2015: Sarah Guido
 
Scala and Spark are Ideal for Big Data - Data Science Pop-up Seattle
Scala and Spark are Ideal for Big Data - Data Science Pop-up SeattleScala and Spark are Ideal for Big Data - Data Science Pop-up Seattle
Scala and Spark are Ideal for Big Data - Data Science Pop-up Seattle
 
20160512 apache-spark-for-everyone
20160512 apache-spark-for-everyone20160512 apache-spark-for-everyone
20160512 apache-spark-for-everyone
 
Big data analysing genomics and the bdg project
Big data   analysing genomics and the bdg projectBig data   analysing genomics and the bdg project
Big data analysing genomics and the bdg project
 
AnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsight
AnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsightAnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsight
AnalyticsConf2016 - Zaawansowana analityka na platformie Azure HDInsight
 
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
Cassandra Summit Sept 2015 - Real Time Advanced Analytics with Spark and Cass...
 
Whirlpools in the Stream with Jayesh Lalwani
 Whirlpools in the Stream with Jayesh Lalwani Whirlpools in the Stream with Jayesh Lalwani
Whirlpools in the Stream with Jayesh Lalwani
 
Fulfilling Apache Arrow's Promises: Pandas on JVM memory without a copy
Fulfilling Apache Arrow's Promises: Pandas on JVM memory without a copyFulfilling Apache Arrow's Promises: Pandas on JVM memory without a copy
Fulfilling Apache Arrow's Promises: Pandas on JVM memory without a copy
 
Real-time Analytics with Cassandra, Spark, and Shark
Real-time Analytics with Cassandra, Spark, and SharkReal-time Analytics with Cassandra, Spark, and Shark
Real-time Analytics with Cassandra, Spark, and Shark
 
Intuitive & Scalable Hyperparameter Tuning with Apache Spark + Fugue
Intuitive & Scalable Hyperparameter Tuning with Apache Spark + FugueIntuitive & Scalable Hyperparameter Tuning with Apache Spark + Fugue
Intuitive & Scalable Hyperparameter Tuning with Apache Spark + Fugue
 
Apache Arrow: Cross-language Development Platform for In-memory Data
Apache Arrow: Cross-language Development Platform for In-memory DataApache Arrow: Cross-language Development Platform for In-memory Data
Apache Arrow: Cross-language Development Platform for In-memory Data
 
Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...
Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...
Streaming Trend Discovery: Real-Time Discovery in a Sea of Events with Scott ...
 
Skutil - H2O meets Sklearn - Taylor Smith
Skutil - H2O meets Sklearn - Taylor SmithSkutil - H2O meets Sklearn - Taylor Smith
Skutil - H2O meets Sklearn - Taylor Smith
 

Similar to Intro to Python for C# Developers

Introduction_to_Python.pptx
Introduction_to_Python.pptxIntroduction_to_Python.pptx
Introduction_to_Python.pptx
RahulChaudhary51756
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Muralidharan Deenathayalan
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Muralidharan Deenathayalan
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Codersebbe
 
PyData Texas 2015 Keynote
PyData Texas 2015 KeynotePyData Texas 2015 Keynote
PyData Texas 2015 Keynote
Peter Wang
 
Intro slides
Intro slidesIntro slides
Intro slides
rekhawankhede1
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
Andrei KUCHARAVY
 
Software Programming with Python II.pptx
Software Programming with Python II.pptxSoftware Programming with Python II.pptx
Software Programming with Python II.pptx
GevitaChinnaiah
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Return on Intelligence
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Return on Intelligence
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert
QA TrainingHub
 
Python Tricks That You Can't Live Without
Python Tricks That You Can't Live WithoutPython Tricks That You Can't Live Without
Python Tricks That You Can't Live Without
Audrey Roy
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
Alfred Jett Grandeza
 
Abhishek Training PPT.pptx
Abhishek Training PPT.pptxAbhishek Training PPT.pptx
Abhishek Training PPT.pptx
KashishKashish22
 
Python intro and competitive programming
Python intro and competitive programmingPython intro and competitive programming
Python intro and competitive programming
Suraj Shah
 
Better Tools, Better Mindset
Better Tools, Better MindsetBetter Tools, Better Mindset
Better Tools, Better Mindset
Yusup
 
Python as the Zen of Data Science
Python as the Zen of Data SciencePython as the Zen of Data Science
Python as the Zen of Data Science
Travis Oliphant
 
Welcome to the Brixton Library Technology Initiative
Welcome to the Brixton Library Technology InitiativeWelcome to the Brixton Library Technology Initiative
Welcome to the Brixton Library Technology Initiative
Basil Bibi
 
Object Oriented Programming in Swift Ch0 - Encapsulation
Object Oriented Programming in Swift Ch0 - EncapsulationObject Oriented Programming in Swift Ch0 - Encapsulation
Object Oriented Programming in Swift Ch0 - Encapsulation
Chihyang Li
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...
Danny Mulligan
 

Similar to Intro to Python for C# Developers (20)

Introduction_to_Python.pptx
Introduction_to_Python.pptxIntroduction_to_Python.pptx
Introduction_to_Python.pptx
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
 
PyData Texas 2015 Keynote
PyData Texas 2015 KeynotePyData Texas 2015 Keynote
PyData Texas 2015 Keynote
 
Intro slides
Intro slidesIntro slides
Intro slides
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Software Programming with Python II.pptx
Software Programming with Python II.pptxSoftware Programming with Python II.pptx
Software Programming with Python II.pptx
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert
 
Python Tricks That You Can't Live Without
Python Tricks That You Can't Live WithoutPython Tricks That You Can't Live Without
Python Tricks That You Can't Live Without
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Abhishek Training PPT.pptx
Abhishek Training PPT.pptxAbhishek Training PPT.pptx
Abhishek Training PPT.pptx
 
Python intro and competitive programming
Python intro and competitive programmingPython intro and competitive programming
Python intro and competitive programming
 
Better Tools, Better Mindset
Better Tools, Better MindsetBetter Tools, Better Mindset
Better Tools, Better Mindset
 
Python as the Zen of Data Science
Python as the Zen of Data SciencePython as the Zen of Data Science
Python as the Zen of Data Science
 
Welcome to the Brixton Library Technology Initiative
Welcome to the Brixton Library Technology InitiativeWelcome to the Brixton Library Technology Initiative
Welcome to the Brixton Library Technology Initiative
 
Object Oriented Programming in Swift Ch0 - Encapsulation
Object Oriented Programming in Swift Ch0 - EncapsulationObject Oriented Programming in Swift Ch0 - Encapsulation
Object Oriented Programming in Swift Ch0 - Encapsulation
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...
 

More from Sarah Dutkiewicz

Passwordless Development using Azure Identity
Passwordless Development using Azure IdentityPasswordless Development using Azure Identity
Passwordless Development using Azure Identity
Sarah Dutkiewicz
 
Predicting Flights with Azure Databricks
Predicting Flights with Azure DatabricksPredicting Flights with Azure Databricks
Predicting Flights with Azure Databricks
Sarah Dutkiewicz
 
Azure DevOps for Developers
Azure DevOps for DevelopersAzure DevOps for Developers
Azure DevOps for Developers
Sarah Dutkiewicz
 
Azure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersAzure DevOps for JavaScript Developers
Azure DevOps for JavaScript Developers
Sarah Dutkiewicz
 
Azure DevOps for the Data Professional
Azure DevOps for the Data ProfessionalAzure DevOps for the Data Professional
Azure DevOps for the Data Professional
Sarah Dutkiewicz
 
Noodling with Data in Jupyter Notebook
Noodling with Data in Jupyter NotebookNoodling with Data in Jupyter Notebook
Noodling with Data in Jupyter Notebook
Sarah Dutkiewicz
 
Pairing and mobbing
Pairing and mobbingPairing and mobbing
Pairing and mobbing
Sarah Dutkiewicz
 
Becoming a Servant Leader, Leading from the Trenches
Becoming a Servant Leader, Leading from the TrenchesBecoming a Servant Leader, Leading from the Trenches
Becoming a Servant Leader, Leading from the Trenches
Sarah Dutkiewicz
 
NEOISF - On Mentoring Future Techies
NEOISF - On Mentoring Future TechiesNEOISF - On Mentoring Future Techies
NEOISF - On Mentoring Future Techies
Sarah Dutkiewicz
 
Becoming a Servant Leader
Becoming a Servant LeaderBecoming a Servant Leader
Becoming a Servant Leader
Sarah Dutkiewicz
 
The importance of UX for Developers
The importance of UX for DevelopersThe importance of UX for Developers
The importance of UX for Developers
Sarah Dutkiewicz
 
The Impact of Women Trailblazers in Tech
The Impact of Women Trailblazers in TechThe Impact of Women Trailblazers in Tech
The Impact of Women Trailblazers in Tech
Sarah Dutkiewicz
 
Unstoppable Course Final Presentation
Unstoppable Course Final PresentationUnstoppable Course Final Presentation
Unstoppable Course Final Presentation
Sarah Dutkiewicz
 
Even More Tools for the Developer's UX Toolbelt
Even More Tools for the Developer's UX ToolbeltEven More Tools for the Developer's UX Toolbelt
Even More Tools for the Developer's UX Toolbelt
Sarah Dutkiewicz
 
History of Women in Tech
History of Women in TechHistory of Women in Tech
History of Women in Tech
Sarah Dutkiewicz
 
History of Women in Tech - Trivia
History of Women in Tech - TriviaHistory of Women in Tech - Trivia
History of Women in Tech - Trivia
Sarah Dutkiewicz
 
The UX Toolbelt for Developers
The UX Toolbelt for DevelopersThe UX Toolbelt for Developers
The UX Toolbelt for Developers
Sarah Dutkiewicz
 
World Usability Day 2014 - UX Toolbelt for Developers
World Usability Day 2014 - UX Toolbelt for DevelopersWorld Usability Day 2014 - UX Toolbelt for Developers
World Usability Day 2014 - UX Toolbelt for Developers
Sarah Dutkiewicz
 
The UX Toolbelt for Developers
The UX Toolbelt for DevelopersThe UX Toolbelt for Developers
The UX Toolbelt for Developers
Sarah Dutkiewicz
 
The Case for the UX Developer
The Case for the UX DeveloperThe Case for the UX Developer
The Case for the UX Developer
Sarah Dutkiewicz
 

More from Sarah Dutkiewicz (20)

Passwordless Development using Azure Identity
Passwordless Development using Azure IdentityPasswordless Development using Azure Identity
Passwordless Development using Azure Identity
 
Predicting Flights with Azure Databricks
Predicting Flights with Azure DatabricksPredicting Flights with Azure Databricks
Predicting Flights with Azure Databricks
 
Azure DevOps for Developers
Azure DevOps for DevelopersAzure DevOps for Developers
Azure DevOps for Developers
 
Azure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersAzure DevOps for JavaScript Developers
Azure DevOps for JavaScript Developers
 
Azure DevOps for the Data Professional
Azure DevOps for the Data ProfessionalAzure DevOps for the Data Professional
Azure DevOps for the Data Professional
 
Noodling with Data in Jupyter Notebook
Noodling with Data in Jupyter NotebookNoodling with Data in Jupyter Notebook
Noodling with Data in Jupyter Notebook
 
Pairing and mobbing
Pairing and mobbingPairing and mobbing
Pairing and mobbing
 
Becoming a Servant Leader, Leading from the Trenches
Becoming a Servant Leader, Leading from the TrenchesBecoming a Servant Leader, Leading from the Trenches
Becoming a Servant Leader, Leading from the Trenches
 
NEOISF - On Mentoring Future Techies
NEOISF - On Mentoring Future TechiesNEOISF - On Mentoring Future Techies
NEOISF - On Mentoring Future Techies
 
Becoming a Servant Leader
Becoming a Servant LeaderBecoming a Servant Leader
Becoming a Servant Leader
 
The importance of UX for Developers
The importance of UX for DevelopersThe importance of UX for Developers
The importance of UX for Developers
 
The Impact of Women Trailblazers in Tech
The Impact of Women Trailblazers in TechThe Impact of Women Trailblazers in Tech
The Impact of Women Trailblazers in Tech
 
Unstoppable Course Final Presentation
Unstoppable Course Final PresentationUnstoppable Course Final Presentation
Unstoppable Course Final Presentation
 
Even More Tools for the Developer's UX Toolbelt
Even More Tools for the Developer's UX ToolbeltEven More Tools for the Developer's UX Toolbelt
Even More Tools for the Developer's UX Toolbelt
 
History of Women in Tech
History of Women in TechHistory of Women in Tech
History of Women in Tech
 
History of Women in Tech - Trivia
History of Women in Tech - TriviaHistory of Women in Tech - Trivia
History of Women in Tech - Trivia
 
The UX Toolbelt for Developers
The UX Toolbelt for DevelopersThe UX Toolbelt for Developers
The UX Toolbelt for Developers
 
World Usability Day 2014 - UX Toolbelt for Developers
World Usability Day 2014 - UX Toolbelt for DevelopersWorld Usability Day 2014 - UX Toolbelt for Developers
World Usability Day 2014 - UX Toolbelt for Developers
 
The UX Toolbelt for Developers
The UX Toolbelt for DevelopersThe UX Toolbelt for Developers
The UX Toolbelt for Developers
 
The Case for the UX Developer
The Case for the UX DeveloperThe Case for the UX Developer
The Case for the UX Developer
 

Recently uploaded

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

Intro to Python for C# Developers

  • 2. A C# Dev’s Guide to Python Presented by: Sarah Dutkiewicz Microsoft MVP, Visual Studio and Development Technologies Microsoft Developers HK 13 June, 2018
  • 3. About the Presenter • 9 time Microsoft Most Valuable Professional – 2 years in Visual C#, 7 years in Visual Studio and Development Tools • Bachelor of Science in Computer Science & Engineering Technology • Published author of a PowerShell book • Live coding stream guest on Fritz and Friends and DevChatter • Why Hong Kong? #ancestraltrip!
  • 4. The Python Community Python’s community is vast; diverse & aims to grow; Python is Open. https://www.python.org/community/
  • 5. Diversity in Python The Python Software Foundation and the global Python community welcome and encourage participation by everyone. Our community is based on mutual respect, tolerance, and encouragement, and we are working to help each other live up to these principles. We want our community to be more diverse: whoever you are, and whatever your background, we welcome you. https://www.python.org/community/diversity/
  • 6. The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! https://www.python.org/dev/peps/pep-0020
  • 7. Areas Using Python • Analysis • Computation • Math • Science • Statistics • Engineering • Deep Learning • Artificial Intelligence • Machine Learning • Data Science
  • 8. Weakness of Python • The Great Python Schism • Hard version split between 2.x and 3.x • Some people are stuck on 2.x due to dependencies following the 2.x line • Greatly opinionated There should be one-- and preferably only one --obvious way to do it.
  • 9. Why Python 3? • Python 2 struggles with text and binary data • ‘abcd’ is both a string consisting of letters (textual) and a string consisting of bytes (binary) • Goes against the “preferably one way” part of the Zen of Python • Doesn’t do well with Unicode • Python was out before Unicode was a standard • Not all projects in Python 2 support Unicode equally • Python 3 • unicode/str/bytes types • Backwards-incompatible – but very much necessary, as Python is a language of the world
  • 10. Python Enhancement Proposals (PEPs) • https://www.python.org/dev/peps/ • Purpose and Guidelines for PEPs • Guidelines for Language Evolution • Deprecation of Standard Modules • Bug Fixes • Style Guides • Docstring Conventions • API for crypto • API for Python database • Python release schedules • … and more!
  • 11. Other Terms… • Benevolent Dictator for Life (BDFL) – Guido van Rossum, father of Python • Pythonista – Python developer • Pythonic – code follows common guidelines, written in idiomatic Python • Pythoneer – pioneers of Python, leaders who create change • A Pythoneer can be a Pythonista, but not all Pythonistas are Pythoneers.
  • 12. Some Tools to Know • Visual Studio with Python Tools • Visual Studio Code • Azure Notebooks • Repl.it • Jupyter Notebooks • PyCharm
  • 13. Package Management • Think NuGet only for Python • Pip (Pip Installs Packages) • Python’s official package manager • Virtualenv • Install pip packages in an isolated manner • Conda – conda.io • Not Python-specific – a cross-platform option similar to apt and yum • Part of Miniconda • Just conda and its dependencies • Also part of Anaconda • Conda, its dependencies, and many packages helpful in data science applications • More than one? Isn’t this anti-Zen? Yes, but… http://jakevdp.github.io/blog/2016/08/25/co nda-myths-and-misconceptions/
  • 14. Presentation Breakdown • Simple Python demos in a Jupyter Notebook – to be shared in an Azure Notebook • Variables • Conditional Structures • Loops • Functions • Exception Handling • Azure Notebook Library: https://notebooks.azure.com/cletechconsulting/libraries/ introtopyforcsharpdevs • More complex code using Visual Studio Community Edition with the Python Tools and/or Visual Studio Code • GitHub repo: https://github.com/sadukie/IntroToPyForCSharpDevs
  • 15. What version of Python am I running? Location Command Command-line python -V Within a Python environment import sys sys.version
  • 16. Key Points from Python Style Guide (PEP 8) • Indentation – 4 spaces • Optional for continuation lines • Make it readable and clearly identifiable • If tabs are already in use, continue with tabs • Do not mix tabs and spaces! • Maximum line length should be 79 characters • Easy for side-by-side files • Works well for code review situations • Docstrings and comments should be limited to 72 characters • Imports on separate lines, always at the top • Be consistent with quoting – single-quoted and double-quoted strings are the same. • Read more at https://www.python.org/dev/peps/pep-0008/#imports
  • 17. DEMO: Basics of Python If Internet is present: Azure Notebooks If Internet is not present: Jupyter Notebooks
  • 19. Object Orientation • Object oriented from the beginning • Classes with: • Data members (class variables and instance variables) • Methods • Class Variables vs Instance Variables • Class variables are accessed for all instances of a class • Within a class, outside of methods • Not common • Instance variables are managed by the instance
  • 20. Inheritance • Can inherit from multiple classes • Can check relationships with isinstance() and issubclass() • Parent class is accessed via super() method call • Typical to call parent’s __init__() from within child’s __init__() before moving on in the child’s initialization method • Child knows about parents through its __bases__attribute
  • 21. Interfaces • Not necessary in Python • No interface keyword in Python • Try to invoke a method we expect • Exception handling • hasattr checking • Duck typing If it talks and walks like a duck, then it is a duck
  • 22. Metaclasses • Things typically defined in the language specification in other languages • Classes’ classes • Class factories! • Can be stored in a __metaclass__ attribute • Can also be declared with metaclass= in the class declaration, following parameters • Most classes have the metaclass of type • Traverse the __class__ tree enough, and you’ll end at type
  • 23. Abstract Base Classes • ABCs! • abc module • ABCMeta metaclass • Use the pass keyword to not define the method’s body • Must also use the @abc.abstractmethod decorator • Can register classes as virtual subclasses of ABCs • Only useful for categorization • Does not know anything about its parent – nothing in __bases__ • Can throw errors if methods aren’t implemented
  • 26. Magic Methods • Key concept to understand for OO Python • Method names are surrounded by double underscores (“dunders”) • Sometimes called dunder methods • Object’s lifespan in magic methods • __new__ - redefined rarely; used to create new instances; phase 1 of the constructor • __init__ - initializer for the class; passed the instance; most commonly used in Python class definitions • __del__ - the destructor; no guarantee that __del__ will be executed
  • 27. Primary Uses for Magic Methods • Constructors / Destructors • Operator handling for Object types • Comparison • Unary Operators • Extended Operators
  • 28. More Magic Methods • Comparison • __eq__ - == • __ne__ - != • __lt__ - < • __gt__ - > • __le__ - <= • __ge__ - >= • Important keywords with these • self – this instance • other – instance to compare to
  • 30. Desktop Application Development • Tkinter (“Tk interface”) – Defacto GUI creation in Python for writing desktop apps based on Tcl/Tk • PyQt – Python package for writing desktop apps based on Qt • If you prefer GTK: • PyGObject • pygtk http://www.pygame.org https://kivy.org
  • 34. Taken from my Jupyter Notebook DataCamp notes…
  • 35. SQL Server 2017 & Machine Learning • Run Python in the server • Brings computation to the data • revoscalepy: https://docs.microsoft.com/en-us/machine-learning- server/python-reference/revoscalepy/revoscalepy-package
  • 36. Learn More! • Seminar of Machine Learning in Python – Open Source Hong Kong – led by Delon Yau, Software Engineer, Microsoft - https://www.meetup.com/opensourcehk/events/251121245/ • Getting Started with Python in Visual Studio Code: https://code.visualstudio.com/docs/python/python-tutorial • Python Tools for Visual Studio: https://www.visualstudio.com/vs/features/python/ • Python at Microsoft blog: https://blogs.msdn.microsoft.com/pythonengineering/
  • 37. Contact Information • Twitter: @sadukie • GitHub: sadukie • LinkedIn: https://linkedin.com/in/sadukie • Email: sarah@cletechconsulting.com

Editor's Notes

  1. Abstract: As technology continues to evolve, our toolset as developers evolves as well. While we can use C# for many things, other languages are growing in popularity in other areas - such as Python being used in AI, ML, and other aspects of data science. In this session, we will see how we do things in Python compared to what we do in C#. Some of the tools we will look at include Anaconda with Visual Studio Code and Visual Studio's Python tooling.
  2. * Source: Why Python 3 Exists - https://snarky.ca/why-python-3-exists/