[EMAIL PROTECTED] wrote:
> Steve, can I quote you on that?
>
> "You can lead an idiot to idioms, but you can't make him think!" --
> Steve Holden 2005
>
Looks like you just did :-). Feel free.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC htt
Steve, can I quote you on that?
"You can lead an idiot to idioms, but you can't make him think!" --
Steve Holden 2005
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> Steve Holden wrote:
>
>
>>Yes. A large part of learning a language is discovering the many idioms
>>that have already been established for doing certain things. These are a
>>kind of shorthand, established by long convention, that allow one to
>>avoid the "learning-by-use"
What you could do is to create a class for this; fill it's __dict__
instance; and use custom getattr() / setattr() methods for accessing
a0, a1, a2 etc.
cheers,
--Tim
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden wrote:
> Yes. A large part of learning a language is discovering the many idioms
> that have already been established for doing certain things. These are a
> kind of shorthand, established by long convention, that allow one to
> avoid the "learning-by-use" curve.
it's not obvious tha
Oops, you're completely right.
I'm sorry, it is indeed my mistake.
I was thinking people were telling me I was quoting Martin wrong, while I was
quoting Rafi wrong. I'll promise not quote anybody anymore until I have an
e-mail program that can quote/copy properly. As reading it in one window, th
Adriaan Renting wrote:
> My original code was: exec(eval("'a%s=%s' % (count, value)"))
> Then Rafi said: exec("'a%s=%s' % (count, value)")
> To which I responded that his example does not work in my Python, and I think
> it's invalid.
> Then Martin came with: exec 'a%s = %s' % (count, value)
> Th
I'm sorry for top-posting and not marking quoted text, but my e-mail reader
(Novell Groupwise 6 for Linux) does not mark quoted text. The only thing it
does is the >>> $NAME <$EMAIL> $DATE >>> above the quoted text. Therefore I add
my comments at the top. The only alternative I have is copying a
[The context is totally hosed by top posting and failure to mark
quoted text. I gave up on recovering it.]
"Adriaan Renting" <[EMAIL PROTECTED]> writes:
> Not in my Python.
>
for count in range(0, 10):
> ... value = count
> ... exec("'a%s=%s' % (count, value)")
You left in the extra
Nx wrote:
> Thanks for all the responses and animated discussion,
> which is still the best way to learn something new.
>
> Most of the time it is not that you want to do something
> in a certain way , it rather is one cannot think of a
> better , faster more efficient way .
>
> Nx
Yes. A large
Adriaan Renting wrote:
> Not in my Python.
>
>
for count in range(0, 10):
>
> ... value = count
> ... exec("'a%s=%s' % (count, value)")
But that's not what rafi suggested.
rafi:
> why using the eval?
>
> exec ('a%s=%s' % (count, value))
See the difference?
--
Robert Kern
[EMAIL
Benji York schrieb:
>> >>> suffix = 'var'
>> >>> vars()['a%s' % suffix] = 45
>> >>> avar
>> 45
>
>
> Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about
> the "vars" built in:
>
> The returned dictionary should not be modified: the effects on the
> corresponding symbol
Adriaan Renting wrote:
> Not in my Python.
>
>
for count in range(0, 10):
>
> ... value = count
> ... exec("'a%s=%s' % (count, value)")
> ...
>
dir()
>
> ['__builtins__', '__doc__', '__name__', 'count', 'value']
You did not copy the suggestion properly:
>>> for count in rang
I was responding to rafi's suggestion, I had not received the "exec 'a%s = %s'
% (count,count)" response yet at that time. The "exec 'a%s = %s' %
(count,value)" works fine.
>Not in my Python.
>
>---snip---
>
>why using the eval?
>
>exec ('a%s=%s' % (count, value))
>
>should be fine
>
>--
Ron Garret wrote:
>>Because eval() takes an expression as an argument, and assignment is a
>>statement.
>
> And if you find this distinction annoying, try Lisp.
that's were I come from :-)
--
rafi
"Imagination is more important than knowledge."
(A
Not in my Python.
>>> for count in range(0, 10):
... value = count
... exec("'a%s=%s' % (count, value)")
...
>>> dir()
['__builtins__', '__doc__', '__name__', 'count', 'value']
>>> for count in range(0, 10):
... value = count
... exec(eval("'a%s=%s' % (count, value)"))
...
>>> di
Thanks for all the responses and animated discussion,
which is still the best way to learn something new.
Most of the time it is not that you want to do something
in a certain way , it rather is one cannot think of a
better , faster more efficient way .
Nx
--
http://mail.python.org/mailman/listi
In article <[EMAIL PROTECTED]>,
Steve Holden <[EMAIL PROTECTED]> wrote:
> rafi wrote:
> > Reinhold Birkenfeld wrote:
> >
> >
> exec(eval("'a%s=%s' % (count, value)"))
> >>>
> >>>why using the eval?
> >>>
> >>>exec ('a%s=%s' % (count, value))
> >>>
> >>>should be fine
> >>
> >>And this demo
Steve Holden wrote:
> Because eval() takes an expression as an argument, and assignment is a
> statement.
I am definitely not a language lawyer... but I should a little bit more
thanks,
--
rafi
"Imagination is more important than knowledge."
(Alber
rafi wrote:
> Reinhold Birkenfeld wrote:
>
>
exec(eval("'a%s=%s' % (count, value)"))
>>>
>>>why using the eval?
>>>
>>>exec ('a%s=%s' % (count, value))
>>>
>>>should be fine
>>
>>And this demonstrates why exec as a statement was a mistake ;)
>>
>>It actually is
>>
>>exec 'a%s=%s' % (count, v
rafi wrote:
> In the meantime another question I cannot find an answer to: any idea
> why does eval() consider '=' as a syntax error?
>
> >>> eval ('a=1')
> Traceback (most recent call last):
>File "", line 1, in ?
>File "", line 1
> a=1
> ^
> SyntaxError: invalid syntax
eva
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
> Robert Kern <[EMAIL PROTECTED]> wrote:
>
>> In the
>>bowels of my modules, I may not know what the contents are at code-time,
>
> Then how do you write your code?
With style. ;-)
I use a Bunch where I might otherwise use a dictionary insid
Reinhold Birkenfeld wrote:
>>> exec(eval("'a%s=%s' % (count, value)"))
>>
>>why using the eval?
>>
>>exec ('a%s=%s' % (count, value))
>>
>>should be fine
>
> And this demonstrates why exec as a statement was a mistake ;)
>
> It actually is
>
> exec 'a%s=%s' % (count, value)
Noted.
In the mea
rafi wrote:
> Adriaan Renting wrote:
>> You might be able to do something along the lines of
>>
>> for count in range(0,maxcount):
>> value = values[count]
>> exec(eval("'a%s=%s' % (count, value)"))
>
> why using the eval?
>
> exec ('a%s=%s' % (count, value))
>
> should be fine
And this de
In article <[EMAIL PROTECTED]>,
Robert Kern <[EMAIL PROTECTED]> wrote:
> In the
> bowels of my modules, I may not know what the contents are at code-time,
Then how do you write your code?
rg
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Hey, if the man wants to write it that way, let the man write it that
> way. If it works for him, great... he's sure confused the heck out of
> all of us, and that translates into job security for him! As you can
> see, the name of the post is 'vari
Carsten Haese wrote:
> On Thu, 2005-08-25 at 11:04, I hastily wrote:
>
>>On Thu, 2005-08-25 at 10:43, Nx wrote:
>>
>>>Thanks for the many replies
>>>
>>> here is an example for what it will be used for , in this case
>>> fixed at 31 fieldvalues:
>>>
>>> inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s
Nx wrote:
>>"""
>>
>>Why unpack inputvalues if your next step is to pack'em back again ? Or
>>what did I miss ?
>
> The original values in this case are being read from a text file
> with one value including a linefeed per line and the original idea was,
> that having them read into a list was the
Ron Garret wrote:
> If you really want to make something like this work you can define a
> class that would work like this:
>
> vars = funkyclass()
> varname = 'x'
> vars[varname] = value
> vars.x
>
> But this is clearly a design mistake. Either you know the names of the
> variables when you
In article <[EMAIL PROTECTED]>,
Benji York <[EMAIL PROTECTED]> wrote:
> Peter Maas wrote:
> > >>> suffix = 'var'
> > >>> vars()['a%s' % suffix] = 45
> > >>> avar
> > 45
>
> Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about
> the "vars" built in:
>
> The returned dicti
Adriaan Renting wrote:
> You might be able to do something along the lines of
>
> for count in range(0,maxcount):
> value = values[count]
> exec(eval("'a%s=%s' % (count, value)"))
why using the eval?
exec ('a%s=%s' % (count, value))
should be fine
--
rafi
"Imagination is more imp
Hey, if the man wants to write it that way, let the man write it that
way. If it works for him, great... he's sure confused the heck out of
all of us, and that translates into job security for him! As you can
see, the name of the post is 'variable hell' and that is exactly what
he
> """
>
> Why unpack inputvalues if your next step is to pack'em back again ? Or
> what did I miss ?
>
The original values in this case are being read from a text file
with one value including a linefeed per line and the original idea was,
that having them read into a list was the best way to ma
On Thu, 2005-08-25 at 11:04, I hastily wrote:
> On Thu, 2005-08-25 at 10:43, Nx wrote:
> > Thanks for the many replies
> >
> > here is an example for what it will be used for , in this case
> > fixed at 31 fieldvalues:
> >
> >
> > inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14
You might be able to do something along the lines of
for count in range(0,maxcount):
value = values[count]
exec(eval("'a%s=%s' % (count, value)"))
But I am also wonder: why?
Peter Maas wrote:
> >>>suffix = 'var'
> >>>vars()['a%s' % suffix] = 45
> >>>avar
>45
--
http://mail.python.
On Thu, 2005-08-25 at 10:43, Nx wrote:
> Thanks for the many replies
>
> here is an example for what it will be used for , in this case
> fixed at 31 fieldvalues:
>
>
> inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
> s26,s2
Nx wrote:
> Thanks for the many replies
>
> here is an example for what it will be used for , in this case
> fixed at 31 fieldvalues:
>
>
> inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
> s26,s27,s28,s29,s30,s31)
>MYINS
Thanks for the many replies
here is an example for what it will be used for , in this case
fixed at 31 fieldvalues:
inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
s26,s27,s28,s29,s30,s31)
MYINSERTSELECT = "INSERT INTO
ADD
Peter Maas wrote:
> >>> suffix = 'var'
> >>> vars()['a%s' % suffix] = 45
> >>> avar
> 45
Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about
the "vars" built in:
The returned dictionary should not be modified: the effects on the
corresponding symbol table are undefined.
Nx schrieb:
> Hi
>
> I am unpacking a list into variables, for some reason they need to be
> unpacked into variable names like a0,a1,a2upto aN whatever is
> in the list.
>
> How to create the variables dynamically ?
>
> I am looking for something like
> pseudo code line follows :
>
Nx enlightened us with:
> I am unpacking a list into variables, for some reason they need to
> be unpacked into variable names like a0,a1,a2upto aN whatever is
> in the list.
You're probably doing things the wrong way. What is your ultimate goal
with this? There is probably a better way of doi
"Nx" <[EMAIL PROTECTED]> wrote:
> I am unpacking a list into variables, for some reason they need to be
> unpacked into variable names like a0,a1,a2upto aN whatever is
> in the list.
why?
--
http://mail.python.org/mailman/listinfo/python-list
Nx wrote:
> Hi
>
> I am unpacking a list into variables, for some reason they need to be
> unpacked into variable names like a0,a1,a2upto aN whatever is
> in the list.
Really? Why?
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
Are the graves of dre
Nx wrote:
> I am unpacking a list into variables, for some reason they need to be
> unpacked into variable names like a0,a1,a2upto aN whatever is
> in the list.
Explain this "some reason". This smells, and the way to go would be to
use a dict mapping a_n to whatever is in the list - not cr
Hi
I am unpacking a list into variables, for some reason they need to be
unpacked into variable names like a0,a1,a2upto aN whatever is
in the list.
How to create the variables dynamically ?
I am looking for something like
pseudo code line follows :
a%s = str(value)
here below i
45 matches
Mail list logo