Questions tagged as 'python'

3
answers

How to convert variable to String?

I have a function that takes a code from the postgreSQL database and displays it set to QLabel with the function setText() . The problem is that this code comes from the database in odd format, between parentheses and comma. Exam...
asked by 14.10.2016 / 21:52
2
answers

Generate autoincrement serial number sequence

I want to generate a service order number, I have the code, but I do want it to query the last number of the service order that was generated in the database. Follow the code: def rangeOrdemServ(self): db = self.conexaoBanco()...
asked by 04.10.2016 / 16:18
1
answer

Increase a numeric string by 1

I want to add 1 to a counter that is represented as a string. the goal is to get the sequence of numbers later. For example: from 000570370 to 000570371. part of the code: def rangeOrdemServ(self): db = self.conexaoBanco()...
asked by 04.10.2016 / 19:29
1
answer

How to return data from a select in sqlite3 as dictionaries instead of tuples in Python?

I'm using sqlite3 to write some data. However, by default, when a select is made, it returns the information as a list of tuples, which is considerably more difficult to work than if they were dictionaries. Example: >>> import sqlite3...
asked by 28.10.2016 / 13:16
1
answer

What is the best method to perform a menu with submenus (while with breaks or calling menus in functions)? [closed]

For a school job, you need to have a menu with several submenus. What is the best way to approach this? I can put the menus inside whiles and go giving break to those whiles when you want to go back to the previous one or separate the...
asked by 21.12.2016 / 14:54
1
answer

What is the correct way to import functions from other packages in python?

If I'm going to create a python package, I'll define a setup.py file that has something like this: from setuptools import setup setup(name='funniest', version='0.1', description='The funniest joke in the world', url='...
asked by 23.09.2016 / 21:07
1
answer

Doubt with parameter

I'm watching a video of python but I do not 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) for _ in range(size)) def create...
asked by 01.12.2016 / 16:17
1
answer

Porting a Python 2 code to Python 3: Error ICMP Scan

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) / 2) * 2 count = 0 while coun...
asked by 31.08.2016 / 23:27
1
answer

How to create a UDP port scanner in python 3?

My code is always giving "port is opened". My idea is: if the destination responds, the door is open. Otherwise, it may be filtered ... ##################################### # Portscan UDP # # # ##################################### # -...
asked by 18.08.2016 / 17:08
1
answer

Import error when sending simple email with python

I am learning to send email in python and am encountering several problems. One of them is already in importing the smtplib module. My code is as follows: from smtplib import SMTP smtp=SMTP('smtp.live.com',587) smtp.starttls() smtp.login('my@h...
asked by 29.12.2016 / 15:42