Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lists to strings
#4
(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
Reply


Messages In This Thread
Lists to strings - by millpond - Jul-29-2019, 12:20 AM
RE: Lists to strings - by ichabod801 - Jul-29-2019, 01:14 AM
RE: Lists to strings - by millpond - Jul-29-2019, 08:15 PM
RE: Lists to strings - by ichabod801 - Jul-29-2019, 09:02 PM
RE: Lists to strings - by millpond - Jul-31-2019, 08:06 PM
RE: Lists to strings - by ichabod801 - Aug-01-2019, 01:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strings inside other strings - substrings OmarSinno 2 3,795 Oct-06-2017, 09:58 AM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020