[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, further lines
of code aren't executed.

#simple.py
import Tkinter as tk

class Simple(tk.Tk):
 def __init__(self):
tk.Tk.__init__(self)
self.mainloop()

# test.py
import unittest
import simple

class SimpleTestCase(unittest.TestCase):
def testSimple(self):
s = simple.Simple()
print 'hi' # have to close the window before this happens

unittest.main()

Am I on the right track? or am I way out in left field? Any pointers/help in
the right direction?

Thanks,
Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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, unprivileged users to safely shut it down


I agree the key is the word "safely"

If the request is how tom invoke the shuitdown sequence in a 
controlled

manner then it is more reasonable.

I interpreted the request as being rto just power it doen from a 
random

Python script.

Of course in a multi-user system, things are more complicated, and 
nor do you want arbitrary programs to be able to shut down your 
computer.


And I tend to work in multi-user environments (even on my personal 
desktop)
so I tend to forget that there are single user computers out there. In 
a

single user then the user is de-facto the administrator too.

So I will temper my words with the caution that it may occasionally
be necessary but its rarely a good idea.

Imagine if your browser could turn your computer off. Imagine if 
arbitrary websites could turn your computer off. Chaos and pain 
everywhere!


And that was precisdely the point I was trying to make albeit rather
over zealously.

An interesting question would be, given that you do have 
administrator rights to log out/reboot/shut down, how would you do 
so from Python? The solution will depend on the OS and possibly the 
window manager, but other than that, I'm completely out of ideas.


Its usually available as a system call (certainly in *nix or windoze) 
but you

do need the right privileges since you are effectively running another
program. So if the OS doesn't allow you to shutdown you can't without
changing user. If the OS allows it you can do it from Python, but how
will depend on the OS!

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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

2010-11-01 Thread TGW
t; 
>def masque(self, chaine, liInd=0):
> 
> 
> Last note on a totally different thing, because this confused me a bit: 
> preferably avoid avoid the lowercase L, lowercase i and uppercase I next to 
> each other. It's very hard to read. See eg 
> http://www.python.org/dev/peps/pep-0008/ (section 'Names to Avoid'). To me, 
> it initially read something like iiind=0. Which is ok, as long as I don't 
> have to work with the code. But it may also bite you some day.
> 
> 
>> I would think it has to do with namespaces, scopes and visibility. But how 
>> do I refer to built-in functions from inside a class?
> 
> Just as you did above: len(chaine). 
> But since that wasn't your problem, I guess this answer is rather meaningless.
> 
> Cheers,
> 
>  Evert
> 
> 
> 
> --
> 
> Message: 3
> Date: Mon, 1 Nov 2010 20:38:06 +0100
> From: "Josep M. Fontana" 
> To: Dave Angel 
> Cc: tutor@python.org
> Subject: Re: [Tutor] Problems with partial string matching
> Message-ID:
>   
> Content-Type: text/plain; charset=ISO-8859-1
> 
>> 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.
> 
> Josep M.
> 
> 
> --
> 
> Message: 4
> Date: Mon, 01 Nov 2010 16:01:39 -0400
> From: Chris King 
> To: python mail list 
> Subject: [Tutor] Complete Shutdown
> Message-ID: <4ccf1ca3.3050...@gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
>  Dear Tutors,
> How do I completely shutdown a computer without administrative 
> rights using a simple python script.
> Sincerely,
> Me, Myself, and I
> 
> 
> --
> 
> Message: 5
> Date: Mon, 01 Nov 2010 16:05:57 -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?
> 
> 
> --
> 
> Message: 6
> Date: Mon, 1 Nov 2010 14:10:43 -0600
> From: Vince Spicer 
> To: Chris King 
> Cc: python mail list 
> Subject: Re: [Tutor] rights
> Message-ID:
>   
> Content-Type: text/plain; charset="iso-8859-1"
> 
> 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/listinfo/tutor
>> 
> 
> 
> Which Operation System?
> 
> In linux the user that is running the script must be have read access
> 
> chmod +r folder
> 
> 
> -- 
> Vince Spicer
> 
> -- 
> Sent from Ubuntu
> -- next part --
> An HTML attachment was scrubbed...
> URL: 
> <http://mail.python.org/pipermail/tutor/attachments/20101101/61ad9dd4/attachment-0001.html>
> 
> --
> 
> Message: 7
> Date: Mon, 1 Nov 2010 21:20:42 -
> From: "Alan Gauld" 
> To: tutor@python.org
> Subject: Re: [Tutor] Complete Shutdown
> Message-ID: 
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>   reply-type=response
> 
> 
> "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 whole concept is evil.
> 
> Administrator rights are required for good reason and are a protection
> against bad things happening to your data and programs. Work with
> it not against it and be grateful it's there.
> 
> 
> -- 
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> 
> 
> 
> 
> --
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> End of Tutor Digest, Vol 81, Issue 3
> 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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) How are you running it?

4) What error messages do you get?

Also, is it a folder you are trying to read or a file?
They are not the same.


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 are exceptions to every rule, except the rule about there always 
being exceptions. But 99% of the time, comments should follow the quote 
they are commenting on, like a conversation:


> comment
reply

> comment
reply

The point you make about long quotes is also very important. Having to 
scroll, and scroll, and scroll, and SCROLL through pages and pages of 
quoted text to get to a single comment at the end is very annoying, 
sometimes more annoying than top-posting. I often get so fed up I'll 
give up and move on to the next email -- I have a *lot* of emails to 
wade through, many of them (like this list) are a labour of love and I 
don't get paid a cent for reading them, and if I have to work hard just 
to reach the relevant text, I will often decide that if the sender 
couldn't be bothered trimming his quoting, he obviously didn't think his 
post was worth spending an extra 2 seconds making it readable, so why 
should I spend any extra time reading it?


Failure to trim the quoting down to the parts that are actually relevant 
is equally as thoughtless as needless top-posting. If the delete key on 
your keyboard is broken, then say so, otherwise use it.


End of rant. Thank you.


--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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. Thanks a lot again.



Dictionaries don't have a "last", or "first", entry -- they're unordered 
collections. Think of them as a bag filled with stuff -- if you reach in 
and grab an item, one at a time, you will get the items in some order, 
but that's imposed on the bag by the sequential nature of taking one 
item at a time. The items themselves have no order.


Iterating over a dictionary, or printing it, is like dipping into the 
bag for each item one at a time. Python carefully ensures that this 
order is consistent: dict,keys(), dict.values() and dict.items() will 
return the objects in the same order, so long as you don't modify the 
dictionary between calls. But that order is arbitrary, depends on the 
history of insertions and deletions, and is subject to change without 
notice. So if we do this:


d = {}
d[0] = 'a'
d[-1] = 'b'
d[-2] = 'c'

and then print d in Python 3.1.1, we get: {0: 'a', -2: 'c', -1: 'b'}

but if we add the items in a different order:

d = {}
d[-2] = 'c'
d[0] = 'a'
d[-1] = 'b'

we get this instead: {0: 'a', -1: 'b', -2: 'c'}.


In general, there is no relationship between the order you insert 
objects into a dict and the order that you will get them out. Sometimes 
it may match. Usually it won't.



--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 you tried to shut it down

* what happened when you tried.


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 = len(chaine)

There are exceptions to this -- class methods and static methods -- but 
you should consider them for advanced use. Normally, so long as you 
remember to put self as the first argument to the method, you will be right.


Because you left that out, Python assigned the instance to "chaine" and 
what you expected to be chaine to "liInd", leading to unexpected results.




Here are the error messages:

 penduGTK.py
Traceback (most recent call last):
  File "/home/xxx/bin/penduGTK.py", line 23, in enter_callback
self.lblMot.set_text(self.masque(self.motChoisi))
  File "/home/xxx/bin/penduGTK.py", line 44, in masque
lenght = len(chaine)
AttributeError: PenduGTK instance has no attribute '__len__'

I would think it has to do with namespaces, scopes and visibility. But how
do I refer to built-in functions from inside a class?


Nothing to do with any of those things.



--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 other methods 
used.


Emile


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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/listinfo/tutor


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 relied upon!


I'm not so sure about that... I think a personal computer which didn't 
allow ordinary, unprivileged users to safely shut it down would be 
worse. One shouldn't need to be root (or Administrator) to turn your own 
laptop or desktop off! Do we really want Aunt Tilly just flicking the 
power switch when she wants to turn her computer off?


Of course in a multi-user system, things are more complicated, and nor 
do you want arbitrary programs to be able to shut down your computer. 
Imagine if your browser could turn your computer off. Imagine if 
arbitrary websites could turn your computer off. Chaos and pain everywhere!


A bit like running IE 6 really :)


An interesting question would be, given that you do have administrator 
rights to log out/reboot/shut down, how would you do so from Python? The 
solution will depend on the OS and possibly the window manager, but 
other than that, I'm completely out of ideas.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 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,
>    When I try to import a module, how can I make it look in certain
> directories for them easily.
> Sincerely,
>    Chris
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

 Hello Chris
 You can manage you path from within your script,
 import sys
 sys.path.append("/home/user/lib")

 Or in bash you can edit your  $PYTHONPATH env variable
 echo $PYTHONPATH

 --
 Vince Spicer

 --
 Sent from Ubuntu

 So doing it in cmd windows will permanently change it?
>>>
>>>
>>> the first way with work for Window,  the second is for Linux or posix
>>> systems
>>> Sorry I can't help with PYTHONPATH on windows.
>>>
>>> --
>>> Vince Spicer
>>>
>>> --
>>> Sent from Ubuntu
>>>
>>> I want a permanent change.
>>
>> There is probably a Windows alternative to env variables and PYTHONPATH,
>> Google may help.
>>
>> --
>> Vince Spicer
>> --
>> Sent from Ubuntu
>
>
> Sorry I don't know any developers that run Windows anymore, if you find the
> solution please post it back here.
> Thanks.
>
>
> --
> Vince Spicer
>
> --
> Sent from Ubuntu
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>



-- 
Configuration
``
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001/09/10
Basemap: 1.0
Matplotlib: 1.0.0
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 PYTHONPATH in Windows, click "Start", right click "My 
computer", click "Properties", click "Advanced" tab/section, click 
"Environment variables" button.  See if you can find an entry in 
either the User  variables or the System variables sections named 
"PYTHONPATH".  If not, add a new entry to "User variables" by clicking 
"New", and entering the name "PYTHONPATH" and whatever you want for 
the path.  Click "OK", "OK", "OK" and you should be back to the 
desktop.  Open the Python shell, and enter:


>>> import sys
>>> print sys.path
['C:\\Python26\\Lib\\idlelib', 
'C:\\Python26\\lib\\site-packages\\pip-0.8.1-py2.6.egg', 'C:\\Test', 
'C:\\Python26\\python26.zip', 'C:\\Python26\\DLLs', 
'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 
'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 
'C:\\Python26\\lib\\site-packages']


As you can see have an entry "C:\\Test" due to the fact that I created 
that as the contents of my "PYTHONPATH" variable.


HTH,

Walter


It worked!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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/section, click "Environment
variables" button.  See if you can find an entry in either the User
variables or the System variables sections named "PYTHONPATH".  If not, add
a new entry to "User variables" by clicking "New", and entering the name
"PYTHONPATH" and whatever you want for the path.  Click "OK", "OK", "OK" and
you should be back to the desktop.  Open the Python shell, and enter:

>>> import sys
>>> print sys.path
['C:\\Python26\\Lib\\idlelib',
'C:\\Python26\\lib\\site-packages\\pip-0.8.1-py2.6.egg', 'C:\\Test',
'C:\\Python26\\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib',
'C:\\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26',
'C:\\Python26\\lib\\site-packages']

As you can see have an entry "C:\\Test" due to the fact that I created that
as the contents of my "PYTHONPATH" variable.

HTH,

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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, 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 or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

>>>
>>>  Hello Chris
>>>
>>> You can manage you path from within your script,
>>>
>>>  import sys
>>> sys.path.append("/home/user/lib")
>>>
>>>  Or in bash you can edit your  $PYTHONPATH env variable
>>>  echo $PYTHONPATH
>>>
>>>
>>> --
>>> Vince Spicer
>>>
>>>
>>>  --
>>> Sent from Ubuntu
>>>
>>>So doing it in cmd windows will permanently change it?
>>>
>>
>>
>> the first way with work for Window,  the second is for Linux or posix
>> systems
>>
>>  Sorry I can't help with PYTHONPATH on windows.
>>
>> --
>> Vince Spicer
>>
>>
>>  --
>> Sent from Ubuntu
>>
>>  I want a permanent change.
>>
>
> There is probably a Windows alternative to env variables and PYTHONPATH,
> Google may help.
>
>
> --
> Vince Spicer
>
> --
> Sent from Ubuntu
>
>

Sorry I don't know any developers that run Windows anymore, if you find the
solution please post it back here.

Thanks.


-- 
Vince Spicer


-- 
Sent from Ubuntu
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 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,
>>>    When I try to import a module, how can I make it look in certain
>>> directories for them easily.
>>> Sincerely,
>>>    Chris
>>> ___
>>> Tutor maillist  -  tu...@python.org
>>> To unsubscribe or change subscription options:
>>> http://mail.python.org/mailman/listinfo/tutor
>>
>> Hello Chris
>> You can manage you path from within your script,
>> import sys
>> sys.path.append("/home/user/lib")
>>
>> Or in bash you can edit your  $PYTHONPATH env variable
>> echo $PYTHONPATH
>>
>> --
>> Vince Spicer
>>
>> --
>> Sent from Ubuntu
>>
>> So doing it in cmd windows will permanently change it?
>
>
> the first way with work for Window,  the second is for Linux or posix
> systems
> Sorry I can't help with PYTHONPATH on windows.
>
> --
> Vince Spicer
>
> --
> Sent from Ubuntu
>
> I want a permanent change.
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>



-- 
Configuration
``
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001/09/10
Basemap: 1.0
Matplotlib: 1.0.0
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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,
>>>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/listinfo/tutor
>>>
>>
>>  Hello Chris
>>
>> You can manage you path from within your script,
>>
>>  import sys
>> sys.path.append("/home/user/lib")
>>
>>  Or in bash you can edit your  $PYTHONPATH env variable
>>  echo $PYTHONPATH
>>
>>
>> --
>> Vince Spicer
>>
>>
>>  --
>> Sent from Ubuntu
>>
>>So doing it in cmd windows will permanently change it?
>>
>
>
> the first way with work for Window,  the second is for Linux or posix
> systems
>
>  Sorry I can't help with PYTHONPATH on windows.
>
> --
> Vince Spicer
>
>
>  --
> Sent from Ubuntu
>
>  I want a permanent change.
>

There is probably a Windows alternative to env variables and PYTHONPATH,
Google may help.


-- 
Vince Spicer

-- 
Sent from Ubuntu
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 it could
ever be relied upon!

The whole concept is evil.

Administrator rights are required for good reason and are a protection
against bad things happening to your data and programs. Work with
it not against it and be grateful it's there.



I restarted the whole system with a script. Why couldn't I shut it down?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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:

 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/listinfo/tutor


Hello Chris

You can manage you path from within your script,

import sys
sys.path.append("/home/user/lib")

Or in bash you can edit your $PYTHONPATH env variable
echo $PYTHONPATH


-- 
Vince Spicer



-- 
Sent from Ubuntu



So doing it in cmd windows will permanently change it?



the first way with work for Window,  the second is for Linux or posix 
systems


Sorry I can't help with PYTHONPATH on windows.

--
Vince Spicer


--
Sent from Ubuntu


I want a permanent change.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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
___
Tutor maillist  - Tutor@python.org 
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Hello Chris

You can manage you path from within your script,

import sys
sys.path.append("/home/user/lib")

Or in bash you can edit your $PYTHONPATH env variable
echo $PYTHONPATH


--
Vince Spicer


--
Sent from Ubuntu


it didn't work
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 subscription options:
http://mail.python.org/mailman/listinfo/tutor


Hello,

PYTHONPATH environment variable set to /path/to/you/libs.

Regards
Karim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Hello Chris

You can manage you path from within your script,

import sys
sys.path.append("/home/user/lib")

Or in bash you can edit your  $PYTHONPATH env variable
echo $PYTHONPATH


-- 
Vince Spicer


-- 
Sent from Ubuntu
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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/listinfo/tutor


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 maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 whole concept is evil.

Administrator rights are required for good reason and are a protection
against bad things happening to your data and programs. Work with
it not against it and be grateful it's there.


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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/listinfo/tutor
>


Which Operation System?

In linux the user that is running the script must be have read access

chmod +r folder


-- 
Vince Spicer

-- 
Sent from Ubuntu
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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.python.org/mailman/listinfo/tutor


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.

Josep M.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 
> Traceback (most recent call last):
>   File "/home/xxx/bin/penduGTK.py", line 23, in enter_callback
> self.lblMot.set_text(self.masque(self.motChoisi))
>   File "/home/xxx/bin/penduGTK.py", line 44, in masque
> lenght = len(chaine)
> AttributeError: PenduGTK instance has no attribute '__len__'

A method takes as its first argument a reference to the class. That is, in 'def 
some_method(blah1, blah2, blah3)', blah1 would be a reference to the class in 
which some_method is defined.
If you look at the error message, you see Python complains that the PenduGTK 
instance has no __len__ attribute, meaning 'chaine' is a PenduGTK instance: 
it's the first argument in the method, taking a reference to the class.
See eg http://diveintopython.org/object_oriented_framework/defining_classes.html
(also, carefully read the error and think what it could mean: it has a lot of 
hints to solve your problem).

Thus, define a method with an extra (first) argument. This is usually called 
self:

def masque(self, chaine, liInd=0):


Last note on a totally different thing, because this confused me a bit: 
preferably avoid avoid the lowercase L, lowercase i and uppercase I next to 
each other. It's very hard to read. See eg 
http://www.python.org/dev/peps/pep-0008/ (section 'Names to Avoid'). To me, it 
initially read something like iiind=0. Which is ok, as long as I don't have to 
work with the code. But it may also bite you some day.


> I would think it has to do with namespaces, scopes and visibility. But how do 
> I refer to built-in functions from inside a class?

Just as you did above: len(chaine). 
But since that wasn't your problem, I guess this answer is rather meaningless.

Cheers,

  Evert

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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:

 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
Traceback (most recent call last):
   File "/home/xxx/bin/penduGTK.py", line 23, in enter_callback
 self.lblMot.set_text(self.masque(self.motChoisi))
   File "/home/xxx/bin/penduGTK.py", line 44, in masque
 lenght = len(chaine)
AttributeError: PenduGTK instance has no attribute '__len__'

I would think it has to do with namespaces, scopes and visibility. But how
do I refer to built-in functions from inside a class?

You're correctly referring to the built-in function len().  But that 
function assumes that the object it gets as an argument has a __len__() 
method.  List, string, tuple all do.  But perhaps PenduGTK does not.  
You don't show us the whole class.


Your real problem is probably that you're missing self as the first 
argument.  So where you think chaine is a string, it's actually an instance.


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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), it's always the same.  And it's
whatever the last value it had in the earlier loop.

The simplest cure would be to fix the outer loop

for name, year in name_year.items():

Alternatively, and maybe easier to read:

for name in name_year:
 year = name_year[name]

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.

I'm still puzzled as to why that particular value was the one picked
up but what's important is that you provided the solution for the
problem in the loop. Now it works perfectly. Thank you very much!

Josep M.

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.

DaveA


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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
> whatever the last value it had in the earlier loop.
>
> The simplest cure would be to fix the outer loop
>
> for name, year in name_year.items():
>
> Alternatively, and maybe easier to read:
>
> for name in name_year:
> year = name_year[name]

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.

I'm still puzzled as to why that particular value was the one picked
up but what's important is that you provided the solution for the
problem in the loop. Now it works perfectly. Thank you very much!

Josep M.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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
lenght = len(chaine)

The offending line is the one with len(chaine)

Here are the error messages:

 penduGTK.py
Traceback (most recent call last):
  File "/home/xxx/bin/penduGTK.py", line 23, in enter_callback
self.lblMot.set_text(self.masque(self.motChoisi))
  File "/home/xxx/bin/penduGTK.py", line 44, in masque
lenght = len(chaine)
AttributeError: PenduGTK instance has no attribute '__len__'

I would think it has to do with namespaces, scopes and visibility. But how
do I refer to built-in functions from inside a class?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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
incorporated that and I changed the loop that I had produced in my
first version because it wasn't doing what it was supposed to do.

Doing that definitely gets me closer to my goal but I'm encountering a
strange problem. Well, strange to me, that is. I'm sure that more
experienced programmers like the people who hang out in this list will
immediately see what is going on. First, here's the code:

--
import os, sys, glob, re
#What follows creates a dictionary with the form {'name':'year'} out
of a csv file called FileNameYear.txt which has a string of the form
'A-01,1374' on each line. The substring before the comma is the code
for the text that appears at the beginning of the name of the file
containing the given text and the substring after the comma indicates
the year in which the text was written.
fileNameYear = 
open(r'/Volumes/DATA/Documents/workspace/MyCorpus/CORPUS_TEXT_LATIN_1/FileNameYear.txt',
"U").readlines()
name_year = {}
for line in fileNameYear: #File objects have built-in iteration
 name, year = line.strip().split(',')
 name_year[name] = year #effectively creates the dictionary by
creating keys with the element 'name' returned by the loop and
assigning them values corresponding to the element 'year' -->  !d[key]
= value" means Set d[key] to value.
os.getcwd()
os.chdir('/Volumes/DATA/Documents/workspace/MyCorpus/CORPUS_TEXT_LATIN_1')
file_names = glob.glob('*.txt')
for name in name_year:
 for name_of_file in file_names:
 if name_of_file.startswith(name):
 os.rename(name_of_file, re.sub('__', '__' + year, name_of_file))
---

What this produces is a change in the names of the files which is not
exactly the desired result. The new names of the files have the
following structure:

'A-01-name1__1499.txt' , 'A-02-name2__1499.txt',
'A-05-name3__1499.txt', ... 'I-01-name14__1499.txt',
...Z-30-name1344__1499.txt'

That is, only the year '1499' of the many possible years has been
added in the substitution. I can understand that I've done something
wrong in the loop and the iteration over the values of the dictionary
(i.e. the strings representing the years) is not working properly.
What I don't understand is why precisely '1499' is the string that is
obtained in all the cases.

I've been trying to figure out how the loop proceeds and this doesn't
make sense to me because the year '1499' appears as the value for
dictionary item number 34. Because of the order of the dictionary
entries and the way I've designed the loop (which I admit might not be
the most efficient way to process these data), the first match would
correspond to a file that starts with the initial code 'I-02'. The
dictionary value for this key is '1399', not '1499'. '1499' is not
even the value that would correspond to key 'A-01' which is the first
file in the directory according to the alphabetical order ('A-02', the
second file in the directory does correspond to value '1499', though).

So besides being able to explain why '1499' is the string that winds
up added to the file name, my question is, how do I set up the loop so
that the string representing the appropriate year is added to each
file name?

Thanks a lot in advance for your help (since it usually takes me a
while to answer).

Josep M.


(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 whatever the last value it had in the earlier loop.


The simplest cure would be to fix the outer loop

for name, year in name_year.items():

Alternatively, and maybe easier to read:

for name in name_year:
 year = name_year[name]

HTH
DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 that I had produced in my
first version because it wasn't doing what it was supposed to do.

Doing that definitely gets me closer to my goal but I'm encountering a
strange problem. Well, strange to me, that is. I'm sure that more
experienced programmers like the people who hang out in this list will
immediately see what is going on. First, here's the code:

--
import os, sys, glob, re
#What follows creates a dictionary with the form {'name':'year'} out
of a csv file called FileNameYear.txt which has a string of the form
'A-01,1374' on each line. The substring before the comma is the code
for the text that appears at the beginning of the name of the file
containing the given text and the substring after the comma indicates
the year in which the text was written.
fileNameYear = 
open(r'/Volumes/DATA/Documents/workspace/MyCorpus/CORPUS_TEXT_LATIN_1/FileNameYear.txt',
"U").readlines()
name_year = {}
for line in fileNameYear: #File objects have built-in iteration
name, year = line.strip().split(',')
name_year[name] = year #effectively creates the dictionary by
creating keys with the element 'name' returned by the loop and
assigning them values corresponding to the element 'year' --> !d[key]
= value" means Set d[key] to value.
os.getcwd()
os.chdir('/Volumes/DATA/Documents/workspace/MyCorpus/CORPUS_TEXT_LATIN_1')
file_names = glob.glob('*.txt')
for name in name_year:
for name_of_file in file_names:
if name_of_file.startswith(name):
os.rename(name_of_file, re.sub('__', '__' + year, name_of_file))
---

What this produces is a change in the names of the files which is not
exactly the desired result. The new names of the files have the
following structure:

'A-01-name1__1499.txt' , 'A-02-name2__1499.txt',
'A-05-name3__1499.txt', ... 'I-01-name14__1499.txt',
...Z-30-name1344__1499.txt'

That is, only the year '1499' of the many possible years has been
added in the substitution. I can understand that I've done something
wrong in the loop and the iteration over the values of the dictionary
(i.e. the strings representing the years) is not working properly.
What I don't understand is why precisely '1499' is the string that is
obtained in all the cases.

I've been trying to figure out how the loop proceeds and this doesn't
make sense to me because the year '1499' appears as the value for
dictionary item number 34. Because of the order of the dictionary
entries and the way I've designed the loop (which I admit might not be
the most efficient way to process these data), the first match would
correspond to a file that starts with the initial code 'I-02'. The
dictionary value for this key is '1399', not '1499'. '1499' is not
even the value that would correspond to key 'A-01' which is the first
file in the directory according to the alphabetical order ('A-02', the
second file in the directory does correspond to value '1499', though).

So besides being able to explain why '1499' is the string that winds
up added to the file name, my question is, how do I set up the loop so
that the string representing the appropriate year is added to each
file name?

Thanks a lot in advance for your help (since it usually takes me a
while to answer).

Josep M.

> On 2:59 PM, Josep M. Fontana wrote:
>>
>> Hi,
>>
>> As I said in another message with the heading "Using contents of a
>> document to change file names", I'm trying to learn Python "by doing"
>> and I was working on a little project where I had to change the names
>> 
>> I run this and I don't get any errors. The names of the files in the
>> directory, however, are not changed. What am I doing wrong?
>>
>> As always, your help is greatly appreciated.
>>
>>
>> Josep M.
>>
> You call re.sub(), but don't do anything with the result.
>
> Where do you call os.rename() ?
>
> DaveA
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor