By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

Curses module.

P: n/a
Hello all,

I'm trying to learn Python, in particular the curses module. My system
is running Slackware 9.0 and the verion of Python that comes installed
with Slackware 9.0 is Python 2.2.2.

I've been trying to access the curses.wrapper module without any
success. I know that the wrapper exists in /usr/lib/python2.2/curses yet
any reference that I make to it is rebuffed by the interpreter.

Here's the python script I'm trying to run:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #!/usr/bin/python
  3. #
  4. # My first attempts at writing a curses interface using python
  5.  
  6. import curses
  7.  
  8. def newWindow():
  9. begin_x = 20 ; begin_y = 7
  10. height = 5 ; width = 40
  11. win = curses.newwin(height, width, begin_y, begin_x)
  12. return
  13.  
  14. # Pass the function to the curses wrapper
  15.  
  16. curses.wrapper(newWindow())
  17.  
  18.  
This is the error message that I get when I try to run the script from
the CLI:

Traceback (most recent call last):
File "./curses3.py", line 15, in ?
curses.wrapper(newWindow())
AttributeError: 'module' object has no attribute 'wrapper'

Any ideas as to what I could be doing wrong?
Alex the Python Newbie

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, Jul 15, 2003 at 07:03:33PM -0400, Alex wrote:
Hello all,

I'm trying to learn Python, in particular the curses module. My system
is running Slackware 9.0 and the verion of Python that comes installed
with Slackware 9.0 is Python 2.2.2.

I've been trying to access the curses.wrapper module without any
success. I know that the wrapper exists in /usr/lib/python2.2/curses yet
any reference that I make to it is rebuffed by the interpreter.

Here's the python script I'm trying to run:

[snip apparently correct code]

This is the error message that I get when I try to run the script from
the CLI:

Traceback (most recent call last):
File "./curses3.py", line 15, in ?
curses.wrapper(newWindow())
AttributeError: 'module' object has no attribute 'wrapper'

Any ideas as to what I could be doing wrong?


Do you, perhaps, have a file named "curses.py" in your current directory?
If so, "import curses" will load this, and not the stdlib module.

You could also try printing "curses.__file__" to make sure the module is
really coming from where you believe it is.

Jp

Jul 18 '05 #2

P: n/a
You were both correct.

I simply had to get rid on the curses.py program (my first test program)
and everything worked fine.

Thanks again for the help. I can get down to some serious
learning/hair-pulling frustration :)
Alex
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.