On Mon, 01 Mar 2010 18:07:17 -, Raphael Mayoraz
wrote:
Thanks for your answer.
However, your solution changes the key name in the dictionary.
That's not what I want I need to do. What I want is to define a new
variable which name is define as a string: 'myPrefx' + key. In the
example
I
On 3/1/2010 1:07 PM, Raphael Mayoraz wrote:
John Posner wrote:
On 2/26/2010 6:32 PM, Raphael Mayoraz wrote:
Hello,
I'd like to define variables with some specific name that has a common
prefix.
Something like this:
varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
for key, value in varDic.iter
John Posner wrote:
On 2/26/2010 6:32 PM, Raphael Mayoraz wrote:
Hello,
I'd like to define variables with some specific name that has a common
prefix.
Something like this:
varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
for key, value in varDic.iteritems():
'myPrefix' + key = value
No trick
On 27 Feb 2010 03:33:57 GMT Steven D'Aprano
wrote:
> exec "'myPrefix_turquoise' = 42"
>
Not quite:
In [1]: exec "'myPrefix_turquoise' = 42"
File "", line 1
SyntaxError: can't assign to literal (, line 1)
I think you meant:
exec
Steven D'Aprano wrote:
for key, value in varDic.iteritems():
varDic['myPrefix_' + key] = value
del varDic[key]
Watch out if any of the existing values already startswith 'myPrefix'
You can end up with trouble just as confusing as if 'myPrefix' is an
empty string
DaveA
--
http:/
On Fri, 26 Feb 2010 15:32:27 -0800, Raphael Mayoraz wrote:
> Hello,
>
> I'd like to define variables with some specific name that has a common
> prefix.
> Something like this:
>
> varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
> for key, value in varDic.iteritems():
> 'myPrefix' + key = va
On 2/26/2010 10:20 PM, Steven D'Aprano wrote:
On Fri, 26 Feb 2010 20:15:16 -0500, John Posner wrote:
On 2/26/2010 6:32 PM, Raphael Mayoraz wrote:
Hello,
I'd like to define variables with some specific name that has a common
prefix.
Something like this:
varDic = {'red': 'a', 'green': 'b', 'bl
On Fri, 26 Feb 2010 20:15:16 -0500, John Posner wrote:
> On 2/26/2010 6:32 PM, Raphael Mayoraz wrote:
>> Hello,
>>
>> I'd like to define variables with some specific name that has a common
>> prefix.
>> Something like this:
>>
>> varDic = {'red': 'a', 'green': 'b', 'blue': 'c'} for key, value in
>
On 2/26/2010 6:32 PM, Raphael Mayoraz wrote:
Hello,
I'd like to define variables with some specific name that has a common
prefix.
Something like this:
varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
for key, value in varDic.iteritems():
'myPrefix' + key = value
No trick, just swap a new ke
On Fri, Feb 26, 2010 at 6:22 PM, Alf P. Steinbach wrote:
> * Raphael Mayoraz:
>
>> Hello,
>>
>>
>> I'd like to define variables with some specific name that has a common
>> prefix.
>> Something like this:
>>
>> varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
>> for key, value in varDic.iteritems
* Raphael Mayoraz:
Hello,
I'd like to define variables with some specific name that has a common
prefix.
Something like this:
varDic = {'red': 'a', 'green': 'b', 'blue': 'c'}
for key, value in varDic.iteritems():
'myPrefix' + key = value
I know this is illegal, but there must be a trick s
On Fri, 26 Feb 2010 23:32:27 -, Raphael Mayoraz
wrote:
I'd like to define variables with some specific name that has a common
prefix.
Why?
No seriously, how do you think this is going to solve whatever problem you
clearly think it will solve?
--
Rhodri James *-* Wildebeeste Herder
12 matches
Mail list logo