standards

How to write in python a parser for a character-based protocol

How to write in python a parser for a character-based protocol Question: I’m implementing a client for an already existing (old) standard for exchanging information between shops and providers of some specific sector, let’s say vegetables. It must be in python, and I want my package to read a plaintext file and build some objects …

Total answers: 1

Python: How to read stdout of subprocess in a nonblocking way

Python: How to read stdout of subprocess in a nonblocking way Question: I am trying to make a simple python script that starts a subprocess and monitors its standard output. Here is a snippet from the code: process = subprocess.Popen([path_to_exe, os.path.join(temp_dir,temp_file)], stdout=subprocess.PIPE) while True: output=process.stdout.readline() print “test” The problem is that the script hangs on …

Total answers: 3

Are docstrings for internal functions (python) necessary?

Are docstrings for internal functions (python) necessary? Question: In python we designate internal function/ private methonds with an underscore at the beginning. Should these functions be documented with docstrings(is it required?)? (the formal documentation i mean, not the one helping the code-reader to understand the code) What is common practice for this? Asked By: 0xc0de …

Total answers: 1

What's the best way to format a phone number in Python?

What's the best way to format a phone number in Python? Question: If all I have is a string of 10 or more digits, how can I format this as a phone number? Some trivial examples: 555-5555 555-555-5555 1-800-555-5555 I know those aren’t the only ways to format them, and it’s very likely I’ll leave …

Total answers: 7