Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Cell objects and their values

Reply
Thread Tools

RE: Cell objects and their values

 
 
Robert Brewer
Guest
Posts: n/a
 
      04-22-2004
Jeff Epler wrote:
> This seems to work, but it's undocumented (specifically,
> func_closure as
> an argument to new.function is undocumented) and makes my tummy feel
> funny when I think about it.
>
> >>> import new
> >>> def cell_get(cell):

> ... def f(): return cell
> ... return new.function(f.func_code, {}, "f", (), (cell,))()
> ...


Rock. On.

That is frickin' brilliant in at least three ways I never would have
thought of. Thanks! Looking back over Raymond's bytecode hack in PEP
329, I notice he also used func_closure as an arg to function(). In
addition, he avoided importing the "new" module by just calling
type(f)().

Danke.


Robert Brewer
MIS
Amor Ministries
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
Michael Hudson
Guest
Posts: n/a
 
      04-22-2004
"Robert Brewer" <(E-Mail Removed)> writes:

> Jeff Epler wrote:
> > This seems to work, but it's undocumented (specifically,
> > func_closure as
> > an argument to new.function is undocumented) and makes my tummy feel
> > funny when I think about it.
> >
> > >>> import new
> > >>> def cell_get(cell):

> > ... def f(): return cell
> > ... return new.function(f.func_code, {}, "f", (), (cell,))()
> > ...

>
> Rock. On.
>
> That is frickin' brilliant in at least three ways I never would have
> thought of. Thanks! Looking back over Raymond's bytecode hack in PEP
> 329, I notice he also used func_closure as an arg to function(). In
> addition, he avoided importing the "new" module by just calling
> type(f)().


That wouldn't work in Python 2.2, I don't know what Jeff is using
these days...

Cheers,
mwh

--
On the other hand, the following areas are subject to boycott
in reaction to the rampant impurity of design or execution, as
determined after a period of study, in no particular order:
... http://www.naggum.no/profile.html
 
Reply With Quote
 
 
 
 
Jeff Epler
Guest
Posts: n/a
 
      04-22-2004
On Thu, Apr 22, 2004 at 10:34:13AM +0000, Michael Hudson wrote:
> That wouldn't work in Python 2.2, I don't know what Jeff is using
> these days...


2.4 CVS .. what, doesn't everybody?

Jeff

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prophets are honored by everyone, except the people of their hometownand their own family. Eljee Digital Photography 8 09-21-2006 05:35 AM
Since MSN CHAT went pay per use. Is their any other free ones out their Hugh Computer Support 8 05-19-2004 05:52 PM
Cell objects and their values Robert Brewer Python 0 04-21-2004 11:06 PM
What the pros use to power their flashes... and their digital cameras. Dan Sullivan Digital Photography 21 01-04-2004 04:40 PM
Stop Spammers by Hitting Their Servers - Not Their Email. Magic347 Computer Support 27 07-03-2003 04:36 PM



Advertisments