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
-
1
votes1
answer1200
viewsObtaining data from excel and turning it into a list by Python
import xlrd def ler_arquivo(teste_termal1): tt1= xlrd.open_workbook('teste_termal1.xls', formatting_info=True) eajp60= workbook_r.sheet_by_index(3) Coluna_4=[3] Coluna_13=[12] return {…
-
1
votes0
answers332
viewsCoefficients of a logistic regression
I would like to know how to show the table of statistics of the coefficients of the independent variables of a logistic model, in sklearn library
-
1
votes1
answer50
viewsSyntaxerror when unpacking elements of iterables
line = 'nobody:*:-2:-2:Unprivileged User:/var/empty:usr/bin/false' uname, *fields, homedir, sh=line.split(':') print fields I was doing studies in Python and I will stop with the line so, when…
-
1
votes2
answers295
viewsUnknown command: 'syncdb' Visual Studio 2013
I’m having trouble developing a system in Django. When I try to synchronize the bank this error appears: Python interactive window. Type $help for a list of commands. Executing manage.py syncdb…
-
1
votes1
answer1156
viewsRead txt with numbers and create a Python dictionary
Good afternoon I’m trying to create a Graph from a Txt file but in the generated dictionary the numbers are coming out as if they were strings someone can help me , follows the code : txt file ` 0 1…
-
1
votes1
answer335
viewsExtend the list to another list
Well I have two lists, list1 and Lista2: lista1 = [['carlos','10','cenouras','carro','agora'],['duarte','34','couves','bus','agora']] lista2 = [['11:30', '12:00'],['13:00', '13:30']] What I want is…
-
1
votes1
answer450
viewsShow mailing list with Tkinter
I’m doing a show in Tkinter that’s based on an e-mail box. I intend, in a Tkinter window to show an email list based on a directory with files .txt ( which are emails). I have been looking for a…
-
1
votes1
answer155
viewsAs I call a method of a Qtgui.Qmainwindow class, within another Qobject class in python
I have a class: class MyWindow2Class(QtGui.QMainWindow, form2_class): within the init I have this piece of code: self.scr = ScriptManager(self)…
-
1
votes1
answer781
viewsTkinter GUI hangs when loop
I am new to programming and have faced some difficulties to execute the code perfectly. I chose python for its flexibility. For some time I have been trying to create a macro with GUI, I use…
-
1
votes1
answer491
viewsHow to add fields dynamically in Django?
I would like to add fields dynamically in Djangoadmin. File models.py: class Book(models.Model): title = models.CharField(max_length=100) def __str__(self): return self.title class…
-
1
votes1
answer147
viewsWhy doesn’t kwargs accept a keyword? [keyword can’t be an Expression]
In python there is the kwargs, that makes things so much easier when I need to name parameters. define the attributes of an element that I will create with this function I have a function where the…
pythonasked 8 years, 10 months ago Wallace Maxters 102,340 -
1
votes2
answers776
viewsError while interpreting special characters
I’m looking for an element, and so far so good, I’ve tested it again and again, but.. by using this code driver.find_element_by_xpath('//*[@data-qtip="Configurações"]').click() gives an error, and…
-
1
votes1
answer23293
viewslist index out of range
Tsup=[] Te=0 dt=1 t=range(0,3600*2,dt) r=len(t) for i in range(0,r): Tsup.append(20) .... Tsup.append( (((Pj[i]+Ps-Pc[i]-Pr[i])*(dt))/((m_al*c_al[i])+(m_a*c_a[i])))+Tsup[i] ) if i==r:…
-
1
votes2
answers540
viewsPython: index 5324 is out of Bounds for Axis 0 with size 5040
Hello, everybody, I have a Python code that reads the 5040 numbers of a TXT file to perform a simulation, as shown in Figure 1. Then the code creates a B(s) function, which is used in the commands…
-
1
votes1
answer420
viewsProblem compiling python in pyqt libraries, with py2exe
I’m trying to compile with py2exe, but when I compile from error. Let me give you an example of this error, with Python 2.7 64-bit programs, pyqt4 for Python 2.7, and py2exe for Python 2.7. Follow…
-
1
votes1
answer3034
viewsAdding up positives in a range using only while
I need to write a program using loop (while) that receives two numbers as input, can be positive or negative and not necessarily in ascending order, and the program must print the sum of all…
-
1
votes1
answer104
viewsDjango and Cloudinary error - can’t use the string Pattern on a bytes-like Object
I’m trying to make a simple app: I made the tutorial of Django Girls and now I’m trying to use the same including also an image using the Cloudinary But I’m having the following mistake: Error…
-
1
votes1
answer40
viewsError in libpython, installing Trac, running apache 2.4
I’m installing Trac with Apche2.4 mod_python, but when I start the service the following error appears: [:error] [pid 7937:tid 140094741256064] python_init: Python version mismatch, expected…
-
1
votes0
answers99
viewsCan Python be used for heavy lifting?
Good morning, I know that python is not a performative mto language (aims more at simplicity) An example here. But can she take the hit? For example on large servers with a lot of load like…
-
1
votes2
answers125
viewsWhy does the list show the first two elements?
Listing >>> convites = ['Flavio Almeida', 'Nico Steppat', 'Romulo Henrique'] when you show it, it comes like this >>> convites[0] 'Flavio Almeida' >>> convites[1] 'Nico…
-
1
votes1
answer646
viewsCharacter Alignment
I wish someone could tell me how do I get the numbers to line up that way with the words in the top index, I’m making a replica of that example for a college job, but I can’t get the numbers to line…
-
1
votes2
answers799
viewsTypeerror - 'int' Object has no attribute '__getitem__' when iterating over list
Problem: Write a function that accepts a list of integers and returns a list that is the drawn (ascending) version of the original list.(Original list should not be modified). You cannot use the…
-
1
votes2
answers272
viewsItems of B whose indices are the positions of occurrences of equal elements in A
If I have the lists: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] B = [0.2, 0.3, 1.1, 0.2, 0.2, 0.7, 0.4, 0.6, 0.1, 0.3, 0.7, 0.4, 0.5, 0.5] How can I group in separate lists the…
-
1
votes1
answer785
viewsError "must be str, not list" while writing to file
I have a job to do but I can’t find the error. This excerpt from the program needs to add words in a text file cumulatively. That is, every time you go through the loop will add numbers and words in…
pythonasked 8 years, 8 months ago Naiane Negri 35 -
1
votes1
answer5079
viewsHow to merge an array?
I am writing a program that merges the values of two arrays, with the same amount of values. The program receives as input amount of values in each array. It then takes the values and at the end…
-
1
votes2
answers281
viewsCount occurrences in tuples
I have a problem that is simple but I’m not getting the solution. I have a list of tuples, for example: lista = [('x',2,3),('y',4,5),('x',6,7),('z',8,9)] What I want is for him to tell me how many…
-
1
votes3
answers1508
viewsPython Vector Fill 3
entrada1 = input() entrada1 = entrada1.split(" ") entrada1 = [float(numero) for numero in entrada1] Can anyone explain what’s happening on line 3?
pythonasked 8 years, 7 months ago Marlon Secundo 11 -
1
votes1
answer577
viewsFM simulation in Python
I study the third semester of electrical engineering, my teacher commented that it is possible to simulate modulations of signals programmatically, I had a brief introduction to programming logic in…
-
1
votes2
answers915
viewshow to override save method of models
I am trying to overwrite the save method of models so that when a new book is created it is saved and exported immediately to a file. json, this would be a form of automatic backup, but when…
-
1
votes3
answers2390
viewsHow to access a list resulting from one function in another?
I have a function in which I got a list and I intend to use that list in another function: def funcao1(): ... lista1 = [.....] def funcao2(): #preciso de chamar a lista aqui…
pythonasked 8 years, 7 months ago Força Chape 349 -
1
votes1
answer199
viewsHow to provide a specific amount of strings to be tested?
I can test whether a user-provided string is a palindrome or not (word or phrase that can be read backwards by ignoring upper and lower case spaces and letters such as: Help me get on the bus in…
-
1
votes0
answers81
viewsdelete the python screen
I want to delete the user screen, as console.clear() does in c#. I’m using print(" n"*50) as some people have told me in other posts. But the courses or the next print is there at the bottom of the…
pythonasked 8 years, 6 months ago Augusto Paiva 41 -
1
votes0
answers56
viewspython relationship in neo4j
I have the following code where I am migrating a relational database to neo4j. I made a node for each latitude and longitude sensor and a distinct node for each rainfall recorded in my database. db…
-
1
votes4
answers12868
viewsHow to print multiples of N in a range?
The program must receive as input three values N, A, and B, and must print the multiples of N contained in the interval between A and B. I am doing it as follows, but it is going wrong: N =…
-
1
votes1
answer111
viewsPython help in object orientation
What’s wrong with this code? Compiler points error on line 8... class Pai(object): Nome='Carlos' Sobrenome='Maria' Residencia='Rio de Janeiro' class Filha(Pai): Nome='Luciana' def __init__(self,…
-
1
votes1
answer160
viewsSettings for Django-allauth
Guys, I’m trying to implement Django-allauth in a personal project however I am not succeeding, in version 0.20.0 it is easy but I wanted to try in the latest one that is the 0.25.2, it does not…
-
1
votes1
answer1198
viewsRemove duplicates from a list keeping order
I had the list: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] , in making: ASemRepetidos=set(A) get ([10, 12, 15]), as it turns out, whether in A my first element is 12, in set(A)…
-
1
votes1
answer130
viewsIs it correct to implement unit test in the model in the context of the Python language?
In some languages it is not suitable. I would like to know if python is different. Thank you.
-
1
votes1
answer179
viewsMove subfolders with python
Some time ago I was trying to create a script Python to move subdirectories from one folder to another for example: root ├── pasta1 │ ├── pastaa │ └── pastab ├── pasta2 └── pasta3 ├── pastac └──…
-
1
votes0
answers342
viewsA good book to start in python 3
Talk guys, I’m wanting to start my studies in python, I’ve already started the course of Academy code to get the basics, but I wanted a good book for beginners, I heard very well of "Learn Python…
pythonasked 8 years, 6 months ago João Paulo 35 -
1
votes1
answer100
viewsError sending - get request.
Considering the code below: path = "/admin/" host = "192.168.1.1" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, 80)) req = ("GET /"+path+" HTTP/1.1\n Host: %s \r\n\r\n",…
-
1
votes1
answer226
viewsimage module does not run on iPython3
I’m still a beginner in the world of programming, and I recently came across a problem that is still unsolved. I’m using an interactive online book to learn python (How to think like a computer…
-
1
votes2
answers302
viewsMedia in lists with dictionaries
I have 2 lists of dictionaries and 1 dictionary , as for example the following : lista1 = [ {'Idade': '8', 'Especie': 'Gato', 'Nome do Animal': 'Felix'}, {'Idade': '57', 'Especie': 'Tartaruga',…
pythonasked 8 years, 7 months ago Força Chape 349 -
1
votes1
answer155
viewsinstalling Django in a venv
I am trying to install the latest version of Django (1.9.6) in my virtualenv, but when I use the Pip install Django command, within the virtual environment, I get the following return: Requirement…
-
1
votes1
answer806
viewsHow to implement "Foreign key" using Micro Services architecture? Django
I’m trying to build a system using micro services architecture, I came across the problem about dependency, in case how to implement chave estrangeira using this architecture? I’m using Django…
-
1
votes1
answer245
viewsDatabase in Tupla
I need a code that receives data (values) and prints them according to your key. Each entry corresponds to a given of a hypothetical person, which contains Age, Name, Sex, Marital Status, Number of…
-
1
votes1
answer561
viewsAjax with Python - I want to call function that is in default
I want to do a validation in Mysql Database through Ajax. I created a function called validaCNPJ() that is in the controller called Default. But I don’t know how to put this function in the…
-
1
votes2
answers481
viewsKeep variable value in python function
Within a function I have a cumulative variable, and I call this function over and over again, the problem that it loses values every time it enters. Summing up what I want to do is: def teste(a):…
-
1
votes2
answers109
viewsMultiple keys and values, Dictionary compreension
I have been playing with python, Dict and list compreensions. I made this little script: import requests url = 'http://www.bankofcanada.ca/en/markets/csv/exchange_eng.csv' resp = requests.get(url)…
-
1
votes1
answer64
viewsError installing ffvideo python package
I’m working with Raspberry Pi with the Raspbian system. I need to install the ffvideo package, but when I try to install it, I get this: error: command 'arm-linux-gnueabihf-gcc' failed with exit…