Most voted questions in Python

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
436 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
397 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,281 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
546 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
515 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
458 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
880 views
0 votes
1 answer

I installed windows 10 through vmware workstation . I want to connect remote machine using python winrm im getting error

Hey, @Natraj, This basically means that no response ...READ MORE

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

AssertionError: <class 'numpy.ndarray'>

Same problem here bro! READ MORE

Dec 8, 2020 in Python by Bijoy
4,035 views
0 votes
1 answer

Are static class variables possible in Python?

Variables declared inside the class definition, but ...READ MORE

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

What is the difference between an abstract function and a virtual function?

An abstract function cannot have functionality. You're basically ...READ MORE

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

What is the difference between Python's list methods append and extend?

Appends object at the end. x = [1, ...READ MORE

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

Difference between __str__ and __repr__?

The default implementation is useless (it’s hard ...READ MORE

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

What is the difference between an interface and abstract class?

Interfaces An interface is a contract: The person writing ...READ MORE

Nov 30, 2020 in Python by Gitika
• 65,910 points
629 views
0 votes
0 answers

How to use create function instead of perform_create in ListCreateApiView in django rest framework

I am trying to create a booking ...READ MORE

Nov 30, 2020 in Python by anonymous
• 120 points
3,355 views
0 votes
1 answer

my Py Audio is not Downloading what should I do

Hello @S.P.D, First try to check your python ...READ MORE

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

can someone please help me with python?

Hello @ Anee, Code: num1 = int(input("Enter First Number: ")) num2 ...READ MORE

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

Error "Failed to load tensorflow runtime"

Hello, Try to downgrade protobuf, this worked for ...READ MORE

Nov 30, 2020 in Python by Niroj
• 82,880 points
389 views
0 votes
0 answers

Why I'm Getting ValueError?

Here is my code: import pandas as p import ...READ MORE

Nov 28, 2020 in Python by Rohan
• 200 points

edited Nov 30, 2020 by Niroj 472 views
0 votes
1 answer

fatal error: Python.h: No such file or directory

On Ubuntu, I was running Python 3 ...READ MORE

Nov 28, 2020 in Python by Gitika
• 65,910 points
3,935 views
0 votes
1 answer

What is the Python 3 equivalent of “python -m SimpleHTTPServer”

The SimpleHTTPServer module has been merged into http.server in Python 3.0. ...READ MORE

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

Extracting extension from filename in Python

Yes. Use os.path.splitext >>> import os >>> filename, file_extension = ...READ MORE

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

How to convert integer to string in Python?

if You Want to convert int to ...READ MORE

Nov 28, 2020 in Python by Rohan
• 200 points
584 views
0 votes
1 answer

Difference between python programing and scripting

Hi,@Sashi, Generally, all the scripting languages are considered ...READ MORE

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

How do I find the a referring sites URL in node?

Hii, In express 4.x: req.get('Referrer') This will also check both spellings of ...READ MORE

Nov 27, 2020 in Python by Niroj
• 82,880 points
2,353 views
0 votes
0 answers

How to create Personalised QR code using Python?

How to read and generate QR codes ...READ MORE

Nov 27, 2020 in Python by kartik
• 37,510 points
639 views
0 votes
1 answer

Python code for motion detection

Hey, @Sushruth, Here the code goes for Motion Detector.py import ...READ MORE

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

How do I get a substring of a string in Python?

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> ...READ MORE

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

How do you use a variable in a regular expression?

Instead of using the /regex/g syntax, you can construct ...READ MORE

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

How to print without newline or space?

In Python 3, you can use the sep= and end= parameters ...READ MORE

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

How to check if a string contains a substring in Bash?

string='My long string' if [[ $string == ...READ MORE

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

How to import other Python files?

Just import file without the '.py' extension. You can mark ...READ MORE

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

Check if a given key already exists in a dictionary?

in is the intended way to test for ...READ MORE

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

How can I get a list of locally installed Python modules?

Do not use with pip > 10.0! My ...READ MORE

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

Importing modules from parent folder

It seems that the problem is not ...READ MORE

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

ImportError: Import by filename is not supported

Instead of doing a import like __import__ you can ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
2,501 views
0 votes
1 answer

Does array element contain substring?

Loop through the $forbiddennames array and use stripos to check if ...READ MORE

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

How do I check if a string contains a specific word?

You can use the strpos() function which is used ...READ MORE

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

How to replace all occurrences of a string?

The general pattern is str.split(search).join(replacement) This used to be ...READ MORE

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

How to convert bytes to a string?

You need to decode the bytes object ...READ MORE

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

How to compare two string with some characters only in python?

You could use in to check if a string ...READ MORE

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

How to Test a string for a substring?

if "ABCD" in "xxxxABCDyyyy": ...READ MORE

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

How to determine whether a substring is in a different string [duplicate]

with in: substring in string: >>> substring = "please help ...READ MORE

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

How do I check if a given Python string is a substring of another one?

Try using in like this: >>> x = 'hello' >>> y ...READ MORE

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

Does Python have a string 'contains' substring method?

You can use the in operator: if "blah" not in ...READ MORE

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

How can I list txt files into the folder?

Hello @Mziko You can refer this:https://datatofish.com/txt-files-d ...READ MORE

Nov 26, 2020 in Python by Niroj
• 82,880 points
430 views
0 votes
0 answers
0 votes
2 answers

ImportError: No system module 'pywintypes' (pywintypes38.dll)

I just copied the DLL pywintypes27.dll in C:\Python27\Lib\site-packages\pywin32_system32. I added it ...READ MORE

Nov 25, 2020 in Python by Roshni
• 10,520 points
4,928 views
0 votes
2 answers

AttributeError: '<invalid type>' object has no attribute 'pen' on line 2

Hello, Turtle.pen is used to set/get pen attributes ...READ MORE

Nov 25, 2020 in Python by Niroj
• 82,880 points
3,609 views
0 votes
0 answers

hello guys i need help to make this code run plz !

H= float (input("Is this circuit charging& ...READ MORE

Nov 25, 2020 in Python by anonymous
• 120 points
352 views