[Tutor] Code review, plase

Alex metallourlante at gmail.com
Wed Sep 8 14:28:26 CEST 2010


On Wed, Sep 8, 2010 at 12:20 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Wed, 8 Sep 2010 06:39:27 am Alex wrote:
>> Hi all.
>>
>> Could someone review my code? It's the first time I develop a
>> reusable module and I would like to have some feedback.
>> If you think it's good enough I will package it for pypi.
>>
>> I put the code on pastebin: http://pastebin.com/Tz367gAM
>
> Let's start with some little things... you talk about "the Unix CronTab"
> command, but there's no such thing, at least on Linux:
>
> [steve at sylar ~]$ CronTab
> bash: CronTab: command not found

Absolutely right I'll update the docstring

> In the _remove_crontab method, you say "*All* the information contained
> in the crontab file are permanently lost", but that's grammatically
> incorrect -- "information" is a mass noun, i.e. neither singular nor
> plural. So in standard English, you would say "all the information in
> the file is permanently lost", not "are lost", in the same way that you
> would say "the sugar is on the table" or "the grass is green".

Argh! I should go back to grammar school :-) English is not my first langage

> ct1 = micron.CronTab()
> ct2 = micron.CronTab()
> ct1.add_job('daily', 'echo "BOOM!"')
> ct2.add_job('daily', 'echo "No BOOM today"')

> Do they fight? What happens?

They will not be duplicated because the class will generate a unique
job_id incrementing the last id used. Since the module is just a
wrapper for the crontab command any other clashing will be managed by
the cron daemon. I will add an example to document this behaviour.

Thanks for your helpful comments.

Alex


More information about the Tutor mailing list