Latest questions in Python

0 votes
0 answers

i want to ask that how can i run one file of python in another file in jupyter notebook

motion_detection.ipynb # Python program to implement # Webcam ...READ MORE

Dec 16, 2020 in Python by Ramsha
• 120 points
705 views
0 votes
1 answer

how easy is yaml to work with in python compared to json?

Hi, First thing YAML and JSON are not ...READ MORE

Dec 16, 2020 in Python by MD
• 95,440 points
636 views
0 votes
1 answer

python pycharm is not proper working

Hi, @Webinar, Are you getting any kind of ...READ MORE

Dec 14, 2020 in Python by Gitika
• 65,910 points
281 views
0 votes
0 answers

can't compare offset-naive and offset-aware datetimes

While I'm Trying to Compare Two dates ...READ MORE

Dec 12, 2020 in Python by Mohamed
• 170 points
1,621 views
0 votes
0 answers

how to solve this

from nsepy import get_history from datetime import date import ...READ MORE

Dec 12, 2020 in Python by Pawan
• 120 points
683 views
0 votes
0 answers

convert dictionary in python

can you please help me on this. ...READ MORE

Dec 10, 2020 in Python by Edureka
• 120 points
285 views
0 votes
1 answer

i am getting this error "TypeError: tuple indices must be integers or slices, not Database"

Hi, @Shabaj, Regarding your query, I hope this ...READ MORE

Dec 10, 2020 in Python by Gitika
• 65,910 points
901 views
0 votes
1 answer

There are some Error so resolve quickly

Hi@Aditya, It is working fine in my python ...READ MORE

Dec 9, 2020 in Python by MD
• 95,440 points
335 views
0 votes
1 answer

How to find local IP addresses using Python's stdlib?

Hello @kartik, Try this out: import socket s = socket.socket(socket.AF_INET, ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
763 views
0 votes
1 answer

How can I open multiple files using “with open” in Python?

Hello @kartik, Just replace and with , and you're done: try: ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
527 views
0 votes
1 answer

How can I use Python to get the system hostname?

Hello @Kartik, Use socket and its gethostname() functionality. This will get the hostname of ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
1,441 views
0 votes
1 answer

How do I change the working directory in Python?

Hello @kartik, use os.chdir like this: os.chdir("/path/to/change/to") By the way, if you ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
602 views
0 votes
1 answer

How to create a GUID/UUID in Python?

Hello @kartiK, If you need to pass UUID ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
1,707 views
0 votes
1 answer

How to make a password validator without the use of the any()?

Hi, @There, Regarding your query I would suggest ...READ MORE

Dec 8, 2020 in Python by Gitika
• 65,910 points
459 views
0 votes
1 answer

How do I detect whether a Python variable is a function?

Hello @kartik, You can import isfunction from the inspect module. >>> from inspect ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
434 views
0 votes
2 answers

How to Import a module from a relative path?

If i understand your question correct then ...READ MORE

Dec 14, 2020 in Python by Tanja84DK

edited Dec 15, 2020 1,296 views
0 votes
1 answer

How to get an absolute file path in Python?

Hello @kartik, Try this out: >>> import os >>> os.path.abspath("mydir/myfile.txt") 'C:/example/cwd/mydir/myfile.txt' Also ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
600 views
0 votes
1 answer

How to check if type of a variable is string?

Hello @kartik, You can do: var = 1 if type(var) ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
410 views
0 votes
1 answer

How to print an exception in Python?

Hello @kartik, For Python 2.6 and later and ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
480 views
0 votes
1 answer

'NoneType' object has no attribute 'text

Hello @Muhammad Umer, As per the Beautiful Soup Documentation: AttributeError: ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
26,678 views
0 votes
1 answer

How do I copy a file in Python?

from shutil import copyfile copyfile(src, dst) Copy the contents ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
382 views
0 votes
1 answer

How do I remove/delete a folder that is not empty?

import shutil shutil.rmtree('/folder_name') By design, rmtree fails on folder trees containing ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
1,071 views
0 votes
1 answer

List changes unexpectedly after assignment. How do I clone or copy it to prevent this?

With new_list = my_list, you don't actually have ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
718 views
0 votes
1 answer

How to delete a file or folder?

os.remove() removes a file. os.rmdir() removes an empty directory. shutil.rmtree() deletes a ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
320 views
0 votes
1 answer

How do I copy a file in Python?

from shutil import copyfile copyfile(src, dst) Copy the ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
345 views
0 votes
0 answers

I need id by objects

Hello geeks: Here is my models:    class Room_Type(models.Model): """Django data ...READ MORE

Dec 5, 2020 in Python by Mohamed
• 170 points
303 views
0 votes
1 answer

pip install mysql-python fails with EnvironmentError: mysql_config not found

It seems mysql_config is missing on your ...READ MORE

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

How to install packages using pip according to the requirements.txt file from a local directory?

This works for me: $ pip install -r ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,910 points
5,229 views
0 votes
1 answer

How to find which version of package is installed with pip?

As of pip 1.3, there is a pip show command. $ ...READ MORE

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

How to uninstall a package installed with pip install --user?

Having tested this using Python 3.5 and ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,910 points
16,843 views
0 votes
1 answer

What is the easiest way to remove all packages installed by pip?

I've found this snippet as an alternative ...READ MORE

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

How to make function decorators and chain them together?

Here is what you asked for: from functools ...READ MORE

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

Getting the last element of a list

some_list[-1] is the shortest and most Pythonic. In fact, ...READ MORE

Dec 3, 2020 in Python by anonymous
• 65,910 points
328 views
0 votes
1 answer

How to find the index of an item in a list?

One thing that is really helpful in ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
1,184 views
0 votes
1 answer

How do I concatenate two lists in Python?

You can use the + operator to combine them: listone ...READ MORE

Dec 3, 2020 in Python by anonymous
• 65,910 points
366 views
0 votes
1 answer

How do you split a list into evenly sized chunks?

Here's a generator that yields the chunks ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
755 views
0 votes
1 answer

Install a Python package into a different directory using pip?

Use: pip install --install-option="--prefix=$PREFIX_PATH" package_name You might also want ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
1,886 views
0 votes
1 answer

How to invoke a python static method inside class via string method name?

Use __import__ function to import the module by giving ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
951 views
0 votes
1 answer

How to invoke a function on an object dynamically by name?

Use "getattr":  obj = MyClass() try: ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
3,660 views
0 votes
1 answer

How do I check if a string is a number (float)?

I'm not sure that anything much could ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
554 views
0 votes
1 answer

How to determine a Python variable's type?

Use the type() builtin function: >>> i = 123 >>> type(i) <type ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
315 views
0 votes
1 answer

How to know if an object has an attribute in Python?

Try hasattr(): if hasattr(a, 'property'): a.property The ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
423 views
0 votes
1 answer

Static methods in Python?

Yep, using the static method decorator class MyClass(object): ...READ MORE

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

Limiting floats to two decimal points?

You are running into the old problem with floating-point ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
3,244 views
0 votes
1 answer

Why is it string.join(list) instead of list.join(string)?

It's because any iterable can be joined ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
513 views
0 votes
1 answer

How to randomly select an item from a list?

Use random.choice() import random foo = ['a', 'b', 'c', 'd', ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
497 views
0 votes
1 answer

Webscraping error using your code

Hi, @Shrinidhi, Kindly share your code snippet with ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,910 points
437 views
0 votes
1 answer

python code for fall detection of a video file

Hello @Aruna, You can refer this for your ...READ MORE

Dec 2, 2020 in Python by Niroj
• 82,880 points
867 views