FAQ
Python experts,

Is there a more pythonic way to do something evquilent to what this line
does without creating a dummy class?

self.file = type("", (object,), {'close':lambda slf: None})()

As you can guess, I want a dummy object that I can call close on with
impunity.

I've been reading _Python in a Nutshell_ (Thanks, Alex!), which defines
a Bunch class that I think could also work, but if I'm only going to use
it to define a class with a dummy close() method, I might as well just
create the dummy class with the dummy method. . . Unless there is
something equvilent to Bunch in one of the standard modules that I don't
know about . . .?

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedAug 7, '03 at 1:42a
activeAug 8, '03 at 3:28p
posts6
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase