Chad Skiles
Chad Skiles

Reputation: 82

Python 3 sched module

I am trying to create a script that will run code at the top of every minute. I'm looking into the sched module and I've encountered some strange problems.

The first problem is that importing sched runs my script twice.

import sched
print('hello')

Output:

Hello
Hello

Also this code which comes straight from the documentation:

import sched, time
s = sched.scheduler(time.time, time.sleep)

produces this error:

AttributeError: module 'sched' has no attribute 'scheduler'

Upvotes: 0

Views: 1026

Answers (1)

Robert Seaman
Robert Seaman

Reputation: 2582

As per my comment - your file is named sched.py, therefore, it was importing itself, of which doesn't have the attribute scheduler.

Upvotes: 1

Related Questions