On 21/12/19 1:59 am, Stefan Ram wrote:
   I would like to add a method to a string.

   This is not possible in Python?

It's not possible. Built-in classes can't have methods added
to them.

You can define your own subclass of str and give it whatever
methods you want.

But in your case:

for s in 'abc'.like( '(.)' ):

I would recommend making it a stand-alone function instead,
so that you would write

  for s in like('abc', '(.)'):

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to