
Show HN: A platform for beginners to learn programming in Python - alexmojaki
https://github.com/alexmojaki/futurecoder
======
dillonmckay
Man, personally, with Python, programming with the language seems to be the
easy part.

I have struggled with virtual environments and runtime executables across
various OSs.

What are current best practices?

~~~
user5994461
1) Create a virtual environment. python3 -m venv myproject (download an
interpreter).

2) Run pip install. myproject/bin/activate; pip install requirements.txt;
(download all project dependencies).

3) Start the application. myproject/bin/activate; python myapp.py

If you can assume that there is an interpreter available on the system, say
/usr/bin/python3, you can use that instead of creating a virtual environment.

If you want to embed all the dependencies, you can save all the files created
by pip install in the /lib directory if I remember the name well.

Should I write a full blog post with example? I used to deploy python
applications in a bank, can explain all the advanced usage with and without
internet access, with and without dependencies.

~~~
noitpmeder

       " you can assume that there is an interpreter available on the system, say /usr/bin/python3, you can use that instead of creating a virtual environment."
    

Please DO NOT do this. It is so much easier to always create a virtual
environment, and then you never have to worry about installing two
applications on the same system that may have conflicting versions.
Additionally, you don't know what else may be installed into the system's
default python environment.

~~~
jamestimmins
I find you're better off pretending that your system doesn't have any builtin
Python. I use virtual environment for everything.

~~~
ptx
Using the system Python for scripts that only depend on the standard library
should be pretty safe. As soon as I need any third-party dependency I create a
virtual environment.

Edit: Although if startup performance is important, using a virtual
environment might be a good idea even for simple scripts. Running a "hello
world" program using the system Python takes twice as long on my system as
running it with "python -S" (i.e. ignoring site packages) or from a fresh
virtual env.

------
opheron
Nice work! I tried to clone the project and run with Docker with the hope of
contributing but I'm getting this error message on the "Introducing the Shell"
page:

    
    
      The process died.
      Your code probably took too long.
      Maybe you have an infinite loop?
    

Do you have a chatroom or something where project devs can discuss work in
realtime?

~~~
alexmojaki
Thanks!

I'm thinking I should start a Slack. Any opinions on that?

In the meantime can you open an issue to talk about it?

~~~
opheron
I highly recommend Zulip. Free, open-source alt to Slack but with good
threaded conversations: [https://zulipchat.com](https://zulipchat.com)

If you don't want to create a full chat I'm happy to host on a Zulip chat for
hackers I'm part of, just let me know.

I'll open an issue, thanks!

------
ggregoire
Is Python the language of choice to teach/learn programming nowadays?

I learned to code with Java like 10 years ago. I haven't touched it again
after graduating, and to be honest I was not so fond of the language (too
verbose and too much OOP for my taste), but I'm glad I learned the benefits of
having static types and a compiler from the start.

Obviously, Python is closer to pseudo code than Java, which is also great when
you just start learning.

~~~
analog31
I've had about 6 people in my work area learn Python. We're not employed as
programmers, but we're scientists in an R&D team. My colleagues varied in
experience, some had used Matlab in college, but none had programmed
extensively.

The scripting aspect is great because you can get useful things done with a
few lines and minimal constructs. There's a pile of solved problems on
Stackoverflow. Folks can approach it at their own pace and on their own terms,
at work or at home. I promise them that if they hate it, I'll refund the
price. ;-)

Now, germane to the discussion in this thread about installing the packages
and so forth. That's a drawback to Python that I tell people about, but my
approach is to provide complete hand holding on installation until they've
come up to speed on programming. If they've never programmed, then they've
probably never approached a computer from the command line or dug into its
file structure. So, learning a bit of programming first is a good way to
prepare for doing that other stuff.

I originally learned BASIC without knowing how to install BASIC on the
mainframe.

We're a Windows shop, so I help them download and install WinPython. Running
into a useful library that WinPython doesn't have is pretty rare, and then a
pip install within the WinPython shell usually works.

------
travisjungroth
I like this idea very much. I've thought about making something similar.

The example in the readme isn't idiomatic Python. It would be better to use
enumerate.

~~~
The-Toon
It's an example for beginners, presumingly to illustrate the range function,
so that's probably why it's done that way.

To continue to be nit picky with that example, the range function produces an
iterable object, which is different from a list.

~~~
travisjungroth
This seems to be non-standard, but I make a serious effort to never teach the
wrong way to do something. Primacy is just so strong.

It makes teaching harder. You really have to work to come up with great
examples. But it makes learning easier and there's less correcting to do
later.

~~~
cgriswald
In general, I agree, and I think it’s especially important in text.

A teacher is in a position of authoritative trust. As a student, after I learn
an example is flawed, I often wonder if I’m just missing some context because
I trust the teacher to have gotten it right. In a setting where communication
is already established ( _e.g._ , a class room) this can be cleared up quickly
with a question. In other settings ( _e.g._ , reading a text), it can leave me
wondering until I reach a much higher level of competence.

~~~
alexmojaki
When the course reaches the point that students are ready to learn about
enumerate (see my reply above) the course will definitely cover it and
emphatically point out that it is the better way.

~~~
travisjungroth
Take it for what it's worth, but that's exactly what I think is a bad idea. It
violates the principle of primacy in learning[1]. It also erodes trust in the
lessons. (Is this the _real_ way to do it?)

There's a similar strategy of building things up and then refactoring when
they get bad (this ifelse is getting too big. We could use a dict). But the
difference is every step along the way is valid or immediately corrected.

[1]
[https://psychology.wikia.org/wiki/Principles_of_learning#Pri...](https://psychology.wikia.org/wiki/Principles_of_learning#Primacy)

~~~
alexmojaki
What would you do in this case?

The student has never seen a tuple, or iterable unpacking of any form. Would
you just show them `for index, word in enumerate(words)` and tell them not to
worry about what that means?

Quite shortly after this, I ask them to essentially do `zip_longest`. Given
two string variables:

    
    
        string1 = "Goodbye"
        string2 = "World"
    

output:

    
    
        G W
        o o
        o r
        d l
        b d
        y  
        e  
    

Here's what I expect their solution to look like:

    
    
                length1 = len(string1)
                length2 = len(string2)
    
                if length1 > length2:  # one could use max, but I don't expect them to
                    length = length1
                else:
                    length = length2
    
                for i in range(length):
                    if i < len(string1):
                        char1 = string1[i]
                    else:
                        char1 = ' '
    
                    if i < len(string2):
                        char2 = string2[i]
                    else:
                        char2 = ' '
    
                    print(char1 + ' ' + char2)
    

That's not something that can nicely be solved with enumerate. Do you think
this exercise is bad because they should just use zip_longest instead?

~~~
travisjungroth
I'd split the problem into two. You're talking about these problems like
they're fixed, but they're not. This is _your_ project.

I'd teach index access and number generation separately, with small
incrementing variations. Then I'd show iteration, then enumeration (maybe
after tuple unpacking).

When you combine two concepts it doesn't create just a combination. It creates
one or more new concepts. Those new concepts have their own idioms and they
should be taught properly.

Combining looping over numbers and index access creates two new concepts:
looping over items and looping over items with their index. Both of those
things have their own idiom in Python and your solution shows neither.

I think telling someone not to worry about the details of how something works
because you'll get back to it later is _way_ better than showing them the
wrong thing and then correcting it. One is a promise kept, the other a promise
broken.

In my opinion, nailing this kind of stuff is like half of the value of the
project you're doing. You need to lean way in on it and get it right.

My take is right now you're thinking backwards from the position of someone
who knows how to code. You need to think forward like someone who doesn't, at
least more often. A student isn't going to be motivated to learn a, b = c by
learning return a, b first because they won't know that second concept exists!

In short, if your students aren't ready to use enumerate or zip_longest, don't
hand them problems that call for enumerate or zip_longest.

~~~
zbentley
> I think telling someone not to worry about the details of how something
> works because you'll get back to it later is way better than showing them
> the wrong thing and then correcting it. One is a promise kept, the other a
> promise broken.

I'm not sure I'd say teaching someone to do something by hand for which they
could use an existing function is "wrong". There's huge pedagogical value in
knowing how powerful tools you _didn 't_ make work. Going bottom-up is a very
effective way to do that (just ask the lisp folks), and a culmination of "nice
job, you've implemented something so useful that it mirrors what the language
designers/library authors did as well, here's how to use their version to save
time in the future" is far from a broken promise.

~~~
travisjungroth
> I'm not sure I'd say teaching someone to do something by hand for which they
> could use an existing function is "wrong".

I didn't say it was wrong the wrong way to teach. I said the code was wrong.
Like, if I removed myself from teaching and I just saw that in a PR, I'd
definitely suggest they use enumerate instead.

I'm a huge fan of reimplementing built in functions as a way to learn. I'm
learning Clojure right now (like I stopped to write this comment) and I do it
all the time. But, I know I'm doing it.

The other thing that's fine is building up to the abstraction. "Let's get the
index, now the item. Okay, there's a better way to do this". But you have to
do it immediately.

I'm just not a fan of showing someone something, letting it sink in, and then
having to go back and correct it.

And while I hope my arguments stand on their own, and I certainly could be
wrong, I'm at least not speaking out of complete inexperience. I've spent a
decent amount of time teaching people to code, juggle, work at rope courses,
and fly airplanes.

~~~
alexmojaki
Do you get reply notifications?

~~~
travisjungroth
No, I just check my comments.

------
raghavtoshniwal
This is a cool idea. In a similar vein, I use Google Colab heavily to induct
new students to python. Requires no setup, we can collaboratively edit and the
output is instantaneous.

------
chopraaa
This is awesome! I was looking for something to teach children programming
with. (10-12 years onwards)

Your project looks amazing. I hope I can find ways to contribute.

------
AtHeartEngineer
This is awesome, I'm sure this was fun to make. I love digging into the python
internals

~~~
alexmojaki
Thanks, it is fun, and quite rewarding. There's still a lot to do, wanna join
in?

------
aroberge
Have you considered using friendly-traceback?

