Posts by Woss • 73,416 points
1,476 posts
-
1
votes1
answer527
viewsA: Runtimeerror: maximum number of recursive calls exceeded - python
Python, by default, allows you to have a maximum depth equal to 1000 within the recursion; when this value is exceeded, the quoted error will be issued. Runtimeerror: Maximum recursion Depth…
-
17
votes1
answer1876
viewsQ: What is Global Interpreter Lock (GIL)?
One of the first things you read when you start studying about threads in Python (Cpython) is about the Global Interpreter Lock (GIL). What exactly is GIL? What are its practical implications for an…
-
2
votes1
answer988
viewsA: Python - invalid literal for float()
The problem is in the format of its value, such as string. You are using the comma as decimal separator, but Python uses the dot. That is, to convert to float, your string should be something like…
-
7
votes1
answer129
viewsA: Function adding values within the list
Your mistake is in the indentation of the expression return total; you put the return inside the loop of repetition for, thus the function will always end in the first iteration, returning the value…
-
0
votes1
answer3717
viewsA: Ways to find out which is the largest and smallest number typed in the user input in a for
You can start the values as None, instead of using values too large or too small and, within the loop, check whether the value is None; if it is, assign the first weight both to the lowest value and…
-
4
votes2
answers17879
viewsA: (Python) Sort lists without Sort()
A little more solution pythonica of reply from José would be: numeros = [] for _ in range(8): numero = int(input("Digite um número: ")) for chave, valor in enumerate(numeros): if numero < valor:…
-
4
votes1
answer2152
viewsA: Python - Open multiple files in one For
Solution with pathlib.Path A simple way to do what you want is by using the library pathlib, available from version 3.4 of Python, through the class Path. Passing a path as the constructor…
-
5
votes2
answers401
viewsA: How to display text with multiple lines with format?
From what I understand, you want if the output is displayed in multiple lines. As it stands, it results in the error: Indexerror: tuple index out of range For the simple fact that his string expects…
-
5
votes3
answers222
viewsA: Getting TD value and placing it in the array - Javascript
You can get the elements td you wish with the querySelectorAll, go through the returned list and add to the array the value of the attribute innerHTML. Take an example: const tds =…
-
12
votes2
answers1007
viewsQ: What is Ellipsis in Python?
In the list of native constants from Python, you can find Ellipsis. print(Ellipsis, type(Ellipsis)) #-> (Ellipsis, <type 'ellipsis'>) In Python 3, there is still syntactic sugar ... that…
-
5
votes1
answer358
viewsA: Sort lists with multiple parameters using lambda expression
The method sort, class list, when used with the parameter key will execute the sort as the value returned by the expression defined in key, not the value present in the list itself. For your case,…
-
2
votes1
answer707
viewsA: Why use Mutationobserver instead of Mutation Events?
In the documentation of MDN about the Mutation Events there is: The Practical reasons to avoid the Mutation Events are performance issues and cross-browser support. In the same documentation it is…
-
5
votes2
answers2397
viewsA: How to transform str into int?
What you’re doing makes no sense, because the string 0 x 0 is not a valid numeric format, so results in error. To get the two values that form the scoreboard, you can use the method split of string:…
-
2
votes1
answer393
viewsA: How to remove null, false and true values from Json file?
Just do a recursive function: def filter_dict_by_value(dicionary, values): result = {} for key, value in dicionary.items(): if type(value) is dict: result[key] = filter_dict_by_value(value, values)…
-
2
votes2
answers949
viewsA: Only take a PHP variable from another page with Jquery
Making the PHP response with JSON will be the easiest way to handle it with Javascript. First, as the PHP file will be requested through AJAX, it is not necessary to have all this HTML structure. It…
-
3
votes1
answer624
viewsA: Adding values from a PHP array
Why You No Longer Sum Up The Values Within Your Own Loop while? $somaLargura = 0; // Será a soma das larguras $somaAltura = 0; // Será a soma das alturas $somaComprimento = 0; // Será a soma dos…
-
0
votes1
answer33
viewsA: Class attribute in constructor
The problem is that when you perform an anonymous function within your class, the reference to this is no longer for your object, but for the object of the AJAX request defined by $.ajax jQuery.…
-
5
votes1
answer53
viewsQ: Is it possible to prevent the user screen from erasing on a page?
I believe that all operating systems have the option for the screen to erase after a certain user downtime, mainly as a way to save battery, however, it is not always desired that this happens. For…
-
5
votes3
answers1234
viewsA: My String is giving error "unicodeescape"
The path of a file in Windows generates a conflict in Python due to the backslash. When you use, for example, C:\Users, Python will interpret the character \U as an escaped U, similar to what occurs…
-
1
votes1
answer810
viewsA: How to keep a key press in pyautogui
As the very documentation says, the function press nothing more than a shortcut to the execution of the function keyDown followed by the function keyUP. That is, when performing the function…
-
1
votes1
answer592
viewsA: Kivy event with keyboard
First, you will need to import the class Window to your code: from kivy.core.window import Window So you can get keyboard events from the method request_keyboard. The first method parameter is a…
-
2
votes2
answers1761
viewsA: Read txt file and validate javascript
As I said, with Javascript running in the browser will not be possible - simply, because Javascript does not have access to files. You commented that are simple validations, are it will be more…
-
2
votes1
answer862
viewsA: Get SRC attribute value of an image in a string
Javascript With Javascript, you can create a new element programmatically, insert the contents of your string as content of this element and after using the function querySelector to fetch the…
-
22
votes1
answer4503
viewsQ: What’s the difference between global and nonlocal in Python?
In Python, there are two statements that are used to reference variables outside the local scope: global and nonlocal. What is the difference between the two statements? When to use each?…
-
21
votes1
answer4503
viewsA: What’s the difference between global and nonlocal in Python?
The functioning of both statements is quite similar, what changes is the scope for each reference. The statement global always refers to the overall scope, that is, the scope of the programme…
-
2
votes2
answers521
viewsA: Validation function gets number 0 or 1
The error is in your condition. When using the empty, which may give rise to unexpected results because empty(false) returns true, entering the if, but empty(true) returns false; When using strlen…
-
4
votes2
answers7137
viewsA: What does KWARGS in Python mean?
As Felipe commented, the nomenclature of the parameter comes from keyword Arguments and, yes, it has a certain relationship with the named parameters. With the named parameters, you can set the…
-
3
votes4
answers571
viewsA: Apply class to a link within an echo?
Yes, the problem is the quotation marks in the middle of your string. I would particularly recommend you to use the printf in this case. <?php $href = $pasta . $resultado["nomearq"]; $label =…
-
2
votes1
answer512
viewsA: How to delete characters from a string within a Python array
To remove the character \n of the line, just you use the method strip: subVet.append(file.readline().strip()) The method strip will return a string by removing blanks and \n both at the beginning…
-
23
votes2
answers3224
viewsQ: What is the Rust programming language?
According to the official page of language: Rust is a system programming language that runs incredibly fast, prevents segmentation failures, and ensures cross-threaded security. It is relatively…
-
4
votes1
answer550
viewsA: Problems with PDO class not found
When you reference a class within a namespace without identifying it with the instruction use, PHP will understand that this class will also belong to namespace. I mean, in doing: <?php namespace…
-
6
votes3
answers1500
viewsA: When to use blank lines in a Python program?
Python has a style guide that is widely used by the community and there is a section on blank lines in the code: PEP 8 -- Style Guide for Python Code: Blank Lines. Below I will quote the original…
-
4
votes1
answer4647
viewsA: How to manipulate strings with ". find"
The method find shall be used only if you are interested in the position of the occurrence in string, that is, to know in which part of string the desired value was found. If the intention is only…
-
3
votes3
answers7670
viewsA: Check if element exists inside another element with Javascript
There is, just try to select the element in the DOM and verify its existence. When it comes to elements with the attribute id defined, just do: const pai = document.getElementById("pai"); const…
javascriptanswered Woss 73,416 -
6
votes1
answer1847
viewsA: How to enable autofocus with jquery in a div?
Just use the function focus jQuery when you want to focus on the field. For example, focus on a text field by clicking the button: $(() => { $("#btn").on("click", event => {…
-
14
votes3
answers135
viewsA: Why 1 2 is 3 and why when I display 0x33 appears 51 and 022 appears 18?
Why 1^2 = 3? Because the operator ^ is a bit-by-bit operator that performs the XOR operation between operands. If we imagine the binary representations of the numbers (considering only 2 bits -…
-
1
votes1
answer21
viewsA: help with for loop, with variable approaching 100
To identify the last iteration in the loop, just check the value of your control variable. In your case, the control variable is i and varies from 0 to quantasImagens, then when it possesses the…
-
8
votes2
answers3074
viewsA: How to calculate numbers in a given range?
This question seems to be quite a common exercise in programming initiation and I will answer as such. I’ve been a monitor of the discipline of algorithms at university and I’ve always noticed that…
-
3
votes2
answers824
viewsA: How do I make the program show all the combinations and then the number of combinations that were formed?
To know the number of combinations, just save them all in a list and check after their size. from itertools import permutations word = str(input()) sequences = list(permutations(word,len(word))) for…
-
12
votes2
answers2720
viewsA: Differences in the use of $this, self, Static and Parent
The recipe is: use the one that should be used. As you well described, the four do different things, so just use the correct, there is no better. Parent It refers to the parent class that has been…
-
3
votes3
answers408
viewsA: Sort array by itself within PHP Intel
With PHP 5.5.0 or higher, you can make use of the function array_multisort together with the array_column: <?php $arr = [['z', 'b', 'h', 'd', 'e'], ['b', 'c', 'r', 'i', 'l'], ['q', 'w', 'y', 'u',…
-
13
votes2
answers671
viewsA: What is HTML Outline (HTML Outlines)?
This is all about Semantics... And semantics matter! If you could, it would be written in red and blinking... Understanding the Outline The term Outline, in this context, it would be better…
-
1
votes1
answer434
viewsQ: When can the setSelectionRange method of Htmlinputelement be used?
Studying the structure of an element HTMLInputElement I arrived at the method setSelectionRange, selecting the text from the positions defined by the parameters, i.e. input.setSelectionRange(0, 8)…
-
0
votes1
answer103
viewsA: Array reading with JSON
If you need to go through the orders, then the foreach should iterate the list of orders, not customers. Probably the "failure" you quoted is an error saying that the array…
-
3
votes1
answer2910
viewsA: How does the 'Shown.bs.modal' event work?
The event shown.bs.modal is a custom Bootstrap event related to modals. Internally, Bootstrap uses functions that jQuery implements to work with such events: the functions are on and trigger. To…
-
1
votes1
answer319
viewsA: Compare two emails at registration time
To retrieve the values typed in the form on the server side, with PHP, you can use the superglobal variable $_POST. It would be something like: $email = $_POST["email"]; $confirmacaoDeEmail =…
-
3
votes2
answers240
viewsA: Concatenate items into a vector
What you are receiving from the database seems to be a list of only one value string, then you will not be able to access the values as if it were a list. What you can do, and it works for this…
-
1
votes1
answer253
viewsA: Insert Data Tuple into same database cell
The initial error is in the form that is passing the value to the function. When you do (cobertura) you are not creating a tuple, as Python interprets only that parentheses are to control the…
-
0
votes2
answers5888
viewsA: Add button, insert input value inside the form itself
The solution with textarea is bad and not usual. The function of this element is to store a text, not a list, so using it is wrong and not semantic. If your problem is having multiple ingredient…
-
4
votes2
answers792
viewsA: What’s the difference between echo, print, var_export in PHP?
As for the comparison between echo and print: Both are language constructors and not function; print receives only one value, while echo receive as many as necessary; print always returns a int 1,…