overiding assignment in module

Steven D'Aprano steve at REMOVETHIScyber.com.au
Tue Oct 25 08:20:54 EDT 2005


On Tue, 25 Oct 2005 04:56:02 -0700, Viktor Marohnic wrote:

> Hello.
> I would to do something like this.
> 
> container = []
> 
> p1 = point()
> l1 = line()

Choosing names that look like numbers is terrible practice. Don't use l,
l1, O, ll, and so forth, unless you are trying to deliberately make your
code hard to read, hard to understand, and easy to miss bugs.


> and i would like to override = method of the module so that its puts
> all objects into container.

What do you mean by put all objects into container?

Do you mean:

container = []
container = point()
container = line()

Or do you mean:

container = []
container.append(point())
container.append(line())

Or even:

container = []
container.insert(0, point())
container.insert(0, line())

Or possibly even:

container = []
container.extend(point())
container.extend(line())



> how i can do something like that.

Choose a different language.

There is no assignment method in Python.


-- 
Steven.




More information about the Python-list mailing list