title: How to build a decorator with optional parameters?
body: <p>I would like to make a decorator which could be used with or without a parameter :
  Something like this :</p>
  
  <pre><code>class d(object):
      def __init__(self,msg='my default message'):
          self.msg = msg
      def __call__(self,fn):
          def newfn():
              print self.msg
              return fn()
          return newfn
  
  @d('This is working')
  def hello():
      print 'hello world !'
  
  @d
  def too_bad():
      print 'does not work'
  </code></pre>
  
  <p>In my code, only the use of decorator with parameter is working: How to proceed to have both working (with and without parameter)?</p>