Ok, so I haven’t done much blogging in a while (I’ve been busy focusing on learning things, I swear!!), but I just discovered a cool thing while writing a Bencoder:
YOU CAN PUT if __name__ == ‘__main__’: statements inside of functions, and they will run in their place in the program & not disrupt the normal flow of the program, either when you run it as main, or import it.
print ‘Bencoding ‘ + text
length = str(len(text))
data = str(length + “:” + text)
print “Becoded: ” + data + “\n”
if __name__ == ‘__main__’:
if name == ‘__main__’:
Would I Ever Do This??
Hopefully not, but it’s cool to know that you can!!