Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99942
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Gary Herron <gherron@digipen.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: 'string.join' is wrong in my Python console |
| Date | Thu, 3 Dec 2015 01:02:21 -0800 |
| Lines | 57 |
| Message-ID | <mailman.162.1449133357.14615.python-list@python.org> (permalink) |
| References | <88afafc5-699f-46ea-aaca-7e78b75a4552@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de QFVSpzCy5vuN2b1e72T12Awd8AC/+wz+mC85TEPSyhqg== |
| Return-Path | <gherron@digipen.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'line:': 0.07; "subject:' ": 0.07; 'nameerror:': 0.09; 'tuple': 0.09; 'python': 0.10; '2.7': 0.13; 'importing': 0.15; 'guess.': 0.16; 'last)': 0.16; 'nameerror': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'url:faq': 0.16; 'wrote:': 0.16; 'string': 0.17; 'module,': 0.18; 'try:': 0.18; 'arguments': 0.22; 'trying': 0.22; 'defined': 0.23; 'thanks,': 0.24; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'function': 0.28; 'context,': 0.29; 'tutorial': 0.29; 'allows': 0.30; 'too.': 0.30; 'skip:& 30': 0.30; "i'd": 0.31; 'error.': 0.31; 'problem': 0.33; 'url:python': 0.33; 'traceback': 0.33; 'skip:- 10': 0.34; 'running': 0.34; 'list': 0.34; 'could': 0.35; 'replaced': 0.35; 'robert': 0.35; 'something': 0.35; 'should': 0.36; 'instead': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'skip:& 10': 0.37; 'method': 0.37; 'hi,': 0.38; 'why': 0.39; 'skip:- 20': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'charset:windows-1252': 0.62; 'else.': 0.66; 'link:': 0.69; 'dr.': 0.69; 'received:204': 0.75; 'institute': 0.77; "'2',": 0.84; '(425)': 0.84; '2.7.': 0.84; '895-4418': 0.84; 'digipen': 0.84; 'herron': 0.84 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| In-Reply-To | <88afafc5-699f-46ea-aaca-7e78b75a4552@googlegroups.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| 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:99942 |
Show key headers only | View raw
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'], ", ")
> -----------------------
>
> 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
>
>
> From the context, I don't see string should be replaced by something else.
>
> Could you tell me why I have such an error?
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.
Gary Herron
>
>
> Thanks,
--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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