Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9236093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:12:23+00:00 2026-06-18T07:12:23+00:00

For homework I am re-implementing the socket class in python. I am not however,

  • 0

For homework I am re-implementing the socket class in python. I am not however, well versed in python. I have a question on syntax.

From the python API when you define a socket you use:

import socket
mySocket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM))

However, I don’t know how to define constants that behave life AF_INET and SOCK_DGRAM.

import mySocket
mySocket = mySocket.socket(mySocket.AF_INET,mySocket.SOCK_DGRAM))

gives the following errors

Undefined variable from import: AF_INET
Undefined variable from import: SOCK_DGRAM

The mySocket class currently looks like:

class socket:
    AF_INET;
    SOCK_DGRAM;

    def socket(.....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:12:24+00:00Added an answer on June 18, 2026 at 7:12 am

    You need to define the constants at module level, not in your socket class:

    AF_INET = 2
    SOCK_DGRAM = 2
    
    class socket:
        def __init__(.....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been working on properly implementing a quicksort algorithm for a homework
I have a homework to classify multi-class images with Support Vector Machines. I am
I'm implementing the producer/consumer problem for homework, and I have to compare the sequential
For homework I have to read from the standard input, save it to a
referring to the old homework question : /* implementing /usr/bin/ps -ef | /usr/bin/more */
This is homework I'm working on implementing a linked list class for my C++
A homework project I'm working on uses static and dynamic arrays. However, I'm not
This is not a homework, it's more of a challenge from our prof but
I am doing homework in C# in which I am implementing the abstract class
I am implementing this hoemwork functionality using Ocaml: Not allowed to use List module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.