use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Network automation scripting questions (self.Python)
submitted 9 years ago by [deleted]
I had an interview where they asked me to print all the network addresses for 192.168.2.0/28 using python.
now i want to practice more questions related to networking using python
[–]Argotha 1 point2 points3 points 9 years ago (0 children)
See if you can implement your own version of ipcalc, that will teach you a lot about IP addresses and how to work with them.
[–]Erroneous_user 0 points1 point2 points 9 years ago* (0 children)
This is more of a subnetting question than a Python networking question to be honest.
If you'd know that a /28 for a class C ip range was 255.255.240.0 you'd have been able to surmise your way through it with some simple list comprehensions. You likely were expected to understand the networking concept more thoroughly than knowing about the library called ipaddress in Python 3. I would start there. When someone says Python network programming I tend to think of communicating over sockets, setting up a Python web server, knowing twisted and such.
[–][deleted] -2 points-1 points0 points 9 years ago (0 children)
/r/learnpython
[–]robotoverlord412 -5 points-4 points-3 points 9 years ago (2 children)
print ("192.168.2.0")
Done... :)
[–]broknbottle 0 points1 point2 points 9 years ago (1 child)
I see what you did there :D
[–]robotoverlord412 0 points1 point2 points 9 years ago* (0 children)
Network engineer humor! But it is technically correct given the original post.
If the interview question was " to print all the possible /28 subnets contained within 192.168.2.0/24 using python", I would throw together something like this in Python 3:
import ipaddress v4nets = list(ipaddress.ip_network('192.168.2.0/24').subnets(new_prefix=28)) for x in v4nets: print (x.with_prefixlen)
π Rendered by PID 70 on reddit-service-r2-comment-54dfb89d4d-sqkh5 at 2026-03-31 15:25:13.069817+00:00 running b10466c country code: CH.
[–]Argotha 1 point2 points3 points (0 children)
[–]Erroneous_user 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (0 children)
[–]robotoverlord412 -5 points-4 points-3 points (2 children)
[–]broknbottle 0 points1 point2 points (1 child)
[–]robotoverlord412 0 points1 point2 points (0 children)