Live data from Hacker News

Ask HN: How do I teach intermediate Python engineering skills?

news.ycombinator.com

1–10 of 14 posts

Ask HN: How do I teach intermediate Python engineering skills?

#1
I have several reports with backgrounds in science or ops who can write python to accomplish tasks, but are bad at engineering (i.e. the type of code you would write for a large project).

I feel that much of my own engineering skills were acquired through a time consuming combination of reading lots of well crafted code and getting feedback pointing out my mistakes from more experienced engineers. Are there resources that would be more time efficient to fill some of the gap for these folks?

What do folks on HN suggest?

Re: Ask HN: How do I teach intermediate Python engineering skills?

#5
Introduce them to Rich IDEs and help them set it up with a consistent configuration so they can help each other. Put git hooks in to control for silly errors. Create a style guide that scales with the importance of the project. for understanding the language more deeply, "python cookbook" by David Beasley. ask them to make everything pip installable. introduce code walk throughs to your workflow, with the intention of group peer-review.

When you see an interesting block of code that you see could be refracted, hold a session showing your refactoring of that code. You'll have to do it twice, once to figure it out, second to present. It's very time-consuming but it's the best way for people to learn

Re: Ask HN: How do I teach intermediate Python engineering skills?

#7
I would start with these:

1. Commit hooks that lint code (pylint3, flake8, ...). Code must be clean before it is merged.

2. Introduce testing: code must be covered by tests.

3. Require documentation: there must exist an independent specification of what the code does, at least from an external point of view: what are the interface contracts.

Once you have code that is specified and covered by tests, only then do you have a proper environment for transforming badly structured code that works into better structured code that still works.

Other than that, organization of programs is a big topic that requires study of theory. For instance, you could probably rediscover the idea that code should be organized into modules such that the content in a module belongs together, and isn't tightly bound to content in another module. You might not have a name for this but an intuitive feeling for it, which is very good. But if you study software engineering, you will learn about cohesion and coupling directly, so you don't have to reinvent or rediscover the wheel. The cumulative effects of learning material directly add up; you can shave years and years from the time it takes to become competent.

I think that the decline in the "Wirthian" languages like Modula 2 has been detrimental. The biggest initial boost that I got in the understanding of structured, modular programming was from programming in Turbo Pascal and Modula 2 in the late 1980's.

In Modula 2, you structure the program in modules which have a clear interface and implementation, declared in separate files. Modules declare their dependencies on other modules. From this, the compiler knows all the dependencies. There is no need for any Makefile or dependency generation; you tell the compiler to build the program, pointing it at the main module and that's it.

Each module has a block of global initialization statements. The compiler/linker, knowing the dependency among the modules, ensure that these statements are executed in module dependency order: if A depends on B, B's global initialization runs first, then A.

When I started coding in C, I realized immediately that this is missing: there is just a main function and after that you're on your own. Moreover, unless you declare your dependencies to the Makefile or IDE system or whatever you're using, or get it to figure them out externally, you will not get correct incremental builds.

So I simulated modules by carefully structuring header files, and giving each module a global initialization function, and then call these in some disciplined way, like from one big init function.

I later saw (thanks in a large part to open source) that other people's big C programs did things like this. I felt that programmers who had exposure to a language supporting modularity had an edge in understanding the issues and motivation for good organization patterns in C programs compared to those who were just getting randomly burned and improving their approach by trial and error.

Re: Ask HN: How do I teach intermediate Python engineering skills?

#8
post #4
post #2

Hire a Python dev / eng to work with them. Pairing eng with domain is always a good choice

I've never done pairing, but this seems like a good suggestion. I've also been looking for an excuse to try https://tuple.app

I'm not saying pair programming, though that is an interesting addition. Just having them collaborate on the code, knowing where their roles lie. You see knowledge transfer happen, which will benefit both sides, because you also want to expose engineers to the theoretical. They'll come back with wild ideas that the domain people refine. It's really quiet beautiful to watch happen, they each make each other better together.

Re: Ask HN: How do I teach intermediate Python engineering skills?

#9
Volume 2 here teaches Python optimization https://foundations-of-applied-mathematics.github.io/ or you could go through a copy of the Pragmatic Programmer with them https://www.cs.cornell.edu/courses/cs3110/2020sp/reflections...

All the "engineer"-ry things like constructing testing oracles or understanding code complexity this can all be found in Programming and Programming Languages https://papl.cs.brown.edu/2020/ that uses Pyret which has similar enough syntax to Python none of your bad engineers will be lost. There are lectures for it too: https://learnaifromscratch.github.io/software.html#org4eef4d... you could teach this class to them the lectures really teach you concepts like trees and graphs and how to reason about them.

Post reply on HN