2018-03-12 05:48:57

How do you do indenting in python? I use notepad but I need smart indenting. Is it like this?

This is for socket server.
while True:
tab c, addr = s.accept()
tab tab print "Thank you for connection.",
tab tab tab c.close()

I hope I got the indents right.

Bitcoin Address:
1MeNca7h6m8du4TV3psN4m4X666p6Y36u5m

2018-03-12 06:41:21

Assuming "c, addr = s.accept()" is a variable declaration, then you are using too many indents. Indentation in Python is used to determine what lines are appart of a code block, so if those lines are all part of one single code block, in this case the while statement, then they should be all the same indentation. Adding code blocks within code blocks, such as with if statements or other functions, is when you'd start using deeper indentation. Example:

while True:
tab c, addr = s.accept()
tab print "Thank you for connection.",
tab if addr != None:
tab tab print "This IP address is: ", addr
tab c.close()
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer