On 10/03/17 12:38, leam hall wrote:
> As noted, the fix was to put the "import socket" above the class
> declaration. What confuses me is that in the calling program I'm importing
> the class:
>
> from mysocket import mysocket
>
> In mysocket.py the "import socket" is above the class
y'all,
Thanks for the explanations! Sorry for the delay in responding, it's been a
rough year these past couple weeks.
As noted, the fix was to put the "import socket" above the class
declaration. What confuses me is that in the calling program I'm importing
the class:
from mysocket import
On Mon, Mar 06, 2017 at 12:35:27PM -0500, leam hall wrote:
> What am I missing?
Let us start by reading the exception that you get, below the class.
That tells us *what* error occurred, but not how or why:
> class mysocket():
> import socket
> def __init__(self, sock=None);
> if sock
On 03/06/2017 10:35 AM, leam hall wrote:
> What am I missing?
>
>
> class mysocket():
> import socket
> def __init__(self, sock=None);
> if sock is None:
> self.sock = socket.socket(socket.socket.AF_NET,
> socket.socket.SOCK_STREAM)
> else:
> self.sock = sock
>
>
>
On 06/03/17 17:35, leam hall wrote:
> What am I missing?
I'd start by moving the import out of the class to
its more normal position at the top of the file.
>
> class mysocket():
> import socket
> def __init__(self, sock=None);
> if sock is None:
> self.sock =
What am I missing?
class mysocket():
import socket
def __init__(self, sock=None);
if sock is None:
self.sock = socket.socket(socket.socket.AF_NET,
socket.socket.SOCK_STREAM)
else:
self.sock = sock
Error:
NameError: global name "socket" is not defined.