EDIT: I realised I made a mistake. Your question if how to overwrite a method without using a class. This is not possible in python, because methods can only be invoked on objects, which are derived from a class.
For starters, you may want to consider defining a class. Methods are called upon objects (magic methods, normal methods, all the same), and objects in turn are derived from their classes. Note that in python everything is an object. There are a couple of classes that come within the standard python library like String, Integer, Boolean, and so on. Your code would have to look more like the following:
def class Some_Class:
name = ""
__init__(self,name):
self.name = name
__setattr__(self,name,value):
if name == "b":
self.doSomething()
def doSomething():
pass
def main():
example_class = Some_Class('Chars')
setattr(example_class, 'b','some_value') #Will trigger doSomething()
main()