OOPS, forwarding my reply to frank.  I accidentally sent it straight to him.
--- Begin Message ---
frank h. wrote:
why I am not using a dictionary: well I am lazy, I do not want to explicitly construct a dictionary :)
You don't have to explicitly construct it.
You can add stuff to it.
If by explicitly construct you meant
d = {'a':'b','b':'c'} or something.
you can just do
d = {}
d['a'] = 'b'
d['b'] = 'c'
etc.
Why is this too hard?
it seems like it'd be faster than saying
tmp = 'myvar'
#put something here that converts the string 'myvar' into a variable name,
#such as exec() or other scary things :)
myvar = 3
I have a parameterized string template, I publish it using

  print mytemplate % locals()
This looks frighteningly dangerous!
So you have to make sure you don't define any variables before this statement? That sounds like a bad idea to me, no matter how much more convenient it is :)

that saves me explicetly collecting all name value pairs in a dictionary first (there are quite a few) well given my current roadblock and your answer, it looks like I am better of creating a dictionary, so I can then do
yes, create a dictionary, please!  :D

In general, when you're presented with a problem like this, consider,
if it's hard to do, either
1) It's just hard to do.
or
2) It's hard to do because you _shouldn't be doing it_ and there's an easier way you're supposed to be using.
I think this is a case for #2.


--- End Message ---
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to