Jul-29-2019, 09:02 PM
(Jul-29-2019, 08:15 PM)millpond Wrote: But as a n00b, only one question remains: is there a way to quickly search to see what method belongs to what module in the standard library (or Pypi)?
Not really. It's easy to do the other way around. If you import a module, dir(module_name) will give you all the names (classes/functions/constants) in it. Likewise, if you do dir() on an instance of a particular data type, it will show you the methods and attribute names for that data type. You can often web search for 'python method_name' for something in the standard library, which is well documented. Outside the standard library the documentation online is really hit or miss.
Good Python code should show you the import so you know where things are coming from. In fact, it's generally considered good form to
import module
instead of from module import name1, name2, name3
, so the module will be directly referenced when the call is made. Some bigger modules are often abbreviated when imported, so you often see tk for tkinter and pd for pandas.In terms of looping, definitely get familiar with the built-in functions enumerate and zip. You use enumerate to loop through a sequence and have the index of the current item, and you use zip to iterate over two or more lists at the same time. And, yes, itertools is a very useful module. Also check out collections, which provides more sequences and mappings.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures