Posts by jsbueno • 30,668 points
811 posts
-
1
votes1
answer932
viewsA: How to perform functions simultaneously through a Socket?
So - you found out why there are higher-level protocols than TCP, like HTTP and FTP for example: TCP deals with the exchange of messages between two computers, with an established connection - but…
-
3
votes1
answer23453
viewsA: How to filter, select and count data on a pandas.Dataframe?
summing up A few separate steps are required for this. The Dataframe object is made so that the call to a method returns a new modified dataframe, and you can already concatenate the next operation…
-
2
votes1
answer331
viewsA: How to get a pixel color out of the screen limit in pygame?
Your screen is the screen, and it only has 500x500 pixels - you don’t know, and there’s nothing outside it. However, to draw the background image, you load it on the line: image =…
-
2
votes2
answers1265
viewsA: How to convert CSV to XLSX with python?
Another cool also (besides the Pandas) is the Rows (installable with Pip install Rows, but then will ask for manual installation of some other packages, also with Pip, to work). It is a Python…
-
3
votes1
answer239
viewsA: Is it possible to inherit a python class without writing all attributes in the definition?
Yes - The easiest way to do it is not perfect - but it is enough for most cases - It is about making use of the mechanism that the language has to write functions that receive an arbitrary number of…
-
5
votes1
answer3184
viewsA: Angular ignores line break in String
If the output is in html, then the \n is not a line break - in html, a character \n is a white space badge (whitespace) as the space (\x20) and tab (\t) . If your output is in HTML, you should be…
-
0
votes2
answers1051
viewsA: Python Build a multiplate parabola chart with matplotlib
Graphs in matplotlib require already filled numeric series in a Numpy array - Then, you can write a function that only cares about the mathematical part itself, taking an 'x' per input, and…
-
0
votes2
answers107
viewsA: How do you inherit a pygame class?
The class you should inherit in Pygame for noral use of the library is pygame.sprite.Sprite - the problem you had was just to confuse pygame.sprite which is the module, with pygame.sprite.Sprite…
-
2
votes1
answer1132
viewsA: Convert Float to Python Binary
Hello - let’s split - first final = []*16 Does nothing - a Python list is not an "array" - it does not have a number of fixed slots, and can grow dynamically with the methods append and extend. If…
-
6
votes2
answers997
viewsA: Django + Python, show modal using {% if %} in template
The code is ok - but you are not passing the variable show_modal from Python to template. This has to be done on the line that has the template rendered (and of course, for each variable you want to…
-
7
votes1
answer377
viewsA: If possible, how can I work with integer values of 1 million digits or more in python?
Yes - it is possible - Python integers have no size limit. I wouldn’t know if the internal implementation for operations with these numbers will be efficient enough to do several operations with…
-
1
votes2
answers66
viewsA: List counting elements
To add up the contents of a sequence, just use the sum. If you want to add up all the numbers in the list, you should not, of course, reduce it to a set using set. Already, to count the number of…
-
8
votes2
answers1283
viewsA: How to access the elements of a set (set)?
The data structure set of Python has no ordering - so it would make no sense to say "me give the element at position 0" (meuset[0]) - however, it is eternal! So if you have an action to perform with…
-
2
votes1
answer382
viewsA: How to kill the process automatically with Popen?
If you have the object created by the call to Popen (in the variable process, in the example you gave), and detect that the process task has been completed, just call the method wait in that object.…
python-3.xanswered jsbueno 30,668 -
1
votes1
answer49
viewsA: Sending mobile information to the web
You will make an HTTP request (HTTP Request) - more specifically, usually using one of the "POST, PUT or PATCH" methods to modify data or "GET" only to retrieve data. So in some documents "HTTP POST…
-
6
votes3
answers341
viewsA: Why am I calling the subclass method?
As already commented, casting does not change the object - it passes a "message" to the compiler that in that context he may consider that object to be of that class. But at runtime, the method…
-
0
votes2
answers121
viewsA: Using float to check overflow in unsigned long int
You don’t have the code you use to call this function from the outside there - but just passing a pointer to a type float for it to work. The problem there, for large numbers is that as many as…
-
12
votes3
answers6965
viewsA: Typed and untyped programming languages
Actually, it’s not a rule. You will certainly find exceptions on both sides. What happens most is a classification error about what is interpreted and what is compiled: this line was certainly…
-
1
votes1
answer89
viewsA: Python Telnet server that changes the title of the Putty window
The title change of the "connection window" is not part of the Telnet or SSH protocols, nor does it make sense to - but Putty emulates the behavior of VT100 terminals - and for these, a protocol…
-
2
votes1
answer38
viewsA: Error to replace characters
In C, a string is fundamentally different from a single character. Strigns are just a memory address that contains a string of characters ending with a byte "0" -in the above codex, just at the time…
-
3
votes2
answers1350
viewsA: Is there any way to receive email through php or in some other programming language?
Yes, you can write a program to "receive an email". And no, you don’t want to do it that way, I explain a little bit why. And definitely not its application can’t receive an email from an existing…
-
3
votes2
answers2791
viewsA: How to turn a character into an integer in C?
C strings, implemented as char array, are actually not "text" - they are only strings of 1 byte numbers (the char type). What causes these numbers to be interpreted as text is just the functions of…
-
1
votes1
answer806
viewsA: Collection of float type data from an Entry Widget - Python Tkinter
The .get will always return a string. If you want to use this content as decimal number, call float the value returned by .get() is the right thing to do. Probably when you tried you must have…
-
2
votes1
answer76
viewsA: Archive keyboard entries in Python
One of the easiest things to use in Python to read the keyboard directly is the library "pygame". With it it is possible to get information about the keystrokes pressed in real time (without having…
-
4
votes2
answers344
viewsA: name is not defined - name/variable undefined, Tkinter and slite3 help
In this case it’s quite simple: you’re making a class, not with loose functions - so by declaring the command=..., instead of command=adic, you must use command=self.adic. And, of course, since they…
-
4
votes1
answer83
viewsA: Python dunders __copy__ e __deepcopy__
They are invoked, but not directly by the language, but by the functions copy and deepcopy module copy of the library Pedron: https://docs.python.org/3/library/copy.html At the end of the…
-
3
votes2
answers130
viewsA: Local variable declaration in a PYTHON function
The key to understanding this is that everything on the right of the = is executed before by the language, and then she makes the assignments - then while doing a, b = b, a + b (which is the same as…
-
8
votes2
answers406
viewsA: Python calling super() in class that does not implement inheritance
In fact, the super Python does more than locate the explicit ancestors of a class. If he did just that, he might as well not even exist - he was always just explicitly putting the parent class in…
-
6
votes1
answer2323
viewsA: What is the difference between Python versions 3.4, 3.5, 3.6, 3.7?
The idea you had earlier is right - the only really old version that is still updated is 2.7. The other versions are updated, but with bug and security updates - no new features. New features always…
-
1
votes1
answer325
viewsA: Doubt with Django 2.0 views and urls
From what I understand, after your comment, you just want to make the code more elegant in the file urls.py. Instead of: ... from contas.views import index, cadastro, contato, sobre, novasenha,…
-
2
votes1
answer65
viewsA: How do edits count during debug?
It would be nice if you put an example of what variables you’re trying to change. But anyway, if you are trying to change local variables in a debugging function, this is not possible because of how…
-
15
votes3
answers1712
viewsA: Why is it considered wrong/bad to repeat an HTML ID?
It’s wrong because it’s in HTML specification that the ID must be unique. (Even, if you look at the linked document, which is the official specification of HTML 5, the English word "must" is used -…
-
0
votes2
answers534
viewsA: Python - Select clickable
Some considerations, without taking into account that you have already decided to use Tkinter: if it is a real problem to be solved, and not a learning exercise, first you have to choose what…
-
7
votes2
answers3155
viewsA: How does Python overload polymorphism work?
By default there is this in Python - Being a dynamic language the approach is completely different: All in Python is an object derived from the class object - and the language does not check the…
-
1
votes1
answer669
viewsA: Button Bind in Tkinter.ttk Treeview in another Class
The question is confused - once you put in the code and don’t say exactly what doesn’t work. But there is no magic, or special syntax of Tkinter - it’s just Python: The methods bind Tkinter ask for…
-
2
votes1
answer566
viewsA: Operationalerror: near "?": syntax error python sqlite3
The substitution of "?" (or "%", "{}") in calls to SQL drivers in Python, including Sqllite does not work exactly like normal string replacement: These calls only replace values to be inserted, but…
-
2
votes1
answer584
viewsA: What can’t be done with f-string that you can do when using . format?
In fact, it does. f"fps {55.3578:.1f}" The fstrings accept any valid Python expression, format.
-
2
votes1
answer55
viewsA: Is it valid for two objects to have reciprocal references?
Yes - there are cases where reciprocal references naturally are the most practical way to solve various problems, and the one you arrived at is one of those. What’s wrong with that? Not many - in a…
-
0
votes1
answer679
viewsA: run python on another machine
The most "Straightforward" way to do this is simply to use ssh - you leave the machine where you want to execute the preconfigured command, and accepting connection by cryptographic keys of an…
-
1
votes1
answer414
viewsA: Python - Tkinter - Dynamic Checkbutton does not take the value of the variable when referenced from another file/screen
Variables from the other file can be accessed normally if you import the other file - but not with the syntax from outro_arquivo import x, and use file name as prefix: For example, you could put all…
-
5
votes1
answer213
viewsA: Good practice of python tests
The unittest requires testing to be in classes more because of how it is implemented - it is practical to find subclasses of Unittests, and have setup and teardown methods for a set of tests - than…
-
1
votes1
answer860
viewsA: Using screens in Tkinter-Python
You have to have a reference outside the function that creates the new window for the created window - then just call the method .destroy hers. And that doesn’t have to be a global variable - you…
-
3
votes3
answers2181
viewsA: Python functions-Global and local variables
Yes - Simply declare the variable as global at the start of the function: def a(): global b b = "teste" a() print(b) (prints "test") The keyword nonlocal can be used in functions declared within…
-
2
votes2
answers110
viewsA: Output not expected in CSV Python (infinite loop) file
Sound - every half second this program calls the function WriteDictToCSV that destroys the generated file half a second earlier, and only writes the new data. The line with open(csv_files, 'w') as…
-
2
votes2
answers92
viewsA: Does Python Command Exist Similar to (Catch and Throw) Ruby?
Similar to the "catch" and "throw" of various languages, in Python we have the the "Try"/"except" blocks and the "raise" command However the use you are making in your example is basically that of…
-
3
votes2
answers551
viewsA: string manipulation python
There is a concept error there - the " b" is simply a control character, named "Backspace", which has decimal code "8" - when printed in a terminal , the terminal protocol is what causes the…
-
1
votes1
answer337
viewsA: Increase Spirograph Loop Speed in Turtle
How to Speed up a Spirograph Program on Turtle? Turtle is slow - but the biggest slowness really comes from the fact that she updates the screen after every step, no matter how small, by default. In…
-
1
votes1
answer701
viewsA: Using Tkinter together with a database
It is because the second parameter of the execute - where you are passing "ed.get()", must be a sequence - that is, even if you will only use a substitution in the query (which is the case, you only…
-
3
votes1
answer1437
viewsA: Attributeerror: __enter__ in context manager implementation
Can someone tell me where the mistake is ? Yes. On this line inside the __call__: return self.__enter__() The object that the with will use have to have a method __enter__. It is called…
-
1
votes2
answers115
viewsA: Is it possible to change the "href" of the <link rel="stylesheet"> of an iframe or even change the class/style an iframe element?
Iframe is not a normal element: it loads another page, which is only viewed in a parent page session. But apart from this "window" which is just for viewing, they are independent pages, as separate…