Giter VIP home page Giter VIP logo

practical-python-projects's Introduction

Practical Python Projects

Hi! 👋

Welcome to the Practical Python Projects repo. Here you can find code for all the projects that you will be making in the book. If you encounter any issues in the book, please open up an issue and I will make sure to give you attribution.

The folders are divided like this:

  • code-listings contains all the code listings shown in the book
  • projects folder contains the final projects code

If you find something wrong with the projects code or the code listings please open an issue and I will try to fix it as soon as possible.

~ Yasoob @yasoobkhalid

practical-python-projects's People

Contributors

audreyfeldroy avatar yasoob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

practical-python-projects's Issues

FIFA Twilio Bot - Security Risk/Warnings With worldcup.sfg.io Website?

Location Within the Book

  • Book order number: 23632316
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions): 2021-02-27-rc.
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 4
  • Section: 3

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

FYI. 3 major browsers (Firefox, Chrome, Safari) are all currently returning security risks/warnings accessing and using worldcup.sfg.io.

Would love to do this project, but believe it will be security risk on my laptop. Should we be proceeding? Is there possible work-around/alternate safe site to use that you recommend?

Possible Solutions

Your full name so I can provide accurate credit within the book

James Diener
Screen Shot 2021-03-28 at 4 01 57 PM
Screen Shot 2021-03-28 at 4 01 15 PM
Screen Shot 2021-03-28 at 4 00 51 PM

Replacing all the variables except for one

Location Within the Book

  • Book order number: 10275 (not sure if this point is correct)
  • Book build date: First Edition, 2020-09-23-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section: 5

Page: 38
Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

In this section we pass a group of variables to the template. Then we start replacing these variables within the .html file. We replace all the variables except for the 'total' variable (line 24). Im not sure why is that. After that there is an explication of single and doble curly braces and just after that there is a code block showing the whole .html file and now the 'total' variable it is used.

5 <td>
6 Price
7 </td>
8 </tr>
9
10 {% for item in items %}
11 <tr class="item">
12 <td>
13 {{item['title']}}
14 </td>
15 <td>
16 {{item['charge']}}
17 </td>
18 </tr>
19 {% endfor %}
20
21 <tr class="total">
22 <td></td>
23 <td>
24 Total: $385.00
25 </td>
26 </tr>

Possible Solutions

Replace the variable in the first iteration just like the rest of the variables

21 <tr class="total">
22 <td></td>
23 <td>
24 Total: ${{total}}
25 </td>
26 </tr>

Jorge Alberto Alvarado Segura

Further clarification needed for 3.7

Location Within the Book

  • Book build date (the date on page 1):First Edition, 2020-08-20-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section: 7

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

I am at a loss re what to do with the page of code given that begins with:
1 import requests 
2
3 url = 'http://127.0.0.1:5000/'

I realize it's testing the json request, but can't tell if the code is supposed to be added to app.py, or run as a separate script?  I think it's the former, as I see no request in app.py to open up 127.0.0.1.  More instruction here would be very helpful.  Thanks.

Possible Solutions

Your full name so I can provide accurate credit within the book

Code Error: 2.7

Location within the Book

  • Book build date (Is the date on page 1): First Edition, 2020-08-20-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 2
  • Section: 2.7

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

If code-related, enter it within these backticks. Otherwise, delete this segment.

2 for info in zip(titles,prices, tags, total_platforms):
3 resp = {}
4 resp['title'] = info[0]
5 resp['price'] = info[1]
6 resp['tags'] = info[2]
7 resp['platforms'] = info[3]
8 output.append(resp)
'''


## Possible Solutions
Line 2 should use the argument total_tags in the zip method, not tags.


## Your full name so I can provide accurate credit within the book
Jeff Czarniak

Suggestion for Scraping Steam Project

  • Book order number: 10379
  • Book build date: 2020-09-23-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 2
  • Section: 2.7

Description

Hello! I was doing the web scraping project in PyCharm and it suggested using a dictionary literal for Lines 27-33. So, instead of:

	resp = {}
	resp['title'] = info[0]
	resp['price'] = info[1]
	resp['tags'] = info[2]
	resp['platforms'] = info[3]
	output.append(resp)

Possible Solutions

PyCharm suggested writing it as:

    resp = {'title': info[0], 'price': info[1], 'tags': info[2], 'platforms': info[3]}
    output.append(resp)

I think this would be good to include since list comprehensions are presented in this chapter too.

Your full name so I can provide accurate credit within the book

Gracie Devine

Fig. 7.2 screenshot no longer matches The Movie DB website

Location within the Book

  • Book build date (the date on page 1): 2020-08-20-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 7
  • Section: 7.3

Description

The screenshot of TMDb says to click on "SIGN UP".

Possible Solutions

The website has changed: the link to click on is "Join TMDb".

Your full name so I can provide accurate credit within the book

Audrey Feldroy

Invoice Generator - app_test.py - [Errno 61]

Location Within the Book

  • Book order number: 23632316
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions): 2021-02-27-rc
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section: 7

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

Cheers and love this book so far. Have been working through the Invoice Generator project, no problem, At last step, running app.py works fine and can verify in browser. However, once creating and running app_test.py, there's some sort of new connection problem "Failed to establish a new connection: [Errno 61] Connection refused')" and won't generate the PDF invoice. I have also attached screenshot of terminal error report.

Have checked app_test.py code and is identical to you code same in book.

Wondering if there's a solution to this?

If code-related, enter it within these backticks. Otherwise, delete this segment.

Possible Solutions

Have Googled this error and appears that it could be firewall related. However, app.py is running fine through the firewall, while app_test.py does not. Please let me know thoughts. Thanks. - JRD
Screen Shot 2021-03-28 at 3 13 04 PM

Your full name so I can provide accurate credit within the book James Diener

Missing host and port in the app.run results in an error when deploying to Heroku

Location Within the Book

  • Book order number: 10275
  • Book build date: First Edition, 2020-09-23-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 6
  • Section: 3

Page: 100
Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

After doing the deploy to Heroku (Page 103), i was getting this error :

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

Following this answer, the problem got fixed. The problem was that the code is missing the host and the port (line 75 of the code snippet, line 59 in the book).

# Copied from the book (page 100)
58 if __name__ == '__main__':
59     app.run()

Possible Solutions

Add the host and port parameters

# The code i copied and worked for me
if __name__ == '__main__':
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)

> I noticed this error when i was doing section 6.4, when i was trying to create the webhook

Jorge Alberto Alvarado Segura

Two questions

Hi — two questions

  1. Does book come in ePub format or only pdf?

  2. Is there a companion github site with code by chapter.

Thanks

[email protected]

Issue template asks for "the date on page 1" which is confusing

Location

The issue template:
https://github.com/yasoob/practical-python-projects/blob/master/ISSUE_TEMPLATE

Description

The issue template asks the reader to provide:

Book build date (the date on page 1)

Page 1 is the cover. It's unclear what to provide from here.

Possible Solutions

I like option 2. @pydanny and @yasoob, thoughts?

Option 1:

Book build date (the date from the book's filename)

Option 2:

Book version (the date from the book's filename)

Option 3:

Book version (the date and version name from the interior matter on page 3, e.g. 2020-08-20-alpha)

Your full name so I can provide accurate credit within the book

Audrey Feldroy

NameError: name 'os' is not defined

Location Within the Book

  • Book order number: 10380
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions): Build: 2020-09-23-alpha.
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section:3.4

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

I run the app.py on windows10 and need to import os

If code-related, enter it within these backticks. Otherwise, delete this segment.

\app.py", line 13, in <module>
    port = int(os.environ.get("PORT", 5000))
NameError: name 'os' is not defined

Possible Solutions

import os in app.py

Your full name so I can provide accurate credit within the book

Peter Huynh

Page 98 problems - Post story to Instagram

Hi,

I have just purchased the book and this is my initial feedback. I was quite interested on the chapter about automatic summarization and automated image generation. After reading the description of the book and the table of contents I decided to buy it. The end of that chapter and, specially page 98, breaks all the promises of the book In less than one A4!

This book is end-to-end Python projects for intermediate Python programmers but...

  • Section called Posting Stories to Instagram is just: Oh no, this goes against Instagram TOS so go and find a library on Github to do it. I won’t tell you how to do it. It’s like in the Steam chapter you started by saying: "In this chapter we will parse Steam content using lxml, but given it goes against TOS... all these sections are left as an exercise to the reader!"

  • Section Troubleshooting is just: if it breaks, there is a search engine called Google where you can paste the error. Then you will find some links to Stack Overflow and usually answer is there... Is this real advice for intermediate Python programmers?

  • Let’s go back to the top of the page 98: resolution of these images is quite poor. RTFM and find the solution.

To me this whole page is an absolute mess! No end-to-end solutions, not tailored to intermediate programmer at all.

Potential fixes:

  • Propose a service to publish stories to Instagram that has an active API. Maybe Later/Buffer/Hootsuite allow you to publish some stories using a trial. Show how to do it using the given API.

  • Create the images for any other service that allows to to publish pictures: Images to go along a Twitter post, images for a Facebook post, thumbnails for Youtube, thumbnails for Twitch, thumbnails for a meetup event, pictures for a TikTok post, Pictures for Pinterest... there are dozens of social networks that allow you to put the content on an automated way without breaking TOS. If Instagram doesn’t, then maybe it’s not a good choice for this chapter.

I will take a look to the other chapters regarding the troubleshooting aspects, to see if this is the common response or if this is an exception.

Code Error 3.6

Location Within the Book

  • Book build date (the date on page 1): 2020-08-20-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section: 6

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

line 12: argument given to html.write_pdf() should be 'path/invoice.pdf', not 'path/invoice.html'

Possible Solutions

Your full name so I can provide accurate credit within the book

Jeff Czarniak

Missing a $ symbol

Location Within the Book

  • Book order number: 10275 (not sure if this point is correct)
  • Book build date: First Edition, 2020-09-23-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section: 5

Page: 38
Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

Here in this section we are replacing the variables declared in the .py file within the .html file.

When we get to the item-charge (line 16) variable, there is a $ symbol missing. This symbol is added a few pages later, when the whole code is being showed. Im not sure if this was done on purpose, but i find very hard to spot that little difference while watching to the whole code

10 {% for item in items %}
11 <tr class="item">
12 <td>
13 {{item['title']}}
14 </td>
15 <td>
16 {{item['charge']}}
17 </td>
18 </tr>
19 {% endfor %}

Possible Solutions

Add the symbol before showing the whole code

10 {% for item in items %}
11 <tr class="item">
12 <td>
13 {{item['title']}}
14 </td>
15 <td>
16 ${{item['charge']}}
17 </td>
18 </tr>
19 {% endfor %}

Jorge Alberto Alvarado Segura

missing one curly pracket at line 53

Location Within the Book

  • Book order number:
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions):
  • Book format (PDF, Epub or Mobi):
  • Chapter:
  • Section:

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

If grammar, quote the grammar error here. Otherwise, delete this line.

If code-related, enter it within these backticks. Otherwise, delete this segment.

Possible Solutions

Your full name so I can provide accurate credit within the book

Possible incorrect file name typo.

Location Within the Book

  • Book order number: Is this the "Transaction" number?
  • Book build date: 2021-02-27-rc
  • Book format: PDF
  • Chapter: 3
  • Section: 3.3

Description

invoice.pdf:

Possible Solutions

Small issue, but it says invoice.pdf for the file name of some Python code. Perhaps it was meant to say invoice.py?

Your full name so I can provide accurate credit within the book

Tames McTigue

Missing parentheses in a print

Location Within the Book

  • Book order number: 10275
  • Book build date: First Edition, 2020-09-23-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 6
  • Section: 3

Page: 100
Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

There are missing parentheses in the last print, line 56 of the code block on that page (Line 73 on this code snippet).

55 if r.status_code != requests.codes.ok:
56     print r.text

Possible Solutions

Add the parentheses

Jorge Alberto Alvarado Segura

The cod is working without io.BytesIO

Location Within the Book

  • Book order number:
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions):
  • Book format (PDF, Epub or Mobi):
  • Chapter:
  • Section:

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

If grammar, quote the grammar error here. Otherwise, delete this line.

If code-related, enter it within these backticks. Otherwise, delete this segment.

Possible Solutions

Your full name so I can provide accurate credit within the book

Typo strftime("%B %-d, %Y")

Location Within the Book

  • Book order number: 10380
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions):2020-09-23-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter:3
  • Section:3.5

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

today = today.strftime("%B %-d, %Y")

ValueError: Invalid format string

If code-related, enter it within these backticks. Otherwise, delete this segment.
today = datetime.today().strftime("%B %-d, %Y")

Possible Solutions

today = datetime.today().strftime("%B - %d, %Y")

Your full name so I can provide accurate credit within the book

Peter Huynh

11.2.1 grammar/word choice

Location Within the Book

  • Book order number: 11306
  • Book build date: Build: 2020-09-23-alpha.
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter:11
  • Section: 11.2.1

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

This is used to send emails from a client to a server and from relaying messages from one server to the next. The second from should read "for"

If code-related, enter it within these backticks. Otherwise, delete this segment.

Possible Solutions

Change word from to for

Your full name so I can provide accurate credit within the book

Chris Hill

'ValueError: Invalid format string' issue in Automatic Invoice Generation

Location Within the Book

  • Book order number: 23632335
  • Book build date (It is in the page footer for the latest PDF version and on page 1 for the MOBI + EPUB versions): 2021-02-27-rc
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter: 3
  • Section: 7

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

Huge thanks Yasoob for this excellent book ! I came to know about this book only recently.
I am having a weird issue here with the invoice generation project. When I'm trying to run the app.py file, I am receiving this error:

ValueError: Invalid format string

I've checked the code and it is identical as you have provided in the book. Still, I am getting this error.
Can you please check where I am going wrong here ?

Possible Solutions

Screenshot 2022-06-14 154624

Your full name so I can provide accurate credit within the book

Tapojoy De

The link to download_trailers.py isn't commit/tag pinned

The link to the download_trailers.py file goes to the master branch. But the master branch seems to use a newer version of the code (there's a required download_all_urls argument).

Two recommendations:

Very neat book. Thanks for writing it @yasoob!

Section 3.1 Setting up the project

Location Within the Book

  • Book build date (the date on page 1):First Edition, 2020-08-20-alpha
  • Book format (PDF, Epub or Mobi): PDF
  • Chapter:3
  • Section:3.1

Hint: Page numbers change all the time. The best way to report an issue is by chapter and section numbers.

Description

Line 3 of "Setting up the project", should be:    3   $  python -m venv env

Possible Solutions

Your full name so I can provide accurate credit within the book

Jeff Czarniak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.