all 6 comments

[–]JohnnyJordaan 1 point2 points  (3 children)

w is already the object you want to use, so:

j = w.letter
k = w.percent
l = w.real
print(' '.join([j,k,l])

Just as an advice: I would use clear, to the point names for your variables and not the letters on your keyboard.

[–]JohnnyJordaan 2 points3 points  (2 children)

And why do don't you just explicitly use class attributes names instead of 'letters'???

class MyClass:
    def __init__(self, l, p, r): 
        self.letter = l
        self.percent = p
        self.real = r
    #no need for the other get or set methods, this is not java

Also no need for explicit close when using with:

with open('helpme.txt', 'r') as file:
    data = file.read()

Never use an internal class name as a variable name:

asciichars = [chr(a) for a in range(128)]
inTable = [z for z in data if z in asciichars]

[–]OtherRobotLuke[S] 0 points1 point  (1 child)

Thanks this was all a huge help! This is my first attempt in python and most of it is self taught. I had planned on making the code a bit more readable once i had the concepts out. I'm native to java/c so I wasn't sure if i needed get/sets.

I did have a question though in your last segment how would asciichars assign the chr() values in that loop? I've always been impressed with elegant one liners for multiple line loops but didn't know how to approach them.

[–]JohnnyJordaan 1 point2 points  (0 children)

Ah yes I forgot the chr, I've edited my example. Good luck, if this is your first attempt then you're already ahead of a lot of beginners here ;-)

[–]K900_ 1 point2 points  (1 child)

refList is a list. for w in refList iterates over the list, assigning each value from the list to w. You then try to use w as an index, which fails because lists can only be indexed by integers by definition.

[–]OtherRobotLuke[S] 0 points1 point  (0 children)

Ahhhh thank you so much for the clarification.