Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jason K. Moore
    @moorepants
    I'm online now so I'll answer you :)
    here is fine
    ljkuhns
    @ljkuhns
    So if I would have used the parentheses it should have work like I had it?
    Jason K. Moore
    @moorepants
    I'm working on some code for another project right now so you can hit me for questions for a bit.
    if you did: playchoice == ('no' or 'No') would it have worked?
    what does 'no' or 'No' return?
    ljkuhns
    @ljkuhns
    I'm going to guess yes it would.
    Jason K. Moore
    @moorepants
    Don't guess, type it into the python interpreter and see what it does :)
    ljkuhns
    @ljkuhns
    working on that now...
    It only understands the first one.
    Jason K. Moore
    @moorepants
    The first what?
    >>> 'no' or 'No'
    'no'
    >>> 'yes' == ('no' or 'No')
    False
    ljkuhns
    @ljkuhns
    It doesn't interpret "No" but will correctly read "no". If I switch the code to playchoice == ('No' or 'no') it will behave with "No" but not "no".
    I think I'm misunderstanding what "or" does
    Jason K. Moore
    @moorepants
    So the 'no' or 'No' simply returns the first true item. It is call a "short circuit" or
    ```python
    >>> if 'no':
    ...     print('it evaluated as true')
    What does that do?
    and this:
    ```python
    >>> False or 'no'
    It is an odd thing I suppose, but Python treats strings as evaluating to true.
    So in the last statement 'no' will be returned because it was the first "true" thing in the or statement
    ljkuhns
    @ljkuhns
    aah I think that's making a bit more sense
    Jason K. Moore
    @moorepants
    this is why
    >>> bool('no')
    True
    That returns True
    So non-empty strings will evaluate to True in logical expressions. Whereas empty strings will evaluate to False
    ```python
    >>> bool('')
    False
    This is just something you'd have to know about the language, it is different in other languages. Not all do that.
    ljkuhns
    @ljkuhns
    Well I'll play around with it.
    I actually have other work to do now. But my mind can rest now that this is working. Thanks your help. I'll test it some more and submit a push request soon.
    Jason K. Moore
    @moorepants
    Cool
    Hooded Ice
    @hoodedice
    Hi, I missed the meeting last Friday because I had to get home early
    I am a bit rusty on my python, but I am currently speed-reviewing it on codeacademy, and will probably be able to code again by Wednesday (Also, will be free enough)
    Hooded Ice
    @hoodedice
    Can I contribute code if someone hasn't fully done their code
    Jason K. Moore
    @moorepants
    Sure
    Try to pick a function that someone hasn't claimed
    Frist
    First
    Then feel free to work on others.
    If people don't speak up in the issues about who's doing what, we can expect that they aren't going to contribute.
    Just contribute one function at a time though.
    Hooded Ice
    @hoodedice
    ok, then I guess I'll be doing is_board_full()
    then maybe move to something else
    Jason K. Moore
    @moorepants
    Yeh, pick one function, implement it, then pick another.
    Nick DiCesare
    @nickdicesare

    Just realized raw_input() returns a string, so is_space_free() won't work in its current form unless the player's input is converted to an int first. I think it would make more sense to do the conversion and check validity within get_player_move() rather than is_space_free(), since get_player_move() is the only one of the group that has to directly deal with player input.

    How's this look? int() will raise a ValueError exception for any string that isn't strictly numeric AFAIK (no decimal points allowed), except when + or - is used as a prefix, which doesn't seem like a big deal.

    while True:
        try:
            space = int(raw_input("Choose a space...\n"))
        except ValueError:
            print 'Please enter an integer between 1 and 9, inclusive.\n'
        else: 
            if space < 1 or space > 9:
                print 'Please enter an integer between 1 and 9, inclusive.\n'
            elif is_space_free(board, space - 1): # is_space_free counts from 0
                break
            else:
                print 'That space is occupied.\n'
    Jason K. Moore
    @moorepants
    @nickdicesare This looks reasonable. I agree that the conversion should happen at the player's raw_input.