GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Greg Wilson (gvwilson@mastodon.social)'s status on Friday, 23-Aug-2024 22:34:08 JST Greg Wilson Greg Wilson

    This just in from the Ministry of Subtle Bugs:

    def f():
    print("false")
    return False

    result = all(func() for func in [f, f, f])
    print("just comprehension", result)

    only prints 'false' once before printing "just comprehension", but

    result = all(list(func() for func in [f, f, f]))
    print("with list", result)

    prints 'false' three times before printing "with list". I understand why, but damn, this one was hard to spot.

    In conversation Friday, 23-Aug-2024 22:34:08 JST from mastodon.social permalink
    • Embed this notice
      powersoffour (powersoffour@mastodon.social)'s status on Friday, 23-Aug-2024 22:34:06 JST powersoffour powersoffour
      in reply to
      • Warrick Ball

      @warrickball @gvwilson So I'm generally not in favor of being pedantic, but can I ask a clarifying question -- is it that it's short-circuiting, or that the objects are being defined/instantiated at different stages in the execution? I read this as being similar-in-spirit to the (common?) mistake of putting a mutable as a default argument in a function.

      In conversation Friday, 23-Aug-2024 22:34:06 JST permalink
    • Embed this notice
      Warrick Ball (warrickball@mas.to)'s status on Friday, 23-Aug-2024 22:34:07 JST Warrick Ball Warrick Ball
      in reply to

      @gvwilson

      Because Python is a short-circuiting language, right? I've seen Python coders get tripped up by languages that don't short circuit or, even more confusingly, where it depends on the compiler.

      When I'm inspecting code with people and notice a short circuit, I always try to point it out, even when it isn't relevant to why we're inspecting the code.

      In conversation Friday, 23-Aug-2024 22:34:07 JST permalink
    • Embed this notice
      powersoffour (powersoffour@mastodon.social)'s status on Friday, 23-Aug-2024 23:14:32 JST powersoffour powersoffour
      in reply to
      • Warrick Ball

      @warrickball

      In conversation Friday, 23-Aug-2024 23:14:32 JST permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/113/011/748/934/014/810/original/de64be8dd88902d9.png
    • Embed this notice
      Warrick Ball (warrickball@mas.to)'s status on Friday, 23-Aug-2024 23:14:33 JST Warrick Ball Warrick Ball
      in reply to
      • powersoffour

      @powersoffour @gvwilson

      Oh, I'm not actually sure. I'm hoping I'm about to learn something and would be interested to see a longer breakdown...

      In conversation Friday, 23-Aug-2024 23:14:33 JST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.