4 votes

Internal Server Error?

Tags: help
Topic removed by site admin

9 comments

  1. [9]
    Deimos
    Link
    Sorry, should be fixed now.

    Sorry, should be fixed now.

    5 votes
    1. [8]
      Neverland
      Link Parent
      Maybe unnecessarily, I created an issue for it.. I was just curious what could break the site for only those two posts.

      Maybe unnecessarily, I created an issue for it.. I was just curious what could break the site for only those two posts.

      3 votes
      1. [7]
        Deimos
        Link Parent
        It was just any topic with zero comments.

        It was just any topic with zero comments.

        4 votes
        1. [6]
          Neverland
          Link Parent
          Cool, thanks. I see the commit now.

          Cool, thanks. I see the commit now.

          1 vote
          1. [5]
            teaearlgraycold
            Link Parent
            @Deimos, if self.tree can be None, shouldn't it be defined as Optional[List[Comment]]?

            @Deimos, if self.tree can be None, shouldn't it be defined as Optional[List[Comment]]?

            1. [4]
              Deimos
              Link Parent
              It's never None. if self.tree won't be satisfied by an empty list.

              It's never None. if self.tree won't be satisfied by an empty list.

              1. [3]
                teaearlgraycold
                Link Parent
                Wow, all these years and I never knew an empty list was false-y. I guess I've always done if len(foo) > 0:. Personally I don't think I'd use those types of checks since it's ambiguous what's being...

                Wow, all these years and I never knew an empty list was false-y. I guess I've always done if len(foo) > 0:. Personally I don't think I'd use those types of checks since it's ambiguous what's being tested.

                I also use if x is None: rather than just if x for an Optional.

                1. [2]
                  Deimos
                  (edited )
                  Link Parent
                  Writing checks like that generally isn't considered "Pythonic", and PEP8 specifically says to use if foo: over things like if len(foo) > 0:. Pylint will throw an error complaining about it if you...

                  Writing checks like that generally isn't considered "Pythonic", and PEP8 specifically says to use if foo: over things like if len(foo) > 0:. Pylint will throw an error complaining about it if you do it:

                  pylint: len-as-condition / Do not use `len(SEQUENCE)` to determine if a sequence is empty (col 11)
                  
                  1. teaearlgraycold
                    (edited )
                    Link Parent
                    Good to know. I don't I'll change my ways, though. It just seems like a bad design choice to have an operation perform so many different things. Imagine if someone wrote a function like that. def...

                    Good to know. I don't I'll change my ways, though. It just seems like a bad design choice to have an operation perform so many different things. Imagine if someone wrote a function like that.

                    def is_truthy(x):
                        if x is None:
                            return False
                    
                        if isinstance(x, bool):
                            return x
                    
                        if isinstance(x, list):
                            return len(x) > 0
                    
                        # Many other checks
                        # ...
                    
                        return True
                        
                    

                    The function makes it harder to read code. I think the best thing Python does as a programming language is make code read like plain English. But we need precision when reading code to understand what's going to happen once the bits hit the interpreter (and not just once the code is written, but also a year down the road).

                    To be fair part of my perception of this being less readable is due to my ignorance of the length check until now. But it still feels icky and I've usually avoided "truthiness" in every language that uses it.