error bluetooth

Discussion in 'Python' started by Luca Sanna, Oct 5, 2012.

  1. Luca Sanna

    Luca Sanna Guest

    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
    Luca Sanna, Oct 5, 2012
    #1
    1. Advertising

  2. 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
    Ulrich Eckhardt, Oct 5, 2012
    #2
    1. Advertising

  3. Luca Sanna

    Dave Angel Guest

    On 10/05/2012 04:51 AM, Luca Sanna wrote:
    > 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


    Perhaps you named your script bluetooth.py, and thus masked the module
    bluetooth.py. Pick a different name for your own sources.

    --

    DaveA
    Dave Angel, Oct 5, 2012
    #3
  4. Luca Sanna

    Hans Mulder Guest

    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
    Hans Mulder, Oct 5, 2012
    #4
  5. Luca Sanna

    Luca Sanna Guest

    Il giorno venerdì 5 ottobre 2012 13:33:14 UTC+2, Hans Mulder ha scritto:
    > 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




    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
    Luca Sanna, Oct 5, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ante

    Bluetooth MIDlet

    Ante, Jul 1, 2003, in forum: Java
    Replies:
    3
    Views:
    6,734
    Darryl L. Pierce
    Jul 2, 2003
  2. Khalid Taib

    Java API for Bluetooth

    Khalid Taib, Feb 26, 2004, in forum: Java
    Replies:
    2
    Views:
    673
    Darryl L. Pierce,,,
    Feb 26, 2004
  3. Eugeniusz Hetmanski

    J2ME BLUETOOTH

    Eugeniusz Hetmanski, May 13, 2004, in forum: Java
    Replies:
    3
    Views:
    12,695
    Rob Shepherd
    May 25, 2004
  4. Boki
    Replies:
    0
    Views:
    401
  5. izzahmeor
    Replies:
    0
    Views:
    769
    izzahmeor
    Feb 3, 2010
Loading...

Share This Page