News for hackers. Stuff that matters.
Re:Python List Comprehensions Explained Visually by tsumnia on Wednesday December 02, 2015 @05:29PM (#10666332)
Maybe its me, but "Explained Visually" sounds more like it would have some 'visual' aspect to it besides a GIF of code (don't get me wrong, I think most code should be made an image to limit copy/pasting).

A website like VisuAlgo (http://visualgo.net/) is a great example of exampling something visually should mean

Re:Python List Comprehensions Explained Visually by th on Wednesday December 02, 2015 @07:32PM (#10666946)
I agree. I was using "List Comprehensions: Now In Color" as a working title but I thought that was too nonsensical. It was actually the colorized code and not the gifs in particular that made me think "visual".

Sorry for the misleading title!

Re:Python List Comprehensions Explained Visually by meric on Thursday December 03, 2015 @01:57AM (#10668187)
It's a good document. I know list comprehensions already but still I found it entertaining to read - I think it'll enlighten a lot of people on this topic.
Re:Python List Comprehensions Explained Visually by exDM69 on Thursday December 03, 2015 @04:36AM (#10668703)
This article needs some more complex examples, e.g. comprehensions with multiple "for" clauses and more complex filtering. Perhaps an example using zip or enumerate.

E.g.

    cartesian_product = [(a,b) for a in [1,2,3] for b in ['a','b','c']]
Could really be nice when explained in color.
Re:Python List Comprehensions Explained Visually by x0 on Wednesday December 02, 2015 @11:22PM (#10667730)
What's the font you're using in that gif? It looks good.
Re:Python List Comprehensions Explained Visually by th on Thursday December 03, 2015 @12:06AM (#10667865)
Re:Python List Comprehensions Explained Visually by x0 on Friday December 04, 2015 @12:35AM (#10674872)
Ah, cheers :)
Re:Python List Comprehensions Explained Visually by scrollaway on Wednesday December 02, 2015 @11:53PM (#10667824)
> I think most code should be made an image to limit copy/pasting

You think what now?

Re:Python List Comprehensions Explained Visually by tsumnia on Thursday December 03, 2015 @10:08PM (#10674353)
As others have discussed, making coding example images for the sole purpose of forcing them to type it out. Don't get me wrong, I copy/paste like the rest of us; however, from a learning perspective, I think forcing students to type out the code gives them practice, akin to how you'd practice your shots for basketball.

I've actually implemented typing exercises that are straight "copy this image" as one of the assignments I give students each week. Now, students have my lecture, the demo done in class, AND a typing exercise before trying to implement something like, say, a collision detection algorithm.

Re:Python List Comprehensions Explained Visually by elevensies on Thursday December 03, 2015 @12:42AM (#10667972)
Not OP but I prefer to re-type rather than copy-paste because too often when I copy paste I discover that I forgot to change something.
Re:Python List Comprehensions Explained Visually by Majestic121 on Thursday December 03, 2015 @03:43AM (#10668556)
It seems to me that the cost of retyping code each time is much higher than the cost of forgetting something.

I get the underlying idea, that you "feel" and understand the code more if you type it, but holy hell would that be annoying !

Re:Python List Comprehensions Explained Visually by elevensies on Thursday December 03, 2015 @02:50PM (#10672071)
To qualify my statement:

- If found a boilerplate HTML layout and wanted to insert some stuff into it, I would use copy-paste.

- If I were editing a function to enqueue data, and I wanted to send it to two queues, I would re-type the 2nd enqueue command to avoid blindly copying over an inappropriate parameter, which is the kind of thing a tired mind might gloss over.

Re:Python List Comprehensions Explained Visually by tsumnia on Thursday December 03, 2015 @10:11PM (#10674360)
Yup! Its suppose to be annoying (well, not 'really').

It's primarily a method to ensure the reader 'learns' by mimicking versus blindly copying. Annoying to a seasoned programmer, but its a great way for students to get extra practice.

Re:Python List Comprehensions Explained Visually by ttkeil on Wednesday December 02, 2015 @07:07PM (#10666840)
Setosa (http://setosa.io/) hosts some impressive interactive visualizations as well.
Re:Python List Comprehensions Explained Visually by x1798DE on Wednesday December 02, 2015 @09:30PM (#10667353)
Why do you want to limit copy pasting?
Re:Python List Comprehensions Explained Visually by ciupicri on Thursday December 03, 2015 @12:01AM (#10667849)
He's probably referring to stuff like this:

> Do Not Copy-Paste

> You must type each of these exercises in, manually. If you copy and paste, you might as well not even do them. The point of these exercises is to train your hands, your brain, and your mind in how to read, write, and see code. If you copy-paste, you are cheating yourself out of the effectiveness of the lessons.

(from the intro of "Learn Python The Hard Way" ( http://learnpythonthehardway.org/book/intro.html#do-not-copy... ))

Re:Python List Comprehensions Explained Visually by tsumnia on Thursday December 03, 2015 @10:14PM (#10674371)
ciupicri has it right. I mention above, I think of it like practice shots in basketball, or going to the batting cage for baseball. While coding isn't as physically demanding, it definitely takes time and practice to get better at it. Forcing someone to write the code versus copy/paste gives them just a little more practice at the discipline.
Re:Python List Comprehensions Explained Visually by x1798DE on Friday December 04, 2015 @02:30PM (#10678499)
I don't know why you would want to force people to do this. There's nothing stopping someone from hand-copying code if you use text, but you're using the wrong format if you encode it as an image. So, as a result, in addition to losing copy+paste (which may be useful for someone who doesn't want to "Learn Python the Hard Way"), you also lose Ctrl + F, and if you're using an animated GIF, you also lose the ability to stop at a specific point or move around.

Overall, I think the right answer is to use the appropriate format and let people sort themselves out.

Re:Python List Comprehensions Explained Visually by birchb on Wednesday December 02, 2015 @11:09PM (#10667698)
I agree.