Have you ever stored some piece of information in the computer and wondered how the computer represents these information? Well, for you it might s...
For further actions, you may consider blocking this person and/or reporting abuse
Some notes
This is very uncommon. Possibly I've never seen this
Rather add the brackets.
This is incorrect and needs comma.
Simply adding brackets is meaningless there.
Make sure to add the comma:
Thank you for the review on the
string_tuple
variable. It was a typo. I'll effect the change immediately.I wrote a cheatsheet for Python data types and how to use them in case you are interested. I keep the focus on syntax and examples
michaelcurrin.github.io/dev-cheats...
Great cheatsheet over here @michaelcurrin . Is it open for contribution? I want to see how I can add to it.
Sure. Check the github link in the corner.
I'm accepting new content for the languages and tools covered.
Make a PR for a small change or an issue to discuss a bigger change first
You may be interested in the raw string.
Useful if you want literal text instead of special characters. Or for regex.
Yes, indeed True and False are just aliases for 1 and 0.
Python is implemented in C language which actually has no boolean type so 1 and 0 are used instead.
I've never seen anyone do
True + True
though, lol.Yeah, true. You might not see someone use
True+ True
in their codes because of it's less practical use. But it is necessary for a beginner to know how these things work under the hood.Well, when I was learning Python, I didn't know that
True
+True
will evaluate to2
. So I think including it in an example will go a long way to help others who want to learn.Anyways, thanks for your reviews. There are absolutely on point 🚀🚀🚀
What I mean is for a teaching a beginner syntax, get them to learn code that is best practice and common i.e. followed by most Python coders. So they pick up good habits
And then as a side note you can mention the alternative syntax without brackets as valid but not encouraged, and like you said something for den
In this case it is covered in the official style guide for Python in PEP8, which will be enforced by style and lint tools too.
Brackets around comma are recommended and leaving it out is less readable it says.
pep8.org/#when-to-use-trailing-commas
Yeah. Great point here @keonigarner . I think stating personal experience may sound biased.
My experience may be indeed be different from others. That's why I backed my comment with a link to the standard style Python programmers are recommended to follow. Not everyone follows it or follow it completely but it encourages quality (readable and debuggable code) and consistency (if you change codebases or change jobs you probably won't have to change styles because you alread follow the prevalent style which is documented and agreed upon).
I also recommend using a tool like pylint and flake8 ans black to give warnings and automated fixes for code style.
They are going to default to a prevalent standard to avoid debate between coders on what is right, as the tools enforce a standard for you.
You can also override with a config if you want 100 characters long instead of 79 or want to change how code is wrapped or variables are named, if you want to deviate from the style.
github.com/MichaelCurrin/py-projec...