[Tutor] Operator Overloading

2005-04-03 Thread Kevin Reeder
Following an example from a book, I'm getting an unexpected outcome. The point of exercise is to extend operator overloading methods from a superclass and track the method calls. Here's the code, class MyList: def __init__(self, start): self.wrapped = [ ] for x in start: self.w

Re: [Tutor] Re: If elif not working in comparison

2005-04-03 Thread gerardo arnaez
On Mar 29, 2005 3:06 AM, C Smith <[EMAIL PROTECTED]> wrote: > If you have Python 2.4 you might want to check out the decimal type > that is now part of the language. There is a description at > > http://www.python.org/doc/2.4/whatsnew/node9.html > > >>> import decimal > >>> a = decimal.Decima

Re: [Tutor] [HELP]how to test properties of a file

2005-04-03 Thread Shidai Liu
On Apr 3, 2005 6:42 PM, Pierre Barbier de Reuille <[EMAIL PROTECTED]> wrote: > Tthe simplest, IMHO, is : > > try: > f = file(filename, "w") > [...] > except IOError: > print "The file is not writable" > > Of course, not that this method empty the file if it is writable ! The > best is to ju

Re: [Tutor] [HELP]how to test properties of a file

2005-04-03 Thread Pierre Barbier de Reuille
Tthe simplest, IMHO, is : try: f = file(filename, "w") [...] except IOError: print "The file is not writable" Of course, not that this method empty the file if it is writable ! The best is to just put your IO code in such a try block ... That way, you're sure the file has the right mode. I

[Tutor] [HELP]how to test properties of a file

2005-04-03 Thread Shidai Liu
Dear all, Here is a simple question. But I can't find a simple answer. How to test if a file is readable, executalbe or writable, especially, writable? -- With best wishes! Shidai ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/l

[Tutor] Script (Python) for Zope

2005-04-03 Thread Mike Jaeger
Hello, I am looking for a Python-script for Zope which counts the objects (files) in the current folder and all its subfolders, but I don't know how to implement this script. Can somebody help me, please? Or ist there a newsgroup/mailing list which can help me to find a solution for this proble

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] What is the best book to start? - Many Thanks!

2005-04-03 Thread John Carmona
Dear Hoffmann, I am also a Newbie and I am currently going through "A Byte of Python" tutorial from Swaroop C H. http://www.byteofpython.info/download?PHPSESSID=c0d52343d90f69f25942f49df9ae7944 If you are completely new to programming like me, you will find that this tutorial is excellent. Good

[Tutor] Re: Re: Self referencing within a dictionary

2005-04-03 Thread Andrei
John Fouhy wrote on Sun, 03 Apr 2005 09:53:56 +1200: > Andrei wrote: >> Liam Clarke wrote on Sat, 2 Apr 2005 22:12:49 +1200: >>>I know that as above doesn't work, but was just wondering if it's >>>possible, and if it's a Bad Thing? >> Max has already shown it's possible. Whether it's a Bad Thing..