SlideShare a Scribd company logo
1 of 76
Download to read offline
On the Usage of Pythonic Idioms
Carol V. Alexandru¹, José J. Merchante², Sebastiano Panichella¹,
³
Sebastian Proksch¹, Harald C. Gall¹, Gregorio Robles²
¹Software Evolution and Architecture Lab, University of Zurich, Switzerland
{alexandru,proksch,gall}@ifi.uzh.ch
²Grupo de Sistemas y Comunicaciones, Universidad Rey Juan Carlos, Spain
jj.merchante@alumnos.urjc.es, grex@gsyc.urjc.es
³Service Prototype Lab, Zurich University of Applied Sciences, Switzerland
panc@zhaw.ch
Onward! 2018
Boston Park Plaza Hotel
Boston, Massachusetts, United States
07 November 2018
Harald C.
Gall
Sebastiano
Panichella
Carol V.
Alexandru
Sebastian
Proksch
Gregorio
Robles
José J.
Merchante
4
Things to know about Python
5
Things to know about Python
●
Created by Guido van Rossum
6
Things to know about Python
●
Created by Guido van Rossum
– He is (was) the “Benevolent Dictator for Life”
– Makes the final decisions when necessary
7
Things to know about Python
●
Created by Guido van Rossum
– He is (was) the “Benevolent Dictator for Life”
– Makes the final decisions when necessary
●
Strong principles
– The “Zen of Python” >>> import this
8
Things to know about Python
9
Things to know about Python
●
Created by Guido van Rossum
– He is (was) the “Benevolent Dictator for Life”
– Makes the final decisions when necessary
●
Strong principles
– The “Zen of Python” >>> import this
– Python Enhancement Proposals (PEPs)
10
Things to know about Python
●
Created by Guido van Rossum
– He is (was) the “Benevolent Dictator for Life”
– Makes the final decisions when necessary
●
Strong principles
– The “Zen of Python” >>> import this
– Python Enhancement Proposals (PEPs)
●
Widespread adoption across many fields
11
Pythonic appears to be 'a thing'
12
Pythonic appears to be 'a thing'
“It would be
more pythonic
to...”
13
A simple question
14
Top Answer claims to be “pythonic”...
15
...but 100s of people seem sceptical
16
“Pythonic” because of the style guide (PEP 8)
17
“Pythonic” because of performance
18
Idioms and signaling
19
Idioms and signaling
20
And there are exceptions
21
Creative use of the word “Pythonic”
22
Is there a definition for “Pythonic”?
23
Is there a definition for “Pythonic”?
24
Is there a definition for “Pythonic”?
25
Is there a definition for “Pythonic”?
26
Pythonic vs. Non-pythonic
27
Pythonic vs. Non-pythonic
28
Pythonic vs. Non-pythonic
29
Is there a definition for “Pythonic”?
So it's “Using Python-specific syntax and concepts”, right?
But what do developers believe?
30
Let's ask a few developers
Interviews done
●
in Person
●
at a Python conference
●
in Spain
●
using open questions
31
Let's ask a few developers
Interviews done
●
in Person
●
at a Python conference
●
in Spain
●
using open questions
32
What does Pythonic mean?
33
What does Pythonic mean?
“makes code easier to
understand and maintain”
“elegant and readable code”
“boosts readability and
performance”
34
What does Pythonic mean?
“makes code easier to
understand and maintain”
“using features provided
by the language or
standard library”
“elegant and readable code”
“boosts readability and
performance”
35
What does Pythonic mean?
“makes code easier to
understand and maintain”
“using features provided
by the language or
standard library”
“elegant and readable code”
“boosts readability and
performance”
“simply the most
accepted way of writing
python”
36
Using Python idioms != Pythonic
37
Using Python idioms != Pythonic
→ Using idioms != Pythonic code
→ Using idioms != always more readable
38
Novice vs. Pro
Novice:
– Better style
– Fewer lines of code
Pro:
– Using built-in functionality
– Efficient execution
39
Novice vs. Pro
Novice:
– Better style
– Fewer lines of code
– Using idioms
Pro:
– Using built-in functionality
– Efficient execution
– Writing elegant code
40
Novice vs. Pro
Novice:
– Better style
– Fewer lines of code
– Using idioms
– Simpler interpretation
Pro:
– Using built-in functionality
– Efficient execution
– Writing elegant code
– Less concrete interpretation
41
Learning 'Pythonic'?
42
Learning 'Pythonic'?
“StackOverflow shows you multiple points of
view of people, and you always learn.”
43
Learning 'Pythonic'?
“StackOverflow shows you multiple points of
view of people, and you always learn.”
“reading code in repositories of other projects”
“saw them in documentation”
44
Learning 'Pythonic'?
“StackOverflow shows you multiple points of
view of people, and you always learn.”
“reading code in repositories of other projects”
“from colleagues
during code review”
“saw them in documentation”
45
Learning 'Pythonic'?
“StackOverflow shows you multiple points of
view of people, and you always learn.”
“Becoming a pythonic programmer takes time”
“My code became more
pythonic year after year”
“reading code in repositories of other projects”
“from colleagues
during code review”
“saw them in documentation”
46
Learning 'Pythonic'?
“StackOverflow shows you multiple points of
view of people, and you always learn.”
“Becoming a pythonic programmer takes time”
“My code became more
pythonic year after year”
“reading code in repositories of other projects”
“from colleagues
during code review”
“saw them in documentation”
→ Pythonic not taught in books or lectures
→ Seems to creep in with experience
47
Do you care? Do your peers care?
48
Do you care? Do your peers care?
“Pythonic code is positively
viewed but not required”
49
Do you care? Do your peers care?
“Pythonic code is positively
viewed but not required”
“If you're a novice Python programmer,
better focus on general programming skills”
50
Do you care? Do your peers care?
“Pythonic idioms can at least
be used to measure a
developer’s knowledge.”
“Pythonic code is positively
viewed but not required”
“If you're a novice Python programmer,
better focus on general programming skills”
51
Do you care? Do your peers care?
“Pythonic idioms can at least
be used to measure a
developer’s knowledge.”
“Pythonic code is positively
viewed but not required”
“If you're a novice Python programmer,
better focus on general programming skills”
“If I learn a new idiom I add it to my toolbox and then when I touch
something, I modify it and leave it better, but it’s not an obsession.
52
Do you care? Do your peers care?
“Pythonic idioms can at least
be used to measure a
developer’s knowledge.”
“Pythonic code is positively
viewed but not required”
“If you're a novice Python programmer,
better focus on general programming skills”
“If I learn a new idiom I add it to my toolbox and then when I touch
something, I modify it and leave it better, but it’s not an obsession.
→ Pythonic important, but not formally
→ Pythonic signals expertise and garners respect
53
A catalogue of Pythonic Idioms
54
A catalogue of Pythonic Idioms
●
Published online at http://pythonic.libresoft.info/catalogue
– including examples, references and benchmarks
55
A catalogue of Pythonic Idioms
●
Published online at http://pythonic.libresoft.info/catalogue
– including examples, references and benchmarks
●
Compiled from
– Several books (on learning and applying Python)
– Online statements by influential and renowned Python developers
56
A catalogue of Pythonic Idioms
●
Published online at http://pythonic.libresoft.info/catalogue
– including examples, references and benchmarks
●
Compiled from
– Several books (on learning and applying Python)
– Online statements by influential and renowned Python developers
●
Classified into “performance” and “readability”
– performance measured using benchmarks
57
A catalogue of Pythonic Idioms
58
Empirical study
59
Empirical study setup
●
Most recent commit in 1000 Python projects from GitHub
– >1mb, sorted by stars, cleaned for books etc., no forks, not archived
– 178,735 files, 38,505,577 lines of code
60
Empirical study setup
●
Most recent commit in 1000 Python projects from GitHub
– >1mb, sorted by stars, cleaned for books etc., no forks, not archived
– 178,735 files, 38,505,577 lines of code
●
Analyzed using LISA (http://t.uzh.ch/Fk)
– AST-based detection of all idioms
61
Empirical study setup
●
Most recent commit in 1000 Python projects from GitHub
– >1mb, sorted by stars, cleaned for books etc., no forks, not archived
– 178,735 files, 38,505,577 lines of code
●
Analyzed using LISA (http://t.uzh.ch/Fk)
– AST-based detection of all idioms
●
Idiom occurences in #projects and total occurence count
62
Empirical study - a quick look
Idiom # projects (out of 1000) # of occurences
List comprehension 866 75,466
Generator expressions 709 33,038
Dict comprehension 146 796
63
Empirical study - a quick look
Idiom # projects (out of 1000) # of occurences
List comprehension 866 75,466
Generator expressions 709 33,038
Dict comprehension 146 796
Simple magic methods
Intermediate magic methods
Advanced magic methods
64
Empirical study - a quick look
Idiom # projects (out of 1000) # of occurences
List comprehension 866 75,466
Generator expressions 709 33,038
Dict comprehension 146 796
Simple magic methods
Intermediate magic methods
Advanced magic methods
__nonzero__(self)
Defines behavior for when bool() is called on an instance of your class.
Should return True or False, depending on whether you would want to
consider the instance to be True or False.
Magic methods
65
Empirical study - a quick look
Idiom # projects (out of 1000) # of occurences
List comprehension 866 75,466
Generator expressions 709 33,038
Dict comprehension 146 796
Simple magic methods 759 78,376
Intermediate magic methods 417 13,255
Advanced magic methods 190 2,613
66
Empirical study - a quick look
Idiom # projects (out of 1000) # of occurences
List comprehension 866 75,466
Generator expressions 709 33,038
Dict comprehension 146 796
Simple magic methods 759 78,376
Intermediate magic methods 417 13,255
Advanced magic methods 190 2,613
→ More in-depth research is needed
→ Detecting anti-idioms is difficult
67
What we learned so far
●
“Pythonic” is important - somehow
68
What we learned so far
●
“Pythonic” is important - somehow
●
“Pythonic” encompasses more than just programming idioms
69
What we learned so far
●
“Pythonic” is important - somehow
●
“Pythonic” encompasses more than just programming idioms
●
Using “Pythonic idioms”...
– makes you appear more knowledgeable
– alone does not necessarily make your code better or more pythonic
70
What we learned so far
●
“Pythonic” is important - somehow
●
“Pythonic” encompasses more than just programming idioms
●
Using “Pythonic idioms”...
– makes you appear more knowledgeable
– alone does not necessarily make your code better or more pythonic
●
“Pythonic” does not always mean “more readable” for everyone
71
What we learned so far
●
“Pythonic” is important - somehow
●
“Pythonic” encompasses more than just programming idioms
●
Using “Pythonic idioms”...
– makes you appear more knowledgeable
– alone does not necessarily make your code better or more pythonic
●
“Pythonic” does not always mean “more readable” for everyone
●
“Pythonic” is not learned systematically
72
Questions remain...
●
Is there something special in the culture of Python?
– The Zen of Python / “one way to do it”
– Why are there no words like “Rubyist”, “Javanese” or “C#y”
73
Questions remain...
●
Is there something special in the culture of Python?
– The Zen of Python / “one way to do it”
– Why are there no words like “Rubyist”, “Javanese” or “C#y”
●
If “Pythonic” is not just syntax and idioms, what is it?
74
Questions remain...
●
Is there something special in the culture of Python?
– The Zen of Python / “one way to do it”
– Why are there no words like “Rubyist”, “Javanese” or “C#y”
●
If “Pythonic” is not just syntax and idioms, what is it?
●
Does “Pythonic” correlate with code quality?
75
Questions remain...
●
Is there something special in the culture of Python?
– The Zen of Python / “one way to do it”
– Why are there no words like “Rubyist”, “Javanese” or “C#y”
●
If “Pythonic” is not just syntax and idioms, what is it?
●
Does “Pythonic” correlate with code quality?
●
Is “Pythonic” just a posh mark of pride serving to create a two-tier
society within the Python community?
Carol V. Alexandru¹, José J. Merchante², Sebastiano Panichella¹,
³
Sebastian Proksch¹, Harald C. Gall¹, Gregorio Robles²
Read the paper: http://t.uzh.ch/S7
Get the slides: http://t.uzh.ch/Sb
Browse the catalogue: http://pythonic.libresoft.info/catalogue
On the Usage of Pythonic Idioms

More Related Content

What's hot

【2000行弱!】x86用自作カーネルの紹介
【2000行弱!】x86用自作カーネルの紹介【2000行弱!】x86用自作カーネルの紹介
【2000行弱!】x86用自作カーネルの紹介Yuma Ohgami
 
A.I robotic presentation
A.I robotic presentation  A.I robotic presentation
A.I robotic presentation Danish khan
 
Deep Reinforcement Learning
Deep Reinforcement LearningDeep Reinforcement Learning
Deep Reinforcement LearningUsman Qayyum
 
Chain-of-thought Prompting.pptx
Chain-of-thought Prompting.pptxChain-of-thought Prompting.pptx
Chain-of-thought Prompting.pptxNeethaSherra1
 
강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introduction강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introductionTaehoon Kim
 
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language UnderstandingBERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language Understandinggohyunwoong
 
Rustで楽しむ競技プログラミング
Rustで楽しむ競技プログラミングRustで楽しむ競技プログラミング
Rustで楽しむ競技プログラミングyoshrc
 
Chain-Of-Thought Prompting.pptx
Chain-Of-Thought Prompting.pptxChain-Of-Thought Prompting.pptx
Chain-Of-Thought Prompting.pptxatharva553835
 
Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)Piyush Chand
 
Educational robotics
Educational roboticsEducational robotics
Educational roboticsJillPears
 
Python用ゲームエンジンPyxelで遊んでみた
Python用ゲームエンジンPyxelで遊んでみたPython用ゲームエンジンPyxelで遊んでみた
Python用ゲームエンジンPyxelで遊んでみたHirofumi Watanabe
 
5. phases of nlp
5. phases of nlp5. phases of nlp
5. phases of nlpmonircse2
 
wireless pick and place robotic arm
wireless pick and place robotic armwireless pick and place robotic arm
wireless pick and place robotic armAyush Verma
 
Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法
Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法
Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法Hiroshi Yoshida
 

What's hot (19)

【2000行弱!】x86用自作カーネルの紹介
【2000行弱!】x86用自作カーネルの紹介【2000行弱!】x86用自作カーネルの紹介
【2000行弱!】x86用自作カーネルの紹介
 
A.I robotic presentation
A.I robotic presentation  A.I robotic presentation
A.I robotic presentation
 
Deep Reinforcement Learning
Deep Reinforcement LearningDeep Reinforcement Learning
Deep Reinforcement Learning
 
Chain-of-thought Prompting.pptx
Chain-of-thought Prompting.pptxChain-of-thought Prompting.pptx
Chain-of-thought Prompting.pptx
 
Universal Robots
Universal RobotsUniversal Robots
Universal Robots
 
arc047
arc047arc047
arc047
 
강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introduction강화 학습 기초 Reinforcement Learning an introduction
강화 학습 기초 Reinforcement Learning an introduction
 
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language UnderstandingBERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
 
Rustで楽しむ競技プログラミング
Rustで楽しむ競技プログラミングRustで楽しむ競技プログラミング
Rustで楽しむ競技プログラミング
 
Chain-Of-Thought Prompting.pptx
Chain-Of-Thought Prompting.pptxChain-Of-Thought Prompting.pptx
Chain-Of-Thought Prompting.pptx
 
Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)
 
Educational robotics
Educational roboticsEducational robotics
Educational robotics
 
Python用ゲームエンジンPyxelで遊んでみた
Python用ゲームエンジンPyxelで遊んでみたPython用ゲームエンジンPyxelで遊んでみた
Python用ゲームエンジンPyxelで遊んでみた
 
Introduction to Robotics
Introduction to RoboticsIntroduction to Robotics
Introduction to Robotics
 
5. phases of nlp
5. phases of nlp5. phases of nlp
5. phases of nlp
 
How AlphaGo Works
How AlphaGo WorksHow AlphaGo Works
How AlphaGo Works
 
wireless pick and place robotic arm
wireless pick and place robotic armwireless pick and place robotic arm
wireless pick and place robotic arm
 
Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法
Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法
Android上での3D(OpenGL)描画の基礎とNDKによる実践的高速化手法
 
Gpt models
Gpt modelsGpt models
Gpt models
 

Similar to On the Usage of Pythonic Idioms

Statistical Entity Linking
Statistical Entity LinkingStatistical Entity Linking
Statistical Entity LinkingPyDataParis
 
Software Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical SciencesSoftware Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical SciencesAron Ahmadia
 
OpenFest 2012 : Leveraging the public internet
OpenFest 2012 : Leveraging the public internetOpenFest 2012 : Leveraging the public internet
OpenFest 2012 : Leveraging the public internettkisason
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of PythonAsia Smith
 
Scientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of dataScientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of dataGael Varoquaux
 
Python on Science ? Yes, We can.
Python on Science ?   Yes, We can.Python on Science ?   Yes, We can.
Python on Science ? Yes, We can.Marcel Caraciolo
 
Research Objects for improved sharing and reproducibility
Research Objects for improved sharing and reproducibilityResearch Objects for improved sharing and reproducibility
Research Objects for improved sharing and reproducibilityOscar Corcho
 
Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python Chariza Pladin
 
Python for security professionals by katoh jeremiah [py con ng 2018]
Python for security professionals by katoh jeremiah [py con ng 2018]Python for security professionals by katoh jeremiah [py con ng 2018]
Python for security professionals by katoh jeremiah [py con ng 2018]jerrykatoh
 
No, you don't need to learn python
No, you don't need to learn pythonNo, you don't need to learn python
No, you don't need to learn pythonQuantUniversity
 
The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!Bruno Rocha
 
Software as a Well-Formed Research Object
Software as a Well-Formed Research ObjectSoftware as a Well-Formed Research Object
Software as a Well-Formed Research ObjectYasmin AlNoamany, PhD
 
SoC Python Discussion Group
SoC Python Discussion GroupSoC Python Discussion Group
SoC Python Discussion Groupkrishna_dubba
 
Python_Interview_Questions.pdf
Python_Interview_Questions.pdfPython_Interview_Questions.pdf
Python_Interview_Questions.pdfSamir Paul
 
Python indroduction
Python indroductionPython indroduction
Python indroductionFEG
 
DRONE: A Tool to Detect and Repair Directive Defects in Java APIs Documentation
DRONE: A Tool to Detect and Repair Directive Defects in Java APIs DocumentationDRONE: A Tool to Detect and Repair Directive Defects in Java APIs Documentation
DRONE: A Tool to Detect and Repair Directive Defects in Java APIs DocumentationSebastiano Panichella
 

Similar to On the Usage of Pythonic Idioms (20)

Statistical Entity Linking
Statistical Entity LinkingStatistical Entity Linking
Statistical Entity Linking
 
interviewbit.pdf
interviewbit.pdfinterviewbit.pdf
interviewbit.pdf
 
Software Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical SciencesSoftware Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical Sciences
 
OpenFest 2012 : Leveraging the public internet
OpenFest 2012 : Leveraging the public internetOpenFest 2012 : Leveraging the public internet
OpenFest 2012 : Leveraging the public internet
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
 
Scientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of dataScientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of data
 
Python on Science ? Yes, We can.
Python on Science ?   Yes, We can.Python on Science ?   Yes, We can.
Python on Science ? Yes, We can.
 
Research Objects for improved sharing and reproducibility
Research Objects for improved sharing and reproducibilityResearch Objects for improved sharing and reproducibility
Research Objects for improved sharing and reproducibility
 
Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python Top Libraries for Machine Learning with Python
Top Libraries for Machine Learning with Python
 
Python for security professionals by katoh jeremiah [py con ng 2018]
Python for security professionals by katoh jeremiah [py con ng 2018]Python for security professionals by katoh jeremiah [py con ng 2018]
Python for security professionals by katoh jeremiah [py con ng 2018]
 
No, you don't need to learn python
No, you don't need to learn pythonNo, you don't need to learn python
No, you don't need to learn python
 
The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!
 
Software as a Well-Formed Research Object
Software as a Well-Formed Research ObjectSoftware as a Well-Formed Research Object
Software as a Well-Formed Research Object
 
SoC Python Discussion Group
SoC Python Discussion GroupSoC Python Discussion Group
SoC Python Discussion Group
 
Python_Interview_Questions.pdf
Python_Interview_Questions.pdfPython_Interview_Questions.pdf
Python_Interview_Questions.pdf
 
The Python Workshop.pdf
The Python Workshop.pdfThe Python Workshop.pdf
The Python Workshop.pdf
 
Python indroduction
Python indroductionPython indroduction
Python indroduction
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
Doing the Impossible
Doing the ImpossibleDoing the Impossible
Doing the Impossible
 
DRONE: A Tool to Detect and Repair Directive Defects in Java APIs Documentation
DRONE: A Tool to Detect and Repair Directive Defects in Java APIs DocumentationDRONE: A Tool to Detect and Repair Directive Defects in Java APIs Documentation
DRONE: A Tool to Detect and Repair Directive Defects in Java APIs Documentation
 

More from Sebastiano Panichella

The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...
Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...
Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...Sebastiano Panichella
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSebastiano Panichella
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...Sebastiano Panichella
 
COSMOS: DevOps for Complex Cyber-physical Systems
COSMOS: DevOps for Complex Cyber-physical SystemsCOSMOS: DevOps for Complex Cyber-physical Systems
COSMOS: DevOps for Complex Cyber-physical SystemsSebastiano Panichella
 
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...Sebastiano Panichella
 
An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...
An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...
An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...Sebastiano Panichella
 
Automated Identification and Qualitative Characterization of Safety Concerns ...
Automated Identification and Qualitative Characterization of Safety Concerns ...Automated Identification and Qualitative Characterization of Safety Concerns ...
Automated Identification and Qualitative Characterization of Safety Concerns ...Sebastiano Panichella
 
The 2nd Intl. Workshop on NL-based Software Engineering
The 2nd Intl. Workshop on NL-based Software EngineeringThe 2nd Intl. Workshop on NL-based Software Engineering
The 2nd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
The 16th Intl. Workshop on Search-Based and Fuzz Testing
The 16th Intl. Workshop on Search-Based and Fuzz TestingThe 16th Intl. Workshop on Search-Based and Fuzz Testing
The 16th Intl. Workshop on Search-Based and Fuzz TestingSebastiano Panichella
 
Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...
Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...
Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...Sebastiano Panichella
 
Exposed! A case study on the vulnerability-proneness of Google Play Apps
Exposed! A case study on the vulnerability-proneness of Google Play AppsExposed! A case study on the vulnerability-proneness of Google Play Apps
Exposed! A case study on the vulnerability-proneness of Google Play AppsSebastiano Panichella
 
Search-based Software Testing (SBST) '22
Search-based Software Testing (SBST) '22Search-based Software Testing (SBST) '22
Search-based Software Testing (SBST) '22Sebastiano Panichella
 
NL-based Software Engineering (NLBSE) '22
NL-based Software Engineering (NLBSE) '22NL-based Software Engineering (NLBSE) '22
NL-based Software Engineering (NLBSE) '22Sebastiano Panichella
 
"An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.
 "An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.  "An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.
"An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021. Sebastiano Panichella
 
An Empirical Investigation of Relevant Changes and Automation Needs in Modern...
An Empirical Investigation of Relevant Changes and Automation Needs in Modern...An Empirical Investigation of Relevant Changes and Automation Needs in Modern...
An Empirical Investigation of Relevant Changes and Automation Needs in Modern...Sebastiano Panichella
 
Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...
Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...
Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...Sebastiano Panichella
 

More from Sebastiano Panichella (20)

The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...
Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...
Diversity-guided Search Exploration for Self-driving Cars Test Generation thr...
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...
 
COSMOS: DevOps for Complex Cyber-physical Systems
COSMOS: DevOps for Complex Cyber-physical SystemsCOSMOS: DevOps for Complex Cyber-physical Systems
COSMOS: DevOps for Complex Cyber-physical Systems
 
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
 
An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...
An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...
An Empirical Characterization of Software Bugs in Open-Source Cyber-Physical ...
 
Automated Identification and Qualitative Characterization of Safety Concerns ...
Automated Identification and Qualitative Characterization of Safety Concerns ...Automated Identification and Qualitative Characterization of Safety Concerns ...
Automated Identification and Qualitative Characterization of Safety Concerns ...
 
The 2nd Intl. Workshop on NL-based Software Engineering
The 2nd Intl. Workshop on NL-based Software EngineeringThe 2nd Intl. Workshop on NL-based Software Engineering
The 2nd Intl. Workshop on NL-based Software Engineering
 
The 16th Intl. Workshop on Search-Based and Fuzz Testing
The 16th Intl. Workshop on Search-Based and Fuzz TestingThe 16th Intl. Workshop on Search-Based and Fuzz Testing
The 16th Intl. Workshop on Search-Based and Fuzz Testing
 
Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...
Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...
Simulation-based Test Case Generation for Unmanned Aerial Vehicles in the Nei...
 
Exposed! A case study on the vulnerability-proneness of Google Play Apps
Exposed! A case study on the vulnerability-proneness of Google Play AppsExposed! A case study on the vulnerability-proneness of Google Play Apps
Exposed! A case study on the vulnerability-proneness of Google Play Apps
 
Search-based Software Testing (SBST) '22
Search-based Software Testing (SBST) '22Search-based Software Testing (SBST) '22
Search-based Software Testing (SBST) '22
 
NL-based Software Engineering (NLBSE) '22
NL-based Software Engineering (NLBSE) '22NL-based Software Engineering (NLBSE) '22
NL-based Software Engineering (NLBSE) '22
 
NLBSE’22: Tool Competition
NLBSE’22: Tool CompetitionNLBSE’22: Tool Competition
NLBSE’22: Tool Competition
 
"An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.
 "An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.  "An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.
"An NLP-based Tool for Software Artifacts Analysis" at @ICSME2021.
 
An Empirical Investigation of Relevant Changes and Automation Needs in Modern...
An Empirical Investigation of Relevant Changes and Automation Needs in Modern...An Empirical Investigation of Relevant Changes and Automation Needs in Modern...
An Empirical Investigation of Relevant Changes and Automation Needs in Modern...
 
Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...
Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...
Search-Based Software Testing Tool Competition 2021 by Sebastiano Panichella,...
 

Recently uploaded

Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCamilleBoulbin1
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Vipesco
 
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Delhi Call girls
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfSenaatti-kiinteistöt
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...amilabibi1
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedDelhi Call girls
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxraffaeleoman
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalFabian de Rijk
 
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...Pooja Nehwal
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lodhisaajjda
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfSkillCertProExams
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoKayode Fayemi
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaKayode Fayemi
 

Recently uploaded (18)

ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptx
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 

On the Usage of Pythonic Idioms

  • 1. On the Usage of Pythonic Idioms Carol V. Alexandru¹, José J. Merchante², Sebastiano Panichella¹, ³ Sebastian Proksch¹, Harald C. Gall¹, Gregorio Robles² ¹Software Evolution and Architecture Lab, University of Zurich, Switzerland {alexandru,proksch,gall}@ifi.uzh.ch ²Grupo de Sistemas y Comunicaciones, Universidad Rey Juan Carlos, Spain jj.merchante@alumnos.urjc.es, grex@gsyc.urjc.es ³Service Prototype Lab, Zurich University of Applied Sciences, Switzerland panc@zhaw.ch Onward! 2018 Boston Park Plaza Hotel Boston, Massachusetts, United States 07 November 2018
  • 2.
  • 4. 4 Things to know about Python
  • 5. 5 Things to know about Python ● Created by Guido van Rossum
  • 6. 6 Things to know about Python ● Created by Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary
  • 7. 7 Things to know about Python ● Created by Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary ● Strong principles – The “Zen of Python” >>> import this
  • 8. 8 Things to know about Python
  • 9. 9 Things to know about Python ● Created by Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary ● Strong principles – The “Zen of Python” >>> import this – Python Enhancement Proposals (PEPs)
  • 10. 10 Things to know about Python ● Created by Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary ● Strong principles – The “Zen of Python” >>> import this – Python Enhancement Proposals (PEPs) ● Widespread adoption across many fields
  • 11. 11 Pythonic appears to be 'a thing'
  • 12. 12 Pythonic appears to be 'a thing' “It would be more pythonic to...”
  • 14. 14 Top Answer claims to be “pythonic”...
  • 15. 15 ...but 100s of people seem sceptical
  • 16. 16 “Pythonic” because of the style guide (PEP 8)
  • 20. 20 And there are exceptions
  • 21. 21 Creative use of the word “Pythonic”
  • 22. 22 Is there a definition for “Pythonic”?
  • 23. 23 Is there a definition for “Pythonic”?
  • 24. 24 Is there a definition for “Pythonic”?
  • 25. 25 Is there a definition for “Pythonic”?
  • 29. 29 Is there a definition for “Pythonic”? So it's “Using Python-specific syntax and concepts”, right? But what do developers believe?
  • 30. 30 Let's ask a few developers Interviews done ● in Person ● at a Python conference ● in Spain ● using open questions
  • 31. 31 Let's ask a few developers Interviews done ● in Person ● at a Python conference ● in Spain ● using open questions
  • 33. 33 What does Pythonic mean? “makes code easier to understand and maintain” “elegant and readable code” “boosts readability and performance”
  • 34. 34 What does Pythonic mean? “makes code easier to understand and maintain” “using features provided by the language or standard library” “elegant and readable code” “boosts readability and performance”
  • 35. 35 What does Pythonic mean? “makes code easier to understand and maintain” “using features provided by the language or standard library” “elegant and readable code” “boosts readability and performance” “simply the most accepted way of writing python”
  • 36. 36 Using Python idioms != Pythonic
  • 37. 37 Using Python idioms != Pythonic → Using idioms != Pythonic code → Using idioms != always more readable
  • 38. 38 Novice vs. Pro Novice: – Better style – Fewer lines of code Pro: – Using built-in functionality – Efficient execution
  • 39. 39 Novice vs. Pro Novice: – Better style – Fewer lines of code – Using idioms Pro: – Using built-in functionality – Efficient execution – Writing elegant code
  • 40. 40 Novice vs. Pro Novice: – Better style – Fewer lines of code – Using idioms – Simpler interpretation Pro: – Using built-in functionality – Efficient execution – Writing elegant code – Less concrete interpretation
  • 42. 42 Learning 'Pythonic'? “StackOverflow shows you multiple points of view of people, and you always learn.”
  • 43. 43 Learning 'Pythonic'? “StackOverflow shows you multiple points of view of people, and you always learn.” “reading code in repositories of other projects” “saw them in documentation”
  • 44. 44 Learning 'Pythonic'? “StackOverflow shows you multiple points of view of people, and you always learn.” “reading code in repositories of other projects” “from colleagues during code review” “saw them in documentation”
  • 45. 45 Learning 'Pythonic'? “StackOverflow shows you multiple points of view of people, and you always learn.” “Becoming a pythonic programmer takes time” “My code became more pythonic year after year” “reading code in repositories of other projects” “from colleagues during code review” “saw them in documentation”
  • 46. 46 Learning 'Pythonic'? “StackOverflow shows you multiple points of view of people, and you always learn.” “Becoming a pythonic programmer takes time” “My code became more pythonic year after year” “reading code in repositories of other projects” “from colleagues during code review” “saw them in documentation” → Pythonic not taught in books or lectures → Seems to creep in with experience
  • 47. 47 Do you care? Do your peers care?
  • 48. 48 Do you care? Do your peers care? “Pythonic code is positively viewed but not required”
  • 49. 49 Do you care? Do your peers care? “Pythonic code is positively viewed but not required” “If you're a novice Python programmer, better focus on general programming skills”
  • 50. 50 Do you care? Do your peers care? “Pythonic idioms can at least be used to measure a developer’s knowledge.” “Pythonic code is positively viewed but not required” “If you're a novice Python programmer, better focus on general programming skills”
  • 51. 51 Do you care? Do your peers care? “Pythonic idioms can at least be used to measure a developer’s knowledge.” “Pythonic code is positively viewed but not required” “If you're a novice Python programmer, better focus on general programming skills” “If I learn a new idiom I add it to my toolbox and then when I touch something, I modify it and leave it better, but it’s not an obsession.
  • 52. 52 Do you care? Do your peers care? “Pythonic idioms can at least be used to measure a developer’s knowledge.” “Pythonic code is positively viewed but not required” “If you're a novice Python programmer, better focus on general programming skills” “If I learn a new idiom I add it to my toolbox and then when I touch something, I modify it and leave it better, but it’s not an obsession. → Pythonic important, but not formally → Pythonic signals expertise and garners respect
  • 53. 53 A catalogue of Pythonic Idioms
  • 54. 54 A catalogue of Pythonic Idioms ● Published online at http://pythonic.libresoft.info/catalogue – including examples, references and benchmarks
  • 55. 55 A catalogue of Pythonic Idioms ● Published online at http://pythonic.libresoft.info/catalogue – including examples, references and benchmarks ● Compiled from – Several books (on learning and applying Python) – Online statements by influential and renowned Python developers
  • 56. 56 A catalogue of Pythonic Idioms ● Published online at http://pythonic.libresoft.info/catalogue – including examples, references and benchmarks ● Compiled from – Several books (on learning and applying Python) – Online statements by influential and renowned Python developers ● Classified into “performance” and “readability” – performance measured using benchmarks
  • 57. 57 A catalogue of Pythonic Idioms
  • 59. 59 Empirical study setup ● Most recent commit in 1000 Python projects from GitHub – >1mb, sorted by stars, cleaned for books etc., no forks, not archived – 178,735 files, 38,505,577 lines of code
  • 60. 60 Empirical study setup ● Most recent commit in 1000 Python projects from GitHub – >1mb, sorted by stars, cleaned for books etc., no forks, not archived – 178,735 files, 38,505,577 lines of code ● Analyzed using LISA (http://t.uzh.ch/Fk) – AST-based detection of all idioms
  • 61. 61 Empirical study setup ● Most recent commit in 1000 Python projects from GitHub – >1mb, sorted by stars, cleaned for books etc., no forks, not archived – 178,735 files, 38,505,577 lines of code ● Analyzed using LISA (http://t.uzh.ch/Fk) – AST-based detection of all idioms ● Idiom occurences in #projects and total occurence count
  • 62. 62 Empirical study - a quick look Idiom # projects (out of 1000) # of occurences List comprehension 866 75,466 Generator expressions 709 33,038 Dict comprehension 146 796
  • 63. 63 Empirical study - a quick look Idiom # projects (out of 1000) # of occurences List comprehension 866 75,466 Generator expressions 709 33,038 Dict comprehension 146 796 Simple magic methods Intermediate magic methods Advanced magic methods
  • 64. 64 Empirical study - a quick look Idiom # projects (out of 1000) # of occurences List comprehension 866 75,466 Generator expressions 709 33,038 Dict comprehension 146 796 Simple magic methods Intermediate magic methods Advanced magic methods __nonzero__(self) Defines behavior for when bool() is called on an instance of your class. Should return True or False, depending on whether you would want to consider the instance to be True or False. Magic methods
  • 65. 65 Empirical study - a quick look Idiom # projects (out of 1000) # of occurences List comprehension 866 75,466 Generator expressions 709 33,038 Dict comprehension 146 796 Simple magic methods 759 78,376 Intermediate magic methods 417 13,255 Advanced magic methods 190 2,613
  • 66. 66 Empirical study - a quick look Idiom # projects (out of 1000) # of occurences List comprehension 866 75,466 Generator expressions 709 33,038 Dict comprehension 146 796 Simple magic methods 759 78,376 Intermediate magic methods 417 13,255 Advanced magic methods 190 2,613 → More in-depth research is needed → Detecting anti-idioms is difficult
  • 67. 67 What we learned so far ● “Pythonic” is important - somehow
  • 68. 68 What we learned so far ● “Pythonic” is important - somehow ● “Pythonic” encompasses more than just programming idioms
  • 69. 69 What we learned so far ● “Pythonic” is important - somehow ● “Pythonic” encompasses more than just programming idioms ● Using “Pythonic idioms”... – makes you appear more knowledgeable – alone does not necessarily make your code better or more pythonic
  • 70. 70 What we learned so far ● “Pythonic” is important - somehow ● “Pythonic” encompasses more than just programming idioms ● Using “Pythonic idioms”... – makes you appear more knowledgeable – alone does not necessarily make your code better or more pythonic ● “Pythonic” does not always mean “more readable” for everyone
  • 71. 71 What we learned so far ● “Pythonic” is important - somehow ● “Pythonic” encompasses more than just programming idioms ● Using “Pythonic idioms”... – makes you appear more knowledgeable – alone does not necessarily make your code better or more pythonic ● “Pythonic” does not always mean “more readable” for everyone ● “Pythonic” is not learned systematically
  • 72. 72 Questions remain... ● Is there something special in the culture of Python? – The Zen of Python / “one way to do it” – Why are there no words like “Rubyist”, “Javanese” or “C#y”
  • 73. 73 Questions remain... ● Is there something special in the culture of Python? – The Zen of Python / “one way to do it” – Why are there no words like “Rubyist”, “Javanese” or “C#y” ● If “Pythonic” is not just syntax and idioms, what is it?
  • 74. 74 Questions remain... ● Is there something special in the culture of Python? – The Zen of Python / “one way to do it” – Why are there no words like “Rubyist”, “Javanese” or “C#y” ● If “Pythonic” is not just syntax and idioms, what is it? ● Does “Pythonic” correlate with code quality?
  • 75. 75 Questions remain... ● Is there something special in the culture of Python? – The Zen of Python / “one way to do it” – Why are there no words like “Rubyist”, “Javanese” or “C#y” ● If “Pythonic” is not just syntax and idioms, what is it? ● Does “Pythonic” correlate with code quality? ● Is “Pythonic” just a posh mark of pride serving to create a two-tier society within the Python community?
  • 76. Carol V. Alexandru¹, José J. Merchante², Sebastiano Panichella¹, ³ Sebastian Proksch¹, Harald C. Gall¹, Gregorio Robles² Read the paper: http://t.uzh.ch/S7 Get the slides: http://t.uzh.ch/Sb Browse the catalogue: http://pythonic.libresoft.info/catalogue On the Usage of Pythonic Idioms