diff --git a/Notes/01_Introduction/01_Python.md b/Notes/01_Introduction/01_Python.md index e56aeebfa..44c7302dc 100644 --- a/Notes/01_Introduction/01_Python.md +++ b/Notes/01_Introduction/01_Python.md @@ -145,6 +145,26 @@ the class by typing in code slowly and thinking about it--not cut and pasting. ### Exercise 1.4: Where is My Bus? +Note: This was a whimsical example that was a real crowd-pleaser when +I taught this course in my office. You could query the bus and then +literally watch it pass by the window out front. Sadly, APIs rarely live +forever and it seems that this one has now ridden off into the sunset. --Dave + +Update: GitHub user @asett has suggested the following modified code might work, +but you'll have to provide your own API key (available [here](https://www.transitchicago.com/developers/bustracker/)). + +```python +import urllib.request +u = urllib.request.urlopen('http://www.ctabustracker.com/bustime/api/v2/getpredictions?key=ADD_YOUR_API_KEY_HERE&rt=22&stpid=14791') +from xml.etree.ElementTree import parse +doc = parse(u) +print("Arrival time in minutes:") +for pt in doc.findall('.//prdctdn'): + print(pt.text) +``` + +(Original exercise example follows below) + Try something more advanced and type these statements to find out how long people waiting on the corner of Clark street and Balmoral in Chicago will have to wait for the next northbound CTA \#22 bus: diff --git a/Notes/01_Introduction/06_Files.md b/Notes/01_Introduction/06_Files.md index 8a960f905..bd6d585ca 100644 --- a/Notes/01_Introduction/06_Files.md +++ b/Notes/01_Introduction/06_Files.md @@ -221,8 +221,8 @@ Try it: ```python >>> import gzip >>> with gzip.open('Data/portfolio.csv.gz', 'rt') as f: - for line in f: - print(line, end='') + for line in f: + print(line, end='') ... look at the output ... >>> diff --git a/Notes/02_Working_with_data/02_Containers.md b/Notes/02_Working_with_data/02_Containers.md index 41833d4aa..68339b840 100644 --- a/Notes/02_Working_with_data/02_Containers.md +++ b/Notes/02_Working_with_data/02_Containers.md @@ -159,7 +159,7 @@ Then to access: >>> ``` -*Neither a list, a set, nor another dictionary can serve as a dictionary key, because lists and dictionaries are mutable.* +*Neither a list, a set, nor another dictionary can serve as a dictionary key, because lists, sets, and dictionaries are mutable.* ### Sets diff --git a/Notes/03_Program_organization/02_More_functions.md b/Notes/03_Program_organization/02_More_functions.md index 579a4b980..2c47872b7 100644 --- a/Notes/03_Program_organization/02_More_functions.md +++ b/Notes/03_Program_organization/02_More_functions.md @@ -501,7 +501,7 @@ For example: ```python >>> portfolio = parse_csv('Data/portfolio.dat', types=[str, int, float], delimiter=' ') >>> portfolio -[{'price': '32.20', 'name': 'AA', 'shares': '100'}, {'price': '91.10', 'name': 'IBM', 'shares': '50'}, {'price': '83.44', 'name': 'CAT', 'shares': '150'}, {'price': '51.23', 'name': 'MSFT', 'shares': '200'}, {'price': '40.37', 'name': 'GE', 'shares': '95'}, {'price': '65.10', 'name': 'MSFT', 'shares': '50'}, {'price': '70.44', 'name': 'IBM', 'shares': '100'}] +[{'name': 'AA', 'shares': 100, 'price': 32.2}, {'name': 'IBM', 'shares': 50, 'price': 91.1}, {'name': 'CAT', 'shares': 150, 'price': 83.44}, {'name': 'MSFT', 'shares': 200, 'price': 51.23}, {'name': 'GE', 'shares': 95, 'price': 40.37}, {'name': 'MSFT', 'shares': 50, 'price': 65.1}, {'name': 'IBM', 'shares': 100, 'price': 70.44}] >>> ``` diff --git a/Notes/04_Classes_objects/02_Inheritance.md b/Notes/04_Classes_objects/02_Inheritance.md index 13e747d6e..6c8932d81 100644 --- a/Notes/04_Classes_objects/02_Inheritance.md +++ b/Notes/04_Classes_objects/02_Inheritance.md @@ -289,13 +289,13 @@ class TableFormatter: ''' Emit the table headings. ''' - raise NotImplementedError() + raise NotImplementedError() def row(self, rowdata): ''' Emit a single row of table data. ''' - raise NotImplementedError() + raise NotImplementedError() ``` This class does nothing, but it serves as a kind of design specification for diff --git a/README.md b/README.md index 5a4db0553..00a55e163 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,21 @@ treatment of Python that has been actively taught to more than 400 in-person groups since 2007. Traders, systems admins, astronomers, tinkerers, and even a few hundred rocket scientists who used Python to help land a rover on Mars--they've all taken this course. Now, I'm -pleased to make it available under a Creative Commons license. Enjoy! +pleased to make it available under a Creative Commons license--completely +free of spam, signups, and other nonsense. Enjoy! [GitHub Pages](https://dabeaz-course.github.io/practical-python) | [GitHub Repo](https://github.com/dabeaz-course/practical-python). ---David Beazley ([https://dabeaz.com](https://dabeaz.com)), [@dabeaz](https://twitter.com/dabeaz) +--David Beazley ([https://dabeaz.com](https://dabeaz.com)), [@dabeaz](https://mastodon.social/@dabeaz) + +(P.S. This course is about Python. If you want a Python course that's about programming, +you might consider [Advanced Programming with Python](https://www.dabeaz.com/advprog.html)) ## What is This? The material you see here is the heart of an instructor-led Python training course used for corporate training and professional -development. It has been in continual development since 2007 and +development. It was in continual development from 2007 to 2019 and battle tested in real-world classrooms. Usually, it's taught in-person over the span of three or four days--requiring approximately 25-35 hours of intense work. This includes the completion of @@ -36,7 +40,7 @@ doing a bit of Python programming. ## Course Objectives The goal of this course is to cover foundational aspects of Python -programming with an emphasis on script writing, data manipulation, and +programming with an emphasis on script writing, basic data manipulation, and program organization. By the end of this course, students should be able to start writing useful Python programs on their own or be able to understand and modify Python code written by their @@ -57,6 +61,9 @@ This is not a course on web development. That's a different circus. However, if you stick around for this circus, you'll still see some interesting acts--just nothing involving animals. +This is not a course on using tools that happen to be written +in Python. It's about learning the core Python language. + This is not a course for software engineers on how to write or maintain a one-million line Python application. I don't write programs like that, nor do most companies who use Python, and neither should @@ -68,9 +75,8 @@ Ok, ok. Point your browser [HERE](Notes/Contents.md)! ## Community Discussion -Want to discuss the course? You can join the conversation on -[Gitter](https://gitter.im/dabeaz-course/practical-python). I can't -promise an individual response, but perhaps others can jump in to help. +Want to discuss the course? Feel free to use [GitHub Discussions](https://github.com/dabeaz-course/practical-python/discussions). +I can't promise an individual response, but perhaps others can jump in to help. ## Acknowledgements @@ -122,6 +128,18 @@ caused everyone's head to explode or there was never enough time to cover it in the first place. Also, this is a course, not a Python reference manual. +### Q: Why isn't awesome `{command}` in awesome `{tool}` covered? + +The focus of this course is on learning the core Python language, +not learning the names of commands in tools. + +### Q: Is this course being maintained or updated? + +This course represents a "finished product" that was taught and +developed for more than decade. I have no plans to significantly +revise the material at this time, but will occasionally fix bugs and +add clarification. + ### Q: Do you accept pull requests? Bug reports are appreciated and may be filed through the diff --git a/_layouts/default.html b/_layouts/default.html index 157eeb417..81a8c456e 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -41,7 +41,7 @@
