Sample Video Frame

Created by Zed A. Shaw Updated 2024-11-11 21:25:38

Exercise 8: cut

Hopefully you're learning more Python but even more about yourself and how you work. In this part of the book you're learning something about process as well as creativity by learning how to refine your process. It's true that you can't be creative with starting friction, but you should also be realizing that the easiest way to improve your own personal process is by watching yourself work. Simply doing exercises isn't enough. You need to take a look at your personal way of working and try to improve on how you do it.

As you refine your starting process you may find that you'll need a couple different starting methods to work on different kinds of projects. When I work on software similar to these little command line tools, I can start with just hacking on the code. When I need to work on anything with a GUI I find that I need to draw the UI out, implement a fake version of it, and then make that work. As you continue with the book you'll learn both ways of working and practice those processes.

In this exercise I want you to focus on your physical health and behavior. Too often programmers wreck their bodies trying to do this job. The job feels like it should not cause you any harm. You're just sitting at a desk all day, not cutting down trees or chasing after criminals in an urban setting. The truth is any job where you sit for long periods of time doing something stressful can destroy your body. To combat that you're going to keep track of the following things while you work:

There's more, but those are the big ones. I think many programmers feel if they get up from their computer it will explode while they're gone. The computer will wait patiently for you to return, and taking breaks gives your brain a chance to work on the problem in a different way.

You should also consider turning on your computer's web camera and record yourself working. You may think you don't slouch, but then in the heat of battle you do some strange things to your body without knowing it. Record yourself this session, and then look for anything causing you tension, problems, back ache or that is just weird.

Exercise Challenge

In this exercise you are implementing the cut tool. I really like cut because it makes me look like a Unix wizard when all it really does is carve streams of text. It is the simplest little text processing tool you could possibly make and still be useful. To work with it you need another tool to feed it some lines of text to carve, so we can do this:

ls -l | cut -d ' ' -f 5-7

That might give you gibberish, but on most systems it should list username and group of every file. The cut command takes options that set a type of delimiter (-d ' ' for a space character), and then a list of fields to extract (5-7 in this case). We use the ls -l command to give it something to carve up.

That's all there is to it, so read the man cut page and see how much of it you can implement while checking out how you keep your body while you work.

Study Drills

Further Study

Remember your body is a part of you, and the idea that your mind is all that matters is completely false. Treating your body like it's just useless junk will make your brain work less efficiently and keep you from doing this work comfortably for a long period of time. I recommend you take time to do some kind of physical health related activity as often as you can. That can be yoga, dance, walking, hiking, or going to the gym. Anything to keep your body healthy so your mind can work without interference.

Think about it this way: If your body is hurt and constantly in discomfort, or weak from abuse, then your brain has to waste cycles on keeping track of it and telling you. If you can keep your body a well-oiled, maintained machine, then your brain doesn't have to worry about it.

Finally, if you are someone whose body doesn't work like other people's, then do the best you can. Nobody is telling you that you have to have my body to be a programmer. One of the great things about coding is anyone can do it even if their physical manifestation can't do many other things. The point is don't let programming make your situation worse. Stay healthy.

Previous Lesson Next Lesson

Register for Learn More Python the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.