Просто хочу убедиться, что я правильно делаю комментарии к документации - PullRequest
0 голосов
/ 27 мая 2019

Я просто хочу быть уверен, что я правильно комментирую свою документацию. Я работаю через LPTHW (в 50-й раз, лол, просто продолжаю сбиваться с пути и перезагружаюсь), и я работаю через ex35. Из моего понимания # комментарии предназначены для объяснения того, как работает код, в то время как комментарии к документации, кажется, больше о том, какова цель кода. При этом, если бы кто-то мог взглянуть на мой код и дать мне знать, если я на правильном пути, а также предложить какие-либо указатели, я был бы очень признателен. Спасибо всем!

Вот пример того, как я написал свою документацию для gold_room ():

    # creates a function called 'gold_room' which takes no parameters
    def gold_room(): 
    """gold_room() asks the player to input how much 
    gold they would like to take from the gold room. It checks the 
    players input to enure that its a number. If it's not, the player 
    will get a 'dead' msg and the game will use the 'dead' function to 
    end and exit the game. If it is a number, it will check if that 
    number is above or below 50. If above,the player will get a 
    'dead' msg and end and exit the game. If it is below
    50, the player will get a win msg then end and exit the game
    """

    print "This room is full of gold. How much do you take?"

    next = raw_input('>')

    if "0" in next or "1" in next: 
        how_much = int(next)

    else:
        dead("Man, learn to type a number.")

    if how_much < 50:
        print "Nice, you're not greedy, you win!"
        exit(0)
    else:
        dead("You greedy bastard!")
...