Trending questions in Python

+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

Aug 24, 2018 in Python by Omkar
• 69,220 points
10,726 views
0 votes
1 answer

How to upgrade all packages using pip at once?

pip doesn’t have a default command for ...READ MORE

Jan 29, 2019 in Python by Omkar
• 69,220 points
1,655 views
0 votes
1 answer

How to enable python3 in vim?

You didn't tell us the platform you're ...READ MORE

Jan 21, 2019 in Python by SDeb
• 13,300 points
2,004 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,615 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
1,061 views
0 votes
1 answer

Empty while loop in Python

while file.readline().startswith("#"):     pass The pass statement does nothing. It ...READ MORE

Dec 5, 2018 in Python by SDeb
• 13,300 points
3,981 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

Apr 2, 2019 in Python by anonymous
6,042 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,220 points
1,368 views
0 votes
1 answer

Problem while using local dynamoDB container (Boto3 put_item error)

DynamoDB does not autogenerate the ID when ...READ MORE

Dec 3, 2018 in Python by charlie_brown
• 7,720 points
4,055 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
939 views
0 votes
1 answer

Path separator char in Python

There is an alternative way. you can ...READ MORE

Jan 4, 2019 in Python by SDeb
• 13,300 points
2,646 views
0 votes
1 answer

Confusion in Python Pandas code

I have added the explanation of code ...READ MORE

Jan 26, 2019 in Python by Omkar
• 69,220 points
1,726 views
0 votes
1 answer

How to convert string into epoch time?

you are passing the parsed datetime object to ...READ MORE

Sep 22, 2018 in Python by SDeb
• 13,300 points
7,162 views
+2 votes
1 answer

“OSError: Unable to open file (bad superblock version number)" in python h5py file read

File could indeed be opened on Linux ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,020 points
6,878 views
0 votes
1 answer

Python inheritance: TypeError: object.__init__() takes no parameters

You are calling the wrong class name ...READ MORE

Nov 15, 2018 in Python by Nymeria
• 3,560 points
4,786 views
0 votes
1 answer

K-means or Hierarchical clustering?

You can use hierarchical clustering for this ...READ MORE

Feb 14, 2019 in Python by Dinesh
865 views
0 votes
1 answer

Need help understanding python code

In this particular code, I think you ...READ MORE

Feb 19, 2019 in Python by Omkar
• 69,220 points
594 views
0 votes
2 answers

Why do we use return statement in python?

def maximum(x, y):     if x > y:     return x     else:    return ...READ MORE

Apr 4, 2019 in Python by anonymous
2,179 views
0 votes
1 answer

how to read a JSON from a file?

You can use with statement with open('strings.json') as ...READ MORE

Oct 24, 2018 in Python by Priyaj
• 58,020 points
5,626 views
0 votes
1 answer

What is logits, softmax and softmax_cross_entropy_with_logits in Python?

Suppose you have two tensors, where y_hat contains computed ...READ MORE

Nov 12, 2018 in Python by Nymeria
• 3,560 points
4,712 views
0 votes
1 answer

Command history in interactive Python

You can use the following to get ...READ MORE

Nov 27, 2018 in Python by SDeb
• 13,300 points
4,032 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
889 views
0 votes
1 answer

Shuffling a Word

You can try the following: import random word = ...READ MORE

Jan 30, 2019 in Python by SDeb
• 13,300 points
1,264 views
0 votes
1 answer

How to activate virtualenv in Python? Help!

One major issue I see is that ...READ MORE

Nov 5, 2018 in Python by Nymeria
• 3,560 points

edited Dec 17, 2018 by Nymeria 4,979 views
0 votes
0 answers
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,220 points
1,050 views
–1 vote
1 answer

Python pandas axis error

When you are applying sum() you don't ...READ MORE

Jan 8, 2019 in Python by Omkar
• 69,220 points
2,212 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,220 points
752 views
0 votes
1 answer

Need help displaying complete output in Jupyter rather than just last result set in Python

Hi, the solution to this is very ...READ MORE

Jan 28, 2019 in Python by Nymeria
• 3,560 points
1,288 views
0 votes
1 answer

Need help with custom authentication in the Google App Engine using Python

Good question. Django 1.0 was updated recently ...READ MORE

Jan 21, 2019 in Python by Nymeria
• 3,560 points
1,584 views
0 votes
0 answers

how to get mongoengine object id in flask program

i am using mongoengine to integrate with ...READ MORE

Oct 5, 2018 in Python by eatcodesleeprepeat
• 4,710 points
6,264 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
1,056 views
+1 vote
1 answer

What does the Raise keyword do in Python?

Hi! I think I can answer this - ...READ MORE

Jan 25, 2019 in Python by Nymeria
• 3,560 points
1,323 views
0 votes
1 answer

How to use HashMap in Python?

You can use Python dictionary it is a built-in type ...READ MORE

Oct 26, 2018 in Python by Priyaj
• 58,020 points
5,271 views
0 votes
1 answer

Run python script on terminal (ubuntu)?

Your shell in the terminal has a concept ...READ MORE

Oct 31, 2018 in Python by Priyaj
• 58,020 points
5,043 views
0 votes
1 answer

Number of private variables in class

In Python, there is no existence of ...READ MORE

Feb 13, 2019 in Python by Prateek
484 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
852 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,220 points
745 views
0 votes
1 answer

How can I prevent or alter access to class variables in Python?

The ActiveState solution that Pynt references makes instances of ...READ MORE

Dec 5, 2018 in Python by aryya
• 7,460 points
3,454 views
0 votes
1 answer

Issue creating S3 Bucket Python

Hello @Suraj, There is an indentation issue, >>> ...READ MORE

Jan 18, 2019 in Python by Priyaj
• 58,020 points
1,538 views
0 votes
1 answer

Need help with Django URL string parameter pattern in Python

Good question. The solution to this short ...READ MORE

Jan 28, 2019 in Python by Nymeria
• 3,560 points
1,115 views
0 votes
1 answer

Can someone help me understand timedelta in Python?

Because timedelta is defined like: class datetime.timedelta([days,] [seconds,] ...READ MORE

Jan 16, 2019 in Python by charlie_brown
• 7,720 points
1,619 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,220 points
827 views
+2 votes
2 answers

Job roles for Python

Hey, Python Developer responsibilities include writing and testing ...READ MORE

May 16, 2019 in Python by Gitika
• 65,770 points
1,337 views
0 votes
1 answer

Need help referencing Python Package when the filename consists of a period key

Hi, it's a very simple answer actually.  You ...READ MORE

Jan 25, 2019 in Python by Nymeria
• 3,560 points
1,225 views
0 votes
1 answer

Get path from open file in Python

The key here is the name attribute ...READ MORE

Jan 16, 2019 in Python by SDeb
• 13,300 points
1,604 views
0 votes
1 answer

Error Code installing Scrapy

You can install it via pip wheel. Download ...READ MORE

Jan 17, 2019 in Python by SDeb
• 13,300 points
1,539 views
0 votes
1 answer

Python if not == vs if !=

Using dis to look at the bytecode ...READ MORE

Jan 29, 2019 in Python by SDeb
• 13,300 points
1,032 views
0 votes
1 answer

How to calculate time interval between two time strings in Python

Try doing this - It is efficient for ...READ MORE

Nov 29, 2018 in Python by Nymeria
• 3,560 points

edited Dec 11, 2018 by Nymeria 3,630 views
0 votes
1 answer

difference between "*" and "**"

The "**" operator is used for 'power ...READ MORE

Nov 19, 2018 in Python by SDeb
• 13,300 points
4,043 views