Am 03.12.2012 23:29, schrieb Larry Hastings:
[...autogen some code from special comment strings...]
   /*[clinic]
   dbm.open -> mapping
   basename=dbmopen

       const char *filename;
           The filename to open.

       const char *flags="r";
           How to open the file.  "r" for reading, "w" for writing, etc.

       int mode=0666;
       default=0o666
           If creating a new file, the mode bits for the new file
           (e.g. os.O_RDWR).

   Returns a database object.

   [clinic]*/

Firstly, I like the idea. Even though this "autogenerate in-place" seems a bit strange at first, I don't think it really hurts in practice. Also, thanks for introducing me to the 'cog' tool, I think I'll use this now and then!

This also brings me to a single question I have for your proposal: Why did you create another DSL instead of using Python, i.e. instead of using cog directly? Looking at the above, I could imagine this being written like this instead:

/*[[[cog
import pycognize
with pycognize.function('dbmopen') as f:
    f.add_param('self')
    f.add_kwparam('filename',
                  doc='The filename to open',
                  c_type='char*')
    f.add_kwparam('flags',
                  doc='How to open the file.'
                  c_type='char*',
                  default='r')
    f.set_result('mapping')
]]]*/
//[[[end]]]

Cheers!

Uli


**************************************************************************************
Domino Laser GmbH, Fangdieckstra�e 75a, 22547 Hamburg, Deutschland
Gesch�ftsf�hrer: Hans Robert Dapprich, Amtsgericht Hamburg HR B62 932
**************************************************************************************
Visit our website at http://www.dominolaser.com
**************************************************************************************
Diese E-Mail einschlie�lich s�mtlicher Anh�nge ist nur f�r den 
Adressaten bestimmt und kann vertrauliche Informationen enthalten. Bitte 
benachrichtigen Sie den Absender umgehend, falls Sie nicht der beabsichtigte 
Empf�nger sein sollten. Die E-Mail ist in diesem Fall zu l�schen und darf 
weder gelesen, weitergeleitet, ver�ffentlicht oder anderweitig benutzt werden.
E-Mails k�nnen durch Dritte gelesen werden und Viren sowie nichtautorisierte 
�nderungen enthalten. Domino Laser GmbH ist f�r diese Folgen nicht 
verantwortlich.
**************************************************************************************

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to