[Tutor] Socket error in class, part the second

leam hall leamhall at gmail.com
Fri Mar 10 07:38:00 EST 2017


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 mysocket

In mysocket.py the "import socket" is above the class declaration. This
works. I would have thought it would fail as the import statement only
imports the class, not the entire module. However, I'm wrong. Still

Also, yes, I re-typed everything which is why the errors crept in. The
machine I have to run python on precludes cut and paste to the machine I
e-mail on. The original code was swiped from Gordan McMillian's tutorial on


I'm just trying to make things modular.

Again, thanks!


More information about the Tutor mailing list