Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99938

Re: 'string.join' is wrong in my Python console

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From dieter <dieter@handshake.de>
Newsgroups comp.lang.python
Subject Re: 'string.join' is wrong in my Python console
Date Thu, 03 Dec 2015 08:39:59 +0100
Lines 31
Message-ID <mailman.160.1449128446.14615.python-list@python.org> (permalink)
References <88afafc5-699f-46ea-aaca-7e78b75a4552@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace news.uni-berlin.de u229cUPxzzP1bKPFXZLmaAkDgRJW2e9Rhd2VJIZQfOWg==
Cancel-Lock sha1:TCFtbgeglWrWeEuM5bVOkfQiwLQ=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'line:': 0.07; "subject:' ": 0.07; 'nameerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tuple': 0.09; 'python': 0.10; '2.7': 0.13; 'last)': 0.16; 'nameerror': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'url:faq': 0.16; 'string': 0.17; 'module,': 0.18; 'arguments': 0.22; 'defined': 0.23; 'import': 0.24; '(most': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; 'tutorial': 0.29; 'allows': 0.30; 'too.': 0.30; 'problem': 0.33; 'url:python': 0.33; 'traceback': 0.33; 'skip:- 10': 0.34; 'running': 0.34; 'list': 0.34; 'robert': 0.35; 'should': 0.36; 'instead': 0.36; 'url:org': 0.36; 'to:addr:python- list': 0.36; 'method': 0.37; 'received:org': 0.37; 'charset:us- ascii': 0.37; 'skip:- 20': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'received:217': 0.66; 'link:': 0.69; "'2',": 0.84; '2.7.': 0.84
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host pd9e09285.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99938

Show key headers only | View raw


Robert <rxjwg98@gmail.com> writes:

> 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'], ", ")
> -----------------------
>
> My Python console is 2.7. It should be no problem because I see the tutorial
> is 2.7 too.
>
> The console has these display:
>
> string.join(['1', '2', '4', '8', '16'], ", ")
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call last)
> <ipython-input-15-3947890a7e6e> in <module>()
> ----> 1 string.join(['1', '2', '4', '8', '16'], ", ")
>
> NameError: name 'string' is not defined 

You need to import the "string" module before you can use it.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

'string.join' is wrong in my Python console Robert <rxjwg98@gmail.com> - 2015-12-02 22:55 -0800
  Re: 'string.join' is wrong in my Python console dieter <dieter@handshake.de> - 2015-12-03 08:39 +0100
  Re: 'string.join' is wrong in my Python console Sijan Bhandari <sijanonly@gmail.com> - 2015-12-02 23:59 -0800
  Re: 'string.join' is wrong in my Python console Gary Herron <gherron@digipen.edu> - 2015-12-03 01:02 -0800
    Re: 'string.join' is wrong in my Python console Robin Koch <robin.koch@t-online.de> - 2015-12-03 17:00 +0100
      Re: 'string.join' is wrong in my Python console MRAB <python@mrabarnett.plus.com> - 2015-12-03 16:24 +0000
      Re: 'string.join' is wrong in my Python console Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-03 09:25 -0700
        Re: 'string.join' is wrong in my Python console Robin Koch <robin.koch@t-online.de> - 2015-12-03 18:01 +0100
          Re: 'string.join' is wrong in my Python console Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-03 17:42 +0000
            Re: 'string.join' is wrong in my Python console Robin Koch <robin.koch@t-online.de> - 2015-12-03 19:15 +0100
      Re: 'string.join' is wrong in my Python console Terry Reedy <tjreedy@udel.edu> - 2015-12-03 12:23 -0500
        Re: 'string.join' is wrong in my Python console Robin Koch <robin.koch@t-online.de> - 2015-12-03 19:16 +0100

csiph-web