Most voted questions in Python

0 votes
1 answer

text = _whitespace_only_re.sub('', text) TypeError: expected string or bytes-like object

This seems like an issue with textwrap ...READ MORE

Feb 13, 2019 in Python by Omkar
• 69,230 points
8,727 views
0 votes
1 answer

How to filter HTML tags and resolve entities using Python?

Him the answer is a pretty simple ...READ MORE

Feb 13, 2019 in Python by Nymeria
• 3,560 points
1,915 views
0 votes
1 answer

How can I go about using var == False in Python?

Hi. Simple answer.  All you need to do ...READ MORE

Feb 13, 2019 in Python by Nymeria
• 3,560 points
516 views
0 votes
1 answer

Program to store the details multiple employees

import random class Bank: ...READ MORE

Feb 13, 2019 in Python by Omkar
• 69,230 points
2,062 views
0 votes
1 answer

Can we access Outer class member from an Inner class in Python?

If you want to access outer class ...READ MORE

Feb 13, 2019 in Python by Omkar
• 69,230 points
12,450 views
0 votes
1 answer

How to resolve ImportError: cannot import name 'add' in python ?

There's no module called "add" in random. ...READ MORE

Feb 13, 2019 in Python by Mark
4,403 views
0 votes
1 answer

Sort a part of a list in place

You can write it as such: a[i:j] = ...READ MORE

Feb 12, 2019 in Python by SDeb
• 13,300 points
3,169 views
0 votes
1 answer

Adding two pandas dataframes

you can try the following: x.add(y, fill_value=0) import pandas ...READ MORE

Feb 12, 2019 in Python by SDeb
• 13,300 points
9,398 views
0 votes
1 answer

Inconsistent Whitespace error occurrence when using Python doctest with newline characters

Hi. It's pretty simple actually. All you ...READ MORE

Feb 12, 2019 in Python by Nymeria
• 3,560 points
2,264 views
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

Feb 12, 2019 in Python by Nymeria
• 3,560 points
10,826 views
0 votes
1 answer

Embed R code in python

You can try this : from rpy import ...READ MORE

Feb 11, 2019 in Python by SDeb
• 13,300 points
864 views
0 votes
1 answer

How to increase plt.title font size?

Try the following : import matplotlib.pyplot as plt plt.figtext(.5,.9,'Temperature', ...READ MORE

Feb 11, 2019 in Python by SDeb
• 13,300 points
914 views
0 votes
1 answer

Need help bootstrapping Python module installation on Amazon EMR

Hello! The easiest way to definitely do this ...READ MORE

Feb 11, 2019 in Python by Nymeria
• 3,560 points
2,372 views
0 votes
1 answer

How to access different Anaconda environments from PyCharm for coding in Python?

Hi! In PyCharm, you can add any number ...READ MORE

Feb 11, 2019 in Python by Nymeria
• 3,560 points
1,223 views
0 votes
1 answer

How to solve indentation in the below code?

Python does not use brackets, it uses ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,230 points
525 views
0 votes
1 answer

Python program to read the excel file which contains more than 65K records

Hi @Rashmi! I read your code and there ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,230 points
1,062 views
0 votes
1 answer

Python convert all sheets of excel to csv

You will have to parse through the ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,230 points
7,032 views
0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,230 points
28,801 views
0 votes
1 answer

How to get base class type in Python?

Yes, There is an alternative. You can ...READ MORE

Feb 8, 2019 in Python by SDeb
• 13,300 points
1,838 views
0 votes
1 answer

Python command line 'file input stream'

You can use argparse to create an ...READ MORE

Feb 8, 2019 in Python by SDeb
• 13,300 points
1,574 views
0 votes
1 answer

Why are dictionary objects unhashable in Python?

Hi, it is not possible to hash ...READ MORE

Feb 8, 2019 in Python by Nymeria
• 3,560 points
489 views
0 votes
1 answer

How can I make use of getopt or optarg in Python?

Hi, I was asked this by one ...READ MORE

Feb 8, 2019 in Python by Nymeria
• 3,560 points
979 views
0 votes
1 answer

Regarding pyc file in Python

When you run a Python script, Python ...READ MORE

Feb 7, 2019 in Python by Yogi
1,432 views
0 votes
1 answer

Permission denied for .pyc file

Did you run the python script as ...READ MORE

Feb 7, 2019 in Python by Omkar
• 69,230 points
5,087 views
0 votes
1 answer

What is the purpose of inner class in Python?

Advantages of inner class: Logical grouping of classes: ...READ MORE

Feb 7, 2019 in Python by SDeb
• 13,300 points
2,027 views
0 votes
1 answer

Circular buffer in Python

You can use collections.deque with a maxlen ...READ MORE

Feb 7, 2019 in Python by SDeb
• 13,300 points
1,675 views
0 votes
1 answer

How to zip with a list output in Python instead of a tuple output?

Good question - Considering that you are ...READ MORE

Feb 7, 2019 in Python by Nymeria
• 3,560 points
1,438 views
0 votes
1 answer

Multi-threading program in python

import threading import os def task1(): print("Task 1 assigned ...READ MORE

Feb 7, 2019 in Python by Omkar
• 69,230 points
574 views
0 votes
1 answer

Convert the keys of a dictionary to list

Unpacking with * works with any object ...READ MORE

Feb 7, 2019 in Python by Omkar
• 69,230 points
341 views
0 votes
1 answer

Print a list in both ascending and descending order

You can use listName.sort(reverse=True). This will sort the ...READ MORE

Feb 7, 2019 in Python by Omkar
• 69,230 points
1,390 views
0 votes
2 answers

Difference between sort and sorted

when to use which? Use list.sort when you ...READ MORE

Mar 26, 2020 in Python by rahul
• 360 points
4,391 views
0 votes
1 answer

How can I lookup hostname using the IP address with a timeout in Python?

Good question. I actually was stuck with ...READ MORE

Feb 6, 2019 in Python by Nymeria
• 3,560 points
2,260 views
0 votes
1 answer

How can I read numbers in Python from a custom file?

Hi, good question. Let us first assume that ...READ MORE

Feb 6, 2019 in Python by Nymeria
• 3,560 points
878 views
0 votes
0 answers
0 votes
1 answer

Convert HTML to an image in Python

webkit2png. The original version is OSX-only, but luckily ...READ MORE

Feb 5, 2019 in Python by SDeb
• 13,300 points
17,375 views
0 votes
1 answer

How can i combine flask and nameko?

You absolutely can use nameko and Flask together.  In that ...READ MORE

Feb 5, 2019 in Python by SDeb
• 13,300 points
1,270 views
0 votes
1 answer

How to set a random seed for prn generation?

The main python module that is run ...READ MORE

Feb 4, 2019 in Python by charlie_brown
• 7,720 points
562 views
0 votes
1 answer

What is the process to kill a particular thread in python?

A multiprocessing.Process can p.terminate() In the cases where I want to ...READ MORE

Feb 4, 2019 in Python by charlie_brown
• 7,720 points
3,495 views
0 votes
1 answer

How to get path with filename in python?

There is no direct way to get ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
3,375 views
0 votes
1 answer

How to list only text files in a directory using python?

Well, you are using a complex way. ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
2,465 views
0 votes
1 answer

How to get absolute path in python?

Instead of using os.path.dirname method which returns the relative ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
7,612 views
0 votes
1 answer

How to list only files in a directory?

Before printing, you can use a check ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
435 views
0 votes
1 answer

How to list files/directories in python

You can use the os module to list the ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
574 views
0 votes
1 answer

How can I run terminal commands in python?

You can use the subprocess or os module to do this. Using ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
967 views
0 votes
1 answer

How to add integer to python array?

You have defined a numpy array but ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
5,158 views
0 votes
1 answer

Python AST with preserved comments

The ast module doesn't include comments. The ...READ MORE

Feb 2, 2019 in Python by SDeb
• 13,300 points
1,294 views
0 votes
1 answer

Weird closure behavior in python

Closures don't refer to variables but rather ...READ MORE

Feb 2, 2019 in Python by SDeb
• 13,300 points
596 views
0 votes
1 answer

Not able to take input in python

You are using python 2 in which ...READ MORE

Jan 31, 2019 in Python by Omkar
• 69,230 points
3,335 views
0 votes
1 answer

Need a python script to login into a website but username and password are in a txt file (Selenium automation script)

I had a similar requirement. I had ...READ MORE

Jan 31, 2019 in Python by Omkar
• 69,230 points
7,945 views
0 votes
0 answers

'module' object has no attribute 'PortScanner'

I am trying to run nmap in ...READ MORE

Jan 30, 2019 in Python by Karan
1,230 views