Hi All,

I'm pretty new to python and still getting to know how python works. I want
to associate some metadata to a function.
In javascript I'm used to associating metadata with a function as
follows.

foo.bar = "foobar";
function foo(){
}

Whats the normal python practice to do this kind of a thing. Whats the
python way of doing this.

Your help is very much appreciated.

Thanks,
Heshan Suriyaarachchi

Something like that?

def foo():
    return foo.bar

foo.bar = "foobar"

print foo()  # foobar
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.