h0arry / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

In Python interpreter module is imported incorrectly. #531

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1.PyScripter version 2.4.2.1 or 2.4.2.2

2. content of module file:

#-------------------------------------------------------------------------------
# Name:        test
# Purpose:
#
# Author:      Rincewind
#
# Created:     07.06.2011
# Copyright:   (c) Rincewind 2011
# Licence:     Standard Ankh-Morpork licence. Steal & kill.
#-------------------------------------------------------------------------------
#!/usr/bin/env python

def adder(a,b):
    return a+b

3. Interpreter window output:

*** Python 3.1.3 (r313:86834, Nov 27 2010, 18:30:53) [MSC v.1500 32 bit 
(Intel)] on win32. ***
>>> import test
>>> dir(test)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> test.adder
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'adder'
>>> test.adder(1,2)
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'adder'
>>> 

___________________________________________________________
Expected output is: "3"

Configuration:

Windows 7 Professional Edition 32-bit SP1
Python 3.1.3
PyScripter version 2.4.2.1 or 2.4.2.2

In standard Python command line all works great.

Original issue reported on code.google.com by shlya...@gmail.com on 16 Jun 2011 at 2:39

GoogleCodeExporter commented 9 years ago
Is test.py a saved file?  Is it on the Python path?  How do you expect Python 
to find your test.py when you issue the command "import test"?

My guess is that Python is finding a different test.py on the python path.

PyScripter offers the command Run, Import to import the file of the current 
editor.  You can also try the Run, Run command and then in the interpreter 
window

>>> addder(3,2)

Original comment by pyscripter on 16 Jun 2011 at 2:59