Latest questions in Python

0 votes
1 answer

In LightFM does the training set need to be the same size as the test set?

I would change the wording. Often in ML, ...READ MORE

Sep 21, 2018 in Python by charlie_brown
• 7,720 points
465 views
0 votes
1 answer

How to get a Mongoengine's object id in a flask program

Check out the documentation, Document.objects is a QuerySet object. You seem to be ...READ MORE

Sep 21, 2018 in Python by charlie_brown
• 7,720 points
2,821 views
0 votes
1 answer

Measuring the distance between pixels on OpenCv with Python

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

Sep 21, 2018 in Python by Priyaj
• 58,090 points
2,415 views
0 votes
1 answer

Pyomo parallel processing to solve an instance

Depends on the solver and the model. ...READ MORE

Sep 21, 2018 in Python by Priyaj
• 58,090 points
1,760 views
0 votes
1 answer

Restart python script automatically even when it crashes in Linux

Maybe this would be more robust? 1) save ...READ MORE

Sep 21, 2018 in Python by Priyaj
• 58,090 points
3,743 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

Sep 21, 2018 in Python by Priyaj
• 58,090 points
2,160 views
0 votes
1 answer

Comparing two files contents in python

This code should work for you: It ...READ MORE

Sep 21, 2018 in Python by Priyaj
• 58,090 points
538 views
+1 vote
1 answer

Quicksort in Python

The following code may solve your problem: def ...READ MORE

Sep 20, 2018 in Python by SDeb
• 13,300 points
537 views
0 votes
1 answer

Key error in Python

A KeyError occurs when the Key doesn't ...READ MORE

Sep 20, 2018 in Python by SDeb
• 13,300 points
1,314 views
0 votes
1 answer

Comparing two files contents in python

Considering your file "Unique.txt" does just containt the IP ...READ MORE

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

Python while sampling

I would say, this could be your ...READ MORE

Sep 20, 2018 in Python by Priyaj
• 58,090 points
343 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,428 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,408 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,345 views
0 votes
1 answer

Is there a way to run Python on Android?

YES! An example via Matt Cutts via SL4A -- "here’s ...READ MORE

Sep 19, 2018 in Python by Priyaj
• 58,090 points
844 views
0 votes
1 answer

How can I build a recursive function in python?

I'm wondering whether you meant "recursive". Here ...READ MORE

Sep 19, 2018 in Python by Priyaj
• 58,090 points
877 views
0 votes
1 answer

Python - abs vs fabs

math.fabs() converts its argument to float if it ...READ MORE

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

how to exit a python script in an if statement

Instead of using the normal UTF-8 encoding, ...READ MORE

Jul 4, 2023 in Python by bodymist
• 140 points
350,192 views
0 votes
1 answer

How does the @property decorator work?

The property() function returns a special descriptor object: >>> property() <property object ...READ MORE

Sep 19, 2018 in Python by Priyaj
• 58,090 points
1,462 views
0 votes
1 answer

What are the ternary conditional operator in Python?

The Ternary Conditional operator was added in ...READ MORE

Sep 19, 2018 in Python by SDeb
• 13,300 points
573 views
0 votes
1 answer

comparing strings in Python using "==" or "is" [closed]

is is used for identity testing and ...READ MORE

Sep 19, 2018 in Python by SDeb
• 13,300 points
622 views
0 votes
1 answer

How does Python know whether a variable in the class is a method or a variable?

In python objects/variables are wrapped into methods ...READ MORE

Sep 18, 2018 in Python by aryya
• 7,450 points
974 views
0 votes
1 answer

How to extract or split characters from number strings using Pandas?

You could just simply use a conversion ...READ MORE

Sep 18, 2018 in Python by aryya
• 7,450 points
1,861 views
0 votes
1 answer

Print C format in Python

For printf- style formatting and special case ...READ MORE

Sep 18, 2018 in Python by SDeb
• 13,300 points
810 views
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

Sep 18, 2018 in Python by SDeb
• 13,300 points
2,118 views
+3 votes
2 answers

How do I install pip on Windows?

pip is already installed if you are ...READ MORE

Nov 2, 2018 in Python by Priyaj
• 58,090 points
1,015 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,618 views
0 votes
1 answer

Determine the type of an object?

To get the type of an object, ...READ MORE

Sep 18, 2018 in Python by Priyaj
• 58,090 points
585 views
0 votes
1 answer

How to add python console in spyder

(Spyder developer here) The Python console was ...READ MORE

Sep 18, 2018 in Python by Priyaj
• 58,090 points
4,690 views
0 votes
1 answer

Writing unit tests in Python: How do I start?

If you're brand new to using unittests, ...READ MORE

Sep 18, 2018 in Python by Priyaj
• 58,090 points
756 views
0 votes
1 answer

How to write "not equal" in python?

The keywords is and is not are ...READ MORE

Sep 18, 2018 in Python by SayantiniDeb
• 200 points
2,204 views
0 votes
1 answer

__init__ and self in python

The self variable represents an instance of ...READ MORE

Sep 18, 2018 in Python by SayantiniDeb
• 200 points
715 views
0 votes
1 answer

What is getattr() exactly and how do I use it?

You can view a full example here: http://www.diveintopython.net/power_of_introspection/index.html Introspection ...READ MORE

Sep 17, 2018 in Python by bug_seeker
• 15,520 points
609 views
0 votes
1 answer

How can I print variable and string on same line in Python?

Use , to separate strings and variables while printing: print ...READ MORE

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

Creating a new dict in Python

Call dict with no parameters new_dict = dict() or simply write new_dict ...READ MORE

Sep 17, 2018 in Python by Priyaj
• 58,090 points
413 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,946 views
0 votes
1 answer

Raw_Input() Is Not Defined

For Python 3.x, use input(). For Python 2.x, ...READ MORE

Sep 17, 2018 in Python by Priyaj
• 58,090 points
1,279 views
0 votes
2 answers

difference between class and instance attributes

Apart from the performance, there is a ...READ MORE

Sep 17, 2018 in Python by SDeb
• 13,300 points
690 views
0 votes
0 answers

Boolean comparison in Python

I am trying to print false using ...READ MORE

Sep 17, 2018 in Python by ana1504.k
• 7,910 points
339 views
0 votes
2 answers

Avoiding multiple nested for-loops in python

Instead of multi-loop, If you can categorize ...READ MORE

Sep 15, 2018 in Python by pedro67657
• 160 points

edited Sep 15, 2018 by Vardhan 15,707 views
0 votes
1 answer

Modify int in place

Use a list rather than a tuple: my_container ...READ MORE

Sep 14, 2018 in Python by Priyaj
• 58,090 points
979 views
0 votes
1 answer

SKLearn NMF Vs Custom NMF

The choice of the optimizer has a ...READ MORE

Sep 14, 2018 in Python by Priyaj
• 58,090 points
569 views
0 votes
1 answer

Avoid killing children when parent process is killed

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

Sep 14, 2018 in Python by Priyaj
• 58,090 points
568 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

Sep 14, 2018 in Python by Priyaj
• 58,090 points
727 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
2,346 views
0 votes
1 answer

How to invoke method on GUI thread but without have that method in QMainWindow class (Pyqt)

It is possible to handle this by ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
2,459 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
687 views
0 votes
1 answer

Python: Issue with 'unexpected end of pattern'

I should start by stating that using ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
2,367 views
0 votes
1 answer

Balanced binary tree python

Instead of multiplying the number of nodes ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
602 views
0 votes
1 answer

How is Python 2.7.3 and Python 3.3 different?

raw_input() is not used in Python 3. Use input()  ...READ MORE

Sep 12, 2018 in Python by SDeb
• 13,300 points
685 views