[Tutor] unittest + tkinter

2010-11-01 Thread Wayne Werner
I'm sure there's an incredibly simple way to do this, but at the moment it eludes me. I'm trying my hand at test driven development via the unittest module. Since my program is using Tkinter, my thought is that I need to create the main window. The only problem is that when I launch the main loop,

Re: [Tutor] Complete Shutdown

2010-11-01 Thread Alan Gauld
"Steven D'Aprano" wrote How do I completely shutdown a computer without administrative rights using a simple python script. If you have such a computer get rid of it, it fails the most basic test I'm not so sure about that... I think a personal computer which didn't allow ordinary, unpriv

Re: [Tutor] Tutor Digest, Vol 81, Issue 3

2010-11-01 Thread TGW
7 -0400 > From: Chris King > To: python mail list > Subject: [Tutor] rights > Message-ID: <4ccf1da5.2020...@gmail.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Dear Tutors, > How do you give a script right to read a folder? > > > ---

Re: [Tutor] rights

2010-11-01 Thread Alan Gauld
"Chris King" wrote You give the user account executing the script rights to read the folder. HTH, It was a folder on my desktop, which I can always read, right, and destroy. I ran it on that user. In that case we probably need to see: 1) What OS? 2) What does the code look like? 3) Ho

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Steven D'Aprano
Josep M. Fontana wrote: Sorry about the top-posting. Sometimes it seems that a little top-posting might make things easier (I hate to have to go through long quotes) but you are totally right, netiquette is netiquette. To all the people who say "Never top-post", I say never say never -- there

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Steven D'Aprano
Josep M. Fontana wrote: The only time year is bound is in the previous loop, as I said. It's the line that goes: name, year = line.strip. So year is whatever it was the last time through that loop. OK, this makes sense. Indeed that is the value in the last entry for the dictionary. Th

Re: [Tutor] Complete Shutdown

2010-11-01 Thread Steven D'Aprano
Chris King wrote: I restarted the whole system with a script. Why couldn't I shut it down? Probably because the script told the computer to restart rather than shut down. It will help if you tell us: * what operating system you are running * what you did to restart the computer * what yo

Re: [Tutor] scope, visibility?

2010-11-01 Thread Steven D'Aprano
Samuel de Champlain wrote: Inside the class is a method with a bit of code: def masque(chaine,liInd=0): i = 0 lenght = len(chaine) As this is a method, you normally need to refer to the instance in the definition: def masque(self, chaine, liInd=0): i = 0 length

Re: [Tutor] pythonpath

2010-11-01 Thread Emile van Sebille
On 11/1/2010 2:41 PM Chris King said... Dear Tutors, When I try to import a module, how can I make it look in certain directories for them easily. Sincerely, Chris I'm not sure it's still the preferred way of setting sys.path, but site.py sets sys.path and contains info on *.pth files and oth

Re: [Tutor] pythonpath

2010-11-01 Thread Steven D'Aprano
Chris King wrote: it didn't work Define "it" and "didn't work". What did you try? What happened when you tried it? -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/l

Re: [Tutor] Complete Shutdown

2010-11-01 Thread Steven D'Aprano
Alan Gauld wrote: "Chris King" wrote How do I completely shutdown a computer without administrative rights using a simple python script. If you have such a computer get rid of it, it fails the most basic test of a secure operating system. No program that runs upon it could ever be relie

Re: [Tutor] pythonpath

2010-11-01 Thread John
hehe. yeah, I had to go check my old PC that's collecting dust on how to navigate the 'happy dungeon' of windows wizards... I do prefer: export PYTHONPATH=/my/custom/dir On Mon, Nov 1, 2010 at 11:03 PM, Vince Spicer wrote: > > > On Mon, Nov 1, 2010 at 4:00 PM, Vince Spicer wrote: >> >> >> On

Re: [Tutor] pythonpath

2010-11-01 Thread Chris King
On 11/1/2010 6:13 PM, Walter Prins wrote: On 1 November 2010 21:58, Chris King @gmail.com > wrote: the first way with work for Window, the second is for Linux or posix systems Sorry I can't help with PYTHONPATH on windows. To set a PYTHON

Re: [Tutor] pythonpath

2010-11-01 Thread Walter Prins
On 1 November 2010 21:58, Chris King wrote: > the first way with work for Window, the second is for Linux or posix > systems > > Sorry I can't help with PYTHONPATH on windows. > > To set a PYTHONPATH in Windows, click "Start", right click "My computer", click "Properties", click "Advanced" tab

Re: [Tutor] rights

2010-11-01 Thread Chris King
On 11/1/2010 5:21 PM, Alan Gauld wrote: "Chris King" wrote How do you give a script right to read a folder? You give the user account executing the script rights to read the folder. HTH, It was a folder on my desktop, which I can always read, right, and destroy. I ran it on that user

Re: [Tutor] pythonpath

2010-11-01 Thread Walter Prins
On 1 November 2010 21:57, Chris King wrote: > On 11/1/2010 5:47 PM, Vince Spicer wrote: > it didn't work > > Then you've done something wrong. Post the code, and/or the error message, if any. Walter ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] pythonpath

2010-11-01 Thread Vince Spicer
On Mon, Nov 1, 2010 at 4:00 PM, Vince Spicer wrote: > > > On Mon, Nov 1, 2010 at 3:58 PM, Chris King wrote: > >> On 11/1/2010 5:57 PM, Vince Spicer wrote: >> >> >> >> On Mon, Nov 1, 2010 at 3:54 PM, Chris King wrote: >> >>> On 11/1/2010 5:47 PM, Vince Spicer wrote: >>> >>> >>> >>> On Mon, No

Re: [Tutor] pythonpath

2010-11-01 Thread John
Chris, I haven't worked on windows in ages, but I think you can set a PYTHONPATH variable if you right click on My Computer and maybe the advanced tab, there is a place to set ENVIRONMENT VARIABLES. Create a new one called PYTHONPATH pointing to your directory. -john On Mon, Nov 1, 2010 at 10:58

Re: [Tutor] pythonpath

2010-11-01 Thread Vince Spicer
On Mon, Nov 1, 2010 at 3:58 PM, Chris King wrote: > On 11/1/2010 5:57 PM, Vince Spicer wrote: > > > > On Mon, Nov 1, 2010 at 3:54 PM, Chris King wrote: > >> On 11/1/2010 5:47 PM, Vince Spicer wrote: >> >> >> >> On Mon, Nov 1, 2010 at 3:41 PM, Chris King wrote: >> >>> Dear Tutors, >>>Whe

Re: [Tutor] Complete Shutdown

2010-11-01 Thread Chris King
On 11/1/2010 5:20 PM, Alan Gauld wrote: "Chris King" wrote How do I completely shutdown a computer without administrative rights using a simple python script. If you have such a computer get rid of it, it fails the most basic test of a secure operating system. No program that runs upon

Re: [Tutor] pythonpath

2010-11-01 Thread Chris King
On 11/1/2010 5:57 PM, Vince Spicer wrote: On Mon, Nov 1, 2010 at 3:54 PM, Chris King @gmail.com > wrote: On 11/1/2010 5:47 PM, Vince Spicer wrote: On Mon, Nov 1, 2010 at 3:41 PM, Chris King http://g.nius.ck>@gmail.com > wrote:

Re: [Tutor] pythonpath

2010-11-01 Thread Chris King
On 11/1/2010 5:47 PM, Vince Spicer wrote: On Mon, Nov 1, 2010 at 3:41 PM, Chris King @gmail.com > wrote: Dear Tutors, When I try to import a module, how can I make it look in certain directories for them easily. Sincerely, Chris

Re: [Tutor] pythonpath

2010-11-01 Thread Karim
On 11/01/2010 10:41 PM, Chris King wrote: Dear Tutors, When I try to import a module, how can I make it look in certain directories for them easily. Sincerely, Chris ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] pythonpath

2010-11-01 Thread Vince Spicer
On Mon, Nov 1, 2010 at 3:41 PM, Chris King wrote: > Dear Tutors, >When I try to import a module, how can I make it look in certain > directories for them easily. > Sincerely, >Chris > ___ > Tutor maillist - Tutor@python.org > To unsubscribe o

[Tutor] pythonpath

2010-11-01 Thread Chris King
Dear Tutors, When I try to import a module, how can I make it look in certain directories for them easily. Sincerely, Chris ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/l

Re: [Tutor] rights

2010-11-01 Thread Alan Gauld
"Chris King" wrote How do you give a script right to read a folder? You give the user account executing the script rights to read the folder. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor m

Re: [Tutor] Complete Shutdown

2010-11-01 Thread Alan Gauld
"Chris King" wrote How do I completely shutdown a computer without administrative rights using a simple python script. If you have such a computer get rid of it, it fails the most basic test of a secure operating system. No program that runs upon it could ever be relied upon! The whol

Re: [Tutor] rights

2010-11-01 Thread Vince Spicer
On Mon, Nov 1, 2010 at 2:05 PM, Chris King wrote: > Dear Tutors, >How do you give a script right to read a folder? > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinf

[Tutor] rights

2010-11-01 Thread Chris King
Dear Tutors, How do you give a script right to read a folder? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Complete Shutdown

2010-11-01 Thread Chris King
Dear Tutors, How do I completely shutdown a computer without administrative rights using a simple python script. Sincerely, Me, Myself, and I ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.py

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Josep M. Fontana
> The only time year is bound is in the previous loop, as I said.  It's the > line that goes: >     name, year = line.strip. > > So year is whatever it was the last time through that loop. OK, this makes sense. Indeed that is the value in the last entry for the dictionary. Thanks a lot again.

Re: [Tutor] scope, visibility?

2010-11-01 Thread Evert Rol
> Here is my main class: > > class PenduGTK: > > Inside the class is a method with a bit of code: > > def masque(chaine,liInd=0): > > i = 0 > lenght = len(chaine) > > The offending line is the one with len(chaine) > > Here are the error messages: > > penduGTK.py > Trace

Re: [Tutor] scope, visibility?

2010-11-01 Thread Dave Angel
On 2:59 PM, Samuel de Champlain wrote: I am learning python. To practice, I am coding a hangman application in pyGTK. Here are my imports: import pygtk pygtk.require('2.0') import gtk import random Here is my main class: class PenduGTK: Inside the class is a method with a bit of code: d

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Dave Angel
On 11/1/2010 1:53 PM, Josep M. Fontana wrote: Hi Dave, On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel wrote: (You top-posted, so I had to remove the out-of-order earlier portion.) I've not tried to run the code, but I think I can see the problem. Since you never assign 'year' inside the loop(s)

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Josep M. Fontana
Hi Dave, On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel wrote: > (You top-posted, so I had to remove the out-of-order earlier portion.) > > I've not tried to run the code, but I think I can see the problem. Since > you never assign 'year' inside the loop(s), it's always the same. And it's > whatev

[Tutor] scope, visibility?

2010-11-01 Thread Samuel de Champlain
I am learning python. To practice, I am coding a hangman application in pyGTK. Here are my imports: import pygtk pygtk.require('2.0') import gtk import random Here is my main class: class PenduGTK: Inside the class is a method with a bit of code: def masque(chaine,liInd=0): i = 0

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Dave Angel
On 11/1/2010 8:48 AM, Josep M. Fontana wrote: Thanks a lot Dave and Joel, You call re.sub(), but don't do anything with the result. Where do you call os.rename() ? Yes, indeed, as you suggested what was missing was the use of os.rename() to apply the substitution to the actual file names. I

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Josep M. Fontana
Thanks a lot Dave and Joel, > You call re.sub(), but don't do anything with the result. > > Where do you call os.rename() ? Yes, indeed, as you suggested what was missing was the use of os.rename() to apply the substitution to the actual file names. I incorporated that and I changed the loop th