Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change python intro to use files #210

Merged
merged 2 commits into from
Dec 2, 2014
Merged

Change python intro to use files #210

merged 2 commits into from
Dec 2, 2014

Conversation

phalt
Copy link
Member

@phalt phalt commented Dec 2, 2014

Changes to the Python Introduction chapter to use files when things get more complex.

This reshuffles the code editor chapter to between the Python installation and Python introduction chapters.

Reading through the tutorial, it felt like the interpreter was a good choice up until conditional loops and functions were introduced, so I didn't rewrite the whole thing. I did however add a small section on getting the code editor open and why we are switching to it at that point (see line 396 and onwards in python_introduction/README.md)

Closes #207 and #190

🎁


With the file saved, it's time to run it! Using the skills you've learned in the command line section, **change directories** to the desktop and then use Python to execute the code in the file like this:

$ python3 python_intro.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we need to make sure that they are in the right directory (desktop) or tell them how to go to this directory (they learned cd commands in intro to command line)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I wasn't sure if they fully understood this yet. Better to be explicit here. I'll make a change.

@olasitarska
Copy link
Member

Thanks for this awesome contribution @phalt! Really well done. I am nitpicking on two things, what do you think?

@bmispelon it'd be awesome if you would have 10 minutes to see if I missed something :)


Earlier, we picked out a code editor from the [code editor](code_editor/README.md) section. We'll need to open the editor now and write some code into a new file:

print('Hello, Django girls!')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked through the entire tutorial, but as far as I can remember we use double quotes " for string most the time. This would reduce confusion if we stick to them here as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it looks like a lot of the tutorial uses single quotes. Happy to change it. Can we get a definitive on this please @olasitarska? Single or double quotes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we haven't ever made that decision. Can you check what this chapter is using and adjust to that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My general guideline is: single quotes for machine-readable strings and double quotes for human readable ones.

It might be nice to be more consistent about this through the tutorial but I think that's out of scope for this PR.

Also note that we do explain the two syntax at the beginning of this chapter and in my exprience, I haven't seen much confusion about this in practice.

@bmispelon
Copy link
Contributor

I will give this a thorough review later in the evening.

Thanks for tackling this, Paul. Much appreciated ❤️


Awesome, right? This way you don't have to repeat yourself every time you want to change the name of the person the function is supposed to greet. And that's exactly why we need functions - you never want to repeat your code!
Now what do you think will happen if you write another name in there? Give it a try and see if you're right!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be before the previous paragraph?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleared this up, it should print out "Hi anonymous" this time, but I can see why there was confusion.

@bmispelon
Copy link
Contributor

I left a few comments here and there but this is a really awesome contribution!

As I mentionned in #210, I think we could switch to file-based execution right before we introduce the print() function.
However, this PR stands on its own and I'd be happy to merge it in its current state (well, after you remove all the if __name__ == '__main__' as noted in my comments :) ).

Thanks again!

@phalt
Copy link
Member Author

phalt commented Dec 2, 2014

Updates should have been pushed up now:

  • Removed all the if __name__ == '__main__' stuff
  • Cleared up the hi() function
  • Removed explanation of colons in favour of "this is how if and for work"

bmispelon added a commit that referenced this pull request Dec 2, 2014
@bmispelon bmispelon merged commit 29ca8f6 into DjangoGirls:master Dec 2, 2014
@bmispelon
Copy link
Contributor

Thank you! 💖

@olasitarska
Copy link
Member

Yay! ✨ 🎉

@phalt
Copy link
Member Author

phalt commented Dec 3, 2014

😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to file-based code execution in chapter 4 (intro to python)
4 participants