anomalous behaviour of bc.homogenize() with list comprehension

10 months ago by
Consider bcs is a list of  DirichletBC instances.
If I do
      bcs_h = [bc.homogenize() for bc in bcs]
      for  bc in bcs_h:
           print type(bc)
It gives <type 'NoneType'>

But if I do
       bcs_h =[]
       for bc in bcs:
then each element of bcs_h  seems to be <class 'dolfin.fem.bcs.DirichletBC'>

In both cases, bcs_h is obtained by bc.homogenize(), but why is it NoneType in first case ?
Community: FEniCS Project

1 Answer

10 months ago by
Clearly, bc.homogenize() returns None.
So bc.homogenize() changes bc in-place  but returns None ?
written 10 months ago by Shriram S  
Well, strictly speaking homogenize() is an instance method so "in-place" does not apply.  Python functions without a "return" clause return "None" by default.
written 10 months ago by pf4d  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »