A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-April/139054.html below:

[Python-Dev] PEP 8 update

[Python-Dev] PEP 8 update [Python-Dev] PEP 8 updateGuido van Rossum guido at python.org
Tue Apr 7 03:08:25 CEST 2015
I've taken the liberty of adding the following old but good rule to PEP 8
(I was surprised to find it wasn't already there since I've lived by this
for ages):


   -

   Be consistent in return statements. Either all return statements in a
   function should return an expression, or none of them should. If any return
   statement returns an expression, any return statements where no value is
   returned should explicitly state this as return None, and an explicit
   return statement should be present at the end of the function (if
   reachable).

   Yes:

   def foo(x):
       if x >= 0:
           return math.sqrt(x)
       else:
           return None

   def bar(x):
       if x < 0:
           return None
       return math.sqrt(x)

   No:

   def foo(x):
       if x >= 0:
           return math.sqrt(x)

   def bar(x):
       if x < 0:
           return
       return math.sqrt(x)





-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150406/2a13f5e4/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4