def ref(function, callback=None):
try:<EOL><INDENT>function.__func__<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _WeakMethodFree(function, callback)<EOL><DEDENT>return _WeakMethodBound(function, callback)<EOL>
Returns a weak reference to the given method or function.
If the callback argument is not None, it is called as soon
as the referenced function is garbage deleted.

:type  function: callable
:param function: The function to reference.
:type  callback: callable
:param callback: Called when the function dies.