Coder Social home page Coder Social logo

mikeckennedy / python-jumpstart-course-demos Goto Github PK

View Code? Open in Web Editor NEW
743.0 106.0 536.0 4.16 MB

Contains all the "handout" materials for my Python Jumpstart by Building 10 Apps course. This includes try it yourself and finished versions of the 10 apps.

Home Page: https://talkpython.fm/course

License: MIT License

Python 100.00%

python-jumpstart-course-demos's Introduction

Python Jumpstart by Building 10 Apps Course Demos

This repository contains all the "handout" materials for my Python Jumpstart by Building 10 Apps course. This includes try it yourself and finished versions of the 10 apps.

Register for the course and get started mastering Python today.

Not familiar with my Python jumpstart course? Here's a quick intro video.

Learn more about Python Jumpstart by Building 10 Apps Course

The 10 apps

What applications will we build?

We will build the following apps, which among many other things, focus on the language concepts listed under them.

  1. Hello world
    • test your environment
  2. Guess that number
    • user input
    • conditionals
    • string parsing
  3. Birthday app
    • dates and times
  4. Personal journal
    • text-based file i/o
  5. Weather client
    • external packages
    • pip
    • screen scraping
    • HTTP clients
  6. LOL Cats Factory
    • binary files on the internet
  7. Wizard battle
    • classes
    • inheritance
    • magic methods
  8. File searcher
    • navigating the file system
    • generator methods
  9. Real estate analyzer
    • file formats
    • list comprehensions
    • generators expressions
  10. Movie lookup app
    • error handling
    • exceptions
    • Advanced HTTP clients

Thanks to my backers

Thanks to everyone who backed the Kickstarter campaign. I want to give a special thanks to backers who backed the project at extra level to make this happen!

Want to enroll in the course?

That'd be wonderful! Currently it's in production. Check out Talk Python Training's course page to get started today.

Thanks!

@mkennedy

python-jumpstart-course-demos's People

Contributors

alt3red avatar anandprabhu avatar mikeckennedy avatar ochawkeye avatar pickleton89 avatar redeemefy avatar redrambles avatar xzackaly 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  avatar  avatar

Watchers

 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  avatar  avatar

python-jumpstart-course-demos's Issues

Wunderground url problem

edit: nevermind, I didn't notice the popup at the start of video saying to check the new strings. Managed to get them by myself before I realized they were provided. Sorry for the spam.


Hi all,
just a heads up, apparently wunderground doesn't let you use the zipcode to search a specific forecast via url anymore.
Also, the api's aren't free.

Regards.

Unicode Decode Error in 8th App - File Search App

I encountered this error when I tried to execute the 8th app -
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x97 in position 17: invalid start byte
May I know how can this issue be resolved?
I am using PyCharm IDE on Windows 10 platform
screenshot 606

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 304: invalid start byte

In the file searcher app, users have run into this error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 304: invalid start byte

The problem here is there is a binary file that is being fed to the read text file option (open(file, 'r')). Here is the fix:

def search_file(filename, search_text):
    
    # NOTE: We haven't discussed error handling yet, but we
    # cover it shortly. However, some folks have been running
    # into errors where this is passed a binary file and crashes.
    # This try/except block catches the error and returns no matches.
    try:

        # matches = []
        with open(filename, 'r', encoding='utf-8') as fin:

            line_num = 0
            for line in fin:
                line_num += 1
                if line.lower().find(search_text) >= 0:
                    m = SearchResult(line=line_num, file=filename, text=line)
                    # matches.append(m)
                    yield m

            # return matches
    except UnicodeDecodeError:
        print("NOTICE: Binary file {} skipped.".format(filename))

Jan 2020 Wunderground changed their site so the recorded presentation doesn't work

As of Jan 2020, Wunderground changed their site so the video as recorded, doesn't work. Here's what you need to change.

First, see that the URL has changed from zipcode to state/city, for example:

https://www.wunderground.com/weather/us/or/portland

That means you'll need to ask for state and city rather than zipcode from the user and pass that to get_html_from_web. This should work now:

# Note: wunderground changed it's URL structure, zipcode no longer works.
# We need to pass state and city (sorry folks outside the US).
# You can update the URL for your country.
state = input('What US state do you want the weather for (e.g. OR)? ')
city = input('What city in {} (e.g. Portland)? ')

html = get_html_from_web(state, city)

Additionally, the CSS selectors have changed to the following:

cityCss = 'h1'
weatherScaleCss = '.wu-unit-temperature .wu-label'
weatherTempCss = '.wu-unit-temperature .wu-value'
weatherConditionCss = '.condition-icon'

Finally, cleanup of the city H1 text needs to change just a little:

loc = soup.find('h1').get_text() \
    .replace(' Weather Conditions', '') \
    .replace('star_ratehome', '')

Sorry for the trouble, but we can't force them to not change the site.

Escape characters in Windows?

I just finished the LOL Cat Factory and I noticed Windows explorer was opening just "This PC : Documents" folder instead of my intended lolcats folder. After doing some troubleshooting, it looks like its related to having numbers at the start of a folder and python is treating them as escape characters.

elif platform.system() == 'Windows':
    print(folder)
    subprocess.call(['explorer', folder])

D:/programming/10PythonApps/LoLCat\cat_pictures

The folder 10PythonApps is the issue.

Obviously I could rename my 10PythonApps folder, but how would you handle this in a real world situation where you might not have that control over where this application might be ran? I seen several people using r to define raw literal, but others said that isn't a good practice to get into either.

Thanks for the help!

Weather underground (app 5) no longer supports the base URL

Unfortunately, they've changed the URL structure here. This is a good lesson in the fragility of screen scraping but not the best for the videos.

We used to be able to use:

url = 'https://www.wunderground.com/weather/{}'.format(zipcode)

Now we must use:

url = 'https://www.wunderground.com/weather/us/{}/{}/{}/{}'.format(
   state_abberv, city, zipcode)

For example:

https://www.wunderground.com/weather/us/or/portland/97221

I'll be amending or re-recording these videos.

'journal.py' not found

I bought your 2016 bundle and the journal program when I run it from pycharm and sublime it generates the error that journal.py doesn't exist?

ImportError: No module named 'journal'

I rewatched the video and it didn't look like you added code so i redownloaded the repo from github and same result.

Beautiful soup is not supported/ not found

Hello Michael,

I am in module 5 but trying to import beautiful soup and it says there is no version available, I tried to run the setup manually and still cannot import it.

Could you please check this out?

Thanks

Mohamed

Weather client server error

Hi.

I just completed the weather client app but regardless of my code or yours from git hub I get a server error back.
It seems to me that the api now requires the state to be in the request all the time for it to work, but not 100% sure as I am still learning.

Thanks for the great course.

Dead Link in wizard_battle README.md

Just FYI, the following anchor in the wizard_battle app README.md is points to a seemingly dead page (looks like the domain gave up the ghost):

More info: [A Guide to Python's Magic Methods] http://www.rafekettler.com/magicmethods.html)

python-jumpstart-course-demos/apps/07_wizard_battle/you_try/README.md

Incorrect output in Birthday app

It is incorrect to use int() for calculating days from seconds, there should be math.ceil()
Now is 3/30/2017, input is 3/31/2017, and the app says that today is the birthday

csv.DictReader returns OrderedDict in 3.6

Issue: Possible confusion going forward of output of csv.Dict for versions of 3.6+ as output does not match presentation

App9 "CSV Processing with the CSV module" uses csv.DictReader and the output is shown as

<class 'dict'> {'street': '3526 HIGH ST',
and talked as such. While using 3.6.2 csv.DictReader returns
<class 'collections.OrderedDict'> OrderedDict([

I looked at CSV sourcecode for 3.5.2
line 118 - d = dict(zip(self.fieldnames, row))
and for csv.DictReader sourecode for 3.6.2
line 120 - d = OrderedDict(zip(self.fieldnames, row))

Want to add more instructions for creating Python virtualenv in Windows.

Hi, Mike.

I hit a speed bump trying to set up python virtual environment on Windows, but figured it out through G-search (Google).

I am asking permission to do a PR to update the document “venv_on_windows.md”.

  1. The “Scripts\activate” in the tutorial DOES work in Windows, without needing “.bat”. The key to getting the Windows shell to work as desired is to do a one-time change to some default shell script settings. Until I made the script settings change, I was unsuccessful at getting activate or activate.bat to work.

  2. The “where” command is “where.exe” (where.exe virtualenv).

  3. And finally, I would like to add the shell command format for creating a virtual environment for earlier versions of Python, pre-Python3.3.

Thanks for your consideration.

@xzackaly

non matching output 09_real_estate_analyzer for 2-bedroom home

Hi Michael,

Nice exercises, thanks.

Running program.py in 09 I get:

Average 2-bedroom home is $56,615, baths=1, sq ft=824.3

The try screenshot shows a higher amount, and the baths feature instead of sq ft:

https://github.com/mikeckennedy/python-jumpstart-course-demos/tree/master/apps/09_real_estate_analyzer/you_try

One thing I spotted in the code is that you take the first 6 items for homes before printing the 2-bedroom bit:

homes = []
for h in two_bed_homes:
    if len(homes) > 5:  # why the break?
        break
    homes.append(h)

When I take the break out, I get the right numbers:

Average 2-bedroom home is $165,428, baths=1.4, sq ft=957.2

Cheers
Bob

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 330: invalid continuation byte

Apologies if this isn't your desired place for these kind of requests.

I am experiencing this error on lesson 8 - the file search app

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 330: invalid continuation byte

The pycharm console gives me this with whatever text file I use.

I had initially tried download some books from Project Guttenberg and then when I encountered that error thought that it might be down to the encoding of the downloaded txt files.

I then tried the attached file, and chose 'Save As with Encoding' from Sublime Test 3. I chose UTF-8 and still received the error. I was using a Python 3 virtualenvironment by adding it in the Pycharm Python Interpreter menu as instructed.

Any assistance would be greatly appreciated. Thanks.

[The file I tried]

lorem.txt

Text search documents

Hi Mike.
I didn't find the target documents for app 8 of the Jump-start course. I couldn't match your results because I don't have the .txt documents you searched.

Could you make those available?

Thanks
Steve Erickson
ps. I love your podcast & have bought the 2016 bundle. This course is bringing back old memories and new ambitions.

'Override method in object' and others... Wizard Battle (7)

As I have been working through the tutorial for the Wizard battle, I am finding, relatively early on, that there are a number of overrides that are cause the app to fail.

image

I have tried retyping the code and finally resigned to copy/paste of your code with the same result.

wunderground actively refusing connection

Creating this app has ground to a halt because wunderground.com are refusing a connection through Python.
I can still go to the web and use it, but any attempt by the Python code is met with this error:
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Anaconda32\lib\site-packages\requests\adapters.py", line 403, in send
timeout=timeout
File "C:\Anaconda32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 623, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Anaconda32\lib\site-packages\requests\packages\urllib3\util\retry.py", line 281, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='www.wunderground.com', port=80): Max retries exceeded with url: /weather-forecast/30207 (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x00000000034DE668>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

Recommendations for replacement websites?

LOLCat Factory, Windows

Hi Mike,

Opening explorer in Windows won't actually work if your project is on different disk than C:

You can probably mitigate this, by changing directories with /d option before opening directory with explorer. I couldn't really find any explorer options to do this in one command. Maybe someone else will have some idea.

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.