473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Works only in interactive mode

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
x=pcop.register_as('kate')
print x
kate-7497

# 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
2
3 # application's registration with DCOP
4 x=pcop.register_as('kate')
5 print x
6
7 # list of DCOP registered applications (emula dcop)
8 print pcop.app_list('kate')

you get:
0
Traceback (most recent call last):
File "/home/bf/python/pippo.py", line 4, in ?
x=pcop.register_as('kate')
AttributeError: 'module' object has no attribute 'register_as'

How is it possible?
Bye.

Oct 10 '05 #1
2 1601
That looks like a different module named pcop getting in the way. If
there's another pcop.py 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
Hi Sam,
thank you very much. Your diagnosis was perfect!
Bye.

Oct 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steven Feil | last post by:
Is there a way to simulate "POST mode user input" while running PHP from the command line or in interactive mode? For example with python, you can simulate the effects of post mode with the...
3
by: Christoph Becker-Freyseng | last post by:
Hello, is there a way to dump (and save) the command-history of the python interactive mode. Thanks, Christoph Becker-Freyseng
0
by: Steve Menard | last post by:
I have a strange problem with Python command-line interactive mode. Problem has been observed on every 2.3 version where it was tested, from 2.3 alpha to 2.3.4 Test is run on windows XP and 2000...
20
by: Joe | last post by:
When you run "python -i scriptname.py" after the script completes you left at the interactive command prompt. Is there a way to have this occur from a running program? In other words can I...
3
by: DGG | last post by:
I have got a question arsing from my perl program. Basically, I want to get the machine date and time, and display it on a Tk label. I am using ActivePerl, and running on DOS/Windows. So I...
1
by: Alex | last post by:
Loking at Rossum's tutorial I've seen that he sometimes uses the expression "interactive mode" and sometimes "calculator mode". Or these concepts same? I've made the following assertion. ...
3
by: Pankaj | last post by:
I am facing a very basic problem as any new bie would face. I know perl and now i want to use python In perl, it is very simple , just "perl scriptname.pl" will execute the script. But i...
4
by: digitnctu | last post by:
Dear all: I am coming with problem, to apply ctypes under interactive mode in python. libdll.dll is a third-party library. The below code segment will run well under the batch mode(ie. python...
1
by: gabitzu4224 | last post by:
import os, envPrep, time, thread, Queue lock = thread.allocate_lock() data = Queue.Queue() open('Queue.txt','w').flush() def producer(ID): lock.acquire() msg = 'message from \n' %...
3
by: Sal | last post by:
I'm running PHP 5.2.6 on WindowsXP. When I try interactive mode with ">php -a" the slightest syntax error throws me out of the interpreter and back to the command line. This is not very useful....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.