[Tutor] what am I not understanding?

Clayton Kirkwood crk at godblessthe.us
Mon Oct 20 23:18:49 CEST 2014


Thanks all for the insight. I'm not sure I fully understand all of the code
snippets, but in time...

This is finally what I came up with:

raw_table = ('''
a: Ask	y: Dividend Yield
b: Bid	d: Dividend per Share
b2: Ask (Realtime)	r1: Dividend Pay Date
b3: Bid (Realtime)	q: Ex-Dividend Date
p: Previous Close
o: Open
Date
''')


import re, string
dict={}
key_name = raw_table.replace('\t','\n')
for each_line in  key_name.splitlines():
    if ':' in each_line:				#this design had to
do with a few different lines
        for key, value in [each_line.split(':')]:	#see the last line
in the data. I still don't fully
            dict[key.strip()] = value.strip()	#understand the second for
and the square brackets.

#I presume that they force the source to look and feel like a tuple or list,
but not sure. I think they force two strings into a two items of a tuple???
Please let me know if I munged bad code together:<))

Clayton




More information about the Tutor mailing list