Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

.

Name: Anonymous 2011-09-26 12:08

class Namespace:
    def __init__(self, **kwargs):
        self.__dict__ = kwargs

    def __str__(self):
        vals = []

        for var in self.__dict__:
            vals.append(
                "%s=%s" % (
                    var,
                    str(self.__dict__[var])
                )
            )

        return "Namespace(%s)" % (', '.join(vals))

    def __repr__(self):
        return str(self)

    def pollute(self, other):
        if not isinstance(other, dict):
            other = other.__dict__

        for var in self.__dict__:
            other[var] = self.__dict__[var]

Name: Anonymous 2011-09-26 12:09

Maybe the most useful code snippet in /prog/

Name: Anonymous 2011-09-26 12:56

namespace.pollute(globals())

Don't change these.
Name: Email:
Entire Thread Thread List