Monday, January 18, 2016

It's late and I'm exhausted but wow did I do some cool stuff today.  My best thing so far, I think, is this error correction module "entry_validation.py"

If it's imported to a python script, you can use validate('question', [list of correct answers], 'data type')
and validate returns an acceptable answer (courtesy of try, assert and while).  You can also test for simple entry types (int, str, float) and force the user to enter an acceptable type by leaving the [list] argument just an empty list.

I'm pretty sure this module can be improved (especially since 'data type' is not just a type, but one of a long list of flags I devised - they're written out in the comment at the top of the module).

But still, I'd seen, but not worked with "Try/except" or "assert" before today.

Also! My budget app now has error correction, entries can be edited, and files can be written and saved and re-opened with no loss of data (even the index/counter will be the same as before).

I'd still like to be able to open a file and append it to an existing inventory (although you can open a file, import it to the in-app dictionary with column titles becoming dictionary keys dynamically).

Also, being able to change the number of data fields in response to user input would be nice.

Also, error correction on the file open function will go in tomorrow.

But still, not too shabby since I only had a few hours to work independently today. (I'm doing some crude version control with file names.  Git tutorial soon!)

Update on the morning after: the error fixing code is probably needlessly complex.  Still a good learning experience.

No comments:

Post a Comment