John Fouhy wrote:
> On 02/10/2007, GTXY20 <[EMAIL PROTECTED]> wrote:
>> Hello all,
>>
>> Let's say I have the following dictionary:
>>
>> {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}
>>
>> I also have another dictionary for new value association:
>>
>> {a:1, b:2, c:3}
>>
>> How should I approach if I wan
GTXY20 wrote:
>
> I have the transFn function as follows:
>
> def transFn(translatefile):
> transfile = open(translatefile, 'r')
> records = transfile.read()
> transfile.close()
> lines = records.split()
> transDict = {}
> for line in lines:
> key, value = line.spl
I have the transFn function as follows:
def transFn(translatefile):
transfile = open(translatefile, 'r')
records = transfile.read()
transfile.close()
lines = records.split()
transDict = {}
for line in lines:
key, value = line.split(',')
transDict[key] = valu
GTXY20 wrote:
> Here's an interesting question:
>
> Can I use the transFn function to remove items in the value list.
>
> Can this be done by simple assigning the current value a value of null
> in the translate file?
No, that will make the translated value be None (I guess that is what
you mea
Here's an interesting question:
Can I use the transFn function to remove items in the value list.
Can this be done by simple assigning the current value a value of null
in the translate file?
M.
On 10/2/07, GTXY20 <[EMAIL PROTECTED]> wrote:
> I adjusted so that I get the following so if I do
I adjusted so that I get the following so if I do not need to translate a
dictionary I do not call the function transFn:
def transFn(translatefile):
transfile = open(translatefile, 'r')
records = transfile.read()
transfile.close()
lines = records.split()
transDict = {}
for
GTXY20 wrote:
>
> This seemed to work:
>
> def transFn(c):
> transfile = open('translate.txt', 'r')
> records = transfile.read()
> transfile.close()
> lines = records.split()
> transDict = {}
> for line in lines:
> key, value = line.split(',')
> transDict[k
John Fouhy wrote:
> You could use the map function...
>
> Let's say we have something like:
>
> transDict = { 'a':1, 'b':2, 'c':3 }
>
> We could define a function that mirrors this:
>
> def transFn(c):
> try:
> return transDict[c]
> except KeyError:
> return c
This coul
This seemed to work:
def transFn(c):
transfile = open('translate.txt', 'r')
records = transfile.read()
transfile.close()
lines = records.split()
transDict = {}
for line in lines:
key, value = line.split(',')
transDict[key] = value
try:
return tran
Sorry - solved my own problem - it was the way I was creating my dictionary
and assigning the value as a list.
I will post my final working code shortly.
M.
On 10/2/07, GTXY20 <[EMAIL PROTECTED]> wrote:
>
> I seem to be encountering a problem and I think it is because I actually
> have my data a
I seem to be encountering a problem and I think it is because I actually
have my data as follows:
data = {1:[a,b,c], 2:[a,c], 3:[b,c], 4:[a,d]}
not as previously mentioned:
data = {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}
So the values are actually stored as a list.
I am trying to adjust so that
On 02/10/2007, GTXY20 <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> Let's say I have the following dictionary:
>
> {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}
>
> I also have another dictionary for new value association:
>
> {a:1, b:2, c:3}
>
> How should I approach if I want to modify the first dictionar
Hello all,
Let's say I have the following dictionary:
{1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}
I also have another dictionary for new value association:
{a:1, b:2, c:3}
How should I approach if I want to modify the first dictionary to read:
{1:(1,2,3), 2:(1,3), 3:(2,3), 4:(1,d)}
There is the p
13 matches
Mail list logo