-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Labels
Description
I applaud you for trying to do this - but I have noted one or more issues :
- Variables page - the id function does not return the address - it returns the object identifier. It is not intended to be nor should it be implied that it is the address.
- Variables Page - a nit pick here but strictly speaking the variable doesn't have a type. The value has a type and the name simply points to an object which has a value. In Python it is dynamic typing, so you can assign an integer object to a name, and two lines later assign a string object to the same name. Talking about objects (rather than 'memory') is important because only some objects in Python are mutable, and some aren't : adding something to a list will change the list - adding a value to a number will create a brand new object for the new value; that distinction is critical.
- Your 'more about the language' page mentions 'Batch mode' - no-one I know calls it that. Please use the right terminology.
- Constructs page : Most beginners wont understand what 'constructs' mean, and if they do, they aren't beginners; I would suggest a page titled making decisions, and another page entitled loops.
- Constructs page: you mention that indentation is counted as 4 spaces - stricly this is wrong - you can use any level of indentation you want so long as your blocks are consistent. I know indents of 4 spaces are recommeded by you can use 1 space, 3, 8 or anything.
- Constructs page: You give this example :
for i in range(len(l)):
print(l[i])
This is so horrible that it is strongly discouraged. If you need to have the index of an item of the list - do this :
for index, item in enumerate(my_list):
print(index, ':', item )
- Constructs page : I appreciate you attempting to show your indentation - but I am not sure using [] to illustrate where the intendentations are works - is there a different way to do this ?
- Constructs page : No mention of else after a loop so that you can execute code only if the list doesn't execute a break.
- Your list, sets, dicts page contains no details of how to iterate around these (i.e. a for loop), and no mention of using enumerate while iterating to get the index and the element.
- Your file handling section is poor to be honest - you do a readline() before each loop; not only is this superfluous, but with a very large file you could well end up filling memory. You appear not to realise that an an open file is an iterator (it has been since Python2.3) or earlier, which means you can use a for loop to iterate around the file contents
- No mention of 'with' to open file safely (i.e. ensure it is always closed). This is much prefered than using open/close and hoping nothing goes wrong.
- Your file handling page mentions list comprehensions - should this be in the list,set,dict page - or a page on it's own ? Also - no mention of dict or set comprehensions.
- Exception handling - no mention of using 'else' to execute code if no exception is triggered - different from 'finally'
- Functions - No mention of mutating arguments (if a function is passed a mutable value as an argument, and the function changes that value, then the calling function will see that change).
- Functions - no mention of not using 'mutable objects' as default arguments - it doesn't do what most beginners think it should.
- Todo list manager : Instead of using a '|' to separate title and content and text files - why not show your students the better way to do things - each task should be a dictionary - that enables you to extend the dictionary later - maybe with due dates etc. and then use the pickle library to save and load your list of tasts. It is far better to do that than to try to use text for complex data.
- CSV to sql - why not use the CSV reader module - you should be showing your students the power of the standard library rather than writing their own.
Please - try to fix these issues - as I say - I applaud you for trying - but if you want to teach - teach best practice.