Questions tagged as 'python'

2
answers

Serialize Object to JSON

How do I convert an object to JSON? I even found some codes on the internet that even worked, but my object has some fields that are other objects and then the conversion did not reach the last level. Example: class Pessoa(object): c...
asked by 09.07.2016 / 02:23
1
answer

Run Python file with arguments

In my program, I do the following operation: import sys qtd_ponts = int(sys.argv[1]) I would like to know a practical way to run this .py file by passing arguments without needing an IDE, for example .bat files.     
asked by 24.06.2015 / 12:22
1
answer

Is it possible to create graphical interfaces for Python applications?

And besides, do you use them on a computer that does not have a Python interpreter? If the answer is yes, what software are able to do this?     
asked by 15.07.2015 / 00:30
2
answers

What does KWARGS mean in Python?

I know that in Python we can define in a function something like what we call "named parameters", that is, "named parameters". def my_func(**kwargs): pass my_func(nome="Stack Overflow", linguagem="Português") I do not know if my defini...
asked by 24.06.2015 / 13:23
3
answers

How to sum list values in tuples?

I have for example a list with tuples, and within these tuples I have 2 lists, where only the second list of each tuple varies: x= [(y, [1, 2]), (y, [3,4]), (y, [5, 6])] How do I add the first values of lists within the tuples, like t...
asked by 17.04.2015 / 16:13
2
answers

Do I need to import a module several times?

I have a class file and a file for the main program, in the two files I need Pygame. I import the classes in the main program this way from classes import * . Do I need to import Pygame into the classes and into the main program, or is Pyg...
asked by 16.10.2017 / 12:41
2
answers

What does float ("NaN") and float ("inf") mean in Python?

I've seen a code like this: def _min(*args): res = float('inf') for value in args: if value < res: res = value return res I would like to know what is a float ("inf") and a float ("NaN").     
asked by 07.04.2018 / 03:01
1
answer

Different types of python dictionaries

Is there any way to convert this dictionary: d = {'Ano; Dia; Mes' : '1995; 2; 5'} for this format: d = {'Ano': '1995'; 'Dia' : '2'; 'Mes': '5'} Thank you     
asked by 16.05.2017 / 18:03
1
answer

How to get the 10 most frequent words of em array?

I need to know how to get the ten most frequent words. This code takes all the words in a text and saves how many times it occurred. if len(palavra) > 0: if palavra in conjunto: qtd = conjunto[palavra] qtd += 1 conjunto...
asked by 30.06.2017 / 17:56
2
answers

Hide password on terminal [duplicate]

I'm developing a python application that will work through the terminal At some point, I need to login: print('É necessário informar suas credenciais para se comunicar com a API') email = input('Email: ') password = input('Senha: ') Th...
asked by 21.07.2017 / 15:40