Questions tagged as 'python'

1
answer

Customize Django Admin

I have 2 classes, one that is the Division and another that is Group. In the group I have the FK for division. I want to register a Storage in the Django Admin and select the Group I want the group to appear and divide it into the same sel...
asked by 22.01.2018 / 16:37
1
answer

Remove repeated words using python

I have a text file with many words repeated. I need every word in the file to appear only once. import codecs wordList = codecs.open('Arquivo.txt' , 'r') wordList2 = codecs.open('Arquivo2.txt', 'w') for x in range(len(wordList)) : f...
asked by 06.09.2017 / 01:42
2
answers

default values for namedtuple

In creating a class I can set some default values: class Point: def __init__(self, x, y, z=0): self.x = x self.y = y self.z = z How to proceed in the same way for namedtuple? from collection import namedtuple P...
asked by 18.08.2017 / 03:49
2
answers

How to Create an Auto Increment in Django other than pk

I am creating a memo system with django and it is working fine, but I need to put a self-increment field other than pk. I have this field in my models. Memo = models.IntegerField() I need it to already receive the value of either the id or...
asked by 16.08.2017 / 14:38
2
answers

Is it possible to add more than one item to a list at one time?

I wonder if it's possible to add more than one element to a list, for example: a=[] a.append('abóbora', 'banana', 'maçã') or you will need to use three lines, for example: a=[] a.append('abóbora') a.append('banana') a.append('maçã') Pl...
asked by 05.11.2017 / 02:42
2
answers

Group per week

I have a table like this I am trying to separate by week, I do not have much knowledge in which functions I can use to check how many weeks have between those dates, to later group. The data is in a csv table, I am using pandas to open the csv f...
asked by 19.08.2017 / 14:05
1
answer

Dependency version control [closed]

Usage python , Django on a server with CloudFoundry installed. There, I keep my requirements.txt with all dependencies of my application and, for security, I always keep the exact name of the version of each plugin to...
asked by 14.08.2017 / 18:53
1
answer

Questions about virtualenv

I'm starting development with virtualenv and some doubts have arisen, they are: Should Python scripts be inside the virtual environment folder? In the PyCharm IDE, do you need to configure something to develop in the enabled virtual enviro...
asked by 26.07.2017 / 21:34
2
answers

Error in root account math.sqrt with multiplication and division

I am making an interface with buttons in Python, but after typing the account it gave error ... I tried to redo and it is giving indentation error. What do I need is the code correct? Follow the code! try: DEMANDA=float(self.DEMANDA.get...
asked by 16.06.2017 / 10:08
1
answer

How to extract specific data from a text file with Python?

I have a * text file of 49633 lines (file.txt) in the following format: -e Tue Mar 28 20:17:01 -03 2017 total used free shared buffers cached Mem: 239956 126484 113472 4904 1...
asked by 05.08.2017 / 22:55