首页 \ 问答 \ 导入的module.submodule命名空间干扰彼此(imported module.submodule namespaces interfering with eachother)

导入的module.submodule命名空间干扰彼此(imported module.submodule namespaces interfering with eachother)

因此,我非常擅长制作自定义作业/流程自定义管理器模块,当我进行集成时,我遇到了一个我以前从未见过的模块和命名空间的交互。

代码说得比文字更好:

所以有两个略有不同的脚本:

测试1:

import jobManager

jobManager.jobMap = {'test1':'test123'}

AND test2:

import jobManager

jobManager.jobMap = {'test2':'test222'}

顶级脚本:

import test1
import test2

print(test1.jobManager.jobMap)
print(test2.jobManager.jobMap)

因此,当我运行顶级脚本时,它会打印:

{'test2':'test222'}
{'test2':'test222'}

但我的预期输出是:

{'test1':'test123'}
{'test2':'test222'}

这只是test1.jobManager和test2.jobManager实际上是同一名称空间的情况吗? 有没有办法让它们分开?


So I'm pretty deep into making a custom job/process custom manager module, and when i got to integrating it I came across an interaction I hadn't seen before with modules and namespaces.

Code speaks better than words:

So there are two slightly different scripts:

test1:

import jobManager

jobManager.jobMap = {'test1':'test123'}

AND test2:

import jobManager

jobManager.jobMap = {'test2':'test222'}

Top Level Script:

import test1
import test2

print(test1.jobManager.jobMap)
print(test2.jobManager.jobMap)

So when I run the top level script it prints:

{'test2':'test222'}
{'test2':'test222'}

But my expected output is:

{'test1':'test123'}
{'test2':'test222'}

Is this just a case where test1.jobManager and test2.jobManager are actually the same namespace? Is there a way to keep them separate?


原文:https://stackoverflow.com/questions/36783693
更新时间:2019-12-07 11:45

最满意答案

这只是test1.jobManager和test2.jobManager实际上是同一名称空间的情况吗?

是。

有没有办法让它们分开?

不是没有创建另一个模块。


Is this just a case where test1.jobManager and test2.jobManager are actually the same namespace?

Yes.

Is there a way to keep them separate?

Not without creating another module.

2016-04-22

相关问答

更多

Reactjs呈现脚本(Reactjs render script)

虽然我不建议渲染脚本,但应该可以工作: var script = document.createElement("script"); script.src = './scripts/jquery/send_keyword.js'; document.body.appendChild(script); Nevermind I used the script through the index.php and not render it from reactjs

模拟一直在调用真正的功能(Mock keeps calling real function)

所以,在github上搜索并查看一些代码,我发现即使函数属于use_cases模块,我也需要从view进行模拟。 所以我现在的代码是: tests.py from unittest.mock import patch, Mock @patch('core.views.add_owner_to_place') @patch('core.forms.PlaceForm.is_valid') @patch('core.forms.PlaceForm.save') def test_save_shou

VBA:使用VLookUps从值列表创建新工作簿(VBA: Creating new workbooks from list of values with VLookUps)

Sub create() Const FPATH As String = "C:\_Stuff\" Dim wb As Workbook, sh1 As Worksheet, lr As Long, rng As Range Dim c As Range Set sh1 = ThisWorkbook.Sheets("GIW") lr = sh1.Cells(Rows.Count, "A").End(xlUp).Row Set rng = sh

如何打破另一页中的对象框架?(How to break trough an object frame in another page?)

你需要一个更大的高度值:185 <object data="includedpage.html" width="100%" height="185"></object> margin-top + text(font-size)+默认用户代理主体边距(顶部+底部)= 150 + 18.5 + 16px(在Chrome上)〜= 185px 或者你可以使用百分数 <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"

华森的会话意图和实体是否支持正则表达式?(Does watson conversation intents and entities support regular expressions?)

您不能在意图或实体中使用正则表达式,但我认为您仍然能够应对变化。 当匹配意图时,目前还没有建立在拼写错误或口音规范化的内置处理,但是如果句子中有足够的功能匹配,偶尔的错字不应引起问题。 对于非常短的示例,添加其他常见错误示例可能会有一些价值。 对于实体,您可以包含同义词,并且我曾经用它来包含常见的错误。 您不应该试图直接在您的意图中包含对实体的引用。 例如,除了Qual a @(producao)您应该只有Qual a produção ,以及其他相同意图的示例,或许具有不同的实体或同一个实体的

svn COPY导致400 Bad Request(svn COPY results in 400 Bad Request)

我不确定第一个问题。 但是在更改配置之后,第二个问题是由具有DAV svn指令的LocationMatch引起的,因为这导致每个路径都被计算为存储库的根。 这个配置应该工作: <Location /> DAV svn SVNParentPath /var/local/svn SVNListParentPath on Order deny,allow Allow from all

CakePHP - 无法直接访问UsersController :: admin_login()(CakePHP - UsersController::admin_login() cannot be accessed directly)

您用于管理员前缀操作的url数组不正确。 例如。 而不是array('controller' => 'users', 'action' => 'admin_login')你需要使用array('controller' => 'users', 'action' => 'login', 'admin' => true) 。 The url arrays you have used for admin prefixed actions are incorrect. For eg. instead of

相关文章

更多

最新问答

更多
  • asp.net任意用户信息(asp.net arbitrary user info)
  • 如何使用python计算docx文件中表中行的值(How to count the row's values in tables in docx file by using python)
  • MySQL:用户访问和数据库覆盖(MySQL: User access and DB overwriting)
  • 还有另一种“使用未分配的局部变量”的问题(Yet Another “Use of unassigned local variable 'whatever' ” question)
  • 开源证书颁发机构软件(Open source certificate authority software)
  • Rails中的迭代form_for是在create上添加模型的所有实例(Iteration in Rails form_for is adding all instances of model on create)
  • 如何扩展我的表视图单元格?(How to expand my table view cell?)
  • 如何使用SPARQL区分Thing和无生命对象(How to differentiate between a Thing and an inanimate object with SPARQL)
  • 在IdentityServer中,Client Secrets和Scope Secrets有什么区别?(In IdentityServer, what is the difference between Client Secrets and Scope Secrets?)
  • 如何在具有附加类时重写类(How do I override a class when it has a attached class)
  • 如何使用Git在Azure上部署C#,MVC4应用程序(How to deploy a C#, MVC4 application on Azure using Git)
  • Sitecore 7内容搜索爬网程序根目录之外的索引项(Sitecore 7 Content Search indexing items outside of crawler root)
  • 我应该在线课程使用utf-8编码吗?(Should I use utf-8 encoding for an online course?)
  • 如何在Cucumber-JS步骤定义中使用Node-mysql连接到MySQL?(How to connect to MySQL using Node-mysql in a Cucumber-JS step definition?)
  • 在MVC 4中的google.maps.LatLng(lat,lon)中将JSON字符串值分配给纬度和经度(Assign the JSON string value to Latitude and Longitude in google.maps.LatLng(lat,lon) in MVC 4)
  • awk:通过特定的分隔符删除字符串(awk: remove strings by specific delimiter)
  • 如何测试Vista的应用程序(How to test app for Vista)
  • Elasticsearch聚合器 - 缺失值的工作原理(Elasticsearch aggregators - How missing values work)
  • 绘制datetime.date熊猫(Plot datetime.date pandas)
  • PostgreSQL作为WSO2 EI和APIM + IS的数据源(PostgreSQL as datasource for WSO2 EI and APIM+IS)
  • 如何使用bash在postgres中运行alter table脚本(How to run alter table script in postgres using bash)
  • 可能使用PHP阻止整个美国州访问我的网站?(Might it be possible to block an entire US state from accessing my site, using PHP?)
  • restangular删除并输入错误网:: ERR_NAME_NOT_RESOLVED(restangular remove and put error net::ERR_NAME_NOT_RESOLVED)
  • 常见问题解答的Modx(Revolution)搜索功能(Modx(Revolution) search function for FAQs)
  • Rubymine如何使用远程口译员和Git?(How Does Rubymine Work With Remote Interpreters and Git?)
  • prepareForSegue和PerformSegueWithIdentifier发件人(prepareForSegue and PerformSegueWithIdentifier sender)
  • postgrsql与PowerShell无提示安装问题(postgresql silent installation issue with powershell)
  • 比较两个greps的输出(Comparing output from two greps)
  • 使用.NET RIA Data Services删除Silverlight 3中的数据(Deleting data in Silverlight 3 with .NET RIA Data Services)
  • 此行中AND运算符的含义(meaning of the AND operator in this line)