Max Frai
Max Frai

Reputation: 64366

Python random numbers

I can't understand the problem in python. I have such code:

class Rain:
    def __init__(self):
       self.x = random.randint(0, Core.Utils.ScreenResolutionX)
       print type(Core.Utils.ScreenResolutionX) # prints int
       print Core.Utils.ScreenResolutionX # print 1152

Error:

    self.x = random.randint(0, Core.Utils.ScreenResolutionX)
  File "/usr/lib/python2.7/random.py", line 241, in randint
    return self.randrange(a, b+1)
  File "/usr/lib/python2.7/random.py", line 213, in randrange
    if width >= maxwidth:
AttributeError: 'Rain' object has no attribute 'getType'

Upvotes: 3

Views: 683

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799520

NULL is being returned to Python in one of your methods erroneously. Always make sure to incref and return PyNone to Python if no exception needs to be raised.

Upvotes: 1

Related Questions