Re: [Tutor] For Loop question

2008-06-26 Thread Mark Tolonen
"Lie Ryan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote:  Hi I'm learning FOR loop now, very easy too learn. But I get confused to understand this code : myList = [1,2,3,4] for index in range(len(myList)):

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread ALAN GAULD
> Though I solved the problem by making database an instance variable, > there's one thing I'm curious about. If I 'overwrite' a class variable > with an instance one (as I did originally), is the class variable > recoverable? Yes, you can always access the class version by using the class as th

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread wesley chun
> If I 'overwrite' a class variable > with an instance one (as I did originally), is the class variable > recoverable? Will objects created later have the class or the instance > variable? yes, but you need to access it with the class name: Grammars.database the other (uglier) alternative is to

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Shrutarshi Basu
Though I solved the problem by making database an instance variable, there's one thing I'm curious about. If I 'overwrite' a class variable with an instance one (as I did originally), is the class variable recoverable? Will objects created later have the class or the instance variable? Basu -- T

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread ALAN GAULD
> > Then database will be shared by all instances of Grammars > > No, the assignment > gram.database = {} > will always (at least absent any extra magic) create an instance attribute. Ah yes, silly me. The assignment creates a new instance variable. If you were only reading gram.database it woul

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread John Fouhy
On 27/06/2008, Kent Johnson <[EMAIL PROTECTED]> wrote: > No, the assignment > gram.database = {} > will always (at least absent any extra magic) create an instance attribute. I think this is the OP's workaround. Quoting: "Shrutarshi Basu": > I have to manually clear gram.database because > ot

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Shrutarshi Basu
It turns out that Alan's catch of the instance vs class variables was right. database was declared in the class body, rather than in the __init__. Doing gram.database = {}, may have replaced it.. But I've changed the Grammars class to have the proper instance variables. Apparently my teammates and

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Kent Johnson
On Thu, Jun 26, 2008 at 6:30 PM, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "Shrutarshi Basu" <[EMAIL PROTECTED]> wrote > >> def parse_display(self ): >> >> try: >> gram = Grammars(10, 10, self.pc_map, self.hard_rules) >> gram.database = {} > > How is gram.database defined? I

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Kent Johnson
On Thu, Jun 26, 2008 at 5:55 PM, Shrutarshi Basu <[EMAIL PROTECTED]> wrote: > Here's the relevant function: Which is the dict that is causing trouble? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Jeff Younker
On Jun 26, 2008, at 2:59 PM, Shrutarshi Basu wrote: self.modules.append(DisplayModule(self.img_map, (self.xOrigin, self.yOrigin), self.rows, self.columns, gram, self.type)) ... As you can see, not only do I delete gram, I also blank out everything that should be cleared. I have to ma

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Alan Gauld
"Shrutarshi Basu" <[EMAIL PROTECTED]> wrote def parse_display(self ): try: gram = Grammars(10, 10, self.pc_map, self.hard_rules) gram.database = {} How is gram.database defined? Is it an instance attribue or a class attribute? If you have class Grammars: data

Re: [Tutor] COM & IE problems

2008-06-26 Thread Alan Gauld
"Aaron Colichia" <[EMAIL PROTECTED]> wrote need to start using comtypes.client because it provides a better wrapper for No expert but looking at the error message... ie = comtypes.client.CreateObject('InternetExplorer.Application') ie.__clsid '{0002DF01---C000-0046}' new

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Shrutarshi Basu
Here's the relevant function: def parse_display(self ): try: gram = Grammars(10, 10, self.pc_map, self.hard_rules) gram.database = {} for key, list in self.grammars.iteritems(): gram.addGram(key, list[0], list[1]) self.modules

Re: [Tutor] Object attributes surviving deletion

2008-06-26 Thread Kent Johnson
On Thu, Jun 26, 2008 at 4:25 PM, Shrutarshi Basu <[EMAIL PROTECTED]> wrote: > At least that's what we want to do. This whole thing is inside a > function. However, when we call that function again to create another > Gen object, the new object seems to retain the dbase dictionary from > the last t

[Tutor] Object attributes surviving deletion

2008-06-26 Thread Shrutarshi Basu
I've been writing code where we have a class that does some basic ordering and packaging of data we send in its constructor. Let's call it Gen. At a particular point in our code we create an object: genObject = Gen( someInt, someInt, aDict, aList) genObject has a dictionary called dbase, which us

[Tutor] COM & IE problems

2008-06-26 Thread Aaron Colichia
I've been using win32com.client to work with IE via COM, but recently had a need to start using comtypes.client because it provides a better wrapper for IE. However, when I want to grab an existing IE using comtypes.client.GetActiveObject() the result is always the same as illustrated below H:\dev

[Tutor] Invoking Python

2008-06-26 Thread kinuthiA muchanE
On Thu, 2008-06-26 at 09:57 -0400, bhaaluu wrote: > You can create a Python script on a *nix system and run it with: > > $ python threeplusfour.py > > You can place a shebang line as the first line of the script, which points > to the python interpreter: > > #!/usr/bin/python > print("Hello, wo

Re: [Tutor] closing a internet explorer com object

2008-06-26 Thread W W
On Tue, Jun 24, 2008 at 3:25 PM, John Chandler <[EMAIL PROTECTED]> wrote: > Below is a bit of code that should work, you might want to change ieregex > because right now it will close anything that has "Microsoft Internet > Explorer" in the title bar. Have fun. The simplest way to do this is use w

Re: [Tutor] For Loop question

2008-06-26 Thread Lie Ryan
On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > Hi I'm learning FOR loop now, very easy too learn. But I get confused > to understand this code : > > myList = [1,2,3,4] > for index in range(len(myList)): > myList[index] += 1 > print myList > > And the response is: >

Re: [Tutor] Hands-on beginner's project?

2008-06-26 Thread George Oliver
> Python Universe Builder (PUB) is an Interactive Fiction module for > Python. It provides a > programming environment similar to that of Inform or TADS but runs > under any Python > interpreter. > > http://py-universe.sourceforge.net/ There also is PAWS (Python adventure writing system): http:/

Re: [Tutor] Invoking Python

2008-06-26 Thread bhaaluu
On Thu, Jun 26, 2008 at 9:53 AM, Cédric Lucantis <[EMAIL PROTECTED]> wrote: > Le Thursday 26 June 2008 15:37:01 kinuthiA muchanE, vous avez écrit : >> On Thu, 2008-06-26 at 12:00 +0200, [EMAIL PROTECTED] wrote: >> > Or more commonly add a first line like: >> > >> > #! /path/to/python/executable >>

Re: [Tutor] Invoking Python

2008-06-26 Thread bhaaluu
You can create a Python script on a *nix system and run it with: $ python threeplusfour.py You can place a shebang line as the first line of the script, which points to the python interpreter: #!/usr/bin/python print("Hello, world!\n") Save the file, then make it an executable with: $ chmod u+

Re: [Tutor] Invoking Python

2008-06-26 Thread Cédric Lucantis
Le Thursday 26 June 2008 15:37:01 kinuthiA muchanE, vous avez écrit : > On Thu, 2008-06-26 at 12:00 +0200, [EMAIL PROTECTED] wrote: > > Or more commonly add a first line like: > > > > #! /path/to/python/executable > > > > Then you can simply make the file executable and run it by typing its > > nam

Re: [Tutor] For Loop question

2008-06-26 Thread Cédric Lucantis
Le Thursday 26 June 2008 15:27:05 Danny Laya, vous avez écrit : > Hi I'm learning FOR loop now, very easy too learn. But I get confused to > understand this code : myList = [1,2,3,4] > for index in range(len(myList)): > myList[index] += 1 > print myList > > And the response is: > [2, 3, 4, 5] >

Re: [Tutor] For Loop question

2008-06-26 Thread bhaaluu
On Thu, Jun 26, 2008 at 9:27 AM, Danny Laya <[EMAIL PROTECTED]> wrote: > Hi I'm learning FOR loop now, very easy too learn. But I get confused to > understand this code : > > myList = [1,2,3,4] > for index in range(len(myList)): > myList[index] += 1 > print myList > > And the response is: > [2,

[Tutor] Invoking Python

2008-06-26 Thread kinuthiA muchanE
On Thu, 2008-06-26 at 12:00 +0200, [EMAIL PROTECTED] wrote: > Or more commonly add a first line like: > > #! /path/to/python/executable > > Then you can simply make the file executable and run it by typing its > name > > $ threeplusfour.py On my computer, running Linux Ubuntu, I always have t

[Tutor] For Loop question

2008-06-26 Thread Danny Laya
Hi I'm learning FOR loop now, very easy too learn. But I get confused to understand this code : myList = [1,2,3,4] for index in range(len(myList)): myList[index] += 1 print myList And the response is: [2, 3, 4, 5] Can you explain me as a newbie, how that code works ?? _

Re: [Tutor] Astonishing timing result

2008-06-26 Thread Kent Johnson
On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > I thought I'd use this to compare the 2 ways of string concatenation. Ever > since I began to learn Python I've been told that only one of these is the > proper and efficient one to use, and especially so if the string to be

Re: [Tutor] Python to exe--how much work?

2008-06-26 Thread Tim Michelsen
> I've had some success generati ng .exe files using pyinstaller for a few simple python programs i've written (less than 100 lines of code, that just use the os module). How much harder will this be for longer code with more modules imported? you may also try GUI2exe http://xoomer.alice.it/i

Re: [Tutor] Invoking Python

2008-06-26 Thread Alan Gauld
"kinuthiA muchanE" <[EMAIL PROTECTED]> wrote From the forward slashes in the file path I assume you are using a Linux based OS you need to to start the terminal or the shell. In Ubuntu, go to Main Menu ==> Accessories and click on Terminal, you will now have a new window open with somethin

Re: [Tutor] Astonishing timing result

2008-06-26 Thread Dick Moores
At 05:52 PM 6/24/2008, Dick Moores wrote: At 05:35 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Basically, I'm not worried, just curious. Not about the small differences, > but why did the use of the standard    if __name__ == '__main