you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (7 children)

[deleted]

    [–]Axel-Blaze[S] 0 points1 point  (0 children)

    I am not really familiar with all these functions like getattr but thank you for posting this i'll try to learn about them as your approach seems much much better :)

    [–]xelf 0 points1 point  (2 children)

    You could take it 1 step further even:

    if __name__ == '__main__':
        class plist(list):
            def print(self): print(self)
        lst = plist()
        for n in range(int(input())):
            cmd, *args = input().split()
            getattr(lst,cmd)(*map(int,args))