756 Answered Questions for the topic Python
Why are Python lambdas useful?
I'm trying to figure out Python lambdas. Is lambda one of those "interesting" language items that in real life should be forgotten? I'm sure there are some edge cases where it might be needed, but...
more
Python File Io
03/27/19
Find all files in a directory with extension .txt in Python?
How can I find all the files in a directory having the extension `.txt` in python?
Python Types
03/26/19
What's the canonical way to check for type in Python?
What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type?Let's say I have an object `o`. How do I check whether it's...
more
How do I trim whitespace from a Python string?
How do I remove leading and trailing whitespace from a string in Python?For example: " Hello " --> "Hello" " Hello" --> "Hello" "Hello " --> "Hello" "Bob has a cat" -->...
more
03/26/19
How can I print literal curly-brace characters in python string and also use .format on it?
x = " \\{ Hello \\} {0} " print x.format(42) gives me : `Key Error: Hello\\\\`I want to print the output: `{Hello} 42`
Python String
03/26/19
Reverse a string in Python?
There is no built in `reverse` function for Python's `str` object. What is the best way of implementing this method?If supplying a very concise answer, please elaborate on its efficiency. For...
more
How do you append to a file in Python?
How do you append to the file instead of overwriting it? Is there a special function that appends to the file?
03/19/19
If Python is interpreted, what are .pyc files?
I've been given to understand that Python is an interpreted language... However, when I look at my Python source code I see `.pyc` files, which Windows identifies as "Compiled Python Files". Where...
more
How can I safely create a nested directory in Python?
What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried: import os file_path =...
more
Does Python have a string 'contains' substring method?
I'm looking for a `string.contains` or `string.indexof` method in Python.I want to do: if not somestring.contains("blah"): continue
03/19/19
Pythonic way to create a long multi-line string?
I have a very long query. I would like to split it in several lines in Python. A way to do it in JavaScript would be using several sentences and joining them with a `+` operator (I know, maybe it's...
more
03/19/19
Python IDE with rich features: code completion, debugging, etc?
I'm looking for a good IDE for Python that should run on Windows 7 and higher. The program should ideally support the following features:
- Syntax highlighting
- Code Completion
- Debugger...
more
Python Dictionary
03/18/19
Add new keys to a dictionary?
Is it possible to add a key to a Python dictionary after it has been created? It doesn't seem to have an `.add()` method.
Python Microsoft Powerpoint
03/18/19
Charts from Excel to PowerPoint with Python?
I have an excel workbook that is created using an excellent "xlsxwriter" module. In this workbook, there about about 200 embedded charts. I am now trying to export all those charts into several...
more
Accessing the index in 'for' loops?
How do I access the index itself for a list like the following? ints = [8, 23, 45, 12, 78]When I loop through it using a `for` loop, how do I access the loop index, from 1 to 5 in this case?
03/18/19
Is Python front end or back end?
Parsing values from a JSON file?
I have this JSON in a file: { "maps": [ { "id": "blabla", "iscategorical": "0" }, { "id": "blabla", ...
more
03/18/19
Any python library to access quickbooks?
I want to integrate my mobile POS system with quickbooks. I need customers, sellers, inventory & post orders & invoices.
I have not not been able to find a python library for this. Is...
more
03/13/19
Does Python have a ternary conditional operator?
If Python does not have a ternary conditional operator, is it possible to simulate one using other language constructs?
Python Html
03/03/19
How to call python from python + html code?
Friends, I have a python program which runs html program to create box as follows which runs on wamp server:**box.py:** #!C:/python27/python.exe -uprint "Content-type: text/html...
more
02/18/19
oops in python.
Write a program using object oriented method to calculate the area. It should require two attributes width W and Height H.2. Write a program using OOP method to calculate the area. It should...
more
Python
10/09/18
Write a program script that traverses through an input string and prints its characters in different lines -- two characters in a line
this is from python programming
Python Programming
09/16/18
How to move down lines in python?
Hello, when I am typing something in command prompt with python activated, I am able to write programs in the first line only. When I press enter, the program executes with just the first line,...
more
Python
09/03/18
Write a Python code to calculate the speed for running a 10-kilometer race in 1 hours 5 minutes 42 seconds.
Write a Python code to calculate the speed for running a 10-kilometer race in 1 hours 5 minutes 42 seconds. What is the average pace (time per mile in minutes and seconds)? What is the average...
more
Python
09/01/18
Create a function that pulls a picture from a URL and creates a thumbnail saved on your local machine
Create a function that pulls a picture from a URL and creates a thumbnail saved on your local machine
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.