Questions tagged as 'python'

1
answer

What is the asterisk in defining a function in Python? [duplicate]

For example, in the documentation for the module pickle it is common to see such notation: pickle.dump(obj, file, protocol=None, *, fix_imports=True) pickle.dumps(obj, protocol=None, *, fix_imports=True) pickl...
asked by 06.07.2018 / 16:20
1
answer

Python, clone lists

Be the code below: def modif1(lista): lista = [4,5,6] lista = [1,2,3] modif1(lista) print(lista) #resultado: [1,2,3] def modif2(lista): lista[0] = 4 lista[1] = 5 lista[2] = 6 lista = [1,2,3] modif2(lista) print(lista) #result...
asked by 12.02.2017 / 21:28
1
answer

How to convert Python encryption to PHP?

I would like to know if it is possible to convert this encryption to the PHP language, I need to convert the passwords that were generated to be accepted in my Login system on the site, but I do not know how to do it. I have a database with p...
asked by 10.08.2017 / 14:19
1
answer

"AttributeError: __exit__" problem in Python

In a group, I asked them to give me tips on a program to test my knowledge. He told me to create a program that reads a file named "arquive.txt" and manages files CHAR and STAGE , with the file like this: [CHAR] Exemplo = C...
asked by 04.12.2016 / 01:58
1
answer

Generate all combinations given a list in python

I have searched extensively and found nowhere exactly what I want. What I want is, given a list of characters, to generate all possible combinations of size x up to size y. Example: given 0,1,2 and ask combinations of size from 1 to 2 generate:...
asked by 15.08.2016 / 07:24
1
answer

In Python, how do you explain the expression 'x = not x'

I already know the result, but I would like to understand what happens, why this result ... For example: >>> a = True >>> b = not a >>> print(b) False It's a simple thing, but I feel annoyed to use somethin...
asked by 13.11.2014 / 10:50
1
answer

It is a good practice to import modules in __init__.py

I noticed that in the Django framework modules are imported into __ init __ .py for convenience. """ Django validation and HTML form handling. """ from django.forms.forms import * # NOQA So this: from django.forms.forms import Form...
asked by 05.06.2014 / 15:46
1
answer

Problem declaring variables for averaging in Python 3

n1 = input("informe sua nota do 1º Bimestre ") n2 = input("informe sua nota do 2º Bimestre ") n3 = input("informe sua nota do 3º Bimestre ") n4 = input("informe sua nota do 4º Bimestre ") media = float((n1 + n2 + n3 + n4)) / int(4) print("A média...
asked by 19.09.2015 / 05:08
2
answers

How do I make Django "see" CSS?

I'm writing a Django and Python application, and I'm having a problem     in the templates part, running locally Django found the template and     I was able to visualize it through localhost:8080/home , it happens that the     style sheet...
asked by 07.05.2014 / 18:07
1
answer

Python: The ^ is not transforming the character class of my regex to negative

I'm learning REGEXes by Automate the Boring Stuff w / Python. In one of the titles in Chapter 7, the book teaches about character classes. Until then, easy. I created character classes for vowels ( re.compile(r'[aeiouAEIOU]') ), for letter...
asked by 23.09.2017 / 22:53