Posts by ThiagoO • 2,022 points
85 posts
-
0
votes0
answers34
viewsQ: React - ref returns null in event handler
I’m developing with React at a time but had found no reason to use refs, decides to read the documentation more deeply and I came across several examples that indicate to developers where it would…
-
0
votes1
answer144
viewsQ: Definition of props in Vue.js rendering function
The Vue.js possesses funções de renderização and various ways to define where the component will be rendered, such as the use of el, template and the function render. The render function has…
-
9
votes2
answers82
viewsA: Dictionary error
A dicionário can’t be chave from another dictionary because the key must be a objeto imutável, moreover it is more logical to define students as a list in the following way: dados = {'Alunos': […
-
6
votes1
answer177
viewsQ: Difference between props and propsData
In the Vue.js we have how to insert data into components through props as follows. const hello = { template: '<div>{{ message }}', props: ['message'] }; new Vue({ el: '#app', data: { message:…
-
2
votes0
answers44
viewsQ: Why extend the Vue.js constructor
I’m studying Vue.js and I came across the method extend which in the documentation says it provides a subclass of the Vue’s base builder. I can understand that, but I couldn’t find a practical…
-
0
votes1
answer273
viewsQ: How to test service worker locally?
In my attempt to understand the workings of Workers services I’m trying to implement the same in a basic application I’m serving locally, the problem is that the service worker fails to register,…
-
0
votes1
answer692
viewsQ: Creation of flask-sqlalchemy tables
I am developing a small application in Flask and I am using the extensions Flask-Sqlalchemy, Flask-Migrate and Flask-Script to manage my migrations in the database, follow the configuration of my…
-
3
votes2
answers154
viewsQ: Flask and its contexts
I’m new to the desenvolvimento Web and I’m studying FLask and it has some objects that should only be manipulated in certain context as the Flask.g and the Flask.current_app what I can’t understand…
-
1
votes1
answer92
viewsQ: Error while passing props with literal objects via v-bind="Object"
In Vue it is described in the documentation that you want to pass all properties of an object via props it is possible to pass it as follows # data do componente post: { title: 'Título da post',…
-
0
votes2
answers142
viewsQ: Manipulation of items during iteration
In Python it is somewhat common to go through items of a everlasting handling or verifying the existence of a particular item, or whatever the operation is. I am reading the Python documentation…
-
2
votes1
answer47
viewsQ: Execution order on a Promise
I have the following code: const execute = function() { return new Promise((resolve, reject) => { setTimeout(() => { console.info('Iniciou'); resolve('Executando'); console.info('Finalizou');…
-
4
votes3
answers122
viewsQ: Module Operator invokes special object methods
To biblioteca padrão do Python has the module operator, studying the same I noticed that some of its functions have say "aliases", for example: operator.setitem(a, b, c) operator.__setitem__(a, b,…
-
3
votes1
answer170
viewsQ: Differences between __name__ and __qualname__
In Python functions/methods and classes have two attributes that in their most "basic" use seem to do exactly the same thing, are they: __name__ and __qualname__, see: def fn(): pass class…
-
0
votes1
answer58
viewsQ: What is the difference between the wraps and update_wrapper functions of the funtools module
In the module functools of bibliotaca padrão of Python there are two functions update_wrapper and wraps in the documentation of the function wraps we have: This is a convenience Function for…
-
4
votes1
answer3271
viewsQ: What are environment variables?
I have seen many questions, articles and even some modules in the standard Python library where a term is introduced which is "environment variables". Here at Stackoverflow there are many questions…
-
3
votes1
answer1172
viewsQ: What are file descriptors and directories?
I’m studying the módulo os of the standard library of Python and I realize that in many cases a function is allowed to receive as a parameter a descritor de arquivo ou diretório some examples are:…
-
9
votes2
answers102
viewsQ: Why should descriptors instances in Python be class attributes?
I’m studying descritores in Python and I found that they should be implemented as atributos de classe for example: class Descriptor: def __init__(self, obj): self.obj = obj def __get__(self,…
-
0
votes1
answer132
viewsQ: Force the implementation of a certain type of abstract method
In the Python it is possible to define classes abstratas and métodos abstratos slightly simply, for example: class Spam(ABC): @abstractmethod def grok(self): pass This class cannot be instantiated…
-
1
votes1
answer45
viewsQ: It is not possible to use a v-for directive on passed prop to the Vue component
Follows the code: <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8" /> <title>Passagem de valores com VueJS</title> </head> <body>…
-
2
votes3
answers1982
viewsA: "for" with step "float": Typeerror: 'float' Object cannot be Interpreted as an integer
Only for sampling purposes notice the inconsistency of the result of this implementation of a generator that performs the sum of integers and floating point. def _range(initial, end = float("inf"),…
-
4
votes3
answers98
viewsA: Doubt in my code is not printing correctly
Your code that is wrong, when you perform the method call sort() It orders the list increasing but the data in the list returned by the method split() are of the type string, that is, when the…
-
0
votes2
answers724
viewsA: Concatenate variables in the Django template
Just iterate the items over the list using a for that it will carry an item per iteration without requiring a variable for indexing. For example to create a list in the Django we can do it like…
-
0
votes1
answer216
viewsA: Notification system
The Django already allows you to do this by implementing Signals which is nothing more than an implementation of design pattern Observer that allows you at certain times like before saving, while…
-
2
votes1
answer585
viewsA: Error: "illegal target for variable Annotation" using "@Property"
As I said in the nomination comment funções/métodos does not allow the use of the character ., so the syntax error. What you can do is with the method decorated with @property return the class…
-
0
votes1
answer29
viewsQ: Functions defined within conditional blocks
I am studying PHP and reading the documentation I came across this example: <?php $makefoo = true; /* Nos nao podemos chamar foo() daqui porque ela ainda não existe, mas nos podemos chamar bar()…
-
1
votes3
answers4852
viewsA: How to remove accents with regular expressions in Python?
View the function signature re.sub(pattern, repl, string, count=0, flags=0), the second argument of the same defines the string or função which will be used when Pattern successfully performs a…
-
3
votes1
answer21
viewsA: Problem registering an item
The page turns white because in controleProduto.php you are making conditional test statements that according to your code have no logic. You are setting a button as follows: <button…
-
7
votes4
answers2878
viewsA: Two "Return" in a function
The return immediately terminates the execution of the function by returning the value in question and the stream to the caller. even a function that does not explicitly define the return will…
-
2
votes2
answers4076
viewsA: Mouse Cursor - Javascript and CSS
Let’s go in pieces. The estate cursor: pointer does not simulate a behavior to certain situation? If yes, why is it defined via CSS and not by Javascript only? The estate cursor of the element…
-
2
votes3
answers134
viewsA: Explanation of name in php
The superglobal array $_POST receives data sent by the method HTTP POST, for being a array it has keys associated with values, in which case this superglobal array associates the value sent by the…
-
2
votes1
answer614
viewsA: Printing all attributes of a class
In Python there are special methods called often dunders(as they begin with two undercores) that are called under certain conditions when an object is being manipulated for example: class…
-
0
votes1
answer148
viewsQ: HTML classes in menu with Wordpress
I’m developing a theme with Wordpress and I would like the same to possess a menu dropdown. I created some pages like Home. Quem Somos, Contato and a category called Produtos would like the category…
-
1
votes2
answers711
viewsA: Split and rsplit methods, python
The problem in your code is in condition: if string[j:j+len(separador)] == separador Not that she is logically wrong but that she stipulates that only if the string current in the iteration is equal…
-
1
votes1
answer58
viewsQ: Image does not float with bootstrap 4
I’m trying to get the image to be next to the content on devices bigger than large but this does not occur: Follows my code: <div class="container"> <div class="row"> <div…
-
1
votes2
answers908
viewsA: Python - Transforming lists into a single list
I tried to abstract to a function and one of the forms would be this: def lista_unica(lista): result = [] for item in lista: if (isinstance(item, (list, tuple))): result = lista.extend(item) else:…
-
1
votes2
answers106
viewsA: Python - libraries without import "*"
You can do the import of an archive in Python using the following declarations. # foo.py def foo(): print("Sou foo") # bar.py import foo def bar(): print("Executando foo") foo.foo() As long as it is…
-
0
votes1
answer36
viewsQ: Header collapse with pure javascript
I would like to make a header that when scrolling down, it compresses its content. I have the following script so far. window.scroll(function() { var scroll = window.scrollTop(); var element =…
-
3
votes2
answers408
viewsA: Django + Python update and do not insert
It is not possible to know which form base class you are using if it is forms.Form or forms.ModelForm the question is whether it is forms.Form the same is trying to save an instance of Student who…
-
0
votes2
answers38
viewsQ: Error while trying to install wordpress
I’m trying to install the wordpress on my local server using xampp but I get the following error: Sorry, but I can’t write the wp-config.php file. You can create the wp-config.php file manually and…
-
0
votes2
answers454
viewsA: How to clone a list with Python 3?
There are several possibilities: >>> lista = [1, 2, 3] >>> copia = lista.copy() >>> copia [1, 2, 3] >>> copia = lista[:] >>> copia [1, 2, 3] In addition…
-
1
votes2
answers96
viewsQ: Guidelines for using object or procedural guidance in Python and PHP
I am studying PHP and Python and I am feeling a huge difficulty, not in relation to concepts, after all they are independent of language, what is making hard the study is how PHP implements the…
-
3
votes1
answer80
viewsQ: Conditional Assignment in PHP
I’m studying PHP and came across a Feature which does not exist in Python (I do not know in other languages), which is the assignment in a conditional test: $file = fopen("arquivo.txt", "w");…
-
2
votes2
answers301
viewsQ: When should I use a string object and a literal string?
Reading an article I find the following excerpt: You can call any of the methods of the string object in a literal string - Javascript automatically converts the literal string for a temporary…
-
3
votes1
answer5459
viewsA: Django: Reverse for '' not found. '' is not a Valid view Function or Pattern name
In the archive urls.py of your app is missing the slash in url by name create_student. Do so: from django.urls import path from .views import list_students, create_student, student_description…
-
1
votes0
answers103
viewsQ: How to name constraints in Mysql?
I’m trying to name constraints in the MySQL but unsuccessfully, I’m doing it this way: create table if not exists pessoas ( id int auto_increment, nome varchar(30) not null, data_nascimento date,…
-
0
votes1
answer856
viewsA: Django + Python how to update a table item
Enough in your view update the object in the database with Model.refresh_from_db follows a link to the documentation refresh_from_db.…
-
0
votes1
answer782
viewsQ: Python asyncio and threading
I’m studying the module asyncio of Python and there is the function run_coroutine_threadsafe which should be executed in a different thread than the event loop. Follow my script: #!usr/bin/python3 #…
-
1
votes1
answer78
viewsQ: Use await with object that implements the __await__method
From the Python 3.5 was introduced async/await I am implementing some objects long-awaited but I am met with doubts follows an example: #!usr/bin/python3 # -*- coding: utf-8 -*- import asyncio class…
-
3
votes3
answers1564
viewsQ: Python variable reference return
When we define a variable, basically we are naming a memory address, follows a script that represents my doubt: class Spam: _value = [] @classmethod def value(cls): return cls._value >>>…
-
1
votes2
answers558
viewsQ: Imports into __init__.py file
I’m studying the documentation of Django and noticed that in some files __init__.py there are imports, I know the archive __init__.py defines a module but do not understand why imports in it.…