From e7ddcc0f4cfdda5efda27da68dda4f1142d4f4af Mon Sep 17 00:00:00 2001 From: marysia Date: Wed, 6 Aug 2014 23:18:07 +0200 Subject: [PATCH 1/2] Editorial tweaks + how to print a given element of a dictionary --- code_editor/README.md | 4 ++-- css/README.md | 19 +++++++++++-------- django_admin/README.md | 4 ++-- django_models/README.md | 29 +++++++++++++++-------------- django_orm/README.md | 10 +++++----- django_start_project/README.md | 10 +++++----- django_templates/README.md | 6 +++--- django_urls/README.md | 4 ++-- how_internet_works/README.md | 4 ++-- html/README.md | 12 ++++++------ intro_to_command_line/README.md | 4 ++-- python_installation/README.md | 4 ++-- python_introduction/README.md | 27 ++++++++++++++++----------- 13 files changed, 73 insertions(+), 64 deletions(-) diff --git a/code_editor/README.md b/code_editor/README.md index 6bad46cfc9e..ae9b087e3fc 100644 --- a/code_editor/README.md +++ b/code_editor/README.md @@ -4,7 +4,7 @@ You're about to write your first line of code, so it's time to download a code e There are a lot of different editors and it largely boils down to personal preference. Most Python programmers use complex but extremely powerful IDEs (Integrated Development Environments), such as PyCharm. As a beginner, however - that's probably less suitable; our recommendations are equally powerful, but a lot more simple. -Our suggestions are below, but feel free to ask your coach what their preference is - it'll be easier to get help from them. +Our suggestions are below, but feel free to ask your coach what their preferences are - it'll be easier to get help from them. ## Gedit @@ -14,7 +14,7 @@ Gedit is an open-source, free editor, available for all operating systems. ## Sublime Text 2 -Sublime Text is a very popular editor with a free evaluation period. It's easy to install and use, and available for all operating systems. +Sublime Text is a very popular editor with a free evaluation period. It's easy to install and use, and it's available for all operating systems. [Download it here](http://www.sublimetext.com/2) diff --git a/css/README.md b/css/README.md index ba16aa17f9d..5a242ff7465 100644 --- a/css/README.md +++ b/css/README.md @@ -39,8 +39,9 @@ CSS is a static file, so in order to customize CSS, we need to first configure s First, we need to create a directory to store our static files in. Go ahead and create a directory called `static` inside your `djangogirls` directory. - static - manage.py + djangogirls + ├─── static + └─── manage.py Open up the `mysite/settings.py` file, scroll to the bottom of it and add the following lines: @@ -55,8 +56,8 @@ This way Django will know where to find your static files. Let's create a CSS file now, to add your own style to your web-page. Create a new directory called `css` inside your `static` directory. Then create a new file called `blog.css` inside this `css` directory. Ready? static - └───css - blog.css + └─── css + blog.css Time to write some CSS! Open up the `static/css/blog.css` file in your code editor. @@ -72,7 +73,7 @@ In your `static/css/blog.css` file you should add following code: `h1 a` is a CSS Selector. Any `a` element inside of an `h1` element (i.e. when we have in code something like: `

link

`) is the tag we're applying our styles to, and we're telling it to change its color to `#FCA205`, which is orange. Of course, you can put your own color here! -In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the element class or the element id. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`: +In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the attribute `class` or the attribute `id`. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`: @@ -86,7 +87,7 @@ We're just loading static files here :). Then, between the `` and ` -We just told our template where our CSS file is located. Ok, save the file and refresh the site! +We just told our template where our CSS file is located. Your file should now look like this: @@ -114,6 +115,8 @@ Your file should now look like this: +OK, save the file and refresh the site! + ![Figure 14.2](images/color2.png) Nice work! Maybe we would also like to give our website a little air and increase the margin on the left side? Let's try this! @@ -152,7 +155,7 @@ Go ahead and name some parts of the HTML code. Add a class called `page-header`

Django Girls Blog

-And now add a class `post` to your `div` containing blogposts. +And now add a class `post` to your `div` containing a blog post.

published: {{ post.published_date }}

@@ -210,7 +213,7 @@ We will now add declaration blocks to different selectors. Selectors starting wi color: #000000; } -Then surround the HTML code which desplayes the posts with declarations of classes. Replace this: +Then surround the HTML code which displays the posts with declarations of classes. Replace this: {% for post in posts %}
diff --git a/django_admin/README.md b/django_admin/README.md index 8d03bf44587..e09cedb719e 100644 --- a/django_admin/README.md +++ b/django_admin/README.md @@ -11,7 +11,7 @@ Let's open the `blog/admin.py` file and replace its content with this: As you can see, we import (include) the Post model defined in the previous chapter. To make our model visible on the admin page, we need to register the model with `admin.site.register(Post)`. -Ok, time to look at our Post model. Remember to run `python manage.py runserver` in the console to run the web server. Go to the browser and type the address: +OK, time to look at our Post model. Remember to run `python manage.py runserver` in the console to run the web server. Go to the browser and type the address: http://127.0.0.1:8000/admin/ @@ -25,7 +25,7 @@ You should use the username and password you chose when you were creating a data Go to Posts and experiment a little bit with it. Add five or six blog posts. Don't worry about the content - you can simply copy-paste some text from this tutorial as your posts' content to save time :). -Make sure that at least two or three posts (but not all) have a publish date set. It will be helpful later. +Make sure that at least two or three posts (but not all) have the publish date set. It will be helpful later. ![Django admin](images/edit_post3.png) diff --git a/django_models/README.md b/django_models/README.md index 3853da8a399..3356c864c17 100644 --- a/django_models/README.md +++ b/django_models/README.md @@ -57,24 +57,25 @@ A model in Django is a special kind of object - it is saved in the `database` (d ### Creating an application -To keep everything tidy, we will create a separate application inside our project. It is very nice to have everything organized from the very beginning. To create an application we need to run in the console (from `djangogirls` directory where `manage.py` file is) `python manage.py startapp blog`. +To keep everything tidy, we will create a separate application inside our project. It is very nice to have everything organized from the very beginning. To create an application we need to run the following command in the console (from `djangogirls` directory where `manage.py` file is): (myvenv) ~/djangogirls$ python manage.py startapp blog You will notice that a new `blog` directory is created and it contains a number of files now. Our directories and files in our project should look like this: - mysite - ├── __init__.py - ├── settings.py - ├── urls.py - ├── wsgi.py - manage.py - blog - ├── __init__.py - ├── admin.py - ├── models.py - ├── tests.py - └── views.py + djangogirls + ├── mysite + | __init__.py + | settings.py + | urls.py + | wsgi.py + ├── manage.py + └── blog + __init__.py + admin.py + models.py + tests.py + views.py After creating an application we also need to tell Django that it should use it. We do that in the file `mysite/settings.py`. We need to find `INSTALLED_APPS` and add a line `blog` just above `)`. We should also add the `mysite` application (which was created for us when we started a new project in the last chapter). So the final product should look like this: @@ -91,7 +92,7 @@ After creating an application we also need to tell Django that it should use it. ### Creating a blog post model -In a file `models.py` we define all objects called `Models` - this is a place in which we will define our blog post. +In the `models.py` file we define all objects called `Models` - this is a place in which we will define our blog post. Let's open `blog/models.py`, remove everything from it and write code like this: diff --git a/django_orm/README.md b/django_orm/README.md index 0b20c4fa1cd..4980d9744e5 100644 --- a/django_orm/README.md +++ b/django_orm/README.md @@ -4,7 +4,7 @@ We have different pieces in place: the `Post` model is defined in `models.py`, w This is exactly what *views* are supposed to do: connect models and templates. In our `post_list` *view* we will need to take models we want to display and pass them to the template. So basically in a *view* we decide what (model) will be displayed in a template. -Ok, so how we will achieve it? +OK, so how we will achieve it? We need to open our `blog/views.py`. So far `post_list` *view* looks like this: @@ -13,18 +13,18 @@ We need to open our `blog/views.py`. So far `post_list` *view* looks like this: def post_list(request): return render(request, 'blog/post_list.html', {}) -Remember when we talked about including code written in different files? Now is a moment when we have to include the model we have written in `models.py`. We will add this line `from .models import Post` like this: +Remember when we talked about including code written in different files? Now it is the moment when we have to include the model we have written in `models.py`. We will add this line `from .models import Post` like this: from django.shortcuts import render from .models import Post Dot after `from` means *current directory* or *current application*. Since `views.py` and `models.py` are in the same directory we can simply use `.` and the name of the file (without `.py`). Then we import the name of the model (`Post`). -But what's next? To take actual blog posts from `Post` model we need something called a `Queryset`. +But what's next? To take actual blog posts from `Post` model we need something called `Queryset`. ## Queryset -So now we are interested in a list of blog posts, right? But all we have is model `Post`. A Queryset will give us a collection we are looking for. All we need to do is use: +So now we are interested in a list of blog posts, right? But all we have is the `Post` model. A Queryset will give us a collection we are looking for. All we need to do is use: Post.objects.all() @@ -52,7 +52,7 @@ Now we put this piece of code inside the `post_list` file, by adding it to the f return render(request, 'blog/post_list.html', {}) Please note that we create a *variable* for our queryset: `posts`. Treat this as the name of our queryset. From now on we can refer to it by this name. -The last missing part is to pass the `posts` queryset to the template (we will cover how to display it in a next chapter). +The last missing part is passing the `posts` queryset to the template (we will cover how to display it in a next chapter). In the `render` function we already have parameter with `request` (so everything we receive from the user via the Internet) and a template file `'blog/post_list.html'`. The last parameter, which looks like this: `{}` is a place in which we can add some things for the template to use. We need to give them names (we will stick to `'posts'` right now :)). It should look like this: `{'posts': posts}`. Please note that the part before `:` is wrapped with quotes `''`. diff --git a/django_start_project/README.md b/django_start_project/README.md index 0fc9a281644..717eb664e6d 100644 --- a/django_start_project/README.md +++ b/django_start_project/README.md @@ -13,9 +13,9 @@ The first step towards creating it is starting a new Django project. Basically, The names of some files and directories are very important for Django. You should not rename the files that we are about to create. Moving them to a different place is also not a good idea. Django needs to maintain a certain structure in order to be able to find important things. -In console you should run (remember that you don't type `(myvenv) ~/djangogirls$`, ok?): +In console you should run (remember that you don't type `(myvenv) ~/djangogirls$`, OK?): -> Remember to run everything in the virtualenv. If you don't see a prefix `(myvenv)` in your console you need to activate your virtualenv. We explained how to that in __Django installation__ chapter in __Working with virtualenv__ part. +> Remember to run everything in the virtualenv. If you don't see a prefix `(myvenv)` in your console you need to activate your virtualenv. We explained how to do that in the __Django installation__ chapter in the __Working with virtualenv__ part. Run on Windows: @@ -27,8 +27,8 @@ or on Linux or Mac OS: `django-admin.py` is a script that will create the directories and files for you. You should now have a directory structure which looks like this: - manage.py - │ + djangogirls + ├───manage.py └───mysite settings.py urls.py @@ -48,7 +48,7 @@ Let's ignore the other files for now - we won't change them. The only thing to r Let's make some changes in `mysite/settings.py`. Open the file using the code editor you installed earlier. -It would be nice to have the correct time on our website. Go to http://en.wikipedia.org/wiki/List_of_tz_database_time_zones and copy your relevant time zone (TZ). (eg. `Europe/Berlin` ) +It would be nice to have the correct time on our website. Go to http://en.wikipedia.org/wiki/List_of_tz_database_time_zones and copy your relevant time zone (TZ). (eg. `Europe/Berlin` ) You should find lines that contain `USE_TZ` and `TIME_ZONE` and modify them to look like this, substituting `Europe/Berlin` with your relevant time zone: diff --git a/django_templates/README.md b/django_templates/README.md index fd413a85bc0..5642ea93059 100644 --- a/django_templates/README.md +++ b/django_templates/README.md @@ -10,7 +10,7 @@ __Django template tags__ allow us to transfer Python-like things into HTML, so y ## Display post list template -In the previous chapter we gave our template a list of posts in a `posts` variable. Now we will display it in HTML. +In the previous chapter we gave our template a list of posts in the `posts` variable. Now we will display it in HTML. To print a variable in Django template, we use double curly brackets with the variable's name inside, like this: @@ -24,7 +24,7 @@ As you can see, all we've got is this: [, ] -This means that Django understand it as a list of objects. Remember from __Introduction to Python__ how we can display lists? Yes, with for loops! In a Django template, you do them this way: +This means that Django understand it as a list of objects. Remember from __Introduction to Python__ how we can display lists? Yes, with the for loops! In a Django template, you do them this way: {% for post in posts %} {{ post }} @@ -34,7 +34,7 @@ Try this in your template. ![Figure 13.2](images/step2.png) -It works! But we want them to be displayed in a way we created earlier in the __Introduction to HTML__ chapter - like the static posts we put there before. You can mix HTML and template tags. Our `body` will look like this: +It works! But we want them to be displayed like the static posts we created earlier in the __Introduction to HTML__ chapter. You can mix HTML and template tags. Our `body` will look like this:

Django Girls Blog

diff --git a/django_urls/README.md b/django_urls/README.md index b0964246e13..7672814aeed 100644 --- a/django_urls/README.md +++ b/django_urls/README.md @@ -31,11 +31,11 @@ As you can see, Django already put something here for us. Lines that start with `#` are comments - it means that those lines won't be executed by Python. Pretty handy, right? -The admin url, which you visited in previous chapter is already here: +The admin URL, which you visited in previous chapter is already here: url(r'^admin/', include(admin.site.urls)), -It means that for every url that starts with `admin/` Django will find a corresponding *view*. In this case we're including a lot of admin urls so it isn't all packed into this small file -- it's more readable and cleaner. +It means that for every URL that starts with `admin/` Django will find a corresponding *view*. In this case we're including a lot of admin URLs so it isn't all packed into this small file -- it's more readable and cleaner. ## Regex diff --git a/how_internet_works/README.md b/how_internet_works/README.md index 10d5e1548bc..271c8156493 100644 --- a/how_internet_works/README.md +++ b/how_internet_works/README.md @@ -1,6 +1,6 @@ # How the Internet works -*This chapter is inspired by a talk "How the Internet works" by Jessica McKellar (http://web.mit.edu/jesstess/www/).* +> This chapter is inspired by a talk "How the Internet works" by Jessica McKellar (http://web.mit.edu/jesstess/www/). We bet you use the Internet every day. But do you actually know what happens when you type an address like http://djangogirls.org into your browser and press 'Enter'? @@ -13,7 +13,7 @@ follow its instructions and present all these files that your website is made of As with every file, we need to store HTML files somewhere on a hard disk. For the Internet, we use special, powerful computers called *servers*. They don't have a screen, mouse or a keyboard, because their main purpose is to store data and serve it. That's why they're called *servers* -- because they *serve* you data. -Ok, but you want to know how the Internet looks like, right? +OK, but you want to know how the Internet looks like, right? We drew you a picture! It looks like this: diff --git a/html/README.md b/html/README.md index b6bb022d9d8..da42ec5ba90 100644 --- a/html/README.md +++ b/html/README.md @@ -10,7 +10,7 @@ A Django template's format is described in a language called HTML (that's the HT HTML is a simple code that is interpreted by your web browser - such as Chrome, Firefox or Safari - to display a webpage for user. -HTML stands for "HyperText Markup Language." __HyperText__ means it's a type of text that supports hyperlinks between pages. __Markup__ means we have taken a document and marked it up with code to tell something (in this case, a browser) how to interpret the page. HTML code is built with __tags__, each one starting with `<`, and ends with `>`. These tags markup __elements__. +HTML stands for "HyperText Markup Language." __HyperText__ means it's a type of text that supports hyperlinks between pages. __Markup__ means we have taken a document and marked it up with code to tell something (in this case, a browser) how to interpret the page. HTML code is built with __tags__, each one starting with `<` and ending with `>`. These tags markup __elements__. ## Your first template! @@ -30,7 +30,7 @@ See how your website looks now: http://127.0.0.1:8000/ ![Figure 11.1](images/step1.png) -No error anymore! Congratulations :) However, your website is isn't actually publishing anything except an empty page, because your template is empty too. We need to fix that. +No error anymore! Congratulations :) However, your website isn't actually publishing anything except an empty page, because your template is empty too. We need to fix that. Add the following to your template file: @@ -56,7 +56,7 @@ Each HTML page is also divided into two elements: __head__ and __body__. - __body__ is an element that contains everything else that is displayed as part of the web page. -We use `` to tell the browser about the configuration of the page, and `` to tell it what's actually in the page. +We use `` to tell the browser about the configuration of the page, and `` to tell it what's actually on the page. For example, you can put a webpage title element inside the ``, like this: @@ -70,15 +70,15 @@ For example, you can put a webpage title element inside the ``, like this: -Save a file and refresh your page. +Save the file and refresh your page. ![Figure 11.3](images/step4.png) Notice how the browser has understood that "Ola's blog" is the title of your page? It has interpreted `Ola's blog` and placed the text in the title bar of your browser (it will also be used for bookmarks and so on). -You will probably also have noticed that each opening tag is matched by a _closing tag_, with a `/`, and that elements are _nested_ (i.e. you can't close a particular tag until all the ones that were inside it have been closed too). +Probably you have also noticed that each opening tag is matched by a _closing tag_, with a `/`, and that elements are _nested_ (i.e. you can't close a particular tag until all the ones that were inside it have been closed too). -It's like putting things into boxes. You have one big box, ``; inside it is ``, and that contains smaller boxes still: `

`. +It's like putting things into boxes. You have one big box, ``; inside it there is ``, and that contains still smaller boxes: `

`. You need to follow these rules of _closing_ tags, and of _nesting_ elements - if you don't, the browser may not be able to interpret them properly and your page will display incorrectly. diff --git a/intro_to_command_line/README.md b/intro_to_command_line/README.md index 078a4c730f1..8e2c88bcb80 100644 --- a/intro_to_command_line/README.md +++ b/intro_to_command_line/README.md @@ -36,7 +36,7 @@ These are just a very few of the commands you can run in your command line. To l * **exit** - closes your command prompt. This makes sense, right? No need to explain too much... -* **cd** - allows you to go to another directory. To use it to go to a directory contained within your current directory, type `cd subdirectory` (where you replace subdirectory with the name of the directory you want to go to) and press enter. +* **cd** - allows you to go to another directory. To go to a directory contained within your current directory, type `cd subdirectory` (where you replace subdirectory with the name of the directory you want to go to) and press enter. **For example:** let's say you are in a directory called `c:\test` with three sub-directories: `documents`, `photos` and `music`. @@ -46,7 +46,7 @@ These are just a very few of the commands you can run in your command line. To l photos music -To go from `test` to the `documents` subdirectory, simply type `cd documents` and press enter. You are now in `c:\test\A`. +To go from `test` to the `documents` subdirectory, simply type `cd documents` and press enter. You are now in `c:\test\documents`. To move back to the `c:\test` directory (or generally, to move 'up' one level), type `cd ..` (`cd` followed by two full stops). diff --git a/python_installation/README.md b/python_installation/README.md index 96f1b0b32a9..86a1b92f671 100644 --- a/python_installation/README.md +++ b/python_installation/README.md @@ -8,7 +8,7 @@ Python originated in the late 1980s and its main goal is to be readable by human # Python installation -*This subchapter is based on awesome tutorials by Geek Girls Carrots (http://django.carrots.pl/)* +> This subchapter is based on awesome tutorials by Geek Girls Carrots (http://django.carrots.pl/) Django is written in Python. We need Python to do anything in Django. Let's start with installing it! We want you to install Python 3.4, so if you have any earlier version, you will need to upgrade it. @@ -42,7 +42,7 @@ Use this command in your console: You need to go to the website https://www.python.org/downloads/release/python-341/ and download the Python installer: -* Download the *Mac OS X 64-bit/32-bit installer* *DMG* file, +* download the *Mac OS X 64-bit/32-bit installer* *DMG* file, * double click to open it, * double click *Python.mpkg* to run the installer. diff --git a/python_introduction/README.md b/python_introduction/README.md index 98da1710b80..faf9565d62e 100644 --- a/python_introduction/README.md +++ b/python_introduction/README.md @@ -217,9 +217,14 @@ Now, try writing the following command: Don't be surprised with the weird names. Go to the link: http://hubpages.com/hub/50-Doll-Names to look for more cute doll names. :P Just Kidding (You should do this if and only if you have a lot of time). -Above, you just created a variable named django_dolls with three key-value pairs. The key Dottie points to the value 15, Lottie points to the value 305, EmmyLou points to the value 17. +Above, you just created a variable named *django_dolls* with three key-value pairs. The key Dottie points to the value 15, Lottie points to the value 305, EmmyLou points to the value 17. Do you want to check? Type: -When to use a dictionary or a list? Well, a good point to ponder on. Just have a soltuion in mind before looking at the answer in the next line. + >>> print(django_dolls['Dottie']) + 15 + +See, it's similar to a list. But you don't need to remember the index - just the name. + +When to use a dictionary or a list? Well, a good point to ponder on. Just have a solution in mind before looking at the answer in the next line. - Do you just need an ordered sequence of items? Go for a list. - Do you need to associate values with keys, so you can look them up efficiently (by key) later on? Use a dictionary. @@ -228,14 +233,14 @@ Dictionaries are mutable like "lists" meaning that they can be changed after the >>> django_dolls['Jilly'] = 67 -Like the lists, using len() method on the dictionaries, returns the number of key-value pairs in the dictionary. Go ahead and type in the command: +Like the lists, using `len()` method on the dictionaries, returns the number of key-value pairs in the dictionary. Go ahead and type in the command: >>> len(django_dolls) 4 I hope it makes sense uptil now. :) Ready for some more fun with Dictionaries? Hop on the next line for some amazing things. -You can use del() command to delete an item in the dictionary which has particular. Say, if you want to delete the entry corresponding to the key Dottie, just type in the following command: +You can use `del()` command to delete an item in the dictionary which has particular. Say, if you want to delete the entry corresponding to the key 'Dottie', just type in the following command: >>> del django_dolls['Dottie'] >>> django_dolls @@ -249,7 +254,7 @@ Apart from this, you can also change a value associated with an already created >>> django_dolls {'Jilly': 100, 'EmmyLou': 17, 'Lottie': 305} -As you can see, the value of the key 'Jilly' has been altered from 67 to 100. :) Exciting? Hurrah! You just learnt another amazing thing. +As you can see, the value of the key 'Jilly' has been altered from *67* to *100*. :) Exciting? Hurrah! You just learnt another amazing thing. ### Summary @@ -308,7 +313,7 @@ You can give Python as many numbers to compare as you want, and it will give you ## Boolean -Accidently, you just learned about a new type of object in Python. It's called a __boolean__ -- and it probably is the easiest type there is. +Accidently, you just learned about a new type of object in Python. It's called a __Boolean__ -- and it probably is the easiest type there is. There are only two boolean objects: - True @@ -346,7 +351,7 @@ Try this: >>> if 3 > 2: ... -So far nothing has happened, as evidenced by the dots `...` instead of incentives `>>>` which we saw so far. Python expects us to give further instructions to it which are supposed to be executed if the condition `3 > 2` turns out to be true. Let’s try to make Python print “It works!”: +So far nothing has happened, as evidenced by the dots `...` instead of incentives `>>>` which we saw so far. Python expects us to give further instructions to it which are supposed to be executed if the condition `3 > 2` turns out to be true (or True for that matter). Let’s try to make Python print “It works!”: >>> if 3 > 2: ... print('It works!') @@ -403,7 +408,7 @@ See what happened there? In the last three exercises you learned about: - __comparing things__ - in Python you can compare things by using `>`, `>=`, `==`, `<=`, `<` and the `and`, `or` operators -- __boolean__ - a type of object that can only have one of two values: `True` or `False` +- __Boolean__ - a type of object that can only have one of two values: `True` or `False` - __if...elif...else__ - statements that allow you to execute code only when certain conditions are met. Time for the last part of this chapter! @@ -424,7 +429,7 @@ As you can see, there are those dots again! This means that nothing has really h ... print('How are you?') ... -Ok, our first function is ready! Press Enter to get back to the Python prompt again. Now let's execute our function: +OK, our first function is ready! Press Enter to get back to the Python prompt again. Now let's execute our function: >>> hi() Hi there! @@ -432,7 +437,7 @@ Ok, our first function is ready! Press Enter to get back to the Python prompt ag Great! You're now a programmer, congratulate yourself :)! -That was easy! Let's build our first function with parameters. We will use the previous example - a function that says hi to the person running it - with a name: +That was easy! Let's build our first function with parameters. We will use the previous example - a function that says 'hi' to the person running it - with a name: >>> def hi(name): ... @@ -478,7 +483,7 @@ That's the last part already. That was quick, right? :) As we mentioned, programmers are lazy, they don't like to repeat themselves. Programming is all about automating things, so we don't want to greet every person by their name manually, right? That's where loops come in handy. -Remember lists yet? Let's do a list of girls: +Still remember lists? Let's do a list of girls: >>> girls = ['Rachel', 'Monica', 'Phoebe', 'Ola', 'You'] From 31a73a629f15ba80906e52d8c8c3729b6251514a Mon Sep 17 00:00:00 2001 From: marysia Date: Thu, 7 Aug 2014 20:04:55 +0200 Subject: [PATCH 2/2] Small tweaks as discussed with bmispelon --- django_orm/README.md | 2 +- django_templates/README.md | 2 +- python_introduction/README.md | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/django_orm/README.md b/django_orm/README.md index 4980d9744e5..e038cb9d7b5 100644 --- a/django_orm/README.md +++ b/django_orm/README.md @@ -4,7 +4,7 @@ We have different pieces in place: the `Post` model is defined in `models.py`, w This is exactly what *views* are supposed to do: connect models and templates. In our `post_list` *view* we will need to take models we want to display and pass them to the template. So basically in a *view* we decide what (model) will be displayed in a template. -OK, so how we will achieve it? +OK, so how will we achieve it? We need to open our `blog/views.py`. So far `post_list` *view* looks like this: diff --git a/django_templates/README.md b/django_templates/README.md index 5642ea93059..4550e5fdf14 100644 --- a/django_templates/README.md +++ b/django_templates/README.md @@ -24,7 +24,7 @@ As you can see, all we've got is this: [, ] -This means that Django understand it as a list of objects. Remember from __Introduction to Python__ how we can display lists? Yes, with the for loops! In a Django template, you do them this way: +This means that Django understands it as a list of objects. Remember from __Introduction to Python__ how we can display lists? Yes, with the for loops! In a Django template, you do them this way: {% for post in posts %} {{ post }} diff --git a/python_introduction/README.md b/python_introduction/README.md index faf9565d62e..150834a7bfc 100644 --- a/python_introduction/README.md +++ b/python_introduction/README.md @@ -217,7 +217,7 @@ Now, try writing the following command: Don't be surprised with the weird names. Go to the link: http://hubpages.com/hub/50-Doll-Names to look for more cute doll names. :P Just Kidding (You should do this if and only if you have a lot of time). -Above, you just created a variable named *django_dolls* with three key-value pairs. The key Dottie points to the value 15, Lottie points to the value 305, EmmyLou points to the value 17. Do you want to check? Type: +Above, you just created a variable named `django_dolls` with three key-value pairs. The key Dottie points to the value 15, Lottie points to the value 305, EmmyLou points to the value 17. Do you want to check? Type: >>> print(django_dolls['Dottie']) 15 @@ -240,7 +240,7 @@ Like the lists, using `len()` method on the dictionaries, returns the number of I hope it makes sense uptil now. :) Ready for some more fun with Dictionaries? Hop on the next line for some amazing things. -You can use `del()` command to delete an item in the dictionary which has particular. Say, if you want to delete the entry corresponding to the key 'Dottie', just type in the following command: +You can use `del` command to delete an item in the dictionary which has particular. Say, if you want to delete the entry corresponding to the key 'Dottie', just type in the following command: >>> del django_dolls['Dottie'] >>> django_dolls @@ -315,7 +315,7 @@ You can give Python as many numbers to compare as you want, and it will give you Accidently, you just learned about a new type of object in Python. It's called a __Boolean__ -- and it probably is the easiest type there is. -There are only two boolean objects: +There are only two Boolean objects: - True - False @@ -351,7 +351,7 @@ Try this: >>> if 3 > 2: ... -So far nothing has happened, as evidenced by the dots `...` instead of incentives `>>>` which we saw so far. Python expects us to give further instructions to it which are supposed to be executed if the condition `3 > 2` turns out to be true (or True for that matter). Let’s try to make Python print “It works!”: +So far nothing has happened, as evidenced by the dots `...` instead of incentives `>>>` which we saw so far. Python expects us to give further instructions to it which are supposed to be executed if the condition `3 > 2` turns out to be true (or `True` for that matter). Let’s try to make Python print “It works!”: >>> if 3 > 2: ... print('It works!')