On Aug 16, 4:02 pm, Maric Michaud <[EMAIL PROTECTED]> wrote:
> I'd say that everywhere exec/eval are used in a application/function/lib that
> doesn't mean to interpret arbitrary and user provided python code, it is a
> bad usage
Problem is, there are things you cannot do without
exec/eval: for in
On Aug 16, 3:25 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Aug 16, 12:50 am, Michele Simionato <[EMAIL PROTECTED]>
> wrote:
> > The namedtuple recipe by Raymond Hetting does
> > exactly that and, guess what, it uses exec!
>
> I might be wrong, but the reason namedtuple uses exec is performa
Le Saturday 16 August 2008 06:50:02 Michele Simionato, vous avez écrit :
> On Aug 16, 4:48 am, Nadeem <[EMAIL PROTECTED]> wrote:
> > I understand the 99% rule... the example I gave was to simplify the
> > issue. The full thing I'm working on is a library for an introductory
> > CS class I'm teachin
Nadeem wrote:
I understand that all this can be done with classes and OO
programming, but the whole point of the HtDP curriculum is to
introduce students to programming in a pedagogically-effective way
using a functional approach instead of OO-first.
And yet, one of the HtDP authors just poste
On Aug 16, 12:50 am, Michele Simionato <[EMAIL PROTECTED]>
wrote:
> On Aug 16, 4:48 am, Nadeem <[EMAIL PROTECTED]> wrote:
>
> > I understand the 99% rule... the example I gave was to simplify the
> > issue. The full thing I'm working on is a library for an introductory
> > CS class I'm teaching. I'
On Aug 16, 4:48 am, Nadeem <[EMAIL PROTECTED]> wrote:
> I understand the 99% rule... the example I gave was to simplify the
> issue. The full thing I'm working on is a library for an introductory
> CS class I'm teaching. I'm trying, essentially, to build a library of
> macros for students to use al
That's a really neat way of doing it, thanks a lot! I hadn't realized
how accessible all those globals() dictionaries were. Guess my example
still falls in the 99%... :)
--- nadeem
>
> def defineStruct(name, *parameters):
> class _struct:
> def __init__(self, *init_parameters):
> for
On Fri, Aug 15, 2008 at 10:48 PM, Nadeem <[EMAIL PROTECTED]> wrote:
> I understand the 99% rule... the example I gave was to simplify the
> issue. The full thing I'm working on is a library for an introductory
> CS class I'm teaching. I'm trying, essentially, to build a library of
> macros for stud
Well, I found one hack that seems to achieve this by accessing the
globals() dictionary of the outermost stack frame and adding an entry
to it for the newly created functions:
import inspect
def dynamicdef(name, amt):
'''Dynamically defines a new function with the given name that
adds
the
I understand the 99% rule... the example I gave was to simplify the
issue. The full thing I'm working on is a library for an introductory
CS class I'm teaching. I'm trying, essentially, to build a library of
macros for students to use allowing them to define records (like
structs in C) with selecto
On Aug 15, 7:26 pm, Nadeem <[EMAIL PROTECTED]> wrote:
> Hello all,
> I'm trying to write a function that will dynamically generate other
> functions via exec.
General tip: whenever you think you need to use exec (or eval), 99% of
the time you don't; most of the time there is a better (meaning, le
11 matches
Mail list logo