Skip to content
Advertisement

How to serialize Python objects in a human-readable format? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. The community reviewed whether to reopen this question 1 year ago and left it closed: Original close reason(s) were not resolved Improve this question

How to limit rate of requests to web services in Python?

I’m working on a Python library that interfaces with a web service API. Like many web services I’ve encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario

Does Python have a ternary conditional operator?

Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Is there a ternary conditional operator in Python? Answer Yes, it was added in version 2.5. The expression syntax is: First condition is evaluated, then exactly one of either

What is the recommended way to use Vim folding for Python code

I am interested in enabling code folding in Vim for Python code. I have noticed multiple ways to do so. Does anyone have a preferred way to do Python code folding in Vim? I.e, Do you have a particular Vim plugin that you use and like? Do you use manual folding or do you place markers in comments? Any other

Printing all instances of a class

With a class in Python, how do I define a function to print every single instance of the class in a format defined in the function? Answer I see two options in this case: Garbage collector This has the disadvantage of being very slow when you have a lot of objects, but works with types over which you have no

Running unit tests on nested functions

I come from the Java world, where you can hide variables and functions and then run unit tests against them using reflection. I have used nested functions to hide implementation details of my classes so that only the public API is visible. I am trying to write unit tests against these nested functions to make sure that I don’t break

Advertisement