-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intermediate level Python tips and functions #76
Comments
Most of these would be good to teach (except |
This idea seemed popular among the students, which made me wonder if one could go further still. I am now considering writing a similar guide covering what I see as the two remaining topics that the students could benefit from; Classes and type annotations. |
You could easily have a full course that would be just about classes in general, and you could easily have a full course that would be just about how classes are implemented in Python. The topic is so broad that when you say you want to introduce classes here I really have no idea what you mean by that. The way I see it using type annotations comes in three tiers: 1) annotating the public API for readability and better autocompletion, 2) making |
There are a number of things in Python that are not required to write working code but that make your code better/cleaner/safer if you use them. For this reason, when the objective is to teach people the basics of programming so that they can do anything at all, these things tend to be skipped. We have an opportunity to provide this knowledge to students at the appropriate level.
Here are some examples of what I have in mind:
enumerate()
instead of manually incrementing an indexing variable in a for-loop.zip()
to iterate over two lists at the same time.pathlib
instead ofos.path
, andPath.open
instead ofopen
..extend()
exists and when to use it instead of.append()
.ord()
andchr()
functions ( I have not found a use for them in a scientific context but they are useful for general programming).set
data type and its uses.map()
andfilter()
.I'm not sure where this could go (though there is no room to spare anywhere except session 4), maybe this should not be in the presentations at all and left as a compendium, either in a manual or as its own document.
The text was updated successfully, but these errors were encountered: