lpy icon indicating copy to clipboard operation
lpy copied to clipboard

Wrong value on evaluate region, different result when paste into python process buffer

Open QiangF opened this issue 1 year ago • 0 comments

Try this code snippet:

class Robot:
    __counter = 0
    def __init__(self):
        type(self).__counter += 1
    @classmethod
    def RobotInstances(cls):
        return cls, Robot.__counter

print(Robot.RobotInstances())
x = Robot()
print(x.RobotInstances())
y = Robot()
print(x.RobotInstances())
print(Robot.RobotInstances())

If the snippet is evaluated by paste into a python process buffer, the result is correct. If first select it and eval with "e", the result is wrong.

QiangF avatar Nov 03 '23 07:11 QiangF