Page 1 of 1

Is there a difference between usocket and socket?

Posted: Sun Jun 30, 2019 12:06 pm
by Jim.S
Are there any differences between import socket and import usocket

This micropython 1.11 document (https://docs.micropython.org/en/latest/ ... twork.html) uses the following import

Code: Select all

 # now use usocket as usual
import usocket as socket
But this example, for the esp 8266 which also works on the Pyboard-d ( https://docs.micropython.org/en/latest/ ... k_tcp.html) just uses import socket

Re: Is there a difference between usocket and socket?

Posted: Sun Jun 30, 2019 12:22 pm
by Christian Walther
Unless you have a socket.py on your filesystem, there is no difference, they will both give you the same thing:

Code: Select all

MicroPython v1.11-8-g48dcbbe60 on 2019-05-29; ESP module with ESP8266
Type "help()" for more information.
>>> import usocket
>>> import socket
>>> socket
<module 'lwip'>
>>> usocket
<module 'lwip'>
>>> socket is usocket
True
See also http://docs.micropython.org/en/latest/l ... -libraries.