Popular recipes by teddy_k http://code.activestate.com/recipes/users/4187115/2013-11-03T18:35:18-08:00ActiveState Code RecipesDetermine bytes needed to hold integer (Python3) (Python) 2013-11-03T18:35:18-08:00teddy_khttp://code.activestate.com/recipes/users/4187115/http://code.activestate.com/recipes/578766-determine-bytes-needed-to-hold-integer-python3/ <p style="color: grey"> Python recipe 578766 by <a href="/recipes/users/4187115/">teddy_k</a> (<a href="/recipes/tags/bytes/">bytes</a>, <a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/integer/">integer</a>). </p> <p>Convenience function to determine the number of bytes needed for a specified integer (split into multiple lines for clarity's sake ... could just as easily be a one-liner).</p> <p>If this is already a defined function within Python, please let me know--a quick web search turned up nothing.</p> Primitive Peer to Peer Chat (Python) 2013-07-07T02:09:57-07:00teddy_khttp://code.activestate.com/recipes/users/4187115/http://code.activestate.com/recipes/578591-primitive-peer-to-peer-chat/ <p style="color: grey"> Python recipe 578591 by <a href="/recipes/users/4187115/">teddy_k</a> (<a href="/recipes/tags/chat/">chat</a>, <a href="/recipes/tags/peer/">peer</a>, <a href="/recipes/tags/select/">select</a>, <a href="/recipes/tags/socket/">socket</a>, <a href="/recipes/tags/threading/">threading</a>). </p> <p>This took me longer than it should have. I am putting it here in the hopes that this post will spare others from having to Google things for extended periods of time.</p> <p>In short, you either listen for a connection (Chat_Server), or connect to a remote IP address (Chat_Client). From there, you can send text strings back and forth. </p> <p>This is a bit rough-hewn, obviously; I apologize in advance.</p>