"ast" <nomail@com.invalid> writes:
> I know two Python's objects which have an intrinsic name, classes and
> functions.
> ...
> Are there others objects with a __name__ attribute
> and what is it used for ?

Some Python objects naturally have a name: functions, classes, modules, ...;
others don't: tuples, lists, integers, ...

If a Python object natureally has a name, there is a good chance that
it is accessible in a standard way: "obj.__name__".

Sometimes, the name is a bit special. An example is the "filename"
(potentially) associated with a "file" like object. In those cases,
the name can be accessed in a slightly different way, e.g. "file.filename".


I recommend that you do not try to enumerate all cases where an object
has a name accessible via "obj.__name__". Instead, start with
your concrete task. Select the objects appropriate for your task.
Use the "buildin" functions "dir" and "help" on a sample object
to find out (in an interactive Python sesssion)
which attributes and methods it supports. If this does not give
enough information, consult the documentation.

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

Reply via email to