Subject: [UFL-dev] [HG UFL] Fix printing without newline on '...' without using print. Found nice

From: [email-masked] (UFL)
Date: Mon, 9 Mar 2009 18:26:46 +0100 (CET)

One or more new changesets pushed to the primary ufl repository.
A short summary of the last three changesets is included below.

changeset:   720:367a728f6c3271cbaf451b0826acc27546c2bb1a
tag:         tip
user:        Anders Logg <[email-masked]>
date:        Mon Mar 09 18:26:41 2009 +0100
files:       ufl/algorithms/formdata.py ufl/log.py
description:
Fix printing without newline on "..." without using print. Found nice
solution at http://mail.python.org/pipermail/python-list/2007-October/632175.html

changeset:   719:f4cf2e6bf4a4cf48fa0f438d3e648229ab33205c
user:        "Martin Sandve Alnæs <[email-masked]>"
date:        Mon Mar 09 16:05:34 2009 +0100
files:       ufl/log.py
description:
Upgraded TODO to FIXME in log.py, use of print destroys
all reasons for using the logging system. Luckily it's
only for info, which isn't really used in UFL.

changeset:   718:d9b4edd6b21f2c5a88bdeb6f8855ac1360b3c611
user:        "Martin Sandve Alnæs <[email-masked]>"
date:        Mon Mar 09 15:58:06 2009 +0100
files:       test/base.py
description:
removed test fail

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/ufl

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Mon, 9 Mar 2009 20:54:07 +0100

Ok for now, but modifying the standard library behaviour isn't a very
nice thing to do :)

Martin

On Mon, Mar 9, 2009 at 6:26 PM, UFL <[email-masked]> wrote:
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev
>
>

---

From: Anders Logg <[email-masked]>
Date: Mon, 9 Mar 2009 22:17:19 +0100

> Ok for now, but modifying the standard library behaviour isn't a very

I tried changing only the method for the UFL StreamHandler instance
but that didn't work.

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)

-- 
Anders

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Mon, 9 Mar 2009 22:27:19 +0100

> I tried changing only the method for the UFL StreamHandler instance

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.

>  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?

Martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 9 Mar 2009 22:37:54 +0100

> 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__)

-- 
Anders

---

From: Johan Hake <[email-masked]>
Date: Tue, 10 Mar 2009 07:44:01 +0100

>   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 :)

Johan