The os module i am importing is coming from cpython modules that I have put in my path. That is the setup that I was talking about.
IronPython 0.9.3 on .NET 2.0.50215.44
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import os
>>> os.__file__
'C:\\IPython\\bin\\Lib\\os.py'
>>>
Hmm, I tend to disagree with you on the fact that in standard python os is not a built in module. Even though nt is built in, the os modules also built in. But what is confusing is that Anthony posted that he was able to import the os module like so…
Anthony's post….
Double check your setup, since here is what I get importing os:
IronPython 0.9.3 on .NET 2.0.50215.44
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import os
>>> dir(os)
['AttributeError', 'Equals', 'False', 'GetHashCode', 'GetType', 'ImportError', '
MakeNew', 'NameError', 'None', 'ToString', 'True', '_', '__all__', '__builtins__
', '__dict__', '__doc__', '__file__', '__name__', '_copy_reg', '_execvpe', '_exi
sts', '_exit', '_get_exports_list', '_make_stat_result', '_make_statvfs_result',
'_pickle_stat_result', '_pickle_statvfs_result', 'altsep', 'curdir', 'defpath',
'dict', 'dir', 'environ', 'error', 'eval', 'execl', 'execle', 'execlp', 'execlp
e', 'execvp', 'execvpe', 'extsep', 'getcwd', 'getenv', 'linesep', 'list', 'listd
ir', 'makedirs', 'name', 'pardir', 'path', 'pathsep', 'remove', 'removedirs', 'r
enames', 'sep', 'spawnl', 'stat', 'stat_result', 'sys', 'unlink', 'waitpid', 'wa
lk']
>>>
He said it had something to do with my set up. Anyway, in terms of the os module in standard python I could do something like so.
Import os
doesFileExist = os.path.isdir(FileName)
if(doesFileExist):
print FileName
else:
print 'No file'
In terms of using the nt module, how would I implement this?
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Martin Maly
Sent: Saturday, October 15, 2005 5:02 PM
To: Discussion of IronPython
Subject: Re: [IronPython] importing the os module
In standard Python, os is not a built-in module, however, nt module is built-in. IronPython includes built-in nt moduel (as built-in module implemented in c#), but not the os. module.
I am not understanding your question about the IO module. There is no "io" module in neither CPython nor IronPython:
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named io
Martin
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Papanii Okai
Sent: Saturday, October 15, 2005 4:53 PM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] importing the os moduleOk, so I stepped through with the debugger and found out that IO module wasn't begin called. Are io and os built in modules? Below is a copy of the stack trace..
Thread [#:0]
*0. IronPython.Objects.Importer.ImportTop (PythonModule.cs:182)
1. IronPython.Objects.Importer.ImportModule (PythonModule.cs:165)
2. IronPython.Modules.Builtin.__import__ (__builtin__.cs:60)
3. ReflectOpt.IronPython.Modules.Builtin.__import__ (source line information unavailable)
4. IronPython.Objects.BuiltinFunction.Call (BuiltinFunction.cs:101)
5. IronPython.Objects.Ops.Call (Ops.cs:1423)
6. IronPython.Objects.Importer.Import (PythonModule.cs:151)
7. IronPython.Objects.Ops.Import (Ops.cs:1864)
8. input_2.Run (source line information unavailable)
9. IronPython.Hosting.PythonEngine.DoOneInteractive (PythonEngine.cs:278)
10. IronPython.Hosting.PythonEngine.RunInteractive (PythonEngine.cs:227)
11. IronPythonConsole.PythonCommandLine.RunInteractive (PythonCommandLine.cs:151)
12. IronPythonConsole.PythonCommandLine.Main (PythonCommandLine.cs:40)
--Papanii
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Martin Maly
Sent: Saturday, October 15, 2005 6:39 AM
To: Discussion of IronPython
Subject: Re: [IronPython] importing the os module
You can either use the CPython libraries, or instead of "os" use the "nt" module which IronPython contains.
Martin
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Papanii Okai
Sent: Saturday, October 15, 2005 12:19 AM
To: [email protected]
Subject: [IronPython] importing the os moduleHi Guys,
I was testing out Iron Python and I was trying to test out the OS module but I got the error ..
TraceBack (most recent call last)
At <shell>
ImportError: No module named os..
Obviously it doesn't exist. Thus is there any means to get around this?
Thank you
--Papanii
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
