From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E54D6C2D0E2 for ; Thu, 24 Sep 2020 16:22:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7395238E4 for ; Thu, 24 Sep 2020 16:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726924AbgIXQW3 (ORCPT ); Thu, 24 Sep 2020 12:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbgIXQW3 (ORCPT ); Thu, 24 Sep 2020 12:22:29 -0400 Received: from ms.lwn.net (ms.lwn.net [IPv6:2600:3c01:e000:3a1::42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 118DDC0613CE; Thu, 24 Sep 2020 09:22:29 -0700 (PDT) Received: from lwn.net (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.lwn.net (Postfix) with ESMTPSA id D281F2CB; Thu, 24 Sep 2020 16:22:27 +0000 (UTC) Date: Thu, 24 Sep 2020 10:22:25 -0600 From: Jonathan Corbet To: Mauro Carvalho Chehab Cc: Linux Doc Mailing List , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] docs: cdomain.py: add support for two new Sphinx 3.1+ tags Message-ID: <20200924102225.46fbfafd@lwn.net> In-Reply-To: <20200924181354.59087a8d@coco.lan> References: <4b8a20013ca0b631724e8a986544ada08ac3dfd7.1600945712.git.mchehab+huawei@kernel.org> <20200924094335.65944316@lwn.net> <20200924181354.59087a8d@coco.lan> Organization: LWN.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Thu, 24 Sep 2020 18:13:54 +0200 Mauro Carvalho Chehab wrote: > > How can this possibly work without a "global namespace" declaration in > > markup_namespace()? > > ... While I'm not a python expert, the namespace variable is global > because it was defined outside the "markup_namespace" function. Assignments within functions are *always* local unless declared global. Try this: $ python3 >>> x = 0 >>> def y(v): >>> x = v >>> >>> y(1) >>> x 0 >>> So your assignment to "namespace" in markup_namespace() cannot change the global, since it's not declared global. jon