Posts by Sidon • 6,563 points
288 posts
-
2
votes1
answer1831
viewsA: Python API for real-time commodity values
Although you asked not to post the code, I did not find a way to explain only verbatim, so I decided to post, even to know if it really works, beyond the fact that it can help other people in other…
-
0
votes1
answer287
viewsA: Import csv from Bucket S3
When you do open('qualquer string') python tries to "resolve" 'any string' as a local file, as you put a url, the file is not found. Here is a solution to read the url file: from contextlib import…
-
0
votes1
answer303
viewsA: Problem when migrating with Python and Django: no such column: forum_thread.Slug
The message says that you are adding a "non-nullable" field, in a database that already has records, but you have not set a default value for that field. The message gives you 2 options: 1) to…
-
1
votes2
answers1210
viewsA: Python Shell and Django
When Voce opens the python shell "pure" Voce has available only the packages available in its env. When opening via Manage.py, Voce has available, in the shell, all the configuration and objects of…
-
1
votes1
answer725
viewsA: How to create a python code and connect it to Mysql
There are several ways to do this, without knowing its context it is difficult to give an accurate answer. Will you use some framework to put the "app" on the air? Do you have any legacy database or…
-
1
votes2
answers23455
viewsA: Get Data in the JSON structure with python
The file should look like this: { "informacao1": "valor_informação1", "informacao2": { "dado": "informação_dado" } } That way, Voce can do: import json from pprint import pprint with…
-
1
votes1
answer275
viewsA: Problem with Classes and Packages in python
In defining init of function main (In python, define class names in Camel-case, I suggest a read on PEP8) def __init__(self, principal): you send the "main" parameter from somewhere right? class…
-
4
votes1
answer774
viewsA: How to Update the value of a variable?
It is difficult to understand your context with this code fragment, but what it seems is that you just want to make a "replace" in the list according to the values of the variables Vnomevalor,…
-
0
votes2
answers444
viewsA: How to configure the Django environment and maintain settings?
Consider "throwing away" the virtual env, seriously! The solution? Anaconda. To install you have two options: Graphical Installer Download the graphical installer Double click on file . dpkg and…
-
1
votes2
answers103
viewsA: Django collectstatic does not update modified files on S3
Okay, You even answered your question (before I see it, Hehe!), but I can’t help but add my answer, even to document it as well. After having several problems with Static files, on several servers…
-
0
votes2
answers328
viewsA: how to make the time appear in the window(label)?
My answer is similar to @Brow-joe’s, but as I tested his and gave an error, I decided to put mine too (environment: Python 3.6): import tkinter as tk import time class showtime(): def __init__(self,…
-
1
votes2
answers1088
viewsA: Delete in more than one table with an SQL?
ON DELETE CASCADE. The message that says Voce cannot "delete the user without first removing it from the table areausuario" indicates that there is a relationship between the two tables through a…
-
5
votes2
answers1898
viewsA: Regex to pick up text between <> in python?
Place an interrogation after the asterisk, like this: m=re.search(r'<(.*?)>','abevbv envvrhwkv <eiwbv> ebvi <wieunv> ajhbsvhj') print (m) <_sre.SRE_Match object; span=(17, 24),…
-
1
votes2
answers2406
viewsA: txt file for python list
Let’s consider the file called txt values. with the following content: 0.4350 0.8798 0.0099 1 0.4375 0.8674 0.0090 1 0.4400 0.8682 0.0082 1 So I "developed" the code below, which is actually a part…
-
3
votes1
answer4852
viewsA: Write to a CSV file
In writer.writerows([dia,hora]) Voce is trying to record a list and csv.DictWriter expects a dictionary. Without knowing the contents of your input file, I made a notification of your code and…
-
0
votes3
answers3909
viewsA: How to install pytest in windows 10 - 64 bits, python3
Depends on your version of Python, version 3, when >3.4 (Released March 2014) and version 2 if >2.7.9 (Released December 2014), already comes with Pip installed. View the Pip documentation. If…
-
2
votes2
answers1417
viewsA: Find the highest value of any python file
Ok, I’ll put the steps for you to get the desired results, I didn’t worry about details such as if the file exists or if this empty, this is with you (This link can adjure), follows the main logic:…
-
0
votes1
answer169
viewsA: 2 types of products in the same view
The "Best way to do this" is a little subjective, it essentially depends on the context. Let’s create a small application to try to solve the problem, I will report the steps (my environment is…
-
6
votes4
answers21505
viewsA: How do python select the largest number of a set?
Taking into account only integers (you can adapt to other types): Version with for: lista = [] qtn = input('informe a qt de numeros: ') for n in range(0,int(qtn)): lista.append(int(input('Digite o…
-
0
votes1
answer438
viewsA: Python remover() list index out of range
If I were to develop Huffman’s algorithm in python I would not do so, but without getting into that merit, I slightly altered his code to highlight his mistake. Behold: import numpy as np def…
-
1
votes1
answer1049
viewsA: Install Module openalpr
Openalpr itself is a binary package developed in C (and other languages) and optionally a webservice. This package makes Binding with several languages, among them python. Att.: Examples of this…
-
3
votes2
answers323
viewsA: Python accumulator list
See if it answers: import functools # Utilizando Funcoes de alta ordem def acumulator(n,dt): current = n+dt['last'] dt['ac'].append(current) dt['last'] = n data = {'last': 0, 'ac': []}…
-
2
votes1
answer61
viewsA: Select from different tables
Although the question does not make explicit the context, I will try to answer in the most general way possible (although for me it is almost impossible not to think about Postgresql. :-)) Let’s say…
-
1
votes2
answers599
viewsA: List of square roots
Here is the answer to what I understood of the question, by the text fragment posed in the question: As shown below: [sqrt(1), sqrt(1)+sqrt(2), sqrt(1)+sqrt(2)+sqrt(3), ...] It is clear that the…
-
4
votes2
answers2086
viewsA: How to capture all exceptions in Python?
I will try to add something to @jbueno’s reply, as there are some more details in the Python exceptions survey. I am only going to present here what I consider most important, explaining, mainly,…
-
17
votes1
answer22460
viewsA: Non-relational Database vs Relational Database
The essential difference between the two teconologia is that one is based on schema (Relational) and the other is not (Nonrelational). To work with an SQL database (Relational) the first thing that…
-
14
votes1
answer1898
viewsA: What is Class Coupling?
In software engineering, coupling is a metric that defines the degree of inter-dependence between the elements of a module. We could summarize in one word: Dependency, that is, coupling is the…
-
2
votes5
answers10407
viewsA: Identify if there is an uppercase letter in the string
Using regex becomes fast, simple and efficient: >>>import re >>> # Retornando a primeira Maiúscula ... print (re.search('[A-Z]', 'Jon Snow').group()) J >>> # Retornando…
-
1
votes1
answer1158
viewsA: Dropdown dependent on each other
I had a similar problem and after hours and hours of research, I decided to implement my version. I’ll explain briefly here, I made the full and functional version available on github, see the links…
-
1
votes2
answers2185
viewsA: How popular select from another select using python and Django?
A path (perhaps the most obvious) is the use of javascript, in the first select you arrow an onchange that calls a function to "popular" the second select. Has a demo here which fits perfectly with…
-
1
votes1
answer190
viewsA: What is wrong with this procedure when saving a form?
For "registration" of users we have the option to use the User framework of Django. This Fw includes the following models: User: Model for users with main fields: username, password, email,…
-
1
votes1
answer485
viewsA: Django without models view in common user admin even if you have permissions and are in the same group
I did a test with your code and it works perfectly, the only error I see in the code you posted here is in the fragment (admin.py): class PacienteAdmin(ModelAdmin): list_display =…
-
2
votes2
answers795
viewsA: Read files . CAP efficiently with Python
To facilitate I simulated a file of the type . cap, creating a cap1.cap text file where each line has only the first characters (indicating the time), according to what Voce posted here. Stayed like…
-
0
votes2
answers166
viewsA: help with indentation that is generating error in python 3.6
First of all I suggest you follow the pep8 style guide (https://wiki.python.org.br/GuiaDeEstilo) recommending 4 spaces for indentation. Specifically about your problem: Change your While block (last…
-
1
votes2
answers3871
viewsA: Matrix multiplication
In fact when you express: n1 = [[1, 2, 3], [4, 5, 6]] n2 = [[2, 3, 4], [5, 6, 7]] You are just "representing" matrices, but in reality you are working with lists. In python, to work with true…
-
2
votes1
answer4680
viewsA: How to create a form and authenticate Django user
Use "the Django Authentication framework". Django brings "built-in" a User framework with User handlers, sessions, permissions and user groups. The User System already includes views for usual…
-
1
votes1
answer71
views -
0
votes2
answers712
viewsA: Rename application in Django Admin
To include the application in the project, you must add the reference to the application configuration class in the INSTALLED_APPS definition. The Controledebolsistasconfig class is in the file…