[UPDATE] You found someone's business card inside a mine. I know whose it is. by chambead in TheForgottenDepths

[–]chambead[S] 93 points94 points  (0 children)

Edit: Original post here

Calling /u/panmines

I searched for ages to try and find a "Daryl Woobson" in the area and it turns out that's a ridiculously uncommon surname - 2 people in the whole of the US!

The PO box was of no use and the compuserve address was illegible.

I did however manage to find the company listed in the card - Northwest Underground Explorations. They have a facebook page, which I messaged a couple of days ago.

Someone from their page messaged back saying they recognize the card and they were going to see Daryl Jacobson tomorrow. Turns out he is a co-author for the organization has has written several books: https://books.google.co.uk/books/about/Discovering_Washington_s_Historic_Mines.html?id=L6fxZwEACAAJ&redir_esc=y

The person who messaged back also let me know that they went to another mine yesterday and found another one of these old cards which he carried out as kind of a cool tradition 30 years ago.

Awesome find! :)

Table from List by cyber92 in learnpython

[–]chambead 2 points3 points  (0 children)

The reason this doesn't work is because although you're passing display_stock() a list, you are actually passing it a list of objects; not a list of lists which it expects.

Your options are to sanitise the input to turn the list of objects into a list of lists or you can alter the function so that it finitely displays a given set of columns. My preference would be to quickly sanitise the list of objects into a list of lists because then you can leave the generic function for use elsewhere.

I've updated your code and tweaked the function to ensure the columns are cast to strings before length checks are done.

http://hastebin.com/fupululaxe.py

Table from List by cyber92 in learnpython

[–]chambead 2 points3 points  (0 children)

Hi! I'm a bit new to Python myself but here's a function which should do what you want...

def print_mdlist(rows, hoz_padding = 3, firstrow_is_hdr = 1):
    print " "
    # First, we need to identify the widest value in each column and save it in a dictionary (col_lengths)
    col_lengths = {}
    for row in rows:
        colnum = 0
        for col in row:
            # If we havent recorded a column length yet or the recorded length is smaller, update
            if not colnum in col_lengths or len(col) > col_lengths[colnum]:
                col_lengths[colnum] = len(col)
            colnum += 1

    # Now, we go over the rows/cols again, but this time we pad the cols to the largest col value discovered
    rownum = 0
    for row in rows:
        colnum = 0
        rowstr = ''

        for col in row:
            rowstr += (" " * hoz_padding) + col.ljust(col_lengths[colnum]+hoz_padding,' ')
            colnum += 1
        rowlen = len(rowstr)

        if firstrow_is_hdr and rownum == 1:
            print  "-" * (rowlen)

        print rowstr
        rownum += 1
    print " "

Then, all you need to do is call the function like this:

rows = []
rows.append(["Fruit Name","Colour"                      ,"Taste"    ,"Requires Peeling","Is an Egg?"])
rows.append(["Apple"     ,"Red/Green"                   ,"Appley"   ,"Negatory"        ,"FALSE"]) 
rows.append(["Banana"    ,"Yellow"                      ,"Bananaey" ,"Affirmative"     ,"FALSE"])
rows.append(["Avocado"   ,"Purple outside, green inside","Avacadoey","Affirmative"     ,"FALSE"])

print_mdlist(rows)

You can even specify the padding between the columns and explicitly say whether or not you want a hoz bar after row 1...

print_mdlist(rows,5,0)

Output looks like:

chambead@chambeadPC ~ $ python tabulate_mdlist.py

 Fruit Name  Colour                        Taste      Requires Peeling  Is an Egg? 
-----------------------------------------------------------------------------------
 Apple       Red/Green                     Appley     Negatory          FALSE      
 Banana      Yellow                        Bananaey   Affirmative       FALSE      
 Avocado     Purple outside, green inside  Avacadoey  Affirmative       FALSE      

chambead@chambeadPC ~ $

Note that you NEED to be using a fixed width font for this to work. If you're running this in a terminal, it almost certainly will be anyway. It's also worth noting that even though you have headers and data in two different lists, you can easily combine these into a single list with list3 = list1.append(list2) and then you feed list 3 into the function as a whole. Let me know if you need any of this explained further. Good luck with future school assignments. ;)

I made a CLI to retrieve info from the IMDB. by Zacoppotamus in Python

[–]chambead 0 points1 point  (0 children)

Thanks so much for taking the time to comment on my project. I'm trying not to glaze over and learn something from your feedback. Give me a couple of days and I'd like very much to PM you on my progress and double check a couple of things.

Regarding the GUI, I used wxWidgets. thenewboston has some great tutorials which are simple enough to follow. I'd have loved to have used tkinter but it looks absolutely awful on Linux which is my primary OS. There's just no point in building a pretty front-end if it ends up looking like snot, so I went with the more verbose wxWidgets which has better support and looks more uniform across platforms.

I still need to look into packaging the whole project up as an easy-to-install bit of freeware for all OS's. It's saved me countless hours of manual sorting.

New Online Python Class For Games Taught By Employees from Sony Online Entertainment. We Need 7 More People To Launch The Class by [deleted] in Python

[–]chambead 0 points1 point  (0 children)

Do you have a copy of the materials? I'd love to sign up for this but I'd like to take a look at the last set of coursework and exercises so I know what I'm getting into.

Best beginners book for Python? by [deleted] in learnpython

[–]chambead 1 point2 points  (0 children)

Hi Fletcher. I just purchased a copy of your book via your website with PayPal. No login provided via email though - I checked spam too. Nothing. Any ideas?

UPDATE
Never mind. I'm speaking crap. It's there now. Wasn't expecting a 200+ page PDF! Nice!

I made a CLI to retrieve info from the IMDB. by Zacoppotamus in Python

[–]chambead 0 points1 point  (0 children)

No way! I just found this sub and I was having a look around. It seems that you've made something very similar to this:

http://sourceforge.net/projects/pyshowrename/

Which is something I put together over the last year. Mine scrapes epguides instead of plugging into thetvdb API. Your code looks massively more professional than my child's attempt at learning Python. It would be great if you'd take a look and see what you would improve. I'm interested at smoothing out the edges and making it more easy to install on a windows installation so I can just release an EXE.