Trending questions in Python

0 votes
1 answer

How to read an excel file (name User defined) from a path using python?

Hi @There, As the path is fixed, use ...READ MORE

Aug 13, 2020 in Python by Gitika
• 65,910 points
4,728 views
0 votes
1 answer

How to overcome “datetime.datetime not JSON serializable”?

Hii @kartik, The simple solution to over come ...READ MORE

Jun 5, 2020 in Python by Niroj
• 82,880 points
7,694 views
0 votes
1 answer

How to print prime numbers from 1 to n?

Hello @divyashree def isPrime(n): # ...READ MORE

Oct 13, 2020 in Python by Niroj
• 82,880 points
2,093 views
0 votes
1 answer

How to return None if Dictionary key is not available

Hello @kartik, You can use dict.get() value = d.get(key) which will ...READ MORE

Apr 30, 2020 in Python by Niroj
• 82,880 points
9,211 views
0 votes
1 answer

How can I do not equal in Django queryset filtering?

Hello @kartik, You can use Q objects for this. They ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
528 views
0 votes
1 answer

I am trying to install os-win on my python 3.8. But I end up with the following error:

I have the same issue and is ...READ MORE

Sep 6, 2020 in Python by anonymous
7,209 views
0 votes
1 answer

How do I get the number of elements in a list?

Hello, The len() function can be used with several different ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
456 views
0 votes
1 answer

How to run code when a class is subclassed?

Classes (by default) are instances of the ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
380 views
0 votes
1 answer

How to concatenate items in a list to a single string?

Hello @kartik, Use join: >>> sentence = ['this','is','a','sentence'] >>> '-'.join(sentence) 'this-is-a-sentence' Hope it ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
482 views
0 votes
1 answer

How to dynamically compose an OR query filter in Django?

Hello @kartik, You could chain your queries as ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,880 points
5,062 views
0 votes
1 answer

ImportError: No module named mpmath. But mpmath has been installed.

You should use conda to install Python ...READ MORE

Nov 4, 2020 in Python by Gitika
• 65,910 points
1,064 views
0 votes
1 answer

Why not inherit from List<T>?

There are some good answers here. I ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
352 views
0 votes
1 answer

AssertionError: <class 'numpy.ndarray'>

Hi, @There, The traceback module and sys.exc_info are ...READ MORE

Oct 19, 2020 in Python by anonymous
• 65,910 points
1,731 views
0 votes
1 answer

Error: Can't import matplotlib library.

Install the older version of python, I also ...READ MORE

Nov 6, 2020 in Python by Gitika
• 65,910 points
933 views
0 votes
1 answer

How are Python metaclasses different from regular class inheritance?

Python 3 class MyClass(object): = New-style class class MyClass: = New-style ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
311 views
0 votes
1 answer

How to call an external command?

Look at the subprocess module in the standard library: import ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,910 points
381 views
0 votes
1 answer

How can I get the domain name of my site within a Django template?

Hello kartik, The variation of the context processor ...READ MORE

Apr 23, 2020 in Python by Niroj
• 82,880 points
9,413 views
0 votes
1 answer

Why do we not follow the "off by one" rule in python

It's because of the way in which ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
493 views
0 votes
1 answer

How can I create a nested directory?

Hello, Using try except and the right error ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
358 views
0 votes
1 answer

How do I list all files of a directory?

Hii, Try this: import os os.listdir("somedirectory") Thank you!! ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
355 views
0 votes
1 answer

How do I parse XML in Python?

Hello @kartik, You can use BeautifulSoup: from bs4 import BeautifulSoup x="""<foo> ...READ MORE

Nov 19, 2020 in Python by Niroj
• 82,880 points
319 views
0 votes
1 answer

How to generate a string token using four of this items random?

One approach just generates random integers up ...READ MORE

Nov 16, 2020 in Python by Gitika
• 65,910 points
475 views
0 votes
1 answer

How to call an external command?

Hello @kartik, Look at the subprocess module in the standard ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
341 views
0 votes
1 answer

Django: Display a custom error message for admin validation error

Hello @kartik, Without looking, it sounds like the ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,880 points
7,212 views
0 votes
1 answer

How to test multiple variables against a value?

Hello @kartik, Your problem is more easily addressed ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
378 views
0 votes
1 answer

Error: showing database is locked

ah, sqlite3 stuff... remove .session file and ...READ MORE

Nov 15, 2020 in Python by Sheema
463 views
0 votes
1 answer

Unable to create a project in django.

I think u didn't install Django. python -m ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,910 points
593 views
0 votes
1 answer

Can't import scikit -learn on python3.

Hi@akhtar, First, remove the Sklearn form your Windows system ...READ MORE

Jun 23, 2020 in Python by MD
• 95,440 points
6,751 views
0 votes
1 answer

AttributeError: module 'http' has no attribute 'client

Hi@akhtar, To avoid this error make sure you ...READ MORE

Apr 22, 2020 in Python by MD
• 95,440 points
9,405 views
0 votes
1 answer

How do I pass a variable by reference?

Hello, Just wrap it in a list: def Change(self, ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
322 views
0 votes
1 answer

how to send post request to a webpage using cookies and headers in python to scrape the webpage ?

Hey @Avinash, Regarding your query, I would suggest ...READ MORE

Sep 29, 2020 in Python by Roshni
• 10,520 points
2,486 views
0 votes
1 answer

Error: Syntax Error: Invalid syntax

Indentation error. There should be indent before def ...READ MORE

Oct 7, 2020 in Python by Gitika
• 65,910 points
2,132 views
0 votes
1 answer

How to read a HDF file with Pandas?

Hi@akhtar, You can read an HDF file using ...READ MORE

Oct 18, 2020 in Python by MD
• 95,440 points
1,685 views
0 votes
1 answer

Sigma code look like this but it’s not working.

Use Markdown to style code: - Use a ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
441 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pyttsx3' || "Running setup.py install for comtypes ... error" error when installing pyttsx3

Hello, @There It depends on which version of ...READ MORE

Oct 7, 2020 in Python by Gitika
• 65,910 points
2,135 views
0 votes
1 answer

How to access environment variable values?

Hello @kartik, To check if the key exists ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
302 views
0 votes
1 answer

Error:Reverse accessor for 'Analysis.assign_user' clashes with reverse accessor for 'Inquiry.assign_user'.

Hello @kartik, The related_name would ensure that the fields were ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
6,376 views
0 votes
1 answer

Python: TypeError :Cannot cast Index to dtype int

Try to use numpy  and use .astype(np,int) ...READ MORE

Jun 25, 2020 in Python by Sirajul
• 59,230 points
6,599 views
0 votes
1 answer

How to print error in web browser if there is error in code?

You can try to catch these errors ...READ MORE

Nov 6, 2020 in Python by Gitika
• 65,910 points
797 views
0 votes
0 answers

Which python projects are good for beginner If I already know the basics very well?

Which python projects are good for beginner ...READ MORE

Nov 19, 2020 in Python by samar
• 120 points
266 views
0 votes
1 answer

The below code prints none at the end.

the code after return does not execute. ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
387 views
0 votes
1 answer

Tried setting up Django-shop on my system, but when I try to run pipenv install , I get this:404 Snippet not found

Uninstall all python first then install python ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,910 points
509 views
0 votes
0 answers

How to get output result from selecting two dropdown menu options in tkinter?

if i choose a value from first ...READ MORE

Sep 4, 2020 in Python by Charitra
• 120 points
3,529 views
0 votes
1 answer

How to Filter for empty or NULL names in a queryset?

Hello @kartik, You could do this: Name.objects.exclude(alias__isnull=True) If you need ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
4,721 views
0 votes
1 answer
0 votes
1 answer

Unable to access UserProfile model fields in templates in Django.

Use {{ request.user.get_profile.whatever }}. Django's templating language ...READ MORE

Nov 13, 2020 in Python by Gitika
• 65,910 points
438 views
0 votes
1 answer

How can I test if a string can be converted to another type dynamically?

You can use isinstance() function to check ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
311 views
0 votes
1 answer

Deployed Django project on heroku But I don't know which database is it using. Is there a way to know that So that I can login to admin page?

If you don't configure one you might ...READ MORE

Nov 12, 2020 in Python by anonymous
• 65,910 points
436 views
0 votes
1 answer

While debugging in visual studio it runs but it doesn't show any error

You're sending infinitely increasing data. Maybe it's ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
277 views
0 votes
2 answers

module 'numpy' has no attribute 'unit8'

Hi@Ganesh, I think you are calling the wrong ...READ MORE

Sep 22, 2020 in Python by MD
• 95,440 points
2,576 views