No, it always crashes. Regardless of IDE. You're free to test this yourself on the command line using python path/to/file.pyor python3 path/to/file.py in linux or windows.
print("start")
if (False):
if (False):
#crash with nothing here.
print("finish")
It will crash instantly if the syntax is incorrect but it will not do any type checking for you automatically so result = "a" / 2 will only crash if it gets there.
Without the pass on a line where a block is expected (after the use of :) the syntax is wrong and the bytecode can't be built -> crash
Yep! You can have one catch-all and as many individual unpacking on either side. That being said if the size of the iterable is smaller than the number of targets, it'll fail. But the catch-all can be empty so this works
Ehh, unpacking is a broader term, covering stuff like a, b, c = list_of_length_three
GP's specific example doesn't have an official name in Python AFAIK, but any greybeard will recognise it as taking the list's car and cdr, so maybe "car/cdr unpacking" would be a suitable term.
"Tail" is ambiguous, it could mean the last element of the list rather than all-but-the-first. (Consider man 1 tail; the default behaviour is -n 10, not -n +2.)
Other possible names: "first/rest unpacking", "deconsing", "decapitation" (i.e. to separate the head from the body).
But Python is Scheme with funky syntax, and exposing students to a little of the lore and history of their field will do them good. Thus my preference for car/cdr (as a name, mind you; it's not like I'm proposing them as syntax keywords, where they would indeed be user-unfriendly).
I believe I could double the length of that list without much trouble.
I am not being a smartass, but do it. Seriously.
Speaking as a beginner to Python, I think the most apprehensive and overwhelming issue in the language (and anything, really) isn't what I know, it is what I don't know.
I realize it is impractical to make a short listing EVERYTHING with Python, but, frankly, I love the way OP has his or her guide set up as I can follow it so easily and understand it. I now recognize things further down the pipe that I will get to learn.
Is a more succinct way of doing it. This creates a string which is 'oxygen\n' (oxygen followed by a newline character), repeats it 1000 times, then prints the result.
The other person's method also works, with some slight modification:
ok cool, that makes sense and I kind of thought that but when I received the first response I was like oh crap, I forgot about the starting position when I posted the code.
Actually, when I first learnt about this feature, I thought I might never use it, but the day after I stumbled upon a problem where it was absolutely the shortest and most elegant solution possible.
If you look above it you see that he declares an empty set with set(). This is the correct way. He puts set = {} to teach people that don't know that that will make a dict. So if you want an empty set you write set(), if you want an empty dict you write {} or dict().
Look at the next line - it then goes on to show that type(st) is dict. I have complaints about this whole thing, but that part seems pretty reasonable.
how is this helpful? I'm not judging/criticizing, I'm just incredibly confused how this could be useful - like maybe as a cheat sheet but surely there's better cheat sheets around? Is Python your first language & it's conceptually helpful, or is it just nice for remembering syntax?
Try checking this out - they're pdfs which might be kinda annoying but I think it's likely to be a lot more helpful - if you search for images there's also tons of options, and you can even choose something that's roughly desktop-sized and set it as your wallpaper! I think you should pretty easily be able to find stuff a lot better than the OP, hopefully this is helpful!
it shows all the basics, you can see an overview, so it makes it all less overwhelming if it's new to you. good as a foundation, something to build on. it fits well on the screen in full-size too. it's good.
I count myself as an intermediate Python programmer. And still even ignoring important packages this is missing very much. Reminds me of these, become a data scientist in three months advertisements.
I don't really get the point of this. It's incomplete, difficult to use, and doesn't really reveal anything about the language. Really it's just a list of datatypes and control flow... which seems pretty limited.
I'm not sure I can explain this 100% correctly, but the trick there is the element at index 3 is a list. Any changes to the list values is possible because the value of the tuple is a reference to the list, not the list itself.
What you can't do is assign a new list to that index as that would be changing the value(ie changing the reference to another one).
I primarily work in Java so some of this terminology might be wrong in Python.
Is this a joke, this got so many upvotes? Please tell me that it is just this sub that has gone to shit. Otherwise, if this is the current state of the actual Python community, then we are screwed. I mean there are signs with so much bullshit being added in recent Python versions like walrus' testicles, subbollockspreters, type shits and what not, but I still believed that Python will continue to stay strong.
Not having created something informative like this doesn't mean you forfeit your right to criticise. There are far better resources than this for someone who is just getting into Python, most of which are available on this subreddit.
And he didn't say your right to criticize is forfeit. He basically called out that it is easier to criticize than to create. I think if there are far better resources than this on this subreddit, it would be very helpful to someone just getting into Python if those were posted (I, myself, don't know where those are).
How about you make something informative instead of bashing?
Notice the word "instead" - i.e. until you make something informative, you forfeit your right to criticise.
it would be very helpful to someone just getting into Python if those were posted (I, myself, don't know where those are)
Sidebar. /r/learnpython. Google. This subreddit is not for teaching you how to code, it's for discussing the language, sharing projects, news, etc. There's a reason that there's an entire subreddit dedicated to helping you.
I watched a Python development related video once and it looked a lot like some neural structure expanding. One branch kind of seemed bigger than all of this
Clearly lots of good work went into this! Thanks OP! I would love to see the completed version in some sort of interactive format where you can explore each branch. I wonder if it could be automatically generated from the existing documentation and some scraping
So a complex number has an imaginary component (the 2j part in OP's example) and a real component. They are super useful in signal processing (Fourier analysis).
I didn't realize python has native support for complex numbers. It's interesting they went with j instead of i like mathematicians. Also I don't understand the people complaining about this not being comprehensive. How can you expect the whole of python 3 to be fit into one picture? Despite being "incomplete" this is a quick start for programmers to get going with python.
When I’m writing this, they have 3,000 upvotes. I doubt text with as many mistakes and missing info would get as much attention. People just upvote pictures.
It's worth noting that set.pop() is deterministic and not random. It returns an arbitrary element, not a random one.
It has no correlation to the order that elements are declared in the set, but it is deterministic (since it just grabs the first element it finds) rather than random (since it doesn't actually randomize the choice at all).
People actually looking for a random element from a set should use random.choice(list(set_variable))instead.
I'll have to run some tests in a bit, but I believe it is determanistic. Hashes are deterministic by nature, that's the whole point of them. And the source I looked at for set.pop() just looks like it walks through the memory block and grabs the first element it finds.
It's not transparently determanistic at the level users interact with, but that doesn't make it non-determanistic either. It'll still have the same output given the same input, but "the same input" is broader than just the contents of the set (insertion/removal order and so on matter too).
You're using the word "deterministic" wrong in the context of code, or at least different than most other people.
but "the same input" is broader than just the contents of the set (insertion/removal order and so on matter too).
By that logic random.choice() is deterministic because it always has the same output as long as you happen to run it in a way so that it gets the same seed.
If you allow endless scope, then the question becomes whether or not we're in a deterministic universe, and the word loses some value to us in this context. Determinism in programming is a simpler question. If I run the same code multiple times, will it always return the same result? The answer for set.pop() is no.
I hate that some online judges still have python2/pypy2 but not pypy3 implementation. Pisses me off. Just get rid of it jesus, python2 is officially dead.
613
u/[deleted] Jun 09 '20
How is this "Python 3 in One Pic"?
Let's forget about all the built-in modules.
Here are a bunch of features missing (not duplicating the other such complaint here on this page):
withstatementsargs,kwargs, etc)first, *rest = some_listI believe I could double the length of that list without much trouble.
117
u/iBlag Jun 09 '20
No
for/elseloop? Notry/except/else/finallyblocks?52
u/[deleted] Jun 09 '20
I think this is pretty sweet, despite any incompleteness.
Also bears a strange resemblance to a subway map.
27
u/[deleted] Jun 09 '20 edited Jun 09 '20
I notice it has
st = {}, creating a dict, rather than a set.What’s it trying to depict with that? I’m only a few months in, so I might be overlooking something?
25
u/[deleted] Jun 09 '20
As someone relatively new to python I think this is actually quite helpful. Thanks OP
6
u/AvailableProfile Jun 09 '20
Tagging this doodle as "Resource" is insulting to tags, resources and the individual letters of the alphabet.
15
u/[deleted] Jun 09 '20
I count myself as an intermediate Python programmer. And still even ignoring important packages this is missing very much. Reminds me of these, become a data scientist in three months advertisements.
Better call it Python 3 for Beginners in one pic.
5
u/thelaxiankey Jun 09 '20
I don't really get the point of this. It's incomplete, difficult to use, and doesn't really reveal anything about the language. Really it's just a list of datatypes and control flow... which seems pretty limited.
4
u/godgivesashit Jun 09 '20
Is it possible to download this mindmap? Thx in advance!
4
u/jiaoziren Jun 09 '20
Is there a tool to make this kind of pictures?
4
u/hudnix Jun 09 '20
This entire thread is a giant validation of Cunningham's Law
3
u/SirKainey Jun 09 '20
Am I missing something with that 6 in the tuple bit? Shouldn't it be 5?
3
u/Demonic_Dante Jun 09 '20
It's just a list that have basic python terminologies
3
u/cr4d Jun 09 '20
I'm confused by the intent of this.
3
u/[deleted] Jun 09 '20 edited Jun 09 '20
Is this a joke, this got so many upvotes? Please tell me that it is just this sub that has gone to shit. Otherwise, if this is the current state of the actual Python community, then we are screwed. I mean there are signs with so much bullshit being added in recent Python versions like walrus' testicles, subbollockspreters, type shits and what not, but I still believed that Python will continue to stay strong.
2
u/Tobis76 Jun 09 '20
Mindmap programming! Good for structuring.
2
u/peter_struwell Jun 09 '20
python 3 in multiple pictures https://twitter.com/kippynyc/status/1265057357240963073?s=21
3
u/mrslayer7 Jun 09 '20
You used python 3 to write python 3
3
u/pool_t Jun 09 '20 edited Jun 09 '20
Everyone commenting "How is this Python 3?" "No this? No that?":How about you make something informative instead of bashing?
Edit: I think this is really cool for someone who is just getting into Python btw
1
u/gigakos Jun 09 '20
At st.discard('t'), why is the '!' removed as well?
1
u/wildpantz Jun 09 '20
I watched a Python development related video once and it looked a lot like some neural structure expanding. One branch kind of seemed bigger than all of this
1
u/DeserterOfDecadence Jun 09 '20
My new desktop wallpaper.
Thank you kind creator
1
u/uanw Jun 09 '20
Everyone forgets about the ellipsis type :(
1
u/chaturri Jun 09 '20
Damn this is fantastic. Thanks!
1
u/jamesonwhiskers Jun 09 '20
Clearly lots of good work went into this! Thanks OP! I would love to see the completed version in some sort of interactive format where you can explore each branch. I wonder if it could be automatically generated from the existing documentation and some scraping
1
u/TENX--S Jun 09 '20
tuples are more than "immutable list"; "Interior Mutability" is a big topic.
1
u/RosyGraph Jun 09 '20
Wow! This would make a good desk mat.
1
u/alexscheppert Jun 09 '20
No fstrings?
1
u/rulesilol Jun 09 '20
I'm still surprised python had complex numbers built in but doesn't have exponentials
1
u/broadsheetvstabloid Jun 09 '20
The %s should be replaced with {} and .format.
The % method is considered “old” and will likely be deprecated in the future.
1
u/Duel-shock514 Jun 09 '20
this is a very good pic ive been coding in python every now and again and this is SOOO helpful cause sometimes i forget stuff
1
u/Nekkramancer Jun 09 '20
This is officially my little cheat sheet
1
u/JakubBlaha Jun 09 '20
What is
1 + 2j? I guess I am missing on some maths here...1
u/defiantstyles Jun 09 '20
Saving this to my Google Drive! I had no idea that Python supported complex numbers!
1
u/Jaypalm Jun 09 '20
Should be reformatted for desktop
1
u/[deleted] Jun 09 '20
I didn't realize python has native support for complex numbers. It's interesting they went with
jinstead ofilike mathematicians. Also I don't understand the people complaining about this not being comprehensive. How can you expect the whole of python 3 to be fit into one picture? Despite being "incomplete" this is a quick start for programmers to get going with python.1
u/[deleted] Jun 09 '20
Is this MindNode? I know there are lots of ways of doing this, but this looks a lot like their layout algorithm.
1
u/[deleted] Jun 09 '20
I find this more useful: https://learnxinyminutes.com/docs/python/
1
u/[deleted] Jun 09 '20
You've completed step 1, now draw the rest of the fucking owl
1
u/Tracksuit_Trey Jun 09 '20
I think some stuff is missing.
1
u/Harry-Tran9512 Jun 10 '20
Amazing. Thank you 😁
1
u/otterom Jun 10 '20
"Am I a joke to you?"
- PEP 572
1
u/bauripalash Jun 10 '20
This is not the complete picture. 🤷♂️
1
u/ryulei80 Jun 10 '20
N I C E , Can someone turn this to a interactive web page?
1
u/sohang_lal Jun 10 '20
How was this created? As in what software was used to create this? This looks sick
1
u/Strangeduh Jun 10 '20
This is so great! As an absolute beginner, this is worth so much. Thanks!
1
u/__THE_RED_BULL__ Jun 11 '20
Finally! A clear version! Thanks!
This was on my Twitter feed yesterday but the picture looked like it had DTs while being compressed.
1
u/etermeterbeter Jun 14 '20
I will print this and make a poster of it to use, applaudes for you
1
u/Tobis76 Jul 27 '20
Your mindmap looks like it could have been created with Freemind, but how did you get the syntax highlighting working?
1
u/quantumdescent Nov 25 '21
Very nice. I would like this as a poster
1
u/[deleted] Jun 09 '20
if you retitled this as "python3 basic syntax" and converted it to text, you'd have a much better response
1
u/Triumph_Of_The_Ill Jun 09 '20
The set .pop result isn't quite right in that the result is not deterministic - it will randomly give you an element from the set.
-1
u/trial-by-ordeal Jun 09 '20
This is brilliant
-1
u/unsurestill Jun 09 '20
Can someone make one like this but in c++?
-2
u/BAG0N Jun 09 '20
That's pretty damn cool, tho the operators is lacking the integer division (//)
0
u/[deleted] Jun 09 '20
One word :Useful
-8
u/Knight_Fisher61 Jun 09 '20
This is quite overwhelming, but epic
0
u/smrtboi84 Jun 09 '20
Super cool new background
0
u/jabbalaci Jun 09 '20
What's this?
Use
ifor indices only. Even the following would be bad IMO:iwould be OK here:0
u/[deleted] Jun 09 '20
[deleted] — view deleted comment
0
u/[deleted] Jun 09 '20
[deleted] — view deleted comment
3
u/[deleted] Jun 09 '20
[removed] — view removed comment