pep

Why is there no xrange function in Python3?

Why is there no xrange function in Python3? Question: Recently I started using Python3 and it’s lack of xrange hurts. Simple example: Python2: from time import time as t def count(): st = t() [x for x in xrange(10000000) if x%4 == 0] et = t() print et-st count() Python3: from time import time as …

Total answers: 6

What's the difference on docstrings with triple SINGLE quotes and triple DOUBLE quotes?

What's the difference on docstrings with triple SINGLE quotes and triple DOUBLE quotes? Question: I was just wondering what is the difference between two ways of writing Python Docstrings (__doc__): three single quotes: ”’ Comment goes here ”’ three double quotes: “”” Comment goes here “”” Is there any subtle difference in the way doc …

Total answers: 4

Which PEP's are must reads?

Which PEP's are must reads? Question: I’m a fairly strong Python coder, but too much of my style is a little haphazard, and I’m sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read? Asked By: Michael Fairley …

Total answers: 7

What's the function like sum() but for multiplication? product()?

What's the function like sum() but for multiplication? product()? Question: Python’s sum() function returns the sum of numbers in an iterable. sum([3,4,5]) == 3 + 4 + 5 == 12 I’m looking for the function that returns the product instead. somelib.somefunc([3,4,5]) == 3 * 4 * 5 == 60 I’m pretty sure such a function …

Total answers: 9