0

This might be a dumb question but I'm a beginner, how do you make your own method in python Example the method list.clear() i want to make one that does that but it says list.NUKE Thank you for the help! So for example I installed colorama if you color of text you type in Fore.RED()

I want to do this with my own command

  • Are you asking how to add methods to an existing, built-in class? Generally, Python does not support this, although it is *possible* using various hacks. Normally, you would just subclass `list` and add your own method to the subclass though – juanpa.arrivillaga Aug 01 '22 at 19:03
  • 1
    @JNevill the answer to that duplicate will not work for lists. – juanpa.arrivillaga Aug 01 '22 at 19:03
  • Just to help you in the future, there's a big difference between customizing a library class and customizing a built-in type. You can modify objects when they are loaded from source, but not the built-in types. – Tim Roberts Aug 01 '22 at 19:05
  • @TimRoberts how do you modify when they are loaded from source thx – Pyonner12345 Aug 01 '22 at 19:31

0 Answers0