Showing results for code-style - Python

Sep 29, 2017
1
0

Idiomatic Python: functions versus classes

Brett Cannon
Brett Cannon

In Python, everything is an object. Compared to Java which forces you to code everything in an object-oriented programming style but still has the concept of primitive types which are not objects on their own (although Java 5 added autoboxing to help hide this discrepancy), Python has no primitive types which aren't objects but provides the concept...

code-styleidioms
Jun 29, 2016
0
1

Idiomatic Python: EAFP versus LBYL

Brett Cannon
Brett Cannon

One idiomatic practice in Python that often surprises people coming from programming languages where exceptions are considered, well, exceptional, is EAFP: "it's easier to ask for forgiveness than permission". Quickly, EAFP means that you should just do what you expect to work and if an exception might be thrown from the operation then catch it and...

code-styleidioms
Apr 18, 2016
0
0

Idiomatic Python: boolean expressions

Brett Cannon
Brett Cannon

You might think that boolean expressions -- most frequently used as conditional guards which are the the bit of code that tests whether an or statement should execute -- are a fairly straight-forward concept and that there isn't really anything subtle to them at all. And while the general concept is simple, there are some idiomatic practices to f...

code-styleidioms
Mar 14, 2016
0
1

Idiomatic Python: comprehensions

Brett Cannon
Brett Cannon

We're lucky to have a few people on our team who have been programming in Python for quite a while (I myself have been using the language now for over 15 years). Over the course of time we have picked up various idioms for programming in Python that may not be obvious or widely known for various reasons. To help share some of this knowledge we plan...

code-styleidioms