10 Replies - 867 Views - Last Post: 02 May 2016 - 08:36 AM Rate Topic: -----

#1 ZachBoyer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-April 16

"Learn Python the Hard Way" Help

Posted 01 May 2016 - 04:43 PM

Hi, I'm totally new to Python and coding, so please use layman's terms. As per the suggestion of a helpful user on this very forum, I have begun the course entitled "Learn Python the Hard Way." I'm really set on following every word its author says and doing a real thorough job of it. However first I had to go to the appendix and learn how to use Terminal in Mac because apparently that's very necessary. I have to memorize a whole bunch of terms. Not a problem. But so the second exercise he has me doing is learning to PWD ("Print Working Directory"). I typed the command into the terminal and I think the prompt came up as expected.

However, he (the author of "LPTHW") described the desired result as follows:

"There's a prompt.
You type a command there. In this case, it's pwd.
It printed something.
Repeat"

I do not have a printer accessible. Do I need one to move on in the appendix? Or is this even talking about printing in the conventional sense, or does it mean something totally different in Python/code? I don't want to move on before I completely understand. Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: "Learn Python the Hard Way" Help

#2 jon.kiparsky  Icon User is online

  • Screw Trump (before he screws you)
  • member icon


Reputation: 10625
  • View blog
  • Posts: 18,185
  • Joined: 19-March 11

Re: "Learn Python the Hard Way" Help

Posted 01 May 2016 - 04:52 PM

"print" in programmer-speak generally means "output to the terminal". This dates back to the old days when the standard output device was a teletype machine, and you'd actually be printing your output to long sheets of fanfold.

You'll notice that terminal sessions are referred to by a "tty" number - this is another reference to teletype.

The pwd command will find absolute path to your current directory and send that path to whatever device is receiving standard output at that moment. Typically, this will be the terminal session in which you're working. If you want to know more about stuff like this, once you've finished with the stuff you're working on, there are a number of good reference books, including "From Bash to Z-Shell" by Kiddle, Peek, and Stephenson and the Free Software Foundation's Introduction to the Command Line which should be available as a free download.
Was This Post Helpful? 1
  • +
  • -

#3 ZachBoyer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-April 16

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 05:53 AM

Hi, I'm totally new to Python and coding, so please use layman's terms. As per the suggestion of a helpful user on this very forum, I have begun the course entitled "Learn Python the Hard Way." I'm really set on following every word its author says and doing a real thorough job of it. However first I had to go to the appendix and learn how to use Terminal in Mac because apparently that's very necessary. I am on the third step of the appendix now. Here he tells you what to do if you get lost.

PWD tells you where you are.

And CD gets you back to your home.

First question: So you press PDW, then enter, then CD, then enter again? Or you press PWD, CD, then enter only once? I think it's the first option.

Next question: In exercise four he says I should do my PWD and CD commands before every exercise. I'm confused by this. I am doing these exercises not all at once. I'm taking my time with this so I am able to do it in my spare time. So I'll do one and close terminal and then bring it up again once I'm ready to do the next one. So why would I need to go home when every time I bring up terminal I think I already am home because I just opened it? Is that the difference? He thinks his readers are doing all, or multiple, exercises at once? Ty.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6340
  • View blog
  • Posts: 25,565
  • Joined: 12-December 12

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 06:09 AM

We can keep these questions together, so I've merged the topics, rather than opening a new topic for every enquiry.
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 06:54 AM

If you read the beginning, I believe he states to lament over the topics covered so they sink in. If you go exercise to exercise, you are focused on moving through the book, but not grasping what you are going over.
Was This Post Helpful? 1
  • +
  • -

#6 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6340
  • View blog
  • Posts: 25,565
  • Joined: 12-December 12

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 07:19 AM

He says this:

Quote

The first command pwd tells you where you are. The second command cd ~ takes you home so you can try again.

So it is not a question of having to do one before the other, or either twice, it is a question of understanding what each command does for you.
Was This Post Helpful? 1
  • +
  • -

#7 ZachBoyer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-April 16

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 07:50 AM

View Postastonecipher, on 02 May 2016 - 06:54 AM, said:

If you read the beginning, I believe he states to lament over the topics covered so they sink in. If you go exercise to exercise, you are focused on moving through the book, but not grasping what you are going over.



I understand that, I'm focused on the process, etc., etc. but I still have to go from one exercise to another at SOME point? I didn't necessarily ever say I was trying to speed through them.
Was This Post Helpful? 0
  • +
  • -

#8 ZachBoyer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-April 16

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 07:55 AM

View Postandrewsw, on 02 May 2016 - 07:19 AM, said:

He says this:

Quote

The first command pwd tells you where you are. The second command cd ~ takes you home so you can try again.

So it is not a question of having to do one before the other, or either twice, it is a question of understanding what each command does for you.


Ty. I better understand now. But still why is he having you type "pwd" and "cd" before each exercise, when "cd" is supposed to take you home and, yet because I just started a new exercise and therefore just opened terminal, I presumably already am home? Is that just so he can drill the commands (those being "pwd" and "cd") into my head more? If so, fine. I'm just curious. Thank you.
Was This Post Helpful? 0
  • +
  • -

#9 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,356
  • Joined: 03-December 12

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 07:57 AM

What dir you need to be in depends where your files are. You can actually run the files from anywhere, that is partly where pwd comes in. It just tells you where you are currently.
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6340
  • View blog
  • Posts: 25,565
  • Joined: 12-December 12

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 08:05 AM

View PostZachBoyer, on 02 May 2016 - 02:55 PM, said:

Is that just so he can drill the commands (those being "pwd" and "cd") into my head more? If so, fine. I'm just curious. Thank you.

I believe so. He wants you to be comfortable with these commands so that you know where you are and where you need to be (and how to get there, and who you need to kill).
Was This Post Helpful? 1
  • +
  • -

#11 jon.kiparsky  Icon User is online

  • Screw Trump (before he screws you)
  • member icon


Reputation: 10625
  • View blog
  • Posts: 18,185
  • Joined: 19-March 11

Re: "Learn Python the Hard Way" Help

Posted 02 May 2016 - 08:36 AM

View PostZachBoyer, on 02 May 2016 - 09:50 AM, said:

I understand that, I'm focused on the process, etc., etc. but I still have to go from one exercise to another at SOME point? I didn't necessarily ever say I was trying to speed through them.


I believe you're referring to this:

Zed Shaw said:

Remember! You need to go home first! Do your pwd then cd ~ before doing this exercise. Before you do all exercises in this appendix, always go home first!


Shaw is assuming that you might be using the terminal for other things between lessons, which means that you might have wound up in some other directory. If he has you cd to your home directory before each exercise, then he knows that you're starting from a known location, which makes it easier for him.
At this point, you probably have a good idea of what cd ~ or just cd is doing for you. If so, you don't need to worry too much about drilling on it, and you can move forward, but it's not a bad habit to always check your local directory if you're coming back to a terminal session.

Spoiler

Was This Post Helpful? 3
  • +
  • -

Page 1 of 1