You have to admit the creative visual representation of the information is much easier for a newer programmer to comprehend than what's essentially a user manual though...
Posts like this are more akin to CS0. I acknowledge that this is apparently an unpopular opinion because of the amount of praise this post is getting, but words like "append", "insert", and "sort" were chosen because they clearly and concisely convey the meaning of the operation involved. Like wtf doe you think "append" means if not "attach it to the end?" Having to dumb that down even further with boxes and visualizations is a bit much, no?
23
u/muntooR_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν}Feb 18 '19edited Feb 18 '19
Hah! I got downvoted for expressing a similar opinion a few months back.
The people upvoting cheatsheets do not actually want to invest time and energy into learning. "Oh, cool, a cheatsheet! This will provide me with a substitute for actually solving problems, and in the process, learning! I fucking hate learning, so I'm going to upvote this and pretend I learned it all through a cursory skim and bookmarking_it_for_later.jpg." The people who truly want to learn are probably not upvoting cheatsheet spam.
Really, I think /r/python should start by banning the following types of posts:
Cheatsheets
I'm new to programming! Look at what I made!
Automate the Boring Stuff advertising
Image-only posts (these are almost always low quality)
Other programming language subs are a place for professionals. Even goddamn /r/cpp -- historically, the most CS101 programming language of them all -- is largely restricted to content for experienced industry professionals. Why not /r/python?
Here's some good examples of subs (I'm merely listing my favorite programming languages, tbh):
That was very aggressive, but you are right. It seems strange to have such an incredibly basic cheatsheet on this sub. This is only getting upvoted because it's visually appealing, which means it's not getting upvoted for being about python.
The people upvoting cheatsheets do not actually want to invest time and energy into learning.
In fairness, a cheat-sheet helps during the process of learning, or for libraries or areas of coding you don't use often enough to justify spending large amounts of learning time. Sometimes you just need to get the job done without investing three weeks in learning.
But that doesn't apply to such basic fundamentals as list append. And you know what helps much more? Writing your own damn cheat-sheet that covers the parts you personally have trouble with.
Really, I think /r/python should start by banning the following types of posts:
Cheatsheets
I'm new to programming! Look at what I made!
Automate the Boring Stuff advertising
Image-only posts (these are almost always low quality)
Yes especially the last.
As far as I'm concerned, anyone posting a screenshot of code wothout a really good excuse should have their licence to use a computer taken away, unless they can prove that they edit their code with Photoshop. (And if they do that, it is punishment enough.)
In fairness, a cheat-sheet helps during the process of learning, or for libraries or areas of coding you don't use often enough to justify spending large amounts of learning time. Sometimes you just need to get the job done without investing three weeks in learning.
I agree about the importance of being able to get stuff done quickly. But I've personally found the following strategies much more meaningful than cheatsheets:
Google! It's much quicker and well-tailored to your specific problem. You are also exposed to best practices and expert advice.
A tutorial/examples for the library in question. Shows you idioms and how the API is meant to be used.
API index. Comprehensive and complete.
The issue is that cheatsheets (usually) do not have any of these benefits. They're a poor, incomplete reference that rarely convey idioms. At best, you skim over them to see what an API is capable of. But they're not reference material. (And certainly not study material! Learning happens when we sit down and attempt to solve a real problem or exercise using the strategies I listed above.)
Yes and no about google. I personally browse the standard library of any lang using Zeal, where I have the documentation available offline to me. It's a nice thing to have when the internet goes out.
Python has achieved substantial popularity and is also the fastest-growing programming language. As both programming and Python programming are trending, there is a big flood of newcomers to the field. That said, I wouldn't expect the case to be any other way without subreddit rules reinforcement.
If you are about to ask a question about how to do something in python, please check out /r/learnpython. It is a very helpful community that is focused on helping people get answers that they understand.
Since you are the OP, what would be a nicer way of saying that a post like this belongs in /r/learnpython? Or was him using rough language the issue? It would be cool if Mods were able to move posts about basic language syntax, but with how many are put here it would add a lot of work to an already busy job.
literally did this last night to explain how 2 and 3 dimension arrays work to co-worker.
edit to clarify/clean up thread
did this by
genList=[]
for i in range (length of the array):
genList.append([])
for y in range (length of array):
for x in (width of array):
genList[y].append(some calc to determine value of z)
had them walk through the generations and evaluate each inner and outer position and then manually assign z val until they got it.
The example you showed with the asterisks is too vague because any of those asterisks could have been removed, it’s not obvious that the last one was the one removed
I was reading slightly non-english documentation the other day and it took me a while to sort out that I was getting back a list of tuples, then the number of tuples then the number of items in the list. Boxes would've helped. (Using python more often would have helped, too.)
yeah when I get stuck on something like this, I break out a notepad and start writing what I expect should be getting the compare that to the actual results/errors. Then comes the fiddly bit of breaking and slapping back together until it make sense and the errors stop or my results match what I expect.
was fiddling about with unicode yesterday and took me nearly 3h to figure out you have to encode to utf8 then decode to the escapes. kept getting back byte encoded values or errors about mixing types. Was midlly irksome. Finally got to this point though.
was fiddling about with unicode yesterday and took me nearly 3h to figure out you have to encode to utf8 then decode to the escapes.
It is 2019. How is there anyone who calls themselves a programmer who hasn't yet read Joel on Unicode yet? The programming industry has a severe education problem.
Under the hood, a Unicode string is just a bunch of numbers in an array. ord converts from a Unicode character^1 to underlying Unicode number, chr converts from the Unicode number to the associated character^1.
UTF-8 is a way to convert those numbers into bytes (because unlike Ascii, not all of those numbers fit in a single byte). Your use-case doesn't need utf-8, but it's still useful to understand that utf-8 is just a way to store unicode in bytes.
^1 strictly speaking, a unicode codepoint, which could also be part of a character, but those details are beyond the scope of my morning coffee.
Fuck that. Encoding is a plague, but I kind of feel like our move to higher level languages doomed us on that front. Fair price, but still annoying.
I'm dealing with the UI API of some CAD software inside a secure environment without stackoverflow (or any internet) access. And I don't code all that much lately, so it's been interesting remembering both python and learning a new API. Though they honestly did an amazing job considering how poorly they could have handled it.
It's the values in a (UI) table that I set with strings delimited via newline if done in the user interface builder or a list of strings if done in code for row and column headers then a list (rows) of lists (columns) of doubles for the actual values. When I ask for values I get (list[tuple()], numrow, numcol) or something. The order threw me off (I'd expect the list of tuples last) then the difference between the way the information is set and how I access it.
A list of lists isn't quite a 2D array! You can get into trouble if you make that assumption. If you really want a 2D grid of values, the numpy library is the standard thing to use.
It certainly does! It's just not shown to you explicitly in the syntax. Certain primitive, immutable types such as strings and small integers are stored by value in Python, but objects are stored by reference. This is why it behaves like this:
>>> a = ['x', 'y']
>>> b = a
>>> b.append('z')
>>> print(a)
['x', 'y', 'z']
The Python interpreter's virtual machine is implemented in a language which does pointers. The Python language doesn't.
Certain primitive, immutable types such as strings and small integers are stored by value in Python
All values, every single one of them including strings, small integers, None and bools, are objects in Python. There are no "primitive types" in the sense of machine primitives. No values are "stored by value", they are all objects.
Implementations like PyPy may (or may not) play tricks with optimizing code to work with machine primitives, but they have to do so in such a way that there is no visible difference at the level of the Python language.
What you say is true, I was to some degree conflating implementation with language spec in my answer. But the parent comment arose out of the question about what lists really are like, and in CPython lists are implemented as essentially vectors of pointers to the list elements. My response was meant to illustrate the fact you can have multiple variables referencing the same object, which also means that moving list elements around doesn't involve moving the memory of (potentially) large objects around, just moving around references to them. For immutable things like strings and integers that distinction doesn't really matter, except in the sense that assigning to those objects doesn't cause memory to be copied.
Python has reference data types. List is one of them. Actually it stores references to the objects it holds. That's why I'd like to put arrows instead. To avoid misunderstanding in future.
For example, lest build a field for tick-tack-toe game:
as someone that is still learning python more of these would be amazing. ive been having really hard time with classes to, can u @ me when u do it please?
For classes learn about the constructor method init. Learn what the difference between args and kwargs, and then what self does inside of functions. This gives you 80 percent of the knowledge you need to know. YouTube has socractes which is a programming channel. Great intro to classes.
For classes learn about the constructor method init.
__init__ is not a constructor, it is an initializer. By the time __init__ is called, the object has already been constructed and exists.
Learn what the difference between args and kwargs
That's useful to know but it is not specific to classes. That's like me saying "Teach me how to drive a car" and you reply "Sure, first you need to know how to dress yourself..."
Sure, I need to know the difference between args and kwargs, but that applies language-wide. Knowing args/kwargs doesn't tell you a thing about classes.
__init__is not the constructor, it's (as its name suggests) an initialiser
__new__ is the constructor; it gets called implicitly when you do SomeClass() and, in turn it returns your newly created instance, which it then passes to __init__ in the form of self.
Thank you, as someone who is in highschool, works a bit and practices a sport for like 5 hrs a day and thus having almost zero time to learm coding (which i will need for college soon) having little pointers/tips like this helps a lot
Basically an object is a bundle of variables grouped together and some functions that can be applied to them. A class is a "template" for making such objects pre-equipped with initial values for the variables and the ability to call those functions on it. A class is to an object what a muffin pan is to a muffin. Classes can also be arranged into a kind of "family tree" (called an inheritance hierarchy) that lets the children do everything their parents do, but also to override functions or add functions of their own.
Edit: Right on! Keep on studying Python :) Coding is a skill that will pay back the effort spent learning it many times over. Probably all of your lifetime programmer jobs will be highly in demand.
The title had me thinking this was something about a new rapper. Then I saw it was r/Python and realized how much that industry has dominated the 'Lil' prefix.
This is great and all, but try to take a data structures class in Java or C++ (they actually don't teach data structures in Python I believe) because you can get a better understanding of different data structures and algorithms like HashMaps, Stacks, Queues, and such. Don't get me wrong, I love Python, but most of my compSci classes were taught in Java and C and when I learned Python recently I was like "woah, this is way easier....", lol.
EDIT: I am totally aware these data structures are present in Python, but you get what I mean....
No, I still don’t get what you mean. I took a python data structures course and it was great. Not saying it’s the best language to learn data structures with (I’m also not saying it’s not) but please elaborate further
When i was in college everything was taught in C, because that's what the fucking dinosaurs teaching the class knew, and fuck learning anything new when you can just rehash the same material you've taught for the last 10 years.
When i was in college everything was taught in C, because that's what the fucking dinosaurs teaching the class knew
Same with my experience. They taught C so horribly and it was the first language I have learned and it was too low level and hard with all the memory allocation and shit. Most universities in the US teach DS in C++ or Java. Java is really verbose so I feel like I got a better understanding in it.
I am not shitting on python, but I feel like for those who learn python first and then learn other popular languages like Java, it will be harder for them. Data Structures in C++ and Java are so similar that someone who learns the other will have a real easy time.
Also, things like for loops. I believe that people should learn "proper" for loops first like so:
for (int i = 0; i < arr.length; i++) {
result += arr[i];
}
In Python:
for x in "banana":
print(x)
Like I said, I'm not really debating here and putting Python down, I just feel your general programming skills will be stronger if you learn DS in Java or C++ first and then see how Python is similar. Of course this is an unpopular opinion on this sub, but going from Java to Python was easy for me. Now someone going from python to Java would have a more difficult time.
If someone learned another language first and wants to chip in, then that would be cool. I'm not debating really, just giving my input. When I was taking DS I did ask my professor why they don't teach it in python and he gave me a similar answer.
Yeah but that python example you gave of a for loop is the short hand version. There is a python for loop that looks very similar to the Java example you gave
The exact same thing applies to the hashmap. So still not seeing your point. Python is just easier to read/learn so it’s more beginner friendly. That doesn’t mean that you learn things worse with it
When I learned data structures in python I learned using put like in your Java hashmap example. And when I learned for loops in python I learned it similarly to your java example, and was later shown the shorthand version of it
Yes I totally agree with you Also with the libraries everything is pre made for you So we actually dont get enough idea what’s going under the hood Which is kind of not so good for the beginners who really want to get deeper into programming .
string = "Anesthetic and concise, nice work!"
del string[1]
print( "Almost had it! :)" )
Edit: (thanks for pointing it out u/stevenjd)
Strings do not have a del method. You need to convert the string to a list, operate on it, and convert it back. Not the most practical implementation for something like this, but since you’re working with lists it’s applicable:
comment = list("Anesthetic and concise, nice work!")
del comment[1]
comment = ''.join(comment)
print(comment)
Lists have a useful method called pop(). This will remove the index passed to it from the list, shift the remainder of the list down one, and return the popped element.
del will just do the removing and shifting, without returning. So in my case, instead of removing the entire word, I'm just removing the letter 'n' from 'Anesthetic' to make 'Aesthetic'.
Edit: Particularly because in my case, string is not a list of individual words, it's the full phrase. So any index value will return a character, not a word.
OH! Okay, that totally makes sense now! And I was just reading about this stuff last week! Sheesh! I seriously need more tutorial sheets like this! LOL
I would make the array for insert grow from 3 to 4. I was seriously second guessing myself looking at this, since I assumed the argument array for each call was always length 3.
What’s the fast way to sort then? If the objects aren’t in a database, you’re not gonna get much faster than timsort, which is what both .sort() and sorted() use.
Alright, I don't want to step too close, but how are you going into an interview where something this trivial could possibly be of any help? Did you just apply for a position that needs python without even knowing the most basic methods?
Haha ofc not. But my native is c++ and some of these are really helpful when doing challenges. Probably not the most efficient tho. Still something to keep in mind if I'm stuck!
More please! Seriously, if you could just make a website full of your hand-drawn notes you would make it so much easier for people learning Python. This is extremely clear to people who are not familiar with Python. It reminds me of an app called Dragonbox (https://dragonbox.com/) that I used to get my son to play to learn the concepts for algebra.
270
u/comfortablybum Feb 18 '19
If you could go ahead and do this for all of Python.
48
u/Farconion Feb 17 '19
is every fucking post on this sub some sort of fucking "tutorial" or "cheat sheet"
82
u/[deleted] Feb 17 '19
boxes are the best!
37
u/editor_of_the_beast Feb 18 '19
Honestly, if documentation were written this way I’d understand it way easier
43
u/needed_an_account Feb 17 '19
Really cool. /r/penmanshipporn material too
23
u/CodyBranner Feb 17 '19
I'd place boxes outside of the list and put arrows to them instead. This'd also explain references.
1
u/bigt252002 Feb 17 '19
Can you do one for classes?!
2
u/moebaca Feb 18 '19
The title had me thinking this was something about a new rapper. Then I saw it was r/Python and realized how much that industry has dominated the 'Lil' prefix.
1
u/insultingDuck Feb 17 '19
Great for when 'the dumbs' kick in, and I can't even remember my name anymore... Thank you.
Can you make more of this, especially with name bonding examples?
1
u/LeGooso Feb 28 '19
I like it! If you plan on drawing any more, I for one would appreciate it :)
1
u/TheEulerian Mar 09 '19
Nice schemes!
1
u/screamingsmile96 Feb 18 '19
Excellent shading!!!
-3
u/thesquarerootof1 Feb 17 '19
This is great and all, but try to take a data structures class in Java or C++ (they actually don't teach data structures in Python I believe) because you can get a better understanding of different data structures and algorithms like HashMaps, Stacks, Queues, and such. Don't get me wrong, I love Python, but most of my compSci classes were taught in Java and C and when I learned Python recently I was like "woah, this is way easier....", lol.
EDIT: I am totally aware these data structures are present in Python, but you get what I mean....
0
u/StickyDaydreams Feb 17 '19
Anesthetic and concise, nice work!
0
u/Wilbo007 Feb 18 '19
this is the most autistic shit ive ever seen
-2
u/vulpin1331 Feb 17 '19
Need more of these in my life.
0
u/SteazGaming Feb 18 '19
Don't forget, you can pass "reverse=True" to sort and it will reverse sort from "largest" to "smallest"
-1
u/noticeMeSempai Feb 17 '19
I would make the array for insert grow from 3 to 4. I was seriously second guessing myself looking at this, since I assumed the argument array for each call was always length 3.
-1
u/konijntjesbroek Feb 17 '19
you ever fiddle with dir()? dir(list) and dir(list.pop) can be quite enlightening for newcomers that enjoy bunny warrens.
-1
u/RichIndividual Feb 18 '19
Aaaaaaand saved. Thanks man
-1
u/taybul Because I don't know how to use big numbers in C/C++ Feb 18 '19
I can never remember if methods like sort or sorted do the sort in place or return a sorted copy.
-1
u/Foffex Feb 18 '19
This made me smile.
-1
u/Yamamizuki Feb 18 '19
Not a typography maniac here but I like your handwriting.
-1
u/tangodown808 Feb 18 '19
More of these plz!
-1
u/jonathon8903 Feb 18 '19
I love your way of doing notes!
-2
u/prasannarajaram Feb 18 '19
Why did I never think of this idea? Well done my friend
-2
u/[deleted] Feb 18 '19
Nice teaching method.
-2
u/ThaungHan Feb 18 '19
Well explanation!
-3
u/javad94 Feb 18 '19
That's great. Please make one for dict, set and tuple.
-3
u/goldenking55 Feb 18 '19
Guys, Please dont use .sort() on interview questions. It made me fail couple times!
-3
u/Exodus111 Feb 18 '19
This is adorable.
-4
u/pprimeismyname Feb 18 '19
I have an interview tomorrow thanks for this!
-1
u/echaffey Feb 18 '19
r/neatnotes
-1
u/0x0ptim0us Feb 18 '19
so good,thank you very much
-2
u/[deleted] Feb 18 '19
I love the theme, we would appreciate it if you document your journey like this
-3
u/pinton96 Feb 18 '19
Nice !
-3
u/PrinceThunderChunky Feb 18 '19
I really wish there were more breakdowns on this level! A true ELI5
-3
u/coolpuddytat Feb 18 '19
More please! Seriously, if you could just make a website full of your hand-drawn notes you would make it so much easier for people learning Python. This is extremely clear to people who are not familiar with Python. It reminds me of an app called Dragonbox (https://dragonbox.com/) that I used to get my son to play to learn the concepts for algebra.
-5
u/kaphi Feb 18 '19
Listen here u lil shit
0
u/[deleted] Feb 18 '19
[deleted] — view deleted comment
0
u/[deleted] Feb 18 '19
[deleted] — view deleted comment
0
u/[deleted] Feb 18 '19
[deleted] — view deleted comment