Most viewed questions in Python

0 votes
1 answer

How to hide a window in the constructor immediately after creation?

You can use QtCore.QTimer class Example(QWidget):     def __init__(self, app):         QWidget.__init__(self)         QTimer.singleShot(0, ...READ MORE

Apr 17, 2018 in Python by anonymous
616 views
0 votes
0 answers

How to handle notifications in Python with selenium windows Chrome Webdriver

Good day, I am kid trying to ...READ MORE

Sep 11, 2020 in Python by Kgohlopo
• 120 points
615 views
0 votes
1 answer

How can I find script's directory with Python?

Hii, You need to call os.path.realpath on __file__, so that when __file__ is ...READ MORE

May 11, 2020 in Python by Niroj
• 82,880 points
615 views
0 votes
1 answer

How to read/process command line arguments?

The canonical solution in the standard library ...READ MORE

Jun 4, 2018 in Python by aryya
• 7,450 points
615 views
0 votes
1 answer

DataFrame slicing in Python

You can use criteria based subset for ...READ MORE

Jul 15, 2019 in Python by Sakra
614 views
+1 vote
1 answer

Can installin pip for python install dependencies aswell?

As long as the dependency is listed ...READ MORE

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

Python class inherits object

Python 3.x: class MyClass(object): = new-style class class MyClass: = new-style ...READ MORE

Aug 30, 2018 in Python by Priyaj
• 58,090 points
614 views
0 votes
0 answers

Python - TypeError: 'int' object is not iterable

Here's my code: import math print("Hey, lets solve Task ...READ MORE

Dec 21, 2022 in Python by erzan
• 630 points
613 views
0 votes
1 answer

How to rename columns in pandas?

Hi,  To rename columns in pandas, you can ...READ MORE

Aug 9, 2019 in Python by Taj
• 1,080 points
613 views
0 votes
1 answer

How to read a large file, line by line, in Python?

The correct, fully Pythonic way to read ...READ MORE

Jul 1, 2019 in Python by SDeb
• 13,300 points
613 views
0 votes
1 answer

Understanding Python's slice notation

It's pretty simple really: a[start:end] # items start ...READ MORE

Oct 25, 2018 in Python by SDeb
• 13,300 points
613 views
0 votes
1 answer

Need help with searching a binary search tree

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

Apr 17, 2018 in Python by anonymous
613 views
0 votes
1 answer

Deleting elements from numpy array

Use the following code: import numpy as np a=np.array([1,2,3,4]) b=np.delete(a,2) OUTPUT: array([1, ...READ MORE

Jun 24, 2019 in Python by Fata
• 1,050 points

edited Jun 25, 2019 by Kalgi 612 views
0 votes
1 answer

How can I represent an Enum in Python?

Here is one implementation: class Enum(set): ...READ MORE

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

How can I rename files on the fly using Python?

You could simply use a wrapper object ...READ MORE

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

Unable to take input from user in Python

num = input("enter number") print(num) READ MORE

May 1, 2018 in Python by aayushi
• 750 points
612 views
0 votes
1 answer

Reverse a string in Python

>>> 'hello world'[::-1] 'dlrow olleh' This is extended slice syntax. It ...READ MORE

Feb 15, 2022 in Python by CoolCoder
• 4,400 points
611 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
611 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
611 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
611 views
0 votes
3 answers

How to add a new item to a dictionary in Python?

There is no add() , append() , or insert() method ...READ MORE

Jan 4, 2021 in Python by Reshma
610 views
0 votes
1 answer

How do I run a set of code for all the requests in Flask?

Hi, You can use dedicated hooks(decorators) called before ...READ MORE

Jun 21, 2019 in Python by Shabnam
• 930 points
610 views
0 votes
1 answer

How do I turn a list into numpy array?

Use this line: numpy_array = np.array(list) And printing/displaying the ...READ MORE

May 24, 2019 in Python by Isha
610 views
0 votes
1 answer

How do I check if a list is empty?

You can try the following: if not a:   print("List ...READ MORE

Mar 14, 2019 in Python by SDeb
• 13,300 points
610 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
610 views
0 votes
0 answers

I am trying to build a pong game this is what they showed me.

import turtle wn = turtle.Screen() wn.bgcolor("blue") wn.tracer(0) #Paddle A paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.shape("square") paddle_a.color("red") paddle_a.ShapeSize paddle_a.penup() paddle_a.goto(-350, ...READ MORE

May 23, 2020 in Python by Praise
• 120 points

edited May 25, 2020 by Gitika 609 views
0 votes
1 answer

What does the map() method do in Python?

The map() function in Python is a ...READ MORE

Jun 17, 2019 in Python by anonymous
609 views
0 votes
1 answer

Normal Python code equivalent to given list comprehension

You can try this code list1=[] for i in ...READ MORE

Jun 8, 2018 in Python by jain12
• 170 points
609 views
0 votes
1 answer

Merge two dicts

dict3 = dict1.copy() # merges ...READ MORE

Apr 27, 2018 in Python by Nietzsche's daemon
• 4,260 points
609 views
0 votes
2 answers

Replacements for switch statement in Python?

The recommended path for Python 3.10 which ...READ MORE

Feb 9, 2022 in Python by Soham
• 9,700 points
608 views
0 votes
1 answer

How to remove the duplicate values in a list?

a = [10,20,30,40,10,20,30,40,30,40,50,60] s = set(a) c = list(s) print(c) this ...READ MORE

Mar 20, 2019 in Python by Mohammad
• 3,230 points
607 views
0 votes
1 answer

How to convert string to date in python with different algorithms ?

Hello @ pagarsach, You can convert a string to ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
606 views
0 votes
0 answers

I am trying to click the button but it is not working and it is drop list ..

<a class="quickreports btn btn3d tbbtn" href="javascript:" style="position:static" ...READ MORE

Dec 2, 2019 in Python by anonymous
• 120 points
606 views
0 votes
0 answers

pass optional or keyword parameters from one function to another in python?

How can I pass optional or keyword ...READ MORE

Jul 24, 2019 in Python by Hari
606 views
0 votes
1 answer

Examples for string find in Python

you can use str.index too: >>> 'sdfasdf'.index('cc') Traceback ...READ MORE

Aug 29, 2018 in Python by Priyaj
• 58,090 points
606 views
0 votes
0 answers

How to make abstract classes in python?

How do you make a class, abstract ...READ MORE

Aug 26, 2019 in Python by Waseem
• 4,540 points
605 views
0 votes
1 answer

How to start IDLE in windows?

It comes with the official python setup. ...READ MORE

Aug 19, 2019 in Python by Mohammad
• 3,230 points
604 views
0 votes
1 answer

Hive client for Python 3.x

If you have HiveServer2 installed you can ...READ MORE

May 29, 2019 in Python by SDeb
• 13,300 points
604 views
0 votes
0 answers

what is the use of args and kwargs in python?

can you an example for each? READ MORE

May 11, 2019 in Python by Waseem
• 4,540 points
603 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
603 views
0 votes
1 answer

Numpy data in csv

Use this -  numpy.savetxt("data.csv", arr, delimiter=",") READ MORE

Jul 3, 2018 in Python by Hamartia's Mask
• 1,580 points
601 views
0 votes
1 answer

Is there a built-in module to handle excel files in python?

You can use the module - openpyxl ...READ MORE

Aug 19, 2019 in Python by Mohammad
• 3,230 points
600 views
0 votes
1 answer

Persisting data in sklearn

If you want to find some fixed ...READ MORE

Jul 10, 2019 in Python by SDeb
• 13,300 points
600 views
0 votes
1 answer

Pytype checker funtion

Pytype checks and infers types for your ...READ MORE

Jun 7, 2019 in Python by Fez
599 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

Reverse a string in Python

How about: >>> 'hello world'[::-1] 'dlrow olleh' This is ...READ MORE

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

Install virtualenv - python

Follow these steps to install virtualenv on ...READ MORE

Oct 7, 2019 in Python by Harshit
596 views
0 votes
1 answer

What data format for large files in R?

Zipping won't help you, as you'll have ...READ MORE

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

How can I install tensorflow?

If you are using the pycharm, you ...READ MORE

May 21, 2019 in Python by Mohammad
• 3,230 points
596 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
596 views