Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
str.join()?
#3
With str.join() you call instance method directly on the class. It expects to implicitly receive instance of the class - that will be used as separator and an iterable, whose elements will be concatenated with the use of the separator

that's why @Griboulis example
str.join('a', 'bc') # 'a' is the instance of str and 'bc' is the iterable

is identical with
'a'.join('bc')
and yield the same output.
metulburr likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
str.join()? - by Skaperen - Oct-16-2020, 12:23 AM
RE: str.join()? - by Gribouillis - Oct-16-2020, 04:49 AM
RE: str.join()? - by buran - Oct-16-2020, 07:17 AM
RE: str.join()? - by Skaperen - Oct-16-2020, 06:50 PM

Forum Jump:

User Panel Messages

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