Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail 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; 'python.': 0.02; 'subject:error': 0.03; 'win32': 0.03; '(at': 0.04; 'digest': 0.04; 'from:addr:yahoo.co.uk': 0.04; 'languages,': 0.04; 'syntax': 0.04; 'value,': 0.04; 'interpreter': 0.05; 'messages.': 0.05; 'mrab': 0.05; 'attribute': 0.07; 'friend.': 0.07; 'interpreter.': 0.07; 'none,': 0.07; 'string': 0.09; '[1,': 0.09; 'append': 0.09; 'assuming': 0.09; 'lawrence': 0.09; 'modifies': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language.': 0.14; 'random': 0.14; 'changes': 0.15; '"python': 0.16; "'mylist'": 0.16; 'ah,': 0.16; 'argument,': 0.16; 'be:': 0.16; 'googling': 0.16; 'idle.': 0.16; 'interpreter,': 0.16; 'mylist': 0.16; 'nameerror:': 0.16; 'none.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'variable': 0.18; 'wed,': 0.18; 'bit': 0.19; 'trying': 0.19; "python's": 0.19; 'result.': 0.19; 'thu,': 0.19; 'not,': 0.20; 'written': 0.21; 'help.': 0.21; 'command': 0.22; '>>>': 0.22; 'programming': 0.22; 'shell': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'example.': 0.24; 'instead.': 0.24; 'tells': 0.24; 'options': 0.25; 'define': 0.26; 'least': 0.26; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'errors': 0.30; 'especially': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'you?': 0.31; '"",': 0.31; '+0100,': 0.31; '>>>>': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'this.': 0.32; "we're": 0.32; 'run': 0.32; '(most': 0.33; 'checking': 0.33; 'message.': 0.35; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'right?': 0.36; "didn't": 0.36; 'method': 0.36; 'useful': 0.36; 'thanks': 0.36; 'should': 0.36; 'list': 0.37; 'clear': 0.37; 'step': 0.37; 'being': 0.38; 'ahead': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'that,': 0.38; 'anything': 0.39; 'recent': 0.39; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'tell': 0.60; 'subject: ': 0.61; "you're": 0.61; 'first': 0.61; 'you.': 0.62; 'show': 0.63; 'information': 0.63; 'name': 0.63; 'our': 0.64; 'more': 0.64; 'talking': 0.65; 'charset:windows-1252': 0.65; 'prompt': 0.68; 'soon.': 0.71; 'url:i': 0.72; 'special': 0.74; 'click': 0.77; 'url:jpg': 0.83; '2014,': 0.84; 'desperate': 0.84; 'ever.': 0.84; 'exercise.': 0.84; 'experiment': 0.84; 'gray': 0.84; 'learn.': 0.84; 'technique.': 0.84; 'url:imgur': 0.84; 'forgotten': 0.91; 'subject:Lists': 0.91; 'success!': 0.93; 'this!': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: I am out of trial and error again Lists Date: Thu, 23 Oct 2014 08:20:32 +0100 References: <54484635$0$12992$c3e8da3$5496439d@news.astraweb.com> <8nmg4aljnmigjtjk70cc4g6dmacca6negc@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-18-1-206.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 122 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414048846 news.xs4all.nl 2863 [2001:888:2000:d::a6]:37359 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79504 On 23/10/2014 02:57, Seymore4Head wrote: > On Wed, 22 Oct 2014 21:35:19 -0400, Seymore4Head > wrote: > >> On Thu, 23 Oct 2014 02:31:57 +0100, MRAB >> wrote: >> >>> On 2014-10-23 01:10, Seymore4Head wrote: >>>> On Thu, 23 Oct 2014 11:05:08 +1100, Steven D'Aprano >>>> wrote: >>>> >>>>> Seymore4Head wrote: >>>>> >>>>>> Those string errors were desperate attempts to fix the "append" error >>>>>> I didn't understand. >>>>> >>>>> Ah, the good ol' "make random changes to the code until the error goes away" >>>>> technique. You know that it never works, right? >>>>> >>>>> Start by *reading the error message*, assuming you're getting an error >>>>> message. I'm the first person to admit that Python's error messages are not >>>>> always as clear as they should be, especially syntax errors, but still >>>>> there is a lot of information that can be gleamed from most error messages. >>>>> Take this attempt to use append: >>>>> >>>>> py> mylist.append(23) >>>>> Traceback (most recent call last): >>>>> File "", line 1, in >>>>> NameError: name 'mylist' is not defined >>>>> >>>>> That tells me that I have forgotten to define a variable mylist. So I fix >>>>> that: >>>>> >>>>> py> mylist = 23 >>>>> py> mylist.append(23) >>>>> Traceback (most recent call last): >>>>> File "", line 1, in >>>>> AttributeError: 'int' object has no attribute 'append' >>>>> >>>>> >>>>> That tells me that I can't append to a int. After googling for "Python >>>>> append" I learn that I can append to a list, so I try again: >>>>> >>>>> py> mylist = [] >>>>> py> mylist.append(23) >>>>> py> print(mylist) >>>>> [23] >>>>> >>>>> >>>>> Success! >>>>> >>>>> If you are familiar with other programming languages, it might help to think >>>>> of append() as being like a procedure in Pascal, for example. You call >>>>> append() with an argument, but don't expect a return result. >>>>> >>>>> Technically, *all* functions and methods in Python return something, even if >>>>> just the special value None, which can lead to "Gotchas!" like this one: >>>>> >>>>> py> mylist = mylist.append(42) # Don't do this! >>>>> py> print(mylist) # I expect [23, 42] but get None instead. >>>>> None >>>>> >>>>> Oops. One of the small annoyances of Python is that there is no way to tell >>>>> ahead of time, except by reading the documentation, whether something is a >>>>> proper function that returns a useful value, or a procedure-like function >>>>> that returns None. That's just something you have to learn. >>>>> >>>>> The interactive interpreter is your friend. Learn to experiment at the >>>>> interactive interpreter -- you do know how to do that, don't you? If not, >>>>> ask. At the interactive interpreter, if a function or method returns a >>>>> value, it will be printed, *except for None*. So a function that doesn't >>>>> print anything might be procedure-like, and one which does print something >>>>> might not be: >>>>> >>>>> py> mylist = [1, 5, 2, 6, 4, 3] >>>>> py> sorted(mylist) # proper function returns a value >>>>> [1, 2, 3, 4, 5, 6] >>>>> py> mylist.sort() # procedure-like function returns None >>>>> py> print(mylist) # and modifies the list in place >>>>> [1, 2, 3, 4, 5, 6] >>>> >>>> I am going to get around to learning the interpreter soon. >>>> >>> Why wait? >>> >>> You're trying to learn the language _now_, and checking things >>> interactively will help you. >> >> Because most of the practice I am getting is not using Python. I use >> Codeskulptor. >> >> OK.........Now is as good a time as ever. >> >> Thanks > > Now I remember why...........nothing happens > http://i.imgur.com/MIRpqzY.jpg > > If I click on the shell window, I can get the grayed options to show > up for one turn. > I hit step and everything goes gray again. > > http://i.imgur.com/NtMdmU1.jpg > > Not a very fruitful exercise. :( > If you were to read and digest what is written it would help. You're trying to run IDLE. We're talking the interactive interpreter. If (at least on Windows) you run a command prompt and then type python you should see something like this. Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence