Cannot use os functions after having imported it
Question: I'm using Python (actually IronPython) with Visual Studio 2015 to make a WPF
application. I imported os but I cannot access its methods.

This is what I did:

    
    
    import os
    
    class Utils(object):
    
        def fcn(self, arg):
    
            if os.path.exists(arg):
                print 'Exists!.'        
            else:
                print 'Doesn't exist... :/'
                raise
    

I call this class from the view model file after pressing a button in the GUI

    
    
    class ViewModel(ViewModelBase):
    
        def __init__(self):
            ViewModelBase.__init__(self)
            self.RunCommand = Command(self.RunMethod)
            self.utils = Utils()
    
        def RunMethod(self):
            self.utils.fcn("C:\path")
    

If I set a breakpoint after "if os.path.exists(arg)" the program freezes, if I
set it before (or on that line) it stops normally.

Any ideas?

Thank you.


Answer: Submodules need to be imported explicitly:

    
    
    import os.path # not just import os
    

In the standard Python implementation, `import os` would probably work on its
own due to the weird way `os.path` is implemented, but it should still be
`import os.path` if you want to use `os.path`.

