Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
4
votes2
answers84
viewsConflict between Jinja and Handlebars
How do I resolve a conflict between Handlebars and Jinja, since the syntax of both are similar?
-
4
votes3
answers1189
viewsPython NLTK method that returns a syntactic tree
I’m using the NLTK Forest library and I saw there that has some sentences with parse (syntactic tree) already created. However, I would like a method that from a new phrase it creates the parse in…
-
4
votes1
answer202
viewsUnexpected Error using parse_args() function of the Argumentparser object in Python
In a simple code I’m doing in Python, I get the exception below, when I call the function parser_args() on the type object ArgumentParser: Unexpected error: (<type 'exceptions.SystemExit'>,…
-
4
votes1
answer1003
viewsError: [Errno 2] No such file or directory
Good afternoon, I’m trying to emulate an IBM 3270 using the py3270 lib, but I’m making a mistake by staging the Emulator class of this lib. Anyone have any idea what it might be? from py3270 import…
pythonasked 9 years, 1 month ago Rafael Galleani 41 -
4
votes3
answers655
viewsHow to use a dictionary value to call a specific Python function?
I’m trying to use a dictionary to identify each function to a value, and call them over the program. My code is below (example): #!/usr/bin/env python menuOpt = { 1 : "valor", } #Main if __name__ ==…
-
4
votes2
answers1077
viewsImplement abstract method in Python inheritance
Be the following class hierarchy, where class "A" has an abstract method called "foo": # -*- coding: utf-8 -*- import abc class A: __metaclass__ = abc.ABCMeta def __init__(self): pass…
-
4
votes3
answers16117
viewsHow to transform a string composed of numbers into an integer list?
I have a list with a string: a = ["1, 2, 3, 4"] I want to take each number inside that list, turn them into integers, and return the highest and lowest value of that list. I’ve tried this with the…
-
4
votes3
answers23189
viewsRecursive and iterative function that calculates the factorial from 1 to n
Good people, wanted help with an exercise: It asks to create a function that calculates the factorial of the numbers from 1 to n. I already have the recursive part, but I don’t know how to make it…
-
4
votes1
answer1203
viewsSend . txt file from one pc to another using http service
I need to send a file from one PC to another over the network, only using requests http, so I don’t have to lower the level of socket, that takes work. Someone enables me to clear up with some API…
-
4
votes5
answers322
viewsPython how to print output
How can I print a list this way, example: l=[4,26,32] I want to print the output as follows: 4 26 32 No comma and a blank space on the same line. Grateful from now on.…
-
4
votes1
answer13184
viewsassignment list index out of range
Part of my Python program is: dt=1 maxt=3600*2 t=range(0,maxt,dt) r=len(t) Tsup_i=20 for i in range(1,r): Tsup[0]=Tsup_i P[i]=((I_dc)**2) * R20 * (1 + a * (Tsup[i] - (20+K))) And the error is…
-
4
votes3
answers1388
viewsMinimum search from a list ignoring zero values
I have a list of values with zero elements and elements other than zero and I wanted to return the lowest value of the list and its Index, but ignoring the zeroes, that is, the fact that there are…
-
4
votes6
answers41177
viewsHow to find the position of an item on a list?
I am writing a program that takes a specific amount of values, and returns the lowest value of the list and its position. It is as follows: quantidade = int(raw_input()) numeros = raw_input()…
-
4
votes2
answers156
viewsWhat to use instead of "-use-mirrors" in the PIP?
When running the following command I get the following answer: sudo pip install --use-mirrors -r test-infra/requirements.txt Usage: pip install [options] <requirement specifier>…
-
4
votes2
answers3669
viewsDecoding of file in Python
I have a file that is completely written like this after my Crawler also written in Python has saved the data in it: b'N\xc3\xa3o n\xc3\xa3o n\xc3\xa3o, n\xc3\xb3s iremos sim!' I wonder if there is…
-
4
votes1
answer5773
viewsHow to specify values for my x-axis using matplotlib.pyplot?
I am unable to specify values for my x-axis, using matplotlib.pyplot. In some images the chart.xticks(years) solves the problem, but it seems that when the x-axis value set is too small, it uses…
-
4
votes1
answer3028
viewsHow to create more than one graph in matplotlib?
I need to create graphs of histograms in python with lists resulting from transformations. My doubt is that whenever I run the program, the next image only appears after I close the previous one.…
-
4
votes1
answer334
viewsProblems importing cx_oracle in python 3.4 64 bits
I have a problem with cx_oracle in 64 bit python. I installed this version of cx_oracle: cx_Oracle-5.2.1-11g. win-amd64-py3.4. But when importing in python import cx_Oracle, the following error…
-
4
votes1
answer123
viewsList compreension vs ciclo for
I have the following code segments: def is_even(num): if(num % 2 == 0): return True return False 1. lista = range(50) pares = [i for i in lista if is_even(i)] # pares = [0, 2, 4, 6, 8...] 2. lista =…
-
4
votes1
answer86
viewsHow to get an end list for the start?
Opening lists: B_I = ['Cab', 'Bou', 'Bou', 'RFF', 'RF1', 'Rf2', 'Cor'] Ba_F = ['Bou', 'Zez1', 'Zez2', 'Praca', 'Sro', 'Sro', 'Falag'] Then I did ........ Final=[] #lista com todos os barramentos sem…
-
4
votes1
answer1118
viewsDiscover common elements in multiple lists
I have the following code: list1 = ['a', 'x', 'c', 'b', 'm'] list2 = ['f', 'x', 'a', 'c'] list3 = ['c', 'e', 'x', 'b', 'p', 'k', 'l'] How do I discover the common elements so that you have a list…
pythonasked 8 years, 8 months ago Alberto Pimenta 169 -
4
votes2
answers138
viewsDoubt with Python+Django
I’m starting with Python and Django, following a tutorial I found: https://docs.djangoproject.com/en/1.9/intro/tutorial01/ When I execute the command django-admin With startproject, it doesn’t…
-
4
votes2
answers1117
viewsHow do I return a new instance of the python class itself dynamically inside it?
I’m giving a study in Python and for this I am building a class in Python that I had already done in PHP. For example, in a given method in PHP I needed to return the same instance of the class,…
-
4
votes1
answer1956
viewsWhile timer in Python
How to make a timer in while? I would like to run a while, and do something, e.g. a print "hello" run print "hello" for 1 hour for example.
-
4
votes1
answer266
viewsHow to execute arbitrary code in Python?
I use an xbase language that has macro substitution as in the original Clipper. Is there anything equivalent in Python? We use a lot of command line assembly via menus at runtime. For example,…
-
4
votes1
answer1502
viewsCheck if there is a file if there is a report of PYTHON Blibioteca > . os
Check if the folder no longer exists, if it exists, you should print a message to the user indicating. I got stuck not knowing how to check on something related to this : os.listdir() os.mkdir…
-
4
votes1
answer1665
viewsHow to get the HOST IP through the PYTHON domain?
In PHP, to get the ip of a given domain, I usually use the function gethostbyname. PHP example: gethostbyname('www.google.com'); //201.17.165.210 And in Python? How can I do this?…
-
4
votes2
answers78
views"Permissive" regular expression to detect extensions and allowed hosts
i have a list with some links https://www.exemplo.com/ https://www.exemplo.com/home/ https://www.exemplo.com/logo.png https://intranet.exemplo.com/ https://admin.exemplo.com/login…
-
4
votes1
answer2424
viewsrunning split() to form a list within another list
have the following list: [['a:/, b:/, w:/, g:/, f:/, d:/Downloads/Torrent/End, x:/files.2t, y:/files.1t'], ['d:/Dropbox/project/rato_bat'], ['data']] however I would like it to be a list within…
-
4
votes1
answer153
viewsHow to write fields with sqlite3 accent via Python?
Hi, guys! I’m making a small program in python and using sqlite3 to save the database. The program is entering, reading and deleting data in the database called "position". I wonder if there’s a way…
-
4
votes1
answer1158
viewsDropdown dependent on each other
I’m using a function taken from this site: https://github.com/nodet07/Django-Related-DropDowns The function works perfectly, when I select an option in a dropdown, in the 2nd Dropdown already brings…
-
4
votes1
answer5651
viewsHow to take screenshot of the screen in Python?
I would like to make a program that screenshots the screen ( screen photo) in Python. I found the following code: import pyscreenshot as ImageGrab if __name__ == "__main__": # fullscreen…
-
4
votes1
answer3781
viewsIDE for Python that has GUI modeling
I wanted to know if there is a IDE for programming in Python that provides a tool for mounting a GUI more easily, in advance that has versions for Linux and Windows.
-
4
votes1
answer231
viewsError installing Python Polyglot package by Pip
I am trying to install this package/module by Pip and I am not able to find the solution. Follows Traceback: C:\Users\chris>pip install polyglot Collecting polyglot Using cached…
pythonasked 8 years, 6 months ago Christian Felipe 628 -
4
votes1
answer170
viewsProblems with python code in file i/o
Hello, I’m beginner in python, I’m programming in 3.5.1, I was doing a snippet of code that reads and then removes a line from a file: lista = {} # Essa função lê o arquivo e divide ele em linhas,…
-
4
votes2
answers337
viewsData entry without echoing on screen
entrada = input("digite a senha") If I use the function input, what the user keystrokes will be echoed on the screen. How to do so so that nothing is shown on the screen?…
-
4
votes1
answer3476
viewsHow to put elements of a list in another list
I have the following code: a = list() b = list() c = list() a = (1,2,3) b = (2,4,6) c = a + b[1] print(c) How do I add an element from a list to another list?…
-
4
votes2
answers3574
viewsAbstract Python class, how to choose implementation
I’m learning python and trying to make a program where I have an abstract class and two subclasses that implement such. I need to make another class that will choose which implinking to use…
-
4
votes1
answer9644
viewsHow to copy a Python file?
How to copy a file fonte to an archive destino in Python?
-
4
votes1
answer260
viewsHow to install Python 3
I’m new to Ubuntu and I’m learning Python. I have installed on my pc Pyhton 2.7.12 and would like to know how I do to upgrade to version 3. I’m taking a course where I need to use a lib. import…
-
4
votes2
answers890
viewsHow to add parallelism in execution with the subprocess module?
The code will be used in 2 testing virtual machines (Linux and Windows). The code below works but every time I run a program, for example the notepad, the prompt is stuck until I close the program.…
-
4
votes1
answer1821
viewsExtract index for repeated elements in Python lists
In case I have a list x that contains several values, and some repeated, and I want to have the index for each element, as I can do? I tried to do using the method .index() but it only returns the…
-
4
votes1
answer731
viewsQuestions in Python (Try and except)
I’m doing a program that calculates the grade of a simulated ENEM style of my school, I ask how many questions of each area the person hit, however, I want to make sure that if the person type an…
-
4
votes2
answers13627
viewsPython second degree equation
The following code calculates roots, vertices and delta of second-degree equations. The code runs clean the first time, but when I loop to restart it gives an error: Traceback (most recent call…
-
4
votes3
answers3733
viewsSet width and height in text box
To expand knowledge, I decided to start a new programming language, Python, and locked in the following situation, I have a screen with some elements and a text box of type Entry. To define the text…
-
4
votes2
answers2001
viewsPython Basic Request
How can I make a basic Python request to a Webserver ? I’m trying, but without success. Desire in get, in the simplest way.
-
4
votes1
answer77
viewsList being modified without implementation
I’m having a problem where the list I’m working on is being modified even though there’s no value passing to it. from random import * from numpy import * m=2 lista_inicial=[[1, 2], [0, 2], [0, 1]]…
-
4
votes4
answers2266
viewsHow to generate random numbers for Draw?
I need to generate numbers for a promotion, these numbers should go from 0 to 99999. How can I distribute these numbers randomly and fairly, without repeating numbers already distributed?…
-
4
votes1
answer676
viewsHow to input a password (password field) in Pyqt4?
To use a field similar to input HTML in Pyqt4, I use QtGui.QLineEdit. But how do I make a field that looks like the input password, which is a specific field to enter passwords? You can define the…
-
4
votes0
answers81
viewsHow to load Flaskbb with Nginx?
I followed the documentation and installed everything without problems, but Nginx only shows his default page warning that it is running. The flaskbb forum never loads. I tried to remove import from…