namespaces

python property class namespace confusion

python property class namespace confusion Question: I am confused about use of property class with regard to references to the fset/fget/fdel functions and in which namespaces they live. The behavior is different depending on whether I use property as a decorator or a helper function. Why do duplicate vars in class and instance namespaces impact …

Total answers: 2

Why async function binds name incorrectly from the outer scope?

Why async function binds name incorrectly from the outer scope? Question: Here is an async function generator by iterating a for loop. I expected this closure to respect the names from the outer scope. import asyncio coroutines = [] for param in (1, 3, 5, 7, 9): async def coro(): print(param ** 2) # await …

Total answers: 2

Python package with optional namespace sub-packages

Python package with optional namespace sub-packages Question: Problem I am struggling to create a single entry point for installing a python package that leverages namespace sub-package to allow users to optionally download additional modules. Below is the piece I am struggling with in this example. I have also provided additional context below as well to …

Total answers: 1

Concept of namespace, global, local with respect to import

Concept of namespace, global, local with respect to import Question: I understand that below are the scoping levels in python (listed in highest to lowest order) Local(L): Defined inside function/class Enclosed(E): Defined inside enclosing functions(Nested function concept) Global(G): Defined at the uppermost level Built-in(B): Reserved names in Python builtin modules I understand this concept when …

Total answers: 2

How to tell if Python module is a namespace module

How to tell if Python module is a namespace module Question: In Python 3, modules can be namespace modules without an __init__.py (as per PEP 420) or as a regular module (i.e. ‘[modules] packages as they are implemented in Python 3.2 and earlier’ – PEP 420) that have an __init__.py or are a single .py …

Total answers: 2

What does "Symbol not found / Expected in: flat namespace" actually mean?

What does "Symbol not found / Expected in: flat namespace" actually mean? Question: When I import a module I built, I get this boost-python related error: Traceback (most recent call last): File “<string>”, line 1, in <module> ImportError: dlopen(./myMod.so, 2): Symbol not found: __ZN5boost6python7objects15function_objectERKNS1_11py_functionERKSt4pairIPKNS0_6detail7keywordES9_E Referenced from: ./myMod.so Expected in: flat namespace in ./myMod.so What does …

Total answers: 9

Checking if variable exists in Namespace

Checking if variable exists in Namespace Question: I’m trying to use the output of my argparse (simple argparse with just 4 positional arguments that each kick of a function depending on the variable that is set to True) Namespace(battery=False, cache=True, health=False, hotspare=False) At the moment I’m trying to figure out how to best ask python …

Total answers: 4

Grouping constants in python

Grouping constants in python Question: This is mainly a “good python style” question. I have a module which is using a number of constants that feels should be grouped. Lets say we have Dogs and cat and each of them have number of legs and favorite food. Note that we want to model nothing but …

Total answers: 5