variable name and type confusion...
Dennis Lee Bieber
wlfraed at ix.netcom.com
Tue Nov 26 01:23:50 EST 2002
eugene kim fed this fish to the penguins on Monday 25 November 2002
10:37 pm:
> after table_name = Graph(table),
> graphs.append(table_name) appends string type not Graph type
>
> if i do exec "table_name = Graph(table)"
> graphs.append(table_name) appends Graph type..
>
> is this expected behavior?
> i'm using python 2.2.1
>
> table_list = ['abc', 'def']
> tables['abc'] = Table(a)
> tables['def'] = Table(b)
>
> graphs = []
> def tests(Graph):
> for table_name in table_list:
> table = tables[table_name]
> table_name = Graph(table) <--------------here
> graphs.append(table_name)
Where is the rest of the program? IOW, how are you calling function
"tests"... What is being passed into the function to be argument Graph.
Also, you need to define graphs as global to get your results out of
the routine.
Heck, why are you tring to assign to the loop variable? You're using
"table_name" in two different ways; it is possible that the next loop
cycle is changing what you thought you appended.
--
> ============================================================== <
> wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wulfraed at dm.net | Bestiaria Support Staff <
> ============================================================== <
> Bestiaria Home Page: http://www.beastie.dm.net/ <
> Home Page: http://www.dm.net/~wulfraed/ <
More information about the Python-list
mailing list