Trending questions in Python

0 votes
1 answer

What is the recommended way to randomize a list of strings using Python?

Hi. Nice question. Here is the simplified answer ...READ MORE

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

Understanding repr( ) function in Python

>>> x = 'foo' >>> x 'foo' So the name x is ...READ MORE

Sep 17, 2018 in Python by Priyaj
• 58,090 points
5,924 views
0 votes
1 answer

Pycharm warning: Must implement all abstract methods in Python. Why?

n vote As expected, python itself recognises that ...READ MORE

Nov 9, 2018 in Python by Nymeria
• 3,560 points
3,635 views
0 votes
1 answer

freopen() in python

sys.stdout is simply file object, so, you ...READ MORE

Jan 3, 2019 in Python by anonymous
1,242 views
–1 vote
1 answer

How to calculate difference in timestamp columns?

First, write the data in a csv file. Then ...READ MORE

Jan 19, 2019 in Python by Omkar
• 69,210 points
626 views
0 votes
1 answer

Size of an open file object

You can use the following and try ...READ MORE

Jan 22, 2019 in Python by SDeb
• 13,300 points
381 views
0 votes
2 answers

Help me solve the code

The fetchone() method fetches the result of ...READ MORE

Jan 9, 2019 in Python by Omkar
• 69,210 points
697 views
+1 vote
1 answer

Index of predicted wrong data in Keras, how to find it?

Simply, use: model.predict() pred = model.predict(x_test) indices = [i for ...READ MORE

Sep 28, 2018 in Python by Priyaj
• 58,090 points
5,349 views
0 votes
0 answers

Is there any module in Python that I can use for Wiki markup?

Hi all, simple question. Is there any ...READ MORE

Jan 22, 2019 in Python by Anirudh
• 2,080 points
424 views
0 votes
2 answers

How do I connect to a MySQL Database in Python?

connect mysql database with python import MySQLdb db = ...READ MORE

Mar 28, 2019 in Python by rajesh
• 1,270 points
1,608 views
0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

Jan 2, 2019 in Python by Omkar
• 69,210 points
1,177 views
0 votes
1 answer

Is there any way to write native apps for Windows, Blackberry, Android and Apple devices using Python?

Hi, This is an amazing Python framework just ...READ MORE

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

Python equivalent for static variables within a function?

You can use the following code, that ...READ MORE

Oct 17, 2018 in Python by Priyaj
• 58,090 points
4,481 views
0 votes
1 answer

How to install OpenCV for python3 in Ubuntu?

I found this: https://pypi.python.org/pypi/opencv-python OpenCV on wheels 'Unofficial OpenCV packages ...READ MORE

Nov 28, 2018 in Python by Nymeria
• 3,560 points
2,616 views
0 votes
1 answer

How do you get the logical xor of two variables in Python?

If you're already normalizing the inputs to ...READ MORE

May 29, 2018 in Python by aryya
• 7,450 points
10,474 views
0 votes
1 answer

How to use Euler's number and power operation?

You can refer the math library of ...READ MORE

Dec 31, 2018 in Python by SDeb
• 13,300 points
1,111 views
0 votes
1 answer

Python Print lines for the closest timestamp of the event

Try this: import re import os import datetime from datetime import ...READ MORE

Jan 2, 2019 in Python by Omkar
• 69,210 points
980 views
0 votes
2 answers

Error: Speech to Text Codec cannot decode the bytes in position

import speech_recognition as sr r = sr.Recognizer() audio ='C\Users\Desktop\audiofile1.wav' with ...READ MORE

Nov 28, 2018 in Python by Nabarupa Das
2,480 views
0 votes
0 answers

How to implement multiple try codes in a single block using Python?

Hi all, As per the title, I am ...READ MORE

Jan 14, 2019 in Python by Anirudh
• 2,080 points
463 views
0 votes
1 answer

ProgrammingError: not all arguments converted during string formatting

Sorted!!!! just found the solution, 1 - apparently ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
5,411 views
0 votes
1 answer

How to download intext images with beautiful soup

Ohh... I got what you need. Try this: html_data ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
5,404 views
0 votes
1 answer

Make a unix alias with python script

The scope of an alias command is the shell ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
5,327 views
0 votes
1 answer

difference between lists and sets

There are a lot more differences such ...READ MORE

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

How to traverse from a file to parse another file?

You use os.walk() module of python for ...READ MORE

Jan 2, 2019 in Python by Omkar
• 69,210 points
794 views
0 votes
1 answer

How can I use indices in math using python

Operator ^ is a bitwise operator, which does "bitwise exclusive or". More: http://wiki.python.org/moin/BitwiseOperators The ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
1,742 views
0 votes
1 answer

How can I define a multidimensional array in python using ctype?

Here's one quick-and-dirty method: >>> A = ((ctypes.c_float ...READ MORE

Oct 9, 2018 in Python by aryya
• 7,450 points
4,436 views
0 votes
1 answer

How to break for loop in an if statement

You can break out of each loop ...READ MORE

Nov 16, 2018 in Python by Jino
• 5,820 points
2,730 views
0 votes
1 answer

Declare variable without assigning any value in Python?

var = None Python is dynamic, so you ...READ MORE

Oct 29, 2018 in Python by Priyaj
• 58,090 points
3,462 views
0 votes
1 answer

Why there is no do while loop in python

There is no do...while loop because there ...READ MORE

Aug 6, 2018 in Python by Priyaj
• 58,090 points
7,083 views
0 votes
1 answer

Need help installing easy_install in Python 2.7.1 on Windows 7

That tool is part of the setuptools ...READ MORE

Dec 26, 2018 in Python by Nymeria
• 3,560 points
951 views
+2 votes
1 answer

How can I record the X,Y limits of a displayed X,Y plot using the matplotlib show() module?

A couple hours after posting this question ...READ MORE

Dec 27, 2018 in Python by anonymous
870 views
0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

Aug 27, 2018 in Python by Priyaj
• 58,090 points
6,152 views
0 votes
1 answer

popen.communicate in Python

Your second bit of code starts the ...READ MORE

Nov 13, 2018 in Python by Priyaj
• 58,090 points
2,778 views
0 votes
1 answer

Django form validation: making “required” conditional?

This is done with the clean method on the ...READ MORE

Aug 30, 2018 in Python by Priyaj
• 58,090 points
5,996 views
0 votes
1 answer

How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?

UPDATED: One way is to look at sys.maxsize as ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
1,531 views
0 votes
1 answer

Measuring the distance between pixels on OpenCv with Python

Assuming input frames will have "close to ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
5,412 views
0 votes
0 answers

How to read lines from compressed text files in Python

Is it easy to read a line ...READ MORE

Dec 27, 2018 in Python by Anirudh
• 2,080 points
754 views
0 votes
1 answer

Is Brython client side?

Brython itself seems to be completely client ...READ MORE

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

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

Nov 27, 2018 in Python by Nymeria
• 3,560 points
1,944 views
0 votes
1 answer

Read & write data in mifare card

Hi, you can check out the following ...READ MORE

Nov 29, 2018 in Python by SDeb
• 13,300 points
1,834 views
0 votes
1 answer

MemoryError binary data storage

The problem occurs when you are using ...READ MORE

Dec 26, 2018 in Python by SDeb
• 13,300 points
658 views
+1 vote
2 answers

Python string formatting: % vs. .format

Using Python format() function is what the ...READ MORE

Apr 11, 2019 in Python by Dasa Ravi
1,045 views
0 votes
1 answer

How to sort Counter by value using python?

Use the Counter.most_common() method, it'll sort the items for you: >>> ...READ MORE

May 23, 2018 in Python by charlie_brown
• 7,720 points
10,044 views
+3 votes
5 answers

is python compatible with Linux?

Just follow these three commands and you ...READ MORE

Sep 12, 2018 in Python by charlie_brown
• 7,720 points
1,630 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

Apr 8, 2019 in Python by rajesh
• 1,270 points
1,729 views
0 votes
1 answer

Avoid killing children when parent process is killed

I would recommend against your design as ...READ MORE

Sep 7, 2018 in Python by Priyaj
• 58,090 points
5,346 views
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

Mar 29, 2019 in Python by rajesh
• 1,270 points
1,654 views
0 votes
0 answers

Creating a mini language parser using Python

I'm planning to create a simple mini-language ...READ MORE

Dec 27, 2018 in Python by Anirudh
• 2,080 points
585 views
0 votes
1 answer

Return a list inside a for loop while iterating over the elements of another list

The print() is getting called multiple times ...READ MORE

Sep 22, 2018 in Python by SDeb
• 13,300 points
4,693 views
+3 votes
2 answers

Compiled vs Interpreted Languages

Compiled languages are written in a code ...READ MORE

Dec 3, 2018 in Python by allenvarna
• 540 points
5,110 views