Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: dieter 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: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99938 Robert 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) > in () > ----> 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.