Show HN: Easy to understand intro to Python
github.com
github.com
https://github.com/thewhitetulip/build-app-with-python-antit...
> Python has been around for more than 30 years
The license says that development began in the early 90s.
The factual errors continue in the explanation of the language, such as describing a triple quote string as a multiline comment.
I might have misstated. The idea was around more than 30yrs albeit the implementation has been for around 27yrs
> triple quote string as a multiline comment.
Don't you use triple quoted string as a multi line comment? Then what do you use for multi line comment? I am curious.
Thank you!
A good rule, especially for beginners, is that triple quotes are primarily for docstrings, and the occasional multi line string. (Too many multi line strings, and it's probably a good idea to put them in a separate file)
Edit: There's also other errors with this "anti-book", including basic stuff like operators. For example, the major operator list at the top is missing "or", the Boolean part probably needs a bit more info on truthiness as "not" works on non-Boolean types also, and the membership test operator ("in") works on many other data types, not just lists. And of course, "!=" == "xor".
Also 'or' is not missing from my "anti-textbook", or is present, I am not sure why you think so. I am yet to reciew thr tutorial once so hopefully mistakes like the in operator would be rectified soon!
Thanks :-)
You might be familiar with the concept in Javascript, if you have ever put 'use strict' at the top of a JS file.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
The guy's handle is thewhitetulip, which is the most Dutch thing I can think of.[0]: https://twitter.com/gvanrossum/status/112670605505077248
Plus, triple quoted strongs are either strings or docstrings not comments, isn't rectifying mistakes good?
I guess it was an ambiguous pronoun reference. Sorry about that.
def demo():
"""I'm a demo. Maybe a few lines of
doctests below.
"""
return 42
You can now, for example in ipython do: help(demo) and get the demo.__doc__ back. See also doctests.So no, they are not comments - they are part of the code -- but they are often used to comment on, and document the code.
docstrings pep: https://www.python.org/dev/peps/pep-0257/
docstring definition from the python docs: https://docs.python.org/3.5/glossary.html#term-docstring
doctest: https://docs.python.org/3.5/library/doctest.html?highlight=d...
You also claimed that Python 3 was written to fix 30-year-old mistakes. Python 3 has been around of a while now.
I'll do that right away
Thank you!