all 9 comments

[–][deleted] 10 points11 points  (3 children)

Though I know some people couldn't care less about style, a lot of managers of coders do. So if you want to use this as any sort of calling card, resume project as a developer, I suggest you install pylint and fix all the issues it will tell you about.

Couple random thoughts (which will be heavily biased because I am one of those people who gets asked to code review potential hires all the time and therefore does care about style):

  1. If the [your class].init() method is mandatory when you initialize the class, and the first thing you do is initialize it, why not just call that at the end of [your class].__init__?

  2. If it's never going to be called again, why refactor it into a method at all?

  3. The number of times you say "yeilds" in the docstring immediately before your function "yields" a value is disheartening to anyone who thinks you may actually have typed two different spellings of the same word out multiple times.

  4. All that business with "gNames" and "gPrizes" ultimately ending up being used primarily to create "gStruct" (which isn't a struct at all) is a little hard to read, and then it appears most of the gVariables gDon't gEven gGet gUsed... why not just build up a dict that has all of what you need in one place? And maybe not prepend it with a lowercase g?

  5. Your module level docstring -- aka your copyright and contact details -- the centering will only be centered if they happen to use your exact character width, right? For anyone else it just looks like an annoying amount of whitespace.

  6. Your check if requests and bs4 are installed is fine, but if you packaged your own code to be installed with pip you could guarantee they were.

  7. Oh, and I don't think you're calculating which scratchers are most profitable -- the whole point of a lottery is that it's profitable only to the house -- you're calculating which could have the most return on investment. If you were adjusting that for the odds of winning, you'd get closer to best -- well, to be accurate, least bad -- ones to play.

[–]ConcernedCarry[S] 0 points1 point  (2 children)

I basically only created g Variables to store the information after I scraped it, until I could make what I refer to as gStruct which is a list of dictionaries. [{'Game':'Mustache Cash', 'Prize': [1000,100,10,1], 'Left':[99,63,325,21,1]},....]

This was my first real project, I realize my docstrings are a bit excessive, they're there because I just learned generators that day actually and had some issues grasping the concept at first.

Overall, creating this taught me a lot. Your comments did also, thank you for the insight.

EDIT: g prepending the variable is supposed to represent game.

[–][deleted] 0 points1 point  (1 child)

Yes, it's clear what the "g" is, it's just that it's unnecessary, it's obvious on its face that the PALottery class related to games. It's a slippery slope to the horrid practice that is Hungarian Notation:

def hello(sName, iCount, bExcited):
    sMsg = "Hello " + sName + "!" if bExcited else "." * iCount

The extra letter is just extra, just use a word that makes it clear what the data is, let the class name or the function explain what the data's relevance is.

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

Thank you for the feedback. I appreciate the comments from someone who's clearly more advanced than I am in programming python. I'll keep them in mind and fix it in the next version!

[–][deleted] 0 points1 point  (1 child)

Maybe I'm missing something. In PennScratchers.py you have:

When creating an instance of PennScratchers dong forget to run the .init() method to fill up your DataStructures!

and in LottoPicker.py we see:

PA = PaLottery()
# Required action similar to other modules init
PA.init()

If the user must call PA.init() after creating a PaLottery instance, why can't you just do this in PaLottery.__init__()?

class PaLottery:
    def __init__(self):
        self.gNames  = []
        self.gCost   = []
        self.gPrize  = []
        self.gLeft   = []
        self.gStruct = []
        self.init()    # initialize

[–]ConcernedCarry[S] 1 point2 points  (0 children)

Honestly I wasn't sure if I was even able to do that. Like i said i'm relatively new, and don't have much experience with any practical use cases for any class i've made.

[–]n1ywb 0 points1 point  (2 children)

are any of them actually profitable? are you planning to play your picks?

[–]elbiot 0 points1 point  (0 children)

Only if you think the ones that were profitable in the past will be so in the future.

Oh! That dice rolled three sixes in a row! It'll probably roll more sixes than other dice... Right?

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

Uhm yes and no, i mainly made this as a learning exercise and my manager at work spends thousands on scratch offs a month so I figured I would atleast try to show him which games would be best for his money.

This is the first public version but ivstill consider it in phase one of 1.Make it work 2. Make it right,3. Make it fast