← Back to team overview

ufl team mailing list archive

Re: [HG UFL] Fix printing without newline on '...'?without using print. Found nice

 

On Tue, Mar 10, 2009 at 08:55:16AM +0100, Johan Hake wrote:
> On Monday 09 March 2009 22:37:54 Anders Logg wrote:
> > On Mon, Mar 09, 2009 at 10:27:19PM +0100, Martin Sandve Alnæs wrote:
> > > On Mon, Mar 9, 2009 at 10:17 PM, Anders Logg <logg@xxxxxxxxx> wrote:
> > > > On Mon, Mar 09, 2009 at 08:54:07PM +0100, Martin Sandve Alnæs wrote:
> > > >> Ok for now, but modifying the standard library behaviour isn't a very
> > > >> nice thing to do :)
> > > >>
> > > >> Martin
> > > >
> > > > I tried changing only the method for the UFL StreamHandler instance
> > > > but that didn't work.
> > >
> > > Don't bother now. Anyway, the point of using the Python logging system
> > > is that we can attach _multiple_ StreamHandlers to the UFL logger,
> > > e.g., for merging with SFC/FFC logs and dumping logs to file, so
> > > modifying the default stream handler isn't the right thing to do.
> > >
> > > > If I do
> > > >
> > > >  self._handler.emit = emit
> > > >
> > > > I get
> > > >
> > > >  File "/usr/lib/python2.5/logging/__init__.py", line 655, in handle
> > > >    self.emit(record)
> > > >  TypeError: emit() takes exactly 2 arguments (1 given)
> > >
> > > I didn't understand this on a first glance. Have you tried defining
> > > emit(self, arg) outside of the Logger class?
> >
> > Yes, same thing.
> >
> > I found a solution. Instead of just
> >
> >   instance.foo = foo
> >
> > one needs to do
> >
> >   instance.foo = new.instancemethod(foo, instance, instance.__class__)
> 
> The new module is deprecated in 2.6 and removed from 3.0. Use the module types 
> instead:
> 
>    instance.foo = types.MethodType(foo, instance, instance.__class__)
> 
> 
> Btw types is a nice module for checking and creating... øhhh, types :)

Fixed.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


References