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
answer353
viewsRun Fortran code that prompts reading data in jupyter-notebook with python Restart kernel
Jupyter notebook Restart when running a Fortran code requesting data entry, as follows: note that the variable a must be provided immediately after the call from f1 .However, an error occurs and the…
-
1
votes2
answers584
viewsPython socket keeps open even using Close
I have a Python App that uses Socket, this App runs on XBMC’s Kodi, and when I close the App I would like to close the Socket and take down customers, the problem is that even I using…
-
1
votes1
answer940
viewsWhat is the correct way to import functions from other packages in python?
If I create a python package, I will define a file setup.py that has more or less this format: from setuptools import setup setup(name='funniest', version='0.1', description='The funniest joke in…
pythonasked 8 years, 2 months ago Daniel Falbel 12,504 -
1
votes1
answer91
viewsPython / Django: sending emails resulting in 535 (gmail working)
I have a contact form where I send the message to the system administrator informing him about it. Email configuration information is fully verified and correct. EMAIL_HOST='mail.xxx.net'…
-
1
votes1
answer3202
viewsProblems with accentuation - Python
Hi, I’m having stress problems in Python. In the code I put this: # -- coding: UTF-8 -- But the accents are not recognized in the cmd. Follow print for better understanding. From now on, thank you!…
-
1
votes4
answers25024
viewsDifference between If and Elif
What is the difference between the two code snippets if variavel < 10: variavel = 1 if variavel >= 10 and <15: variavel = 2 . . . else variavel = 0 if variavel < 10: variavel = 1 elif…
pythonasked 8 years ago Guilherme Lima 3,129 -
1
votes1
answer244
viewsOrdering relationship results "Manytomanyfield" with the same table in Django
I have the Many to Many relationship with the same table, and I need to order the result with the same creation sequence. ex: add basic Django, intermediate Django, advanced Django; It has q appears…
-
1
votes1
answer574
viewsgetch python returning without using
I’m trying to use the getch from python to grab the key the user pressed, but without me pressing anything it is returning "b'\xff'", and if I use ord(getch()), it returns 255. If you can help me…
-
1
votes1
answer498
viewsElementnotvisibleexception Selenium
I’m trying to log in to www.pactpub.com using the following idea def setUp(self): self.driver = webdriver.Chrome(executable_path='C:\_workspace\projects\Packtpub\chromedriver')…
-
1
votes1
answer81
viewsConcurrent.Utures and Class Object
I am trying to create a class (Processor) that runs a series of functions to get results from a State-to-State API. (STATE) 1- READ data from a table. 2-SEND request for the API to process. 3- WAIT…
-
1
votes2
answers1892
viewsIF, ELIF AND ELSE
I’m taking my first steps in Python, and I came up with a question in the if/Else sentence, trying to solve the following exercise: "Using a person’s height and gender as input data, construct an…
-
1
votes2
answers2187
viewsThe/ python library
This program aims to show certain type of file you have in a folder. But it is giving the following: erro: WindowsError: [Error 2] O sistema não pode encontrar o arquivo especificado: 'pythonteste'.…
pythonasked 7 years, 11 months ago Igor Bastos 11 -
1
votes2
answers765
viewsTypeerror: split() Missing 1 required positional argument: 'string'
One more basic question on my part. I am 'Pythonist' super basic level and I am simply trying to read a text line by line and make a split each time I find a punctuation mark or a space. I tried…
-
1
votes1
answer151
viewsWhat’s wrong with the logic of this Python code?
x = bool(input("True or False...? ")) if x == 'True': print("Você escollheu True") else: print("Você escolheu False") What’s wrong with this logic, more specifically about logic involving the…
-
1
votes2
answers86
viewsInserting a string into a list of ints
I have the following rule: Create a function that receives a list of integers, and replaces the items as below: if Multiples of 3 = 'Fizz' multiples of 5 = 'Buzz' multiples of 3 and 5 = 'Fizzbuzz' I…
-
1
votes1
answer116
views**kwargs optional with default
It is common to find several Pis who make use of the KeyWordArgument python. My question is how to use this decline for object attributes. Sometimes when I use an API and pass a named parameter…
-
1
votes2
answers1104
viewsHow to create a virtualenv with a python seaman other than the ones installed?
I am using virtualenv to install some packages of my projects so that they do not conflict, but I need to use a version of python that is not installed on the system, as I use linux the same already…
-
1
votes1
answer149
viewsHow can I test an Exception in my code with unittest?
I am studying a little of Python’s unittest and I have stopped there. In my code the user must enter a valid value, if an invalid value occurs should fall in Exception, however how can I test it ?…
-
1
votes1
answer1096
viewsFunction Returning None
I am trying to calculate the area of a file using Python with the following function: from __future__ import division import ogr import osr def transform_geometries(datasource, src_epsg, dst_espg):…
pythonasked 8 years, 1 month ago Guilherme Lima 3,129 -
1
votes1
answer159
viewsWhy does this instance variable never take False value?
When running the following code, the variable _order_stability never gets a False value, even when I try to force it during debug. The variable can take other values, for example of the type int…
-
1
votes1
answer950
viewsHow to return data from a select in sqlite3 as dictionaries instead of tuples in Python?
I’m using sqlite3 to record some data. However, by default, when a select is made, it returns the information as a list of tuples, which is considerably harder to work with than if they were…
-
1
votes1
answer439
viewsI calculate to buy fuel by value?
I am doing a program of a fuel pump using classes, but I am not able to calculate the amount of fuel for the value inserted, someone can give a light? class BombaCombustivel(): def __init__(sel,…
-
1
votes0
answers103
viewsPython I can’t import Recaptchafield
There’s a project that was sent to me that I’m going to work on. I created an Environment to move up the project and in the project had the requeriments where I surrounded it. But when executing the…
-
1
votes1
answer98
viewsFormat value in Pyhton
I have a Crawler where I get values in this format: "R$ 450,000.00". But I need to convert these values into float and save in the database to make queries of this type: Take the values that are…
pythonasked 7 years, 11 months ago Lucas Lopes 33 -
1
votes1
answer599
viewsError "No module named 'pytube'"
When installing a package using PIP I cannot use it. Example: pip install pytube So far so good, down easy# In the IDLE: import pytube Upshot: Traceback (most recent call last): File…
-
1
votes1
answer1552
viewsPython administrator privileges
Is there any way or command to run a Python script with administrator privileges?
-
1
votes1
answer2166
viewsRedirect and Render in Django
I have a file views.py which has the following method: def alterar(request, pk): cliente = get_object_or_404(Cliente, pk=pk) if request.method == 'POST': form = ClienteForm(request.POST, instance =…
-
1
votes1
answer898
viewsPython sockets disconnect client
I would like to make with a command of the server, was disconnected a client specific. from socket import * meuHost = '' minhaPort = 50007 sockobj = socket(AF_INET, SOCK_STREAM)…
-
1
votes2
answers303
viewsIncorrect python value conversion
I have a Rawler who takes the amount STRING R$ 560,000,00. I need to convert this value to FLOAT because I will use this value to carry out consultations, of this type: Selecionar todos os carros…
-
1
votes1
answer1277
viewsTypeerror in python: source code string cannot contain null bytes
Good morning/late/evening. I am trying to create a simple calculator in python in the IDE Visual studio. The following is the script (sorry to be in English): import os,sys #from colored import…
pythonasked 8 years ago Pedro Brito 65 -
1
votes1
answer59
viewsWhy is this server crashing?
from socket import* Host = "localhost" Port = 255 sockobj = socket(AF_INET, SOCK_STREAM) sockobj.bind((Host, Port)) sockobj.listen(5) while True: conexão, endereço = sockobj.accept() print('Server…
-
1
votes1
answer258
viewsafter creating a file(.txt) iterate from a line that is not the beginning
The following I have an input file(.txt) which is the following: 9 branco preto azul verde rosa amarelo vermelho cinza lilas OHLEMREVU BBRANCOZA SRAMSUPAO AABAPOTZZ LNZROERNU IUIEPDOII LOLLORACA…
-
1
votes1
answer2037
viewsSockets - Tic-tac-toe / Rooster Game MULTIPLAYER
EDITED POST I’m creating the so-called 'Tic-tac-toe' (or 'Rooster Game'), right now I’m trying to create a feature that allows two players on different devices - although on the same network - to…
-
1
votes1
answer728
viewsHelp with a simple game
Well, I’m trying to make a "ball" follow the rectangle of the game, but it doesn’t seem to be happening because the "ball" kind of blurs the screen when I move the player. I already looked for the…
-
1
votes1
answer62
viewsQuery with parameter
I’m watching a video python but I didn’t understand one thing. I have the file utils.py def code_generator(size=6, chars=string.ascii_lowercase + string.digits): return ''.join(random.choice(chars)…
-
1
votes1
answer193
viewsPython Using . replace() with list comprehension
Can someone tell me if I can make it work: a = ['<a1>', '<a2>', '<a3>', '', '<a5>'] b = ['<b1>', '<b2>', '<b3>', '', '<b5>'] txt = '<a1> test…
-
1
votes1
answer513
viewsException handling (Try) error in python
I am making a program that makes numerical calculations, but constantly appear to me operations where there is division by 0 (zero). I ended up finding a solution using if, but still wanted to know…
-
1
votes1
answer932
viewsHow I create 2 Foms simultaneously Django
What I want is in a single templante bring these 2 Forms simultaneously, in separate pages works, but the two together still could not do. Do I need to make an intermediate form? Am I making a point…
-
1
votes1
answer217
viewsError pressing Alt+Tab using pyHook
I am working on a python script that captures keystrokes typed by the user. For this, I used the pyHook module. However, using the program, I realized that every time the user presses Alt+Tab, an…
-
1
votes1
answer5595
viewsWhat is the best way to perform a menu with submenus ( while with breaks or calling the menus in functions )?
For a school project I need to have a menu with several submenus. What is the best way to approach this? I can put the menus inside whiles and give away break to those whiles when you want to go…
-
1
votes1
answer54
viewsTwitter User-App Authentication
I am developing some Python scripts with the intention to bring specific tweets and perform further analysis, but I have doubts about the type of Twitter authentication. As I noticed, there are two…
-
1
votes1
answer58
viewsGoogle App Engine Python project works on localhost but gives server error
My project is running perfectly on the localhost but when I deploy and access it gives the following error: Here is my code: import os import jinja2 import webapp2 import json from…
-
1
votes1
answer770
viewsErrors being generated when converting python code to exe with cx_freeze
I converted the Tucha.py file to exe following the instructions and with the following setup.py: from cx_Freeze import setup, Executable setup( name="tucha EXECUTABLE", version = "1.0.0",…
-
1
votes2
answers811
viewsHow to create sublists with numerical elements that are in a sequence?
Friends, imagine a list: lista = [1, 2, 2, 3, 3, 3, 6, 6, 7, 11, 12, 12, 13, 14, 14] Could I create sublists only with the elements that are in sequence? For example, in this case it would be: lista…
-
1
votes1
answer241
viewsAccent problem when running python script straight from C#
I’m using this to run the code: processo.StartInfo = new System.Diagnostics.ProcessStartInfo { FileName = @"\Python27\python.exe", Arguments = arquivoResposta, UseShellExecute = false,…
-
1
votes2
answers12804
viewsCounter in python
Well I’m doing a screenshot program but I want it to replace in the file name when saving, the characters "XX" by the print number. Ex: Screenshotxx.jpg in "XX" I want to put the print number ex:…
-
1
votes2
answers764
viewsuse variable cmd command with python
I wanted to make a program that opens and reads a text file. Then run or command on cmd using what he had read in the text file more or less like this: import os nome = open ('nome.txt') nome1…
-
1
votes1
answer38
viewsThis program on Tkinter does not display its widgets. Can anyone explain why?
from tkinter import * class Autenticar(object): def __init__(self, toplevel): self.Lab1 = Label(main, text = "Usuário", fg = "Blue") …
-
1
votes1
answer247
viewsImport error when sending simple email with python
I am learning to send email in python and I am facing several problems. One of them is already in the import of the smtplib module. My code is this: from smtplib import SMTP…
-
1
votes1
answer80
viewsSpecific url in Django
I’m rewriting a website using Django. This is a blog and I need the urls to be the same as the old site so that the site does not lose ranking in the search engines. What would be the best way to…