hi everyone

so I am trying to do something after waiting a random number of seconds in a while loop.I have python22 installed and I am working on windows xp. The problem is that it time.sleep works fine the first time but returns the following error after that. I dont understand why that could be.
Traceback (most recent call last):
File "testing.py", line 11, in ?
AttributeError: 'unicode' object has no attribute 'sleep'

import feedparser, string, os, time, smtplib,platform,random

timeholder = ''
while 1:
	wait = 	random.uniform(60, 121)
	print "fetching now"		
	# do something

         # If new post update time
         if timeholder != time:
           timeholder = time
           print "New post at " + timeholder

         # If no new posts do nothing
         elif timeholder == time:
if timeholder != time:

This will always be true on the first pass as timeholder is a string and time is a builtin class/module. Print type(time) and type(timeholder) to show this.

timeholder = time

This statement then copies the time class to timeholder, so the two will always be equal on subsequent passes, i.e. the same class/module. You possibly want time.time() or datetime.datetime.now(). Also, the indentation is off by one, which I assume is from the error in using a combination of tabs and spaces, instead of spaces only (which is preferred).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.