Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error bluetooth

34 views
Skip to first unread message

Luca Sanna

unread,
Oct 5, 2012, 4:51:42 AM10/5/12
to
the code is output the error of the ubuntu

from bluetooth import *

target_name = "My Phone"
target_address = None

nearby_devices = discover_devices()

for address in nearby_devices:
if target_name == lookup_name( address ):
target_address = address
break

if target_address is not None:
print "found target bluetooth device with address", target_address
else:
print "could not find target bluetooth device nearby"

the error

luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py
Traceback (most recent call last):
File "bluetooth.py", line 14, in <module>
from bluetooth import *
File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in <module>
nearby_devices = discover_devices()
NameError: name 'discover_devices' is not defined
luca@luca-XPS-M1330:~/py-temperature/py-temperature$

it's a bug of the module? thanks

Ulrich Eckhardt

unread,
Oct 5, 2012, 6:03:38 AM10/5/12
to
Am 05.10.2012 10:51, schrieb Luca Sanna:
> the code is output the error of the ubuntu
>
> from bluetooth import *
>
[...]
>
> nearby_devices = discover_devices()
>
[...]
>
> the error
>
> luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py
> Traceback (most recent call last):
> File "bluetooth.py", line 14, in <module>
> from bluetooth import *
> File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in <module>
> nearby_devices = discover_devices()
> NameError: name 'discover_devices' is not defined

The module "bluetooth" doesn't export any function called
discover_devices(). You could try "dir(bluetooth)" or "help(bluetooth)"
(do that from an interactive prompt) to find out what is in there. I
don't know why you expect such a function there, if it is mentioned in
the documentation or example code that would be a bug.

Uli

Dave Angel

unread,
Oct 5, 2012, 6:33:18 AM10/5/12
to Luca Sanna, pytho...@python.org
Perhaps you named your script bluetooth.py, and thus masked the module
bluetooth.py. Pick a different name for your own sources.

--

DaveA

Hans Mulder

unread,
Oct 5, 2012, 7:32:49 AM10/5/12
to
On 5/10/12 10:51:42, Luca Sanna wrote:

> from bluetooth import *

[......]

> luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py

When you say "from bluetooth import *", Python will find a file
name "bluetooth.py" and import stuff from that file. Since your
script happens to be named "bluetooth.py", Python will import
your script, thinking it is a module.

> it's a bug of the module?

You've chosen the wrong file name. Rename your script.


Hope this helps,

-- HansM

Luca Sanna

unread,
Oct 5, 2012, 8:03:00 AM10/5/12
to
i'm sorry, it's ok the rename file in bt.py

how do I send a ping in bluetooth?
because android phones are not always visible.
I can not find the ping command
thanks
0 new messages