756 Answered Questions for the topic Python

03/27/19

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
Python String Trim

03/26/19

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
Python File Append

03/26/19

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?

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

03/19/19

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

03/19/19

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

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.

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
Python List Loops

03/18/19

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?

Python Json Parsing

03/18/19

Parsing values from a JSON file?

I have this JSON in a file: { "maps": [ { "id": "blabla", "iscategorical": "0" }, { "id": "blabla", ... more
Python Quickbooks Api

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

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 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.