Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
1
votes2
answers158
viewsHow to use Kivy with Python 3.4.3 on Mac
How can I use Kivy with Python 3.4.3 on OS X? Only works with Python 2.7
-
1
votes1
answer2951
viewsSort a second column matrix
How to order the following matrix according to the x-coordinate column? I want you not only to order the coordinates, but to change the lines so that the city coordinates are correct. What I have so…
-
1
votes1
answer801
viewsEncoding, bytes conversion - strings
I have a problem, I’ve been researching but all the solutions I find don’t work. The problem is that I am accessing a page (.txt) and cannot convert it from bytes for string, to be able to work the…
-
1
votes1
answer419
viewsFunction code works on IDLE, but the program shuts down
I’m a beginner, I’ve been training in my free time for a couple of months and so far my programs had five lines, very simple. This program taught me several new concepts, and it’s part of a larger…
python-3.xasked 9 years, 3 months ago Daniel Oliveira 61 -
1
votes1
answer1008
viewsHow to run a module in Python?
have a question. A few days ago I am creating an application with GUI interface to show movie schedules. It was built in modules, for example, a module takes care of the images, searches the web and…
-
1
votes1
answer1855
viewsHow to clean the screen on Tkinter?
There is a practical way to "clean" a screen by giving a destroy() in all the widgets at once, without having to do it one by one?
-
1
votes2
answers399
viewsImport modules with Python
How can I do import of libraries, for example, I was researching and found the Babel to internationalize dates, but I don’t know how to import this library?…
-
1
votes1
answer198
viewsHow to convert an integer to a binary string in Python 3?
If I want to convert between integers and characters, use chr and ord: >>> chr(10) '\n' >>> ord('$') 36 However I need to do a string test binary, something new in Python 3, and I…
-
1
votes2
answers1570
viewsWhich PIP version should I use?
My current question is: must I use pip3 for Python3.x or can I use Pip without any problem? What are the differences between Pip versions?
-
1
votes2
answers1691
viewsHow to get the line of a particular Python matrix dice
I need through the index of a "column" matrix to access your row completely to be able to make changes in the indexes of this row. The part of collecting the indexes I managed, but I do not know how…
python-3.xasked 9 years ago Acneto 61 -
1
votes2
answers1697
viewsAckerman function - Python
Well, I’m still learning to code in python and I came across exercise that I can’t solve. I need to write a function that solves Ackermann’s famous function. I think I will not have problems with…
-
1
votes1
answer1141
viewsVariable with multiple lists for matrix
Good night. I have a text file where I have already converted your content to lists. Each line in the file has become a list[], but now I need these lists to be all within an array. This way I can’t…
-
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
votes1
answer88
viewsSeries using recursiveness
I’m trying to make a show x^(n)/n! but although it seems simple I have a constraint that is: It has to be a recursive function. What I’ve got so far that I don’t even know if it’s right is this::…
-
1
votes2
answers1150
viewsPass pythonic form parameters
The database driver I am using returns the data of a record in the form of an example tuple ('João', 32, False). I’m thinking of a pythonic way of passing this data to the constructor of a Person…
-
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
answer202
viewsWhat is the lifetime of a variable in the method, class and module?
I know that a variable declared in a method lasts for as long as the scope of the method. How python has the concept of class variables, until when lasts a variable declared in the class? And a…
-
1
votes1
answer29
viewsStop Generator
What would be the best way to stop a Generator? Example: >>> def get_fruits(): fruits = ['Mamão', 'Abacate', 'Melão', 'Banana', 'Maçã', 'Uva'] for fruit in fruits: yield fruit >>>…
-
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
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
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
votes2
answers526
viewsPython 3.5 + Django + Postgresql on Windows
I am currently starting a web system project using Python 3.5 and the Django 1.9.1 framework, aiming to integrate them with a database Postgresql 9.5, all installed on a Windows 10 x64 OS machine.…
-
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
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
answers98
viewsHow to get nested Rest?
I happen to have the classes Pessoas, Profissoes, ProfissoesPessoa and QualificacoesProfissoesPesssoa In thesis my Models is so below: # -*- coding: utf-8 -*- from django.db import models from…
-
1
votes0
answers153
viewsSelecting and deleting random lines from csv in python
I need to make a small script in python that meets the following requirements: Open a csv file; Delete first row and first column from reading as it contains information that will not be needed in…
-
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
votes0
answers366
viewsHow to place a Progress Bar for a process in Flask?
Hello, By clicking the 'Send' button, the selected file (.jpg) is copied to several directories. I want to show this process to the user via a simple progress bar. Any hints? this is part of my…
-
1
votes2
answers63
viewsLooping for as a looping parameter while
Whereas the list cont would have the values: cont = ['t','f','f','t','f'] It would be possible something like this: while(for cont in cont == 'f'): pass…
-
1
votes1
answer164
viewsPython Shell cannot run a module with more than one while loop
I have serious problems in being able to build a functional module in which I have to use more than 1 while loop, because the program stops running. Especially when I use modules like pygame and…
python-3.xasked 8 years, 3 months ago Inês Barata Feio Borges 313 -
1
votes1
answer2883
viewsHow do you make a socket that actually connects to other computers?
I tried to make a Python 3.5.1 socket, but when I went to test it only connects with me. I tried to connect to another computer (from my friend), but it does not connect. Does anyone know how to…
-
1
votes2
answers1216
viewsinput() and raw_input()
According to the Python 2.x documentation, it is recommended to use the function raw_input instead of input. Conversely, in the Python 3.x documentation, the function raw_input doesn’t even appear.…
-
1
votes1
answer936
viewsVariable not defined Python
I’m trying to run a code and all of a sudden you’re making this mistake, for example if you write "m" Traceback (most recent call last): File "Energias", line 5, in <module> var = input("\nQue…
-
1
votes1
answer418
viewsSending a payload with scapy
from scapy.all import * ip = IP(dst = "192.168.1.1") tcp = TCP (dport = 80, flags = "S") raw = Raw(b"Olaa") pkt = ip/tcp/raw sr(pkt) ans,unans = sr(pkt) I’m learning to use Python Scapy. I couldn’t…
-
1
votes1
answer506
viewsHow to "generate" multiple TCP clients using Threads in the same script?
I wrote the code of a simple TCP client: from socket import * # Configurações de conexão do servidor # O nome do servidor pode ser o endereço de # IP ou o domínio (ola.python.net) serverHost =…
-
1
votes1
answer819
viewsHow to create an UDP port scanner in python 3?
My code is always "port is opened". My idea is: if the destination responds, the door is open. Otherwise, it may be filtered... ##################################### # Portscan UDP # # #…
-
1
votes1
answer1139
viewsCreation of a random vector
from random import randint # para gerar os nums aleatorios def criaVetor(L, H, tam): vec = [] for i in range(tam): # vamos fazer isto tam (N) vezes vec.append(randint(L, H)) # gerar numero aleatorio…
-
1
votes1
answer7755
viewsMatrix (Create 2 Matrices and Sum them)
How could I build this matrix without using Random/randit? Then I need to do the function sum element by element, of the first two. The sum shall be settled via written sub-programme for that…
python-3.xasked 8 years, 2 months ago ABSoares 47 -
1
votes1
answer98
viewsCreate a new function with scrapy
I’m starting to learn scrapy and created the following function: import scrapy class ModelSpider(scrapy.Spider): name = "model" start_urls = [ 'http://www.icarros.com/' ] def parse(self, response):…
-
1
votes1
answer550
viewsHow to find a "<li>" tag with a "dorm" text from a list of tags in python3?
I’m learning to code now, and python is the first language I’m working on and I’m having trouble capturing the tag: <li> 4 dormitórios html: <div class="crop"> <ul style="width:…
python-3.xasked 8 years, 2 months ago Jeu Domingos 11 -
1
votes1
answer134
viewsPorting a Python 2 code to Python 3: Scan ICMP with errors
I have the following code: import random import socket import time import ipaddress import struct from threading import Thread def checksum(source_string): sum = 0 count_to = (len(source_string) /…
-
1
votes3
answers7867
viewsInstantiate a Python class using an object as argument
I am starting to work with Python and saw that there is no way to create multiple constructors in the same class. With that I thought I’d move on to the constructor __init__ an object containing…
-
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
answers1966
viewsPandas Soma Condicional
Hello. I have the following situation df1 = pd.DataFrame({'Key':['a','b','c','a','c','a','b','c'],'Value':[9.2,8.6,7.2,8.3,8.5,2.1,7.4,1.1]}) df2 = pd.DataFrame({'Key':['a','b','c']}) and would like…
-
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
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
votes1
answer1857
viewsArchitecture incompatibility between drive and app
I’m trying to access data from a database using pyodbc with this code: import pyodbc cnxn = pyodbc.connect("DSN=banco;uid=usuario;pwd=senha") cursor = cnxn.cursor() But when I make that mistake:…
-
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
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
answer49
viewsI would like to turn "a"+str(1) into a1 without being a strig, so I can associate a value "a"+str(1)=2 as I do?
"a"+str(1)=2 File "<ipython-input-44-929460161ba7>", line 1 "a"+str(1)=2 ^ Syntaxerror: can’t assign to Operator I want to create a series of variables a1 a2 A3 an and then associate to a…