<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.1">
</HEAD>
<BODY>
On Fri, 2011-02-04 at 13:08 -0800, Wanderer wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
I want to give the option of changing attributes in a method or using
the current values of the attributes as the default.

class MyClass():
     """  my Class
     """
     def __init__(self):
          """ initialize
          """
          self.a = 3
          self.b = 4

     def MyMethod(self, a = self.a, b = self.b)
          """ My Method
          """
          self.a = a
          self.b = b
          DoSomething(a, b)

The above doesn't work. Is there a way to make it work?

Thanks

</PRE>
</BLOCKQUOTE>
This doesn't work because you can't reference keyword arguments in the keyword argument array. This will work:<BR>
<TT>class MyClass:</TT><BR>
<BR>
<TT>    def __init__(self):</TT><BR>
<TT>        """ initialize</TT><BR>
<BR>
<TT>        Really? These are the worst docstrings ever.</TT><BR>
<BR>
<TT>        """</TT><BR>
<TT>        self.a = 3</TT><BR>
<TT>        self.b = 4</TT><BR>
<BR>
<TT>    def MyMethod(self, a=None, b=None)</TT><BR>
<TT>        if a is not None:</TT><BR>
<TT>            self.a = a</TT><BR>
<TT>        if b is not None:</TT><BR>
<TT>            self.b = b</TT><BR>
<TT>        DoSomething(a, b)</TT>
</BODY>
</HTML>