开发者

Python random numbers

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜