3 ms·
Mr Kennedy -- this is an interesting course synopsis, it looks like you've put a lot of good work into it. The course itself is not public access, but the mate
by wyldfire 10y ago
Mr Kennedy -- this is an interesting course synopsis, it looks like you've put a lot of good work into it. The course itself is not public access, but the materials are.
> The few features that are Python 3 specific will be highlighted as such (e.g. new dictionary merging syntax).
The print statement=>function is a pretty big one too. IMO it's not too much of a wart to import it from the future in order to straddle 2.x/3.x.
Anyone else who came hoping to read actual content on how to write more Pythonic code should consult this popular reference from Pycon '07 [1].
[1] http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html http://python.net/~goodger/projects/pycon/2007/idiomatic/han...
- mikeckennedy 10y agoThanks so much. I do agree with you on the print statement to function, although other than choosing python 3 vs 2 you don't have much control over that. As for the materials, good link. I'll be releasing 10 of the 50 topics as a free video series outside the course over the next few weeks.
- wyldfire 10y ago> other than choosing python 3 vs 2 you don't have much control over that. But you do! Add "from __future__ import print_function" to your code and now it can execute identically or near identically among python 2, 3. [1] [1] https://docs.python.org/2/library/__future__.html https://docs.python.org/2/library/__future__.html
- mikeckennedy 10y agoOK, true. :) But given the course is Python 3 it's moot in that scenario.
- ubernostrum 10y agoIMO it's not too much of a wart to import it from the future in order to straddle 2.x/3.x. print() works, without a __future__ import, in Python 2.6. And 2.6 is already well past end-of-life; anyone using a version of Python which doesn't support print-as-function without an import is someone whose timeline for a Python 3 upgrade is "never" -- they'd have moved to at least a later 2.x by now.
- wyldfire 10y agoprint() "works" but it's not a function in 2.6 without the import. It's still the print statement and those parens are just gratuitous. If you happen to pass multiple "function arguments" then what really happens is that you're providing a tuple to the print statement. This will cause the printout to have commas and parens which is not how the print function behaves. There are other subtle differences between the print statement and function (line-ending, etc). Example: https://gist.github.com/androm3da/dd257031eeaf3ff09d6654726a63f93f https://gist.github.com/androm3da/dd257031eeaf3ff09d6654726a...
- Bromskloss 10y ago> The course itself is not public access, but the materials are. What materials are you referring to?