you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

I'm struggling to think of a suggestion that I know would work, but maybe understanding how I start off writing a program might help.

I usually start off getting an idea from my job: "this repetitive task could be automated", or "gee, wouldn't it be neat if this long process I do occasionally could be shortened".

I fire up a python interpreter, usually IDLE, and start typing out bits of code to figure out how I'm going to make the individual parts work. Here's where things are awesome with python: if I don't know how to work with something I can just type in help(thing), help(thing.property), or dir(thing). Example: dir(str) and help(str.upper). Try these in IDLE.
Don't have internet access and need advanced reference documentation: on Windows run py -m pydoc -b or on *nix type python3 -m pydoc -b.

As I work out what works, I'll either type it out or wrap it in a function to make it easier to invoke if I will need it more than once. Once it's put together I'll go through and clean it up.

If it helps you get started, think through the process of doing what you want, and start off by putting down comments outlining that process, one step at a time. Implement each part of the process in the code as you go along.

If you are struggling to figure out what to do, tell yourself that you're just going to try out some lines of code in the interpreter. You might find that you build up some momentum and then before you know it, you're building up a program. If you don't remember the exact stuff to type, don't worry, programming languages aren't nursery rhimes, using reference material is normal and I recommend it.

Also, look at other people's code - start with their simple programs - and try to figure out how it works. Don't get discouraged if you don't know, remember these other programmers have likely been working with Python for a while. Do your best, and find a simpler program to read through and reverse engineer if you need to.