Onward! 2018 Boston Park Plaza Hotel Boston, Massachusetts, United States 07 November 2018 On t the Usa Usage o of P Pyth thonic I c Idioms ms 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
Carol V. Sebastiano Sebastian Harald C. Alexandru Panichella Proksch Gall José J. Gregorio Merchante Robles
Th Things t to k know a about t Pyth thon 4
Th Things t to k know a about t Pyth thon ● Cr Crea eated ted by y Guido van Rossum 5
Th Things t to k know a about t Pyth thon ● Cr Crea eated ted by y Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary 6
Th Things t to k know a about t Pyth thon ● Cr Crea eated ted by y Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary ● Str trong principles es – The “Zen of Python” >>> import this 7
Th Things t to k know a about t Pyth thon 8
Th Things t to k know a about t Pyth thon ● Cr Crea eated ted by y Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary ● Str trong principles es – The “Zen of Python” >>> import this – Python Enhancement Proposals (PEPs) 9
Th Things t to k know a about t Pyth thon ● Cr Crea eated ted by y Guido van Rossum – He is (was) the “Benevolent Dictator for Life” – Makes the final decisions when necessary ● Str trong principles es – The “Zen of Python” >>> import this – Python Enhancement Proposals (PEPs) ● Wi Widesprea ead adopti tion across many y fi fiel elds 10
Py Pythonic a c appears to s to b be 'a th thing' 11 11
Py Pythonic a c appears to s to b be 'a th thing' “It would be more pythonic to...” 12
A simp mple q question 13
T op Answer cl r claims t ms to b be e “pythonic” c”... ... 14
.. ...but t 100s 0s of people se seem em sce ceptica cal 15
“Pythonic” c” beca cause of t the s style guide ( (PEP 8) PEP 8) 16
“Pythonic” c” beca cause o of p performa rmance ce 17
Idioms ms and signaling 18
Idioms ms and signaling 19
And th there a are exceptions 20
Cr Creati tive use o of th the word “Pyth thonic” c” 21
Is th s there a a d definiti tion f for “Pyth thonic” c”? 22
Is th s there a a d definiti tion f for “Pyth thonic” c”? 23
Is th s there a a d definiti tion f for “Pyth thonic” c”? 24
Is th s there a a d definiti tion f for “Pyth thonic” c”? 25
Pyth thonic c vs. N s. Non-pyth thonic 26
Pyth thonic c vs. N s. Non-pyth thonic 27
Pyth thonic c vs. N s. Non-pyth thonic 28
Is th s there a a d definiti tion f for “Pyth thonic” c”? So it' t's “Using Pyth ython-specific syn yntax x and concep epts ts”, right? But t what t do devel eveloper ers bel elieve? eve? 29
Let' t's ask k a f few d devel elopers Interviews done ● in Person ● at a Python conference ● in Spain ● using open questions 30
Let' t's ask k a f few d devel elopers Interviews done ● in Person ● at a Python conference ● in Spain ● using open questions 31
What t does P s Pythonic c me mean? 32
What t does P s Pythonic c me mean? “ elegant and readable code” “makes code easier to understand and maintain ” “boosts readability and performance ” 33
What t does P s Pythonic c me mean? “ elegant and readable code” “makes code easier to understand and maintain ” “boosts readability and performance ” “using features provided by the language or standard library” 34
What t does P s Pythonic c me mean? “ elegant and readable code” “makes code easier to understand and maintain ” “boosts readability and performance ” “using features provided “simply the most by the language or accepted way of writing standard library” python” 35
Usi Using Py Python i idioms ms != != Pyth thonic 36
Usi Using Py Python i idioms ms != != Pyth thonic → Using idioms → ms != = Pyth ythonic code → → Using idioms ms != = always mo more e readable 37
Novice ce vs. P s. Pro Novi ovice: Pro: o: – Better style – Using built-in functionality – Fewer lines of code – Efficient execution 38
Novice ce vs. P s. Pro Novi ovice: Pro: o: – Better style – Using built-in functionality – Fewer lines of code – Efficient execution – Using idioms – Writing elegant code 39
Novice ce vs. P s. Pro Novi ovice: Pro: o: – Better style – Using built-in functionality – Fewer lines of code – Efficient execution – Using idioms – Writing elegant code – Simpler interpretation – Less concrete interpretation 40
Le Learn rning ' 'Pyth thonic' c'? 41
Le Learn rning ' 'Pyth thonic' c'? “StackOverflow shows you multiple points of view of people, and you always learn.” 42
Le Learn rning ' 'Pyth thonic' c'? “StackOverflow shows you multiple points of view of people, and you always learn.” “ reading code in repositories of other projects” “saw them in documentation ” 43
Le Learn rning ' 'Pyth thonic' c'? “StackOverflow shows you multiple points of view of people, and you always learn.” “ reading code in repositories of other projects” “saw them in documentation ” “from colleagues during code review” 44
Le Learn rning ' 'Pyth thonic' c'? “StackOverflow shows you multiple points of view of people, and you always learn.” “ reading code in repositories of other projects” “My code became more “saw them in documentation ” pythonic year after year ” “from colleagues “Becoming a pythonic programmer takes time ” during code review” 45
Le Learn rning ' 'Pyth thonic' c'? “StackOverflow shows you multiple points of view of people, and you always learn.” “ reading code in repositories of other projects” “My code became more “saw them in documentation ” pythonic year after year ” “from colleagues “Becoming a pythonic programmer takes time ” during code review” → Pythonic not ta taught t in books or lec ectu tures → Seems eems to to cree eep in with th exp experien ence 46
Do Do y you ca care? ? Do Do your r peer ers ca care? 47
Do Do y you ca care? ? Do Do your r peer ers ca care? “Pythonic code is positively viewed but not required ” 48
Do Do y you ca care? ? Do Do your r peer ers ca care? “Pythonic code is positively viewed but not required ” “If you're a novice Python programmer, better focus on general programming skills ” 49
Do Do y you ca care? ? Do Do your r peer ers ca care? “Pythonic code is positively “Pythonic idioms can at least viewed but not required ” be used to measure a developer’s knowledge .” “If you're a novice Python programmer, better focus on general programming skills ” 50
Do Do y you ca care? ? Do Do your r peer ers ca care? “Pythonic code is positively “Pythonic idioms can at least viewed but not required ” be used to measure a developer’s knowledge .” “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. 51
Do Do y you ca care? ? Do Do your r peer ers ca care? “Pythonic code is positively “Pythonic idioms can at least viewed but not required ” be used to measure a developer’s knowledge .” “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 imp mporta tant, t, but t not fo forma mally → Pythonic signals exp exper ertise e and garners res espect 52
A ca cata talogue of Py Pythonic I c Idioms ms 53
A ca cata talogue of Py Pythonic I c Idioms ms ● Published ed online e at http ttp://p /pyth ythonic.libres esoft. t.info fo/c /cata talogue – including examples, references and benchmarks 54
A ca cata talogue of Py Pythonic I c Idioms ms ● Published ed online e at http ttp://p /pyth ythonic.libres esoft. t.info fo/c /cata talogue – including examples, references and benchmarks ● Co Compiled ed fr from – Several books (on learning and applying Python) – Online statements by influential and renowned Python developers 55
Recommend
More recommend