first abstraction added

This commit is contained in:
waldek 2021-10-26 14:31:10 +02:00
parent bb1ec3b9bc
commit 9801ac0379
2 changed files with 130 additions and 4 deletions

View File

@ -0,0 +1,30 @@
import sys
import threading
import time
import queue
input_queue = queue.Queue()
def add_input(input_queue):
while True:
input_queue.put(sys.stdin.read(1))
def foobar():
global input_queue
input_thread = threading.Thread(target=add_input, args=(input_queue,))
input_thread.daemon = True
input_thread.start()
last_update = time.time()
while True:
if time.time()-last_update>0.5:
sys.stdout.write(".")
sys.stdout.flush()
last_update = time.time()
if not input_queue.empty():
print("\ninput:", input_queue.get())
foobar()

View File

@ -73,6 +73,11 @@ TODO
TODO helloworld
## How to execute
* within pycharm
* from the command line
## Simple printing
## String formatting
@ -89,23 +94,38 @@ TODO say hello program
TODO say hello plus ask for age
* slightly insist on *blocking* nature of `input()`
## Conditional logic
* introduction to `if`, `elif` and `else`
## Class string methods
# Coding challenge - Celsius to Fahrenheit converter
# Creating your own functions
## Functions that *do* something
TODO pretty_print
## Functions that *do* something
## Variable scope
## Functions that *return* something
TODO basic math functions
# Using the standard library
TODO import random exercise (digital dice)
TODO import datetime exercise (will it be Sunday)
# Coding challenge - Memento Mori calculator
# Writing your first library
TODO import pretty print
TODO import pretty print and digital dice
## What are libraries?
@ -113,8 +133,84 @@ TODO import pretty print
## What is `__name__ == "__main__"`?
# Using the standard library
## Anatomy of a program
TODO import random exercise
TODO imports, functions, execution
# While loop
TODO guess the number exercise
# Lists
## Creating lists
## Picking elements
## Slicing lists
# For loop
TODO say hello to my friends exercise
# Coding challenge - Cheerleader chant
TODO nested for loop exercise
# Dictionaries as data containers
TODO adapt the login generator to output a dict
# Handling files
## Reading from a file
## Writing to a file
## csv, JSON and yaml
# Coding challenge - Login generator
TODO write a login generator as a library with a cli as program
BONUS argparse, save to file, read from file
# Creating our own classes
## Class examples
TODO simple animal or vehicle exercise
## Class inheritance
TODO superhero game
## Improve the login generator
TODO convert the login generator to a class
# Infinite programs
* insist on the nature of scripts we did up until now
## Logic breakdown of a simple game
TODO hangman exercise
## Trivial pursuit multiple choice game
TODO [db](https://opentdb.com/api_config.php)
## Threading
TODO add a countdown timer to the multiple choice game
# GUI programming
## wxpython helloworld
## wxpython guess the number
# Introduction to the `logging` library
# Coding challenge - Login generator with GUI