On Mon, Nov 16, 2009 at 8:22 AM, James Youngquist
<james.youngqu...@gmail.com> wrote:
>
> On November 15, 2009 10:54:16 pm William Stein wrote:
>> On Sun, Nov 15, 2009 at 10:23 PM, kstueve <kevin.stu...@gmail.com> wrote:
>> > An alternative to adding/removing/commenting out/uncommenting print
>> > statements through your code may be to use decorators.  A decorator is
>> > a a function that is passed your function whenever it is called.  A
>> > decorator can do whatever you want.  Some of the possibilities are
>> > caching values of the function, but a decorator might be used to print
>> > debugging statements or keep track of how many times a method is
>> > called (or even pause or wait for input).  Some IDEs might have step
>> > through and breakpoint capability.  If my memory serves me correctly,
>> > there is a command (I think it works only in the command line, not in
>> > the notebook) that will give timing and method invocations for code.
>> >
>> > @somedecorator
>> > def somefunction():
>> >    code
>> >
>> > When somefunction is called, somedecorator (which is actually another
>> > callable function somewhere) gets called.
>>
>> That is not correct.  Doing
>>
>> @somedecorator
>> def somefunction():
>>     code
>>
>> is equivalent to doing
>>
>> somedecorator
>> def somefunction():
>>      code
>> somefunction = somedecorator(somefunction)
>>
>> The callable somedecorator is called when somefunction is created, not
>> when somefunction is called.
>>
>> William
>>
>> >
>
> Thank you all for the suggestions and links.  Would it be possible to add them
> as a subsection to 'Coding in Python for Sage' (at
> http://sagemath.org/doc/developer/)?  Perhaps 'Basic debugging techniques.'
>
> - Jim

Sure. It's easy.   All you have to do is take any copy of Sage and:

  (1) edit files in SAGE_ROOT/devel/sage/doc/en/developer
  (2) from the sage: prompt type
            sage: hg_sage.ci()
       to checkin your changes to your local repo.
  (3) export your changes
           sage: hg_sage.export('tip')
       and posted the resulting .patch file to a trac ticket here:
           http://trac.sagemath.org/

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to