Posts by jsbueno • 30,668 points
811 posts
-
1
votes1
answer30
viewsA: Flask does not expect function return to show view
since you have to wait for the function to return there, the simplest is __not usar_ Concurrent.Futures, nor threads - just do links_list = get_movie_players(soup). Using these parallel call…
-
0
votes1
answer312
viewsA: Exports data to excel with python
Your call result_format.format(key, value['Cotacao'], value['P/L'], value['P/VP'], ... ) does exactly what you are asking - takes all your data, which usually comes separately, and pastes all…
-
1
votes2
answers238
viewsA: What happened to Unicode in Python 3?
This change is actually the main change from Python 2 to Python 3 - and basically on account of her that they opted for the transition with breach of compatibility. All text in Python3 is now…
-
0
votes1
answer84
viewsA: I cannot use the shell in Docker-Compose
After the container has gone up, you can activate a shell within it (already running), using docker exec instead of docker run: docker exec -it nome-do-projeto /bin/bash…
-
3
votes1
answer242
viewsA: Matrix transposition
You have to remember that the numpy.ndarray not only for two-dimensional matrices, as we are used to, but for "multidimensional arrays" - so, if you have a two-dimensional matrix, and you don’t pass…
-
3
votes1
answer715
viewsA: Doubt about the __dict__ method in Python
__dict__ is not a method - is an attribute - and is the way implemented, officially, in the language of storing instance attributes in objects. It is a common dictionary, and you can use any code…
-
2
votes2
answers80
viewsA: Where do I add the ". py" calculations to the HTML page?
Python programs are not normally added directly to an HTML page - they can Beget HTML pages or data that will be rendered by javascript code. You interact with your Python programs from the…
-
3
votes2
answers294
viewsA: Regex does not take all span tag strings
the specific problem of this tag, in the example that is there, is that the cell content extends over more than one line. You didn’t put your Python code (it’s hard to answer the question like…
-
3
votes1
answer93
viewsA: Basic closures
You understood the usage correctly. But there are some traps that can still catch you - Pattern as you wrote in your example, does not bring great advantages over an object-oriented approach, or…
-
3
votes1
answer45
viewsA: What does this expression mean?
Although the library compatibility is marked as "from 3.4", this code is using Python 3.6-specific syntax up. Looking at the project page, in Pypi.python.org, they actually list themselves as…
python-3.xanswered jsbueno 30,668 -
2
votes1
answer164
viewsA: Named async Python class
The requests is a synchronous library - that is, nothing you do will allow requests to run in a non-blocking and collaborative way with asyncio, directly. A path would be to search Pypi for other…
-
3
votes1
answer445
viewsA: Access properties of a Python file
The method .stat object pathlib.Path brings the information in the form of a Namedtuple (basically, brings the attributes): In [1]: from pathlib import Path In [2]: Path("teste.txt").stat() Out[2]:…
-
0
votes2
answers354
viewsA: Improve python apply performance with lambda
To apply ai calls rsua function once for each line. The "lambda" there does nothing - it’s just a syntactic sugar to pass the specific columns to the other function calcMovelMensalCircuito - it…
-
2
votes1
answer91
viewsA: pop-up with python progress bar
Power can. I don’t have a windows here to put some examples - but most likely you can call these functions already ready for use in Python in pywin32 - https://github.com/mhammond/pywin32 - will be…
-
0
votes1
answer79
views -
0
votes2
answers274
viewsA: How to resolve character overlays (sprites) on screen with Pygame
Ah - with code it is easier. Although it is incomplete. The class Inimigo must inherit from pygame.sprite.Sprite, and instead of a common list, you should add the Inimigo in a group - a class…
-
3
votes3
answers4009
viewsA: How does the python sys module work and what is it for?
The module sys Python contains some variables and functions related to the operation of Python itself in the environment in which it is running. So actually, everything inside the sys has very…
python-3.xanswered jsbueno 30,668 -
1
votes1
answer116
viewsA: Problem Reading Unicode python file
If the file is in utf-8 itself, just state this explicitly when opening the file in Windows. Otherwise Python will use the default encoding system, which in case is latin-1, and the contents of the…
-
1
votes1
answer146
viewsA: Read binary file using struct created in C++
Struct in C or C++ defines the fields of your data object, and for each field, not only the name, but the exact type of data - and therefore its size in bytes. If the code writes the structure as it…
-
-1
votes1
answer71
viewsA: Cannot multiply the sequence by a non-int of type 'float', even when transformed into 'map'
Python’s default multiplication of a Sequence is "concatenate the Sequence with itself N times" - and is therefore defined only for sequences X integers. Apparantly you intend to have each Member of…
-
0
votes2
answers330
viewsA: Web scraping of a microsoft form Forms returns None [python]
Unable to retrieve information as it is being done. In doing requests.get you retrieve the html from the server to that URL - but that’s it - any external resources of the page are not recovered -…
-
2
votes1
answer243
viewsA: What’s the "@" in python for?
The "@" prefix of an expression that is a line above a function or class statement is a "decorator" (Decorator) . What they are and how decorators work is explained in the question that was marked…
-
5
votes1
answer822
viewsA: How to add license for my python application?
A 100% guaranteed way to do this does not exist. However, you can create the thing so that without doing a reverse engineering of your code the person has no way to use - and if you do, you will…
-
1
votes1
answer378
viewsA: How to save many arrays in the same txt in Python3?
Note that although you open file with "a" in the second access, you are not passing the file you opened (which is in the variable file) for the function savetxt numpy - instead, you pass only the…
-
3
votes1
answer217
viewsA: How to set default in parameters when specifying the type of the object?
The order of the Annotation (the type marking) and the default values is contrary to what you are trying to do: first the parameter name, the sign of :, the note, and then the sign of = followed by…
-
0
votes1
answer26
viewsA: Googlesearch library does not work
You’re trying to use the library the wrong way - the call search is not a library function googlesearch, and yes, a class method GoogleSearch. This class yes, can be imported from the library. This…
-
1
votes2
answers83
viewsA: How to specify different precision for different values in python
The problem is that the value before the : in the formatting expression, it is not an indicator of the numerical value before the decimal places - and, yes, it is what positional argument of the…
python-3.xanswered jsbueno 30,668 -
3
votes1
answer1279
viewsA: Referencing Variables in Python Imported Functions
In Python, the so-called global variables are not truly "global" - fortunately. This makes them manageable. The model you are trying to make is not the best - but do so, gain some experience and…
-
3
votes2
answers7068
viewsA: How to get out of one loop inside another through a function in python?
This coming out of nested loops really is a generational programming problem. The command break, as you may know, comes out of a single for or while, and it has to be directly inside that for or…
-
10
votes1
answer561
viewsA: How to program in java and python together
There is a Python 2 implementation called "Jython" - it allows you to execute Python code within the JVM environment, importing and instantiating Java classes normally. This is what is usually meant…
-
0
votes1
answer37
viewsA: Value of a variable to be equal to the comparison of two variables
A Python comparison, either between variables, or between direct values, will always result in an object Bool - with True or False value. The sign of = simply resove the expression right first, and…
-
7
votes2
answers105
viewsA: Does Python syntax accept either "+" or "," in the "print()" command?
"+" and "," in the print, are two very different things "under the hood" in Python - although the result may be similar or even the same. It’s important to understand what happens - and why "goes…
python-3.xanswered jsbueno 30,668 -
6
votes3
answers614
viewsA: Accept user input without pressing enter
This is boring to do, because "input" doesn’t even do this, and then it depends on calling, from Python, the Apis that each terminal application makes available - and they are fundamentally…
python-3.xanswered jsbueno 30,668 -
1
votes3
answers182
viewsA: Select returns nothing when I have NULL in foreign key
There is no secret - the SQL language was made to look English and only following the logic of its "Where" is it easy to understand that there will be no record for which the "a. subproject" is NULL…
-
1
votes1
answer397
viewsA: How do I connect to another network with a socket?
You have to study networks. Understand about NAT - and then yes, after you understand what you’re doing, or use a product like Hamachi, or configure your router at home, so that some of the ports in…
-
6
votes1
answer328
viewsA: How to increase the number of floats in python
In Python, "float" numbers use by default the floating point numbers available more directly on the CPU- think that on all platforms where Python is supported, this is 64bit floats (IEEE 754).…
-
5
votes1
answer170
viewsA: What is a constant?
Basically, regardless of the language, a constant is a declared value that goes along with the Runtime distribution of your code - that is, it is not a value that will change coming from some…
-
5
votes1
answer181
viewsA: Is it possible to merge Java with Javascript?
Unless you find a maintained Javascript Runtime project running on JVM, the only way to do that is to have two separate processes, with one of them acting in a "listening" mode - then you can use…
-
21
votes1
answer3610
viewsA: What exactly is the backslash ( ) for in Python?
\ "loose" in the code The backslash outside of strings serves to indicate a line change without leaving the context of the current line (that is - after a \, you can continue the current line on the…
-
0
votes3
answers450
viewsA: Rename files and move out of the Python directory
os.chdir is a bad approach to working with files in multiple folders, why the current directory is changed - and your program has to know "where it is". The best is always working with the directory…
-
4
votes2
answers2470
viewsA: How to use Python Random.Seed()?
To increase randomness, make use of random.SystemRandom(): The following happens: the most visited part of the official documentation shows "chargeable" that look like functions, in the module…
-
1
votes2
answers81
viewsA: Is there an extra parameter for the linux script command for characters to be saved with the correct encoding?
(attention: the question-specific example is not an encoding problem - this answer is for this example. For encoding problems see the @Leo response) In this case, it is not a problem of encoding:…
-
0
votes1
answer405
viewsA: Simulate click touchscreen in python
in fact, Pyautogui does not have Apis to simulate multi-touch. frmework Kivy has Apis to receive and manage multi-touch - but not to send events. summary - I did a search with the detailed path…
-
2
votes1
answer93
viewsA: Keep a larger number in a Python division
a * h = X b * C = Y so far so good No, there is nothing certain "so far" - these expressions may be mathematically valid, but they are a syntax error in Python, and make no sense (although they are…
-
1
votes1
answer71
viewsA: Check if e-mail has loophole through have I been Pwned (Selenium/Python)
You are checking whether the content Oh no - pwned is in the page source code, not on the screen. If you look at the source code of the page (as it is always good to do if it is developing with…
-
5
votes1
answer248
viewsA: Formatted printing that replaces the use of . format() in python versions from 3.6 onwards. How to use?
The f-strings actually use exactly the same formatting markups as the method .format - In the .format the markers : or ! indicate the beginning of the formatting markup - and what goes before these…
-
1
votes1
answer126
viewsA: curve_fit: can’t Multiply Sequence by non-int of type 'numpy.float64'
The problem is that although normal Python lists and numpy "arrays" both function as sequences, and can be passed in the calls to the plt, they’re not the same thing. In particular, one for Python’s…
-
3
votes1
answer350
viewsA: Screen system by console (python)
Zérima thing - you have to evaluate if you really want to make a larger application with console, only with input and print, or want to create something with a more familiar interface for users -…
-
5
votes2
answers245
viewsA: Nested data class built from a dictionary
There is no standard way to do this in language - and of course it can be useful in many cases. updating: A cool, modern, production-ready design that does this kind of thing (but needs to define…
-
3
votes4
answers620
viewsA: How to delete files and folders recursively safely with Python?
Writing data over the data of a file is not "safe" - and the reason is that it depends on the filesystem layer (F.S.) of the operating system to decide what to do when you open a file to write - and…