开发者

Python random numbers

开发者 https://www.devze.com 2023-02-24 08:14 出处:网络
I can\'t understand the probl开发者_如何转开发em in python. I have such code: class Rain: def __init__(self):

I can't understand the probl开发者_如何转开发em 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'


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消