Re: [Tutor] self keyword in recursive function

2014-05-31 Thread Ritwik Raghav
That's all the code I'm writing. As for the reference to line 182, I have no idea since my code doesn't have line 182. Also, as Peter wrote: "The "topcoder" site is probably infested with the world view of Java where every function is a method inside a class." Topcoder seems too much in love wit

Re: [Tutor] self keyword in recursive function

2014-05-31 Thread Alan Gauld
On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav mailto:ritwikragha...@gmail.com>> wrote: and the error is: Correct Return Value: No Answer check result: Result must be not null. Execution Time: 0.017s Peak memory used: 24.551MB abnormal termination (exit 1)

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Marc Tompkins
On Fri, May 30, 2014 at 11:06 PM, Ritwik Raghav wrote: > That's all the code I'm writing. > That can't be true - the 11 lines of code you posted doesn't include anything that would give you "Correct Return Value: No", let alone any reference to PersistentNumber. From the error message, it would

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
That's all the code I'm writing. The complete problem statement is: http://pastebin.com/E970qYXk On Sat, May 31, 2014 at 11:25 AM, Marc Tompkins wrote: > On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav > wrote: > > >> It has again given some error I do not understand. This time my code is: >>

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Marc Tompkins
On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav wrote: > It has again given some error I do not understand. This time my code is: > > count = 0 > def getPersistence(self,n): > > product = 1 > if len(str(n)) == 1: > return self.count > else: > a = str(n) > for

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
Peter Otten wrote: >Ritwik Raghav wrote: > >> I joined the topcoder community tomorrow and tried solving the >> PersistentNumber problem: >> "Given a number x, we can define p(x) as the product of the digits of x. >> We can then form a sequence x, p(x), p(p(x))... The persistence of x is >> then d

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
Alan Gauld wrote: >On 30/05/14 14:14, Ritwik Raghav wrote: >> I joined the topcoder community tomorrow and tried solving the >> PersistentNumber problem: > >Time travel! I love it already... :-) > >> 8*1 = 8. Thus, the persistence of 99 is 2. You will be given n, and you > >must return its persist

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Peter Otten
Ritwik Raghav wrote: > I joined the topcoder community tomorrow and tried solving the > PersistentNumber problem: > "Given a number x, we can define p(x) as the product of the digits of x. > We can then form a sequence x, p(x), p(p(x))... The persistence of x is > then defined as the index (0-base

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Alan Gauld
On 30/05/14 14:14, Ritwik Raghav wrote: I joined the topcoder community tomorrow and tried solving the PersistentNumber problem: Time travel! I love it already... :-) 8*1 = 8. Thus, the persistence of 99 is 2. You will be given n, and you must return its persistence." It asks to define a fun

[Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
I joined the topcoder community tomorrow and tried solving the PersistentNumber problem: "Given a number x, we can define p(x) as the product of the digits of x. We can then form a sequence x, p(x), p(p(x))... The persistence of x is then defined as the index (0-based) of the first single digit num

Re: [Tutor] Self and class functions

2013-06-29 Thread Dave Angel
On 06/30/2013 12:10 AM, Phil wrote: On 30/06/13 11:41, Dave Angel wrote: Thank you Dave, Matthew and Steven for taking the time to reply. All hints are greatly appreciated. I'm attempting to access the GUI widgets. The buttonClicked slot does what I want but I'd like to access the widgets outs

Re: [Tutor] Self and class functions

2013-06-29 Thread Steven D'Aprano
On 30/06/13 08:36, Phil wrote: Thank you for reading this. I'm attempting to access the GUI widgets. The buttonClicked slot does what I want but I'd like to access the widgets outside of the class. My function setLabel doesn't work because self and ui are not known. What does "doesn't work"

Re: [Tutor] Self and class functions

2013-06-29 Thread Dave Angel
On 06/29/2013 06:36 PM, Phil wrote: Thank you for reading this. You should be telling us some things. I'll guess for you: You're using Python 3.3 with Qt for a gui, and Linux 12.04 for an OS. I'm attempting to access the GUI widgets. The buttonClicked slot does what I want but I'd like to

Re: [Tutor] Self-intro and two short newbie questions

2010-03-18 Thread Kevin Kirton
Thanks very much for the responses. I feel encouraged now to try to create the guitar tuner program by myself first, and then the simple turtle art program after that. It's kind of both exhilarating and daunting that I don't know exactly where to start at the moment, but that's the fun of learning

Re: [Tutor] Self-intro and two short newbie questions

2010-03-18 Thread Alan Gauld
"Kevin Kirton" wrote know it varies depending on the person, but for example, how long would it take _you_?) (i) a simple guitar tuning program involving an image of a guitar and the playing of each of the standard strings of a guitar (E, A, D, G, B, E) upon key input by the user For a profe

Re: [Tutor] Self-intro and two short newbie questions

2010-03-18 Thread spir
On Thu, 18 Mar 2010 22:42:05 +1100 Kevin Kirton wrote: > My questions are: how long would you estimate it to take and how > complicated would it be to create the following as Python programs? (I > know it varies depending on the person, but for example, how long > would it take _you_?) My opinio

Re: [Tutor] Self-intro and two short newbie questions

2010-03-18 Thread Wayne Werner
On Thu, Mar 18, 2010 at 6:42 AM, Kevin Kirton wrote: > Hi all, > > I've committed myself to learning Python and have started reading > "Learning Python" (Mark Lutz) and looking through various online > resources. > My career so far has involved a little high school teaching and about > 10 years o

[Tutor] Self-intro and two short newbie questions

2010-03-18 Thread Kevin Kirton
Hi all, I've committed myself to learning Python and have started reading "Learning Python" (Mark Lutz) and looking through various online resources. My career so far has involved a little high school teaching and about 10 years of translating Japanese to English, but no programming or coding. I'

Re: [Tutor] self-learning Python

2008-03-12 Thread Kent Johnson
Kaushal Shriyan wrote: > I am a newbie with no programming experience. As Kent Johnson has > already pointed here about the book "Python Programming for the > absolute beginner" by Michael Dawson,I checked both in www.amazon.com > and www.ebay.com website. Both this website say "Unavailable" or "Ou

Re: [Tutor] self-learning Python

2008-03-12 Thread Kaushal Shriyan
On Wed, Mar 12, 2008 at 9:00 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Kaushal Shriyan wrote: > > I am a newbie with no programming experience. As Kent Johnson has > > already pointed here about the book "Python Programming for the > > absolute beginner" by Michael Dawson,I checked both in w

Re: [Tutor] self-learning Python

2008-03-12 Thread Kaushal Shriyan
On Tue, Mar 11, 2008 at 1:11 AM, Ian Ozsvald <[EMAIL PROTECTED]> wrote: > Hi Enrique. I'll suggest my ShowMeDo for video tutorials - our 'beginner' > subsection for Python has 101 videos: > http://showmedo.com/videos/python?topic=beginner_programming > > Most of the videos are free (3 series -

Re: [Tutor] self-learning Python

2008-03-10 Thread Ian Ozsvald
Hi Enrique. I'll suggest my ShowMeDo for video tutorials - our 'beginner' subsection for Python has 101 videos: http://showmedo.com/videos/python?topic=beginner_programming Most of the videos are free (3 series - in yellow - require a subscription, everything else is free). Topics covered incl

Re: [Tutor] self-learning Python

2008-03-09 Thread Lowell Tackett
Julia <[EMAIL PROTECTED]> wrote: On Sun, Mar 9, 2008 at 5:00 PM, Lowell Tackett <[EMAIL PROTECTED]> wrote: There's an essential (in my opinion) principle of learning programming...learning is not only absorbing stuff, but what I call (and I'm certain it didn't originate with me) "finger t

Re: [Tutor] self-learning Python

2008-03-09 Thread Julia
On Sun, Mar 9, 2008 at 5:00 PM, Lowell Tackett <[EMAIL PROTECTED]> wrote: > > > There's an essential (in my opinion) principle of learning programming > that doesn't seem to have made its' way into this conversation. I'll > preface my thoughts by saying that in-again, my opinion- Michael Dawson's

Re: [Tutor] self-learning Python

2008-03-09 Thread Lowell Tackett
Julia <[EMAIL PROTECTED]> wrote: Emad Nawfal wrote: > On Sun, Mar 9, 2008 at 8:16 AM, Julia <[EMAIL PROTECTED] > > wrote: > To be honest I truly dislike the Dawson book. I wouldn't recommend > it to anyone. It's lacks technical clarity, examples and has a mes

Re: [Tutor] self-learning Python

2008-03-09 Thread Alan Gauld
"Julia" <[EMAIL PROTECTED]> wrote > When I was a complete beginner I preferred Beginning Python over > Dawson and > I still do (I'm still a beginner). But that might just me be me :) Book (and tutorial) choices are very subjective. I know the styles of book I like and dislike. I hate "chatty, i

Re: [Tutor] self-learning Python

2008-03-09 Thread Julia
> > Emad Nawfal wrote: > > On Sun, Mar 9, 2008 at 8:16 AM, Julia <[EMAIL PROTECTED] > > > wrote: > > To be honest I truly dislike the Dawson book. I wouldn't recommend > > it to anyone. It's lacks technical clarity, examples and has a messy > > index. I'm going

Re: [Tutor] self-learning Python

2008-03-09 Thread bhaaluu
On Sun, Mar 9, 2008 at 8:54 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > On Sun, Mar 9, 2008 at 8:16 AM, Julia <[EMAIL PROTECTED] wrote: > > To be honest I truly dislike the Dawson book. I wouldn't recommend > > it to anyone. It's lacks technical clarity, examples and has a messy > >

Re: [Tutor] self-learning Python

2008-03-09 Thread Luciano Ramalho
My recommendation for a book to learn to program, using Python is "How to think like a Computer Scientist: learning with Python (2nd edition)" [1]. It's a free online book, but a printed version of the first edition is also available. [1] http://openbookproject.net/thinkCSpy/index.xhtml Don't let

Re: [Tutor] self-learning Python

2008-03-09 Thread Kent Johnson
Emad Nawfal wrote: > On Sun, Mar 9, 2008 at 8:16 AM, Julia <[EMAIL PROTECTED] > > wrote: > To be honest I truly dislike the Dawson book. I wouldn't recommend > it to anyone. It's lacks technical clarity, examples and has a messy > index. I'm going to sell my e

Re: [Tutor] self-learning Python

2008-03-09 Thread Emad Nawfal
On Sun, Mar 9, 2008 at 8:16 AM, Julia <[EMAIL PROTECTED]> wrote: > Message: 3 > > Date: Sat, 08 Mar 2008 16:39:16 -0500 > > From: Kent Johnson <[EMAIL PROTECTED]> > > Subject: Re: [Tutor] self-learning Python > > To: "Enrique Nieves, Jr." <[EM

Re: [Tutor] self-learning Python

2008-03-09 Thread Julia
> > Message: 3 > Date: Sat, 08 Mar 2008 16:39:16 -0500 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] self-learning Python > To: "Enrique Nieves, Jr." <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]&

Re: [Tutor] self-learning Python

2008-03-08 Thread Alan Gauld
"Enrique Nieves, Jr." <[EMAIL PROTECTED]> wrote > I'm not a programmer, but would like to learn to program. I'm > considering > self-learning python on my spare time. Can you recommend the best > books, > online training, or other resources? I know nothing about > programming. Yes, you can

Re: [Tutor] self-learning Python

2008-03-08 Thread Kent Johnson
Enrique Nieves, Jr. wrote: > I’m not a programmer, but would like to learn to program. I’m > considering self-learning python on my spare time. Can you recommend > the best books, online training, or other resources? I know nothing > about programming. There are several good on-line tutorial

Re: [Tutor] self-learning Python

2008-03-08 Thread jim stockford
i'm working (gratefully) with a small python study group and preparing an intro to python class. if you like, i'll send you my lessons and hope for your questions and feedback.mine is certainly not the best python material (i think it's not bad), but it comes with the ability for you t

[Tutor] self-learning Python

2008-03-08 Thread Enrique Nieves, Jr.
I'm not a programmer, but would like to learn to program. I'm considering self-learning python on my spare time. Can you recommend the best books, online training, or other resources? I know nothing about programming. enrique ___ Tutor maillist -

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-26 Thread Alan Gauld
Replying to my own post, how sad... "Alan Gauld" <[EMAIL PROTECTED]> wrote > First we need a way to create objects since we dont have > classes...so we write a function that returns a dictionary. > We'll make it simple and have a message class that stores > a string and has a display method. >

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-26 Thread Alan Gauld
> I ran onto the problem of the dictionary being changed globally, > when I > thought that use of "self" meant that any changes to that data were > limited > to the scope of the method in that particular class No, but you know that now :-) Let me try an alternative explanaytion for self, since

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-26 Thread doug shawhan
On 10/25/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: >> I'm sure this is so obvious that a crack-addled tapeworm head down in> a bucket of stupid could understand it, unfortunately, I'm not quite> at that level today. Sorry.Uh, I don't understand why you're passing Fields to the functions but

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-26 Thread Alan Gauld
"doug shawhan" <[EMAIL PROTECTED]> wrote > I'm having a rather difficult time understanding the proper use of > "self". Doug, I think you may be having a more fundamental problem. Looking at your code at the most superficial level it seems you may not understand objects. Classes are used to gene

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-25 Thread John Fouhy
On 26/10/06, doug shawhan <[EMAIL PROTECTED]> wrote: > class Create: > def freshDB(self, DBPATH, Fields): > # ... > def comparisonTable(self, DBPATH, Fields, columns, mode): > # ... > Now when I run freshDB from the other script: > > Fields = {"Common":"Inventory_Nu

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-25 Thread Luke Paireepinart
> > I'm sure this is so obvious that a crack-addled tapeworm head down in > a bucket of stupid could understand it, unfortunately, I'm not quite > at that level today. Sorry. Uh, I don't understand why you're passing Fields to the functions but then putting the value in self.Fields... but we'll

[Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-25 Thread doug shawhan
I'm having a rather difficult time understanding the proper use of "self". I have two functions (yes, they are ugly, I was getting ready to split them in to smaller bits when this particular hole in my skull opened up) in a module. They use the same list of dictionaries to create some tables in a

Re: [Tutor] self-modification

2006-08-21 Thread Alan Gauld
> I'm a newbie to Python. I wanted to write a graphical interface > which would show the built-in documentation (I mean dir() and > __doc__ ) of Python. The code shows how far I got before realizing > that I had to use some self-modification feature (converting a > string to a function or to an

Re: [Tutor] self-modification

2006-08-21 Thread Kent Johnson
Zsiros Levente wrote: > I'm a newbie to Python. I wanted to write a graphical interface which > would show the built-in documentation (I mean dir() and __doc__ ) of > Python. The code shows how far I got before realizing that I had to use > some self-modification feature (converting a string to

[Tutor] self-modification

2006-08-21 Thread Zsiros Levente
I'm a newbie to Python. I wanted to write a graphical interface which would show the built-in documentation (I mean dir() and __doc__ ) of Python. The code shows how far I got before realizing that I had to use some self-modification feature (converting a string to a function or to an object; i

Re: [Tutor] self (again)

2006-08-13 Thread Alan Gauld
> I think it works as follows. I just need to know what is right. > > Class variables are 'global' for the class and all instances of the > class. Correct. Classes are containers and they contain the class variables and method definitions shared by all instances of the class (and its subclasses).

[Tutor] self (again)

2006-08-13 Thread John Aherne
I have been following the thread on self because for the past month I have been driven potty trying to be sure that I understand the ramifications of how self works. I have tried to create some code that tries to prove how self, variables, assignment and namespace gel together. I can't convince

Re: [Tutor] self

2006-02-13 Thread Ewald Ertl
Hi Shuying! Shuying Wang wrote: > Hi, > > I'm having problems understanding some code I came across: > > class Singleton: > __single = None > def __init__( self ): > if Singleton.__single: > raise Singleton.__single > Singleton.__single = self > > What does

[Tutor] self

2006-02-12 Thread Shuying Wang
Hi, I'm having problems understanding some code I came across: class Singleton: __single = None def __init__( self ): if Singleton.__single: raise Singleton.__single Singleton.__single = self What does passing self to Singleton.__single do? --Shuying

Re: [Tutor] self knowledge

2005-10-21 Thread Alan Gauld
Hi Ethan, > When using the class in practice, I've found it natural to > create instances of Foo so that the instance itself is called > name. Thus, I find myself doing things like: > a=Foo('a') b=Foo('b') > This is very common at the interactive prompt. However its nearly always the w

Re: [Tutor] self knowledge

2005-10-21 Thread Kent Johnson
Ethan Ligon wrote: > I've devised a simple class; one of the class attributes is an identifier. > > Thus, > > class Foo: > def __init__(self,name): > self.name=name > > When using the class in practice, I've found it natural to > create instances of Foo so that the instance itself is calle

[Tutor] self knowledge

2005-10-21 Thread Ethan Ligon
I've devised a simple class; one of the class attributes is an identifier. Thus, class Foo: def __init__(self,name): self.name=name When using the class in practice, I've found it natural to create instances of Foo so that the instance itself is called name. Thus, I find myself doing thi

Re: [Tutor] Self referencing within a dictionary

2005-04-03 Thread Alan Gauld
> foo = {'a':1, 'b':2, 'c':foo['a']} TRy foo = {'a':1, 'b':2} foo['c'] = foo['a'] The only reasobn it ddidn't work before was that foo didn't exist at the time you tried to add the reference. foo['c'] is just a reference to whatever foo['a'] references. foo['d'] = foo is a tad more interestin

Re: [Tutor] Self referencing within a dictionary

2005-04-02 Thread Max Noel
On Apr 2, 2005, at 12:12, Liam Clarke wrote: Hi, Out of curiosity, is it possible to create a dictionary like this - foo = {'a':1, 'b':2, 'c':foo['a']} I know that as above doesn't work, but was just wondering if it's possible, and if it's a Bad Thing? Regards, Liam Clarke It doesn't work because

[Tutor] Self referencing within a dictionary

2005-04-02 Thread Liam Clarke
Hi, Out of curiosity, is it possible to create a dictionary like this - foo = {'a':1, 'b':2, 'c':foo['a']} I know that as above doesn't work, but was just wondering if it's possible, and if it's a Bad Thing? Regards, Liam Clarke -- 'There is only one basic human right, and that is to do as

[Tutor] (Self resolved) os.spawn behaviorism issue

2004-12-10 Thread David Broadwell
Further note: widen the window, this has long strings in it ... and is PURELY for edification. To work around a problem between my ISP and my router, I have to make my router RELogin the PPPoE every time the wan ip changes. Which is not hard, it's a http string in a browser to log in, followed by

[Tutor] (Self resolved) os.spawn behavior issue

2004-12-10 Thread David Broadwell
Further note: widen the window, this has long strings in it ... and is PURELY for edification. To work around a problem between my ISP and my router, I have to make my router RELogin the PPPoE every time the wan ip changes. Which is not hard, it's a http string in a browser to log in, followed by