[Tutor] checking connection to internet until success
Hi Tutor, with this code i am getting actual date from internet. I need correct date, because i am not sure this set on computer is right. import requests, time try: OnLineDate = requests.get("http://just-the-time.appspot.com";).text[:10] OffLineDate = time.strftime("%Y-%m-%d") if OnLineDate == OffLineDate: do_something else: do_something_else except requests.ConnectionError: print("Can not connect.") But this code is run once. And i am stuck. Tries with while loop doesnt took any advance. I was thinking about something like after method used in tkinter, but still i cant figure out how do this. Can You guide me, how check connection to internet to check for every lets say 30 seconds until success? Best regards ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] os.walk() with multiple paths
Hello Tutor, I'm stuck and i really need help. Google and I can't find answer for my problem. I've wrote app searching through directories database files. It works fine, but only for one path. And I need to use more than one path. This is my code: import os files = [] def find_db(paths): for path in paths.split(): for root, dirs, filenames in os.walk(path): for name in filenames: if name.endswith((".db", ".sqlite", ".sqlite3")): files.append(name + ', ' + os.path.join(root, name)) return sorted(set(files)) With one path given works great: >>> find_db("/dbbs") ['april.db, /dbbs/analysis/april.db', 'important.sqlite, /dbbs/temp/important.sqlite', 'march.db, /dbbs/analysis/march.db', 'weelky.sqlite3, /dbbs/analysis/queue/weelky.sqlite3'] But with more paths gives files only for last path given: >>> find_db("/home/user/Desktop, /dbbs") ['april.db, /dbbs/analysis/april.db', 'important.sqlite, /dbbs/temp/important.sqlite', 'march.db, /dbbs/analysis/march.db', 'weelky.sqlite3, /dbbs/analysis/queue/weelky.sqlite3'] I was trying to debug this code and I think problem is somewhere here: for path in paths.split(): for root, dirs, filenames in os.walk(path): Can You guide me where i've made mistake? os.walk() accepts one path to look, so was searching something like chain from itertools, or argparse. But none of them works. I couldn't find anything suits my needs. Is there some way do what i need without import anything else than os module? If not what I should search for? Best Regards ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] looking for a Python feature for computer teaching
As a teacher I find python simple and effective. However, appreciate feedback from anyone who knows of a Python version with this feature: Want each interpreted line of code to introduce as a cells on a spreadsheet window each new variable (or array) with its initialized value, and show the updated contents of each previously defined variable (or array). As a student types in a line of code they will see how that line impacts old data and introduces new data. This can now be done manually on a blackboard but is slow and tedious. Here are two simple spreadsheets that show how it might look for a student to step through their code: https://docs.google.com/spreadsheets/d/1FkyzsT4VcGf9APE4IgHEYl4f6EI3C_DdUi_oD9K9shU/edit?usp=sharing https://docs.google.com/spreadsheets/d/1mxIlScRBUa0Qtxg0G65Pw4FupeuDTDXQQbvpON7EH5M/edit?usp=sharing If anyone knows another language (assembler, forth, C, J, ...) which already has this feature, appreciate a link. But as syntax of Python is relatively clean and suited for instruction, much prefer something in Python. Cam Trenor secondary math/science ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor