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

Works only in interactive mode

P: n/a
Hi all,
using Python 2.4 under Linux (SUSE 9.3) I was developping a script to
get various lists related with DCOP.
In interactive Python all is working correctly:

import pcop

# application's registration with DCOP
print x

# list of DCOP registered applications
print pcop.app_list('kate')
['kwin', 'kicker', 'konqueror-7203', 'kate', 'kded', 'kmix',
'kate-7497', 'knotify', 'susewatcher', 'suseplugger',
'kio_uiserver', 'kcookiejar', 'klauncher', 'khotkeys', 'kdesktop',
'konsole-7340', 'klipper', 'ksmserver', 'kaccess', 'kpowersave']

Instead as a script:

1 import pcop
3 # application's registration with DCOP
4 x=pcop.register_as('kate')
5 print x
7 # list of DCOP registered applications (emula dcop)
8 print pcop.app_list('kate')

you get:
Traceback (most recent call last):
File "/home/bf/python/", line 4, in ?
AttributeError: 'module' object has no attribute 'register_as'

How is it possible?

Oct 10 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
That looks like a different module named pcop getting in the way. If
there's another in the directory where you're running it as a
script, then that gets priority and you'll end up with an error like
the one you got. However, if you run it interactively, then that
directory is not checked, or is (normally) checked lower-down than,
say, Python's standard library. Try checking if help(pcop) and
dir(pcop) are what you expect in the script, and looking at where
sys.path is looking for scripts.

Oct 10 '05 #2

P: n/a
Hi Sam,
thank you very much. Your diagnosis was perfect!

Oct 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.