On Tuesday, December 13, 2011 9:35:52 AM UTC+8, Steven D'Aprano wrote:
> On Mon, 12 Dec 2011 15:45:06 -0800, alex23 wrote:
>
> > On Dec 12, 10:49 pm, 8 Dihedral
> > wrote:
> >> This is the way to write an assembler or to roll out a script language
> >> to be included in an app by users.
> >
On Mon, 12 Dec 2011 15:45:06 -0800, alex23 wrote:
> On Dec 12, 10:49 pm, 8 Dihedral
> wrote:
>> This is the way to write an assembler or to roll out a script language
>> to be included in an app by users.
>
> This is a garbage comment that has absolutely nothing to do with the
> topic at han
On Dec 12, 10:49 pm, 8 Dihedral
wrote:
> This is the way to write an assembler or
> to roll out a script language to be included in an app
> by users.
This is a garbage comment that has absolutely nothing to do with the
topic at hand _at all_.
--
http://mail.python.org/mailman/listinfo/pytho
On Monday, December 12, 2011 3:11:18 PM UTC+8, alex23 wrote:
> On Dec 8, 3:09 am, Massi wrote:
> > in my script I have a dictionary whose items are couples in the form
> > (string, integer values), say
> >
> > D = {'a':1, 'b':2, 'c':3}
> >
> > This dictionary is passed to a function as a parameter
On Monday, December 12, 2011 3:11:18 PM UTC+8, alex23 wrote:
> On Dec 8, 3:09 am, Massi wrote:
> > in my script I have a dictionary whose items are couples in the form
> > (string, integer values), say
> >
> > D = {'a':1, 'b':2, 'c':3}
> >
> > This dictionary is passed to a function as a parameter
On Dec 8, 3:09 am, Massi wrote:
> in my script I have a dictionary whose items are couples in the form
> (string, integer values), say
>
> D = {'a':1, 'b':2, 'c':3}
>
> This dictionary is passed to a function as a parameter, e.g. :
>
> def Sum(D) :
> return D['a']+D['b']+D['c']
>
> Is there a
alex23 wrote:
On Dec 11, 4:42 pm, Nobody wrote:
If just you're trying to avoid getting a repetitive strain injury in your
right-hand little finger from typing all the [''], you could turn
the keys into object attributes, e.g.:
class DictObject:
def __init__(self, d):
On Dec 11, 4:42 pm, Nobody wrote:
> If just you're trying to avoid getting a repetitive strain injury in your
> right-hand little finger from typing all the [''], you could turn
> the keys into object attributes, e.g.:
>
> class DictObject:
> def __init__(self, d):
>
On Fri, 09 Dec 2011 01:55:28 -0800, Massi wrote:
> Thank you all for your replies, first of all my Sum function was an
> example simplifying what I have to do in my real funciton. In general
> the D dictionary is complex, with a lot of keys, so I was searching
> for a quick method to access all th
Massi wrote:
Thank you all for your replies, first of all my Sum function was an
example simplifying what I have to do in my real funciton. In general
the D dictionary is complex, with a lot of keys, so I was searching
for a quick method to access all the variables in it without doing the
explici
On Fri, Dec 9, 2011 at 10:59 PM, Steven D'Aprano
wrote:
> (4) If you think you can make exec safe with a prohibited list of
> dangerous strings, you probably can't.
If you think that it's even _possible_ to make exec safe with a
blacklist, I have a nice padded cell for you over here.
Security is
On Fri, 09 Dec 2011 11:59:16 +, Steven D'Aprano wrote:
> Just the second-most common source of viruses, malware and security
> vulnerabilities (behind buffer overflows): code injection attacks.
Oops, I forgot to go back and revise this sentence. Code injection
attacks are now the most common
On Fri, 09 Dec 2011 01:55:28 -0800, Massi wrote:
> for k in D : exec "%s = D[k]" %k
>
> That seems to do the trick, but someone speaks about "dirty code", can
> anyone point me out which problems this can generate? Again, thank you
> for your help!
Just the second-most common source of viruses,
Massi wrote:
> for k in D : exec "%s = D[k]" %k
>
> That seems to do the trick, but someone speaks about "dirty code", can
> anyone point me out which problems this can generate?
exec can run arbitrary code, so everybody reading the above has to go back
to the definition of D to verify that it
Thank you all for your replies, first of all my Sum function was an
example simplifying what I have to do in my real funciton. In general
the D dictionary is complex, with a lot of keys, so I was searching
for a quick method to access all the variables in it without doing the
explicit creation:
a,
Terry Reedy writes:
> On 12/7/2011 7:03 PM, Steven D'Aprano wrote:
> > On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
> >
> >> Is there a way to create three variables dynamically inside Sum
> >> in order to re write the function like this?
>
> I should have mentioned in my earlier response tha
On Thu, Dec 8, 2011 at 11:03 AM, Steven D'Aprano
wrote:
>> It is really important that the scope of a,b,c is limited to the Sum
>> function, they must not exisit outside it or inside any other nested
>> functions.
>
> The second part is impossible, because that is not how Python works.
> Nested fu
On Wed, 07 Dec 2011 19:27:43 -0500, Terry Reedy wrote:
> On 12/7/2011 7:03 PM, Steven D'Aprano wrote:
>> On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
>>
>>> Is there a way to create three variables dynamically inside Sum in
>>> order to re write the function like this?
>
> I should have menti
On 12/7/2011 7:03 PM, Steven D'Aprano wrote:
On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
Is there a way to create three variables dynamically inside Sum in order
to re write the function like this?
I should have mentioned in my earlier response that 'variable' is a bit
vague and mislead
On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
> Is there a way to create three variables dynamically inside Sum in order
> to re write the function like this?
>
> def Sum(D) :
> # Here some magic to create a,b,c from D
> return a+b+c
No magic is needed.
a, b, c = D['a'], D['b'], D['
On 12/7/2011 12:09 PM, Massi wrote:
in my script I have a dictionary whose items are couples in the form
(string, integer values), say
D = {'a':1, 'b':2, 'c':3}
This dictionary is passed to a function as a parameter, e.g. :
def Sum(D) :
return D['a']+D['b']+D['c']
Is there a way to crea
On 07/12/2011 17:45, John Gordon wrote:
In
Massi writes:
in my script I have a dictionary whose items are couples in the form
(string, integer values), say
D = {'a':1, 'b':2, 'c':3}
This dictionary is passed to a function as a parameter, e.g. :
def Sum(D) :
return D['a']+D['b']
On Thu, Dec 8, 2011 at 4:09 AM, Massi wrote:
> def Sum(D) :
># Here some magic to create a,b,c from D
>return a+b+c
Welcome to TMTOWTDI land! We do magic here... several different ways.
You _may_ be able to do this, which is roughly equivalent to the
extract() function in PHP:
locals().
On Wed, 7 Dec 2011 09:09:16 -0800 (PST), Massi wrote:
> def Sum(D) :
> return D['a']+D['b']+D['c']
>
> Is there a way to create three variables dynamically inside Sum in
> order to re write the function like this?
>
> def Sum(D) :
> # Here some magic to create a,b,c from D
> return a+
In Massi
writes:
> in my script I have a dictionary whose items are couples in the form
> (string, integer values), say
> D = {'a':1, 'b':2, 'c':3}
> This dictionary is passed to a function as a parameter, e.g. :
> def Sum(D) :
> return D['a']+D['b']+D['c']
> Is there a way to create th
Hi everyone,
in my script I have a dictionary whose items are couples in the form
(string, integer values), say
D = {'a':1, 'b':2, 'c':3}
This dictionary is passed to a function as a parameter, e.g. :
def Sum(D) :
return D['a']+D['b']+D['c']
Is there a way to create three variables dynamic
26 matches
Mail list logo