Earlier quoted context omitted.
And that is where problems start with keen and eager junior developers who think by knowing the 90% they really know the 100%.
Unfortunately here in HN we constantly upvote those junior developer's Medium posts.
90% of Python in 90 Minutes (2013)
41–50 of 61 posts
Re: 90% of Python in 90 Minutes (2013)
#42From slide 32: > (In Python 3 // is integer division) I find it clearer to describe this behavior as "floor" division. You might think "integer division" would have the same results as python 3's `int(a / b)` when `a` and `b` are ints, but, no, this is not the case. I never could quite understand why all the hub-bub about "integer division" and why it should change from python 2 to python 3 because the behavior seeme…
The term "integer division" comes from the fact that Python 2 a/b is the same as Python 3 a//b if a and b are integers. It's not the same as int(a/b), because like most languages int() rounds toward zero, and unlike most languages Python division rounds down. 100% agreed that "floor division" is a better description (e.g. it covers floats too).
As someone who only occasionally needs to manipulate python, and someone who rarely needs to do integer arithmetic on negative numbers (beyond addition/subtraction) this caused me to do a double-take.
I'd always just assumed that languages that treat floats and integers separately would always round integer division towards zero, but TIL python rounds to the left on the number line.
It's really true! Turns out it's true in ruby, too:
-5 / 4 == -2
How 'bout that. Anyone know what other languages treat integer division in this way?
Re: 90% of Python in 90 Minutes (2013)
#43This is an old and condensed version of corporate training that I run. Typically the training runs for some 4 days. If you want a more modern version of this material (that you can submit your PR's to), check out my Python 3.6 reference[0].
If you have any questions, fire away, and I'll do my best to answer them.
[0]- https://github.com/mattharrison/Tiny-Python-3.6-Notebook
Re: 90% of Python in 90 Minutes (2013)
#44That's nowhere near 90% of Python. It's strange because everyone thinks Python is an easy language to learn, but that's not True at all. It's easy to pick up and be productive with it in a very short time, yes, but the interpreter has so much going on you can't learn everything in years. If you happen to learn everything about protocols, the interpreter gotchas, there is the standard library which is also huge, and i…
> If you happen to learn everything about protocols, the interpreter gotchas, there is the standard library which is also huge, and if you got everything in it, there is the ecosystem, which is so large nobody can know about every package. I don't think the library and packages are part of the language though. Just like there is a 'C' without a standard library there is Python 'the language'. As for the 90%, 90% of t…
(List) comprehensions are super cool, as are generators, decorators, etc, but there just wasn't enough time to cover that. Plus, as you say most code is boring, and you can get by with the material in this deck.
Re: 90% of Python in 90 Minutes (2013)
#45Learning Python is easy but learning how to use Python well isn't. However, learning to use Python well pays great dividends and so the experience is worthwhile.
Re: 90% of Python in 90 Minutes (2013)
#46That's nowhere near 90% of Python. It's strange because everyone thinks Python is an easy language to learn, but that's not True at all. It's easy to pick up and be productive with it in a very short time, yes, but the interpreter has so much going on you can't learn everything in years. If you happen to learn everything about protocols, the interpreter gotchas, there is the standard library which is also huge, and i…
I'm pretty sure that this "90% of Python" is in the context of the stuff an already-experienced developer needs to absorb to honestly put "Python" under "Languages" in a resume...
... Not the amount of knowledge you need to say "I know everything there is to know about Python, it's implementation details, and its entire associated ecosystem of third-party applications."
> but that's not True at all
Can't tell if intentional, or habit :P
Re: 90% of Python in 90 Minutes (2013)
#47From slide 32: > (In Python 3 // is integer division) I find it clearer to describe this behavior as "floor" division. You might think "integer division" would have the same results as python 3's `int(a / b)` when `a` and `b` are ints, but, no, this is not the case. I never could quite understand why all the hub-bub about "integer division" and why it should change from python 2 to python 3 because the behavior seeme…
Re: 90% of Python in 90 Minutes (2013)
#48From slide 32: > (In Python 3 // is integer division) I find it clearer to describe this behavior as "floor" division. You might think "integer division" would have the same results as python 3's `int(a / b)` when `a` and `b` are ints, but, no, this is not the case. I never could quite understand why all the hub-bub about "integer division" and why it should change from python 2 to python 3 because the behavior seeme…
Re: 90% of Python in 90 Minutes (2013)
#49Earlier quoted context omitted.
The term "integer division" comes from the fact that Python 2 a/b is the same as Python 3 a//b if a and b are integers. It's not the same as int(a/b), because like most languages int() rounds toward zero, and unlike most languages Python division rounds down. 100% agreed that "floor division" is a better description (e.g. it covers floats too).
> like most languages int() rounds toward zero, and unlike most languages Python division rounds down As someone who only occasionally needs to manipulate python, and someone who rarely needs to do integer arithmetic on negative numbers (beyond addition/subtraction) this caused me to do a double-take. I'd always just assumed that languages that treat floats and integers separately would always round integer division…
In some other languages, the % operator (IMO wrongly) takes the sign of a, making it more like a “remainder” operator than a “modulo” operator, whereas in Python % (IMO correctly) takes the sign of b.
I also agree that this should be thought of as “floor division” rather than “integer division” though.
Re: 90% of Python in 90 Minutes (2013)
#50From slide 32: > (In Python 3 // is integer division) I find it clearer to describe this behavior as "floor" division. You might think "integer division" would have the same results as python 3's `int(a / b)` when `a` and `b` are ints, but, no, this is not the case. I never could quite understand why all the hub-bub about "integer division" and why it should change from python 2 to python 3 because the behavior seeme…
https://www.python.org/dev/peps/pep-0238/
And is currently documented as such:
https://docs.python.org/3/tutorial/introduction.html#numbers
https://docs.python.org/3/glossary.html#term-floor-division
https://docs.python.org/3/library/operator.html#operator.flo...