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
    veer66 (veer66@mstdn.in.th)'s status on Sunday, 30-Mar-2025 21:48:36 JST veer66 veer66

    From the statement below, can I infer that an if-block is a scope because it doesn't have a name, and therefore it is not directly accessible?

    > A scope is a textual region of a Python program where a namespace is directly accessible. “Directly accessible” here means that an unqualified reference to a name attempts to find the name in the namespace."

    https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces

    #python

    In conversation about 3 months ago from mstdn.in.th permalink

    Attachments

    1. Domain not in remote thumbnail source whitelist: docs.python.org
      9. Classes
      from ../about.html
      Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have ...
    • Embed this notice
      sedje (sedje@fosstodon.org)'s status on Sunday, 30-Mar-2025 21:48:35 JST sedje sedje
      in reply to

      @veer66 ?

      No. It has nothing to do with "naming" the if-block, but with resolving a variable name (the unqualified reference). The if-expression may or may not use variables, but that is irrelevant.

      An if-block does not create a separate scope.

      In conversation about 3 months ago permalink

      Attachments


      clacke@libranet.de is my main likes this.
    • Embed this notice
      veer66 (veer66@mstdn.in.th)'s status on Sunday, 30-Mar-2025 21:49:06 JST veer66 veer66
      in reply to
      • sedje

      @sedje

      > An if-block does not create a separate scope.

      Because a variable inside an if-block is directly accessible in the same namespace as it is outside the if-block?

      In conversation about 3 months ago permalink
      clacke@libranet.de is my main likes this.
    • Embed this notice
      sedje (sedje@fosstodon.org)'s status on Sunday, 30-Mar-2025 22:14:54 JST sedje sedje
      in reply to

      @veer66 Correct. Generally only a function or class will open a new scope/namespace.

      But also take care with exception handler (argument)s and list comprehension and generator expressions.

      In conversation about 3 months ago permalink
      clacke@libranet.de is my main likes this.

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.