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
Determining application path in a Python EXE generated by pyInstaller
I have an application that resides in a single .py file. I’ve been able to get pyInstaller to bundle it successfully into an EXE for Windows. The problem is, the application requires a .cfg file that always sits directly beside the application in the same directory. Normally, I build the path using the following code: However, it seems the sys.path
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
How do I parse a string to a float or int?
How can I convert a str to float? How can I convert a str to int? For the reverse, see Convert integer to string in Python and Converting a float to a string without rounding it. Please instead use How can I read inputs as numbers? to close duplicate questions where OP received a string from user input and immediately
What are the differences between Perl, Python, AWK and sed? [closed]
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.
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
Currency formatting in Python
I am looking to format a number like 188518982.18 to £188,518,982.18 using Python. How can I do this? Answer See the locale module. This does currency (and date) formatting.