Decorator syntax (was Re: PEP 318 - PyFIT comments)

Michael Hudson mwh at python.net
Fri Aug 6 07:09:40 EDT 2004


This reply was a touch more hostile that I was expecting; if I've hit
some nerve, sorry, if not, err, can you relax a bit?

"John Roth" <newsgroups at jhrothjr.com> writes:

> "Michael Hudson" <mwh at python.net> wrote in message
> news:m3pt65g4hb.fsf at pc150.maths.bris.ac.uk...
>
> > Well, that would be because that's impossible :-)
> 
> I wish you'd have told me that before I did it. As I said in
> a prior post, I had to put a general metadata facility into
> PyFIT, and it's working quite nicely, thank you.

OK, poor choice of words.

[snippity]

> > What kind of metadata do you want?
> 
> Type and other declaration information for any identifiers
> that will be referenced in the FIT tests. Other information
> includes things like precision for floating point numbers,
> strings that are accepted as "true" or "false" for booleans,
> the subtype for lists and tuples, references to custom
> type adapters and other stuff.

So, you would like to write 

class Thiny(object):
    @attribute(type=float, precision=3)
    a = 1.23

?

I really don't see how you could make that work.  attribute() could
return something that was called with the dictionary being inserted
into, the string 'a' and the value 1.23, but... ick.  I don't think I
like that idea.  What would you find helpful?

Cheers,
mwh

-- 
  ... but I'd rather not reinvent the wheel if I don't have to.  On
  the other hand, if the currently instantiated version of the wheel
  consists of a square rock covered with moss, I might as well just
  start fresh.                          -- Roy Smith, comp.lang.python



More information about the Python-list mailing list