I have some projects I try to split up for easier management. Therefor I moved some parts that are used by different applications into modules rather than copying files around.  Right now I have the following structure for my modules (every module has its own docs and tests):  /projects   /module1     __init__.py     run_tests.py     /docs       ...     /module1       __init__.py       module1.py     /tests       __init__.py       module1_test.py   /module2     ...   Now I got myself the "main app" directory laid out in the same manner:  /projects   run_app.py   run_tests.py   /docs     ...   /app     __init__.py     app.py     module1 &lt;-- Link to the module1 repository   /tests     __init__.py     app_tests.py   All my __init__.py files are empty at the moment and I do not know how to write a proper import statements in my app.py file. Since there is only one class in module1 I don't want a hugh import module1.module1.module1.ModuleClass so the ModuleClass should be imported to "module level" so I can just do something like a import module1.ModuleClass. I figure I have to tweak the __init__.py files but all I tried broke either the tests or the whole import.  Any help would be very much appreciated and sorry for my poor explanations I am not a native speaker...
21007
How do I import a Python module given its relative path?  For example, if dirFoo contains Foo.py and dirBar, and dirBar contains Bar.py, how do I import Bar.py into Foo.py?  Here's a visual representation:  dirFoo\     Foo.py     dirBar\         Bar.py   Foo wishes to include Bar, but restructuring the folder hierarchy is not an option.
27590
states:  Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.  However if the class/method/function that I am importing is only used in rare cases, surely it is more efficient to do the import when it is needed? Isn't this: class SomeClass(object):      def not_often_called(self)         from datetime import datetime         self.datetime = datetime.now()  more efficient than this? from datetime import datetime  class SomeClass(object):      def not_often_called(self)         self.datetime = datetime.now()
14731
It is much more convenient and cleaner to use a single statement like  import java.awt.*;   than to import a bunch of individual classes  import java.awt.Panel; import java.awt.Graphics; import java.awt.Canvas; ...   What is wrong with using a wildcard in the import statement?
36851
Is it possible to run specific method before each test in an assembly?  I know about TestInitialize attribute but this attribute has "class scope". If it's defined in a Test class it will be executed before each test from this class.   I want to define a method that will be executed before each test defined in a whole assembly.
89657
I'm trying to unit test a custom ConfigurationSection I've written, and I'd like to load some arbitrary configuration XML into a  for each test (rather than put the test configuration xml in the Tests.dll.config file.  That is, I'd like to do something like this:  Configuration testConfig = new Configuration("&lt;?xml version=\"1.0\"?&gt;&lt;configuration&gt;...&lt;/configuration&gt;"); MyCustomConfigSection section = testConfig.GetSection("mycustomconfigsection"); Assert.That(section != null);   However, it looks like  will only give you Configuration instances that are associated with an EXE file or a machine config.  Is there a way to load arbitrary XML into a Configuration instance?
38527
I'm just trying to streamline one of my classes and have introduced some functionality in the same style as the .  However, I'm a bit confused as to why __init__ is always called after __new__. I wasn't expecting this. Can anyone tell me why this is happening and how I can implement this functionality otherwise? (Apart from putting the implementation into the __new__ which feels quite hacky.)  Here's an example:  class A(object):     _dict = dict()      def __new__(cls):         if 'key' in A._dict:             print "EXISTS"             return A._dict['key']         else:             print "NEW"             return super(A, cls).__new__(cls)      def __init__(self):         print "INIT"         A._dict['key'] = self         print ""  a1 = A() a2 = A() a3 = A()   Outputs:  NEW INIT  EXISTS INIT  EXISTS INIT   Why?
23941
I have been using Python more and more, and I keep seeing the variable __all__ set in different __init__.py files.  Can someone explain what this does?
24641
We put all of our unit tests in their own projects.  We find that we have to make certain classes public instead of internal just for the unit tests.  Is there anyway to avoid having to do this.  What are the memory implication by making classes public instead of sealed?
3767
I created a module through Drupal Console, unfortunately it wasn't placed in a folder of its own, rather straight into /modules/custom. Before I noticed where it had gone, I enabled the module.   In Drupal 6/7, this was easy to fix - I could literally just put the files into the correct path, clear the cache (maybe rebuild the registry, it wasn't an exact science), and all was well.  The same isn't true for Drupal 8; I moved the files into a subfolder, rebuilt cache, and all requests tell me that Drupal is failing to include a required file. The particular file is a block class, and the path Drupal is trying to find it is where it used to be, not where I've moved it to.  The bit of code objecting is in Symfony's ApcClassLoader, so I guess I need to clear something that's slightly above Drupal's head to get this path reference updated.  How can I do that?  Uninstalling and re-installing the module does work, but once there's important data stored that's not going to be an option.  I was wrong, uninstalling and re-installing is not a viable option. After uninstalling and reinstalling, Drupal can no longer pick up the custom blocks the module defines. I'm guessing that reference is cached somewhere that isn't cleared when the module is uninstalled. Just need to find out where that is and how to clear it...
30349
I'm working on a large c++ system that is has been in development for a few years now. As part of an effort to improve the quality of the existing code we engaged on a large long-term refactoring project.  Do you know a good tool that can help me write unit tests in C++? Maybe something similar to Junit or Nunit?  Can anyone give some good advice on the methodology of writing unit tests for modules that were written without unit testing in mind?
5757
When used like this:  import static com.showboy.Myclass;  public class Anotherclass{}   what's the difference between import static com.showboy.Myclass and import com.showboy.Myclass?
32948
I have a function that resembles the one below. I'm not sure how to use the os module to get back to my original working directory at the conclusion of the jar's execution.   def run():      owd = os.getcwd()     #first change dir to build_dir path     os.chdir(testDir)     #run jar from test directory     os.system(cmd)     #change dir back to original working directory (owd)   note: I think my code formatting is off - not sure why. My apologies in advance
97516
I have Apex Controller Class, say, LWCController and several methods inside of it, let's say Method1, Method2, Method3, Method4, Method5.   to      Use default import syntax to import an Apex method via the   @salesforce/apex scoped packages.        import { export1 , export2 } from "module-name";  import { foo , bar } from "module-name/path/to/specific/un-exported/file";  import { export1, export2 as alias2 , [...] } from "module-name";  import defaultExport, { export [ , [...] ] } from "module-name";      I am trying to import all of them simultaneously at the same line   import {Method1, Method2, Method3, Method4, Method5 } from '@salesforce/apex/LWCController';   And I receive the following errors   === Deploy Errors PROJECT PATH  ERRORS     N/A           [Line: 2, Col: 118] LWC1501: @salesforce/apex modules should have both class and method names. N/A           LWC1513: @salesforce/apex modules only support default imports.
38258
Most of my C/C++ development involves monolithic module files and absolutely no classes whatsoever, so usually when I need to make a DLL with accessible functions I just export them using the standard __declspec(dllexport) directive.  Then access them either dynamically via LoadLibrary() or at compile time with a header and lib file.   How do you do this when you want to export an entire class (and all it's public methods and properties)?  Is it possible to dynamically load that class at runtime and if so, how?  How would you do it with a header and lib for compile time linking?
79960
I am unit testing a .NET application (.exe) that uses an app.config file to load configuration properties.  The unit test application itself does not have an app.config file.    When I try to unit test a method that utilizes any of the configuration properties, they return null.  I'm assuming this is because the unit test application is not going to load in the target application's app.config.  Is there a way to override this or do I have to write a script to copy the contents of the target app.config to a local app.config?     post kind-of asks this question but the author is really looking at it from a different angle than I am.  EDIT: I should mention that I'm using VS08 Team System for my unit tests.
85490
I have more than 50 menus which I need to create custom. as per the module structure, we need to create routing.yml in root folder. but I want to do something like this below:     myModule       -  products(folder)               - routing.yml               - src(folder)                 - productController         -  brands(folder)               - routing.yml               - src(folder)                 - brandsController.php           - myModule.info.yml       - myModule.module   is it way to do achive something like this.  I just want to make code seperation and avoid to add all routes in routing.yml
19614
This questions has been asked before too and I did go through most of the suggestions. Things I have tried so far: setting up correct  path variable environment, installing anaconda 32 bits, python 2.7, or even switching to python 2.7 in cmd while initially using Anaconda 3 , adding Desktop 10.4.pth file with  following path.  C:\Program Files (x86)\ArcGIS\Desktop10.4\bin C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcToolBox\Scripts   I also added those paths in environment variable   These suggestions help me to reduce the error. But Now I am getting a different error. Looks like python can find arcpy but missing another package.  Getting this error while trying to import arcpy in python 3.6.   File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 22, in &lt;module&gt;     from arcpy.geoprocessing import gp    File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in &lt;module&gt;     from _base import *  ModuleNotFoundError: No module named '_base'   Any suggestions?