Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-17 Thread Hans Fangohr
Ricardo Aráoz wrote: Kent Johnson wrote: I don't know the answer, but it has nothing to do with the logging module. The question is, can the same file reliably be opened twice for writing in the same module. Well, the question would actually be if the logging module is smart enough to find out

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-17 Thread Hans Fangohr
Ricardo Aráoz wrote: Why should it be all or nothing. Couldn't the programmer indicate that both handlers use the same file? It would be very easy to do this using StreamHandlers instead of FileHandlers. It would also be easy to make a FileHandler subclass that keeps a map from file name to fil

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-17 Thread Ricardo Aráoz
Hans Fangohr wrote: Ricardo Aráoz wrote: > Kent Johnson wrote: >> I don't know the answer, but it has nothing to do with the logging >> module. The question is, can the same file reliably be opened >> twice for >> writing in the same module. > > Well, the question w

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-17 Thread Hans Fangohr
HI Riccardo, >>> >>> As far as I can see, the only reason in your example program to >>> open the >>> same file twice is to use two different formatters (i.e. two >>> different >>> type of lines) in the same log, >> Absolutely right. >> >>> if you'd drop the requirement for two >>> different f

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-17 Thread Kent Johnson
Hans Fangohr wrote: > FYI: The reason for wanting to use two different file formats is this: > we have a somewhat larger project (http://nmag.soton.ac.uk) where we > combine high-level Python code with low-level Objective Caml code (and > a number of libraries). We would like to use the Python-logg

[Tutor] Bound To Be A Typo

2007-12-17 Thread earlylight publishing
Okay I copied this code directly from a book (author Michael Dawson) and it's not working. I'm sure I've missed something obvious like the spacing or something but I've been staring at it for 10 minutes and I can't see it. I'll put the code and error message below. Can someone else spot the p

Re: [Tutor] Bound To Be A Typo

2007-12-17 Thread Kent Johnson
earlylight publishing wrote: > class Critter(object): > """A virtual pet""" > def ___init___(self, name): Too many underscores, just use two before and two behind, i.e. __init__ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.or

[Tutor] Bound To Be A Typo

2007-12-17 Thread Michael H. Goldwasser
You've inadvertently used three underscores around __init__ rather than two, and therefore you are not really defining __init__ but instead are relying upon the inherited one from object (which takes no parameters). With regard, Michael On Monday December 17, 2007, earlylight publishing wrote:

Re: [Tutor] Bound To Be A Typo Thank You

2007-12-17 Thread earlylight publishing
I have no idea why I did that either. I know perfectly well it's supposed to be 2 underscores! Thanks to everyone who spotted the problem. "Michael H. Goldwasser" <[EMAIL PROTECTED]> wrote: You've inadvertently used three underscores around __init__ rather than two, and therefore you are no

Re: [Tutor] Bound To Be A Typo

2007-12-17 Thread Joshua Simpson
On Dec 17, 2007 12:16 PM, earlylight publishing < [EMAIL PROTECTED]> wrote: > > class Critter(object): > """A virtual pet""" > def ___init___(self, name): > print "A new critter has been born!" > > You're using 3 underscores before and after 'init'. The constructor for Python cla

Re: [Tutor] Bound To Be A Typo

2007-12-17 Thread Alan Gauld
Your init method has 3 underscores each side, it should be 2. (As all the magic methods in Python do) The result is the init is not recognised as an initialiser and the default object.new method is called. as the messaage says it takes no parameters... HTH, Alan G. "earlylight publishing" <[EMA

Re: [Tutor] Bound To Be A Typo

2007-12-17 Thread Michael Langford
Its "under under", not "under under under" before and after init --Michael On 12/17/07, earlylight publishing <[EMAIL PROTECTED]> wrote: > Okay I copied this code directly from a book (author Michael Dawson) and > it's not working. I'm sure I've missed something obvious like the spacing

[Tutor] Something I don't understand

2007-12-17 Thread Jim Morcombe
Below, "student_seats" is a list of the class "student". Why does this code set every student.row to zero when there is only one student in the list with row > 5? It still sets them all to zero if I change the test to ">200" when there are no student.rows > 200. But if I change the test to "<1"

[Tutor] Oops:

2007-12-17 Thread Jim Morcombe
I solved my last problem. The data was string data and of course '1' is > 5. Now, if I take int(string) the code will work, except it crashes out when the data is null. student.row = int(student.row) ValueError: invalid literal for int() with base 10: '' What is the easiest and recomended w

Re: [Tutor] Oops:

2007-12-17 Thread John Fouhy
On 18/12/2007, Jim Morcombe <[EMAIL PROTECTED]> wrote: > Now, if I take int(string) the code will work, except it crashes out when > the data is null. > > student.row = int(student.row) > ValueError: invalid literal for int() with base 10: '' > > What is the easiest and recomended way of turning th