I agree it's annoying that warnings are always printed twice, but I wonder if there's a good reason for it.
On Wed, Apr 18, 2012 at 12:19 PM, Ronan Lamy <ronan.l...@gmail.com> wrote: > Le mercredi 18 avril 2012 à 23:16 +0545, Chris Smith a écrit : >> On Wed, Apr 18, 2012 at 11:02 PM, Joachim Durchholz <j...@durchholz.org> >> wrote: >> > Am 18.04.2012 17:55, schrieb smichr: >> >> >> >> I am proposing a change to the warning handling for >> >> SymPyDeprecationWarning: >> > >> > >> > The output sure looks better, what's the change in the code? >> > >> >> Just added a warn property: >> >> ``` >> @property >> + def warn(self): >> + from sympy.utilities.misc import filldedent >> + from warnings import warn as warning >> + msg = self.fullMessage >> + see_above = '\n%s\n' % filldedent(msg) >> + # the next line is what the user will see after the error is printed >> + warning (see_above) >> ``` > > Properties with side-effects are evil. They break introspection, making > e.g. graphical debuggers unusable. So this should definitely be a method > instead of a property. Agreed. > > Also, forcing the import of all of sympy just to raise a warning doesn't > seem like a good idea. If you're referring to sympy.utilities.misc, it doesn't appear to import all of sympy (all sympy imports in that file are inside of functions). > >> So instead of doing >> >> ``` >> import warnings >> warnings.warn(SymPyDeprecationWarning(foo)) >> ``` > > Note that 'import warnings' should be at the top of the file, not next > to the warning. > >> >> you do >> >> ``` >> SymPyDeprecationWarning(foo).warn >> ``` >> > > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sympy@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.