Am 03.12.2015 um 18:23 schrieb Terry Reedy:
On 12/3/2015 11:00 AM, Robin Koch wrote:
Am 03.12.2015 um 10:02 schrieb Gary Herron:
On 12/02/2015 10:55 PM, Robert wrote:
Hi,

I read the tutorial on "Why is join() a string method instead of a list
  or tuple method?"
at link:
https://docs.python.org/2/faq/design.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls




I have a problem on running the last line:
---------------
If none of these arguments persuade you, then for the moment you can
  continue to use the join() function from the string module, which
allows
  you to write

string.join(['1', '2', '4', '8', '16'], ", ")
-----------------------
...
You are trying to use the *string* module without importing it, I'd
guess.

Try:
     import string
first then you should be able to access string.join without error.

Now *I* am confused.

Shouldn't it be

", ".join(['1', '2', '4', '8', '16'])

instead? Without any importing?

Yes, that is what one *should* do in late 2.x and indeed must do in 3.x,
where the string module has been stripped of the functions that later
became string methods.  The FAQ entry was written when the join method
was new as a method and some people were upset by the reversal of the
order of the two arguments, an iterable of strings and the joining string.

Thank you.
I figured that out by now. :-)

I just didn't followed the link of the OP.

--
Robin Koch

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to