how to distinguish invoke method or instance an object?

Apr 12, 2011 at 9:48 AM
Edited Apr 12, 2011 at 9:51 AM

when i use ironpython a few days,i find a funny problem,let us look at following codes:

import MyAssembly

from MyAssembly.MyFunction import *  #there is a method named "ABC" without params in the class "MyAssembly.MyFunction"

from MyAssembly import * #there is a class named "ABC" in the namespace "MyAssembly"

a = ABC();  # the grammer here really confused me...

 i don't know how IronPython will process ABC  ? to invoke a method or instance an object??

 to discuss more, how ironpython to solve the problem about the duplication name of the objects

Apr 12, 2011 at 12:25 PM

The way to think about this is to ask yourself "How would Python behave if these were Python modules instead of .NET namespaces?" You can always use the fully-qualified name "MyAssembly.MyFunction.ABC" to get at the ABC method after it's been replaced in the current scope by the ABC class.

Some people believe that "from module import *" is not a good practice when developing robust code because unrelated changes in MyAssembly may suddenly create this collision where it didn't exist before, and end up change the meaning of the code in this module.