Posts by jsbueno • 30,668 points
811 posts
- 
		2 votes1 answer755 viewsA: How to save images to a server folder via sockets using python and opencv?You know that "sockets" are a low level of network programming, don’t you? It’s a point where you have to worry about every byte read, sending messages - etc... are details so complex, that in the… 
- 
		10 votes4 answers11601 viewsA: Set constant in PythonAs put in the other answers, Python, being a dynamic language, does not have the "constants" feature in a simple way: everything in Python is an object. When you define a literal number in Python… 
- 
		2 votes1 answer742 viewsA: Converting a text file to XML with PythonThere’s no magic there - is a complex data structure, which you want to transform into another complex structure - have to read the source file, line by line, separate the information elements of… 
- 
		10 votes1 answer3403 viewsA: How does any and all work in Python?I don’t know enough about the fundamentals of Javascript - but superficially yes. The "any" and "all" in Python are functions that receive a sequence or iterator and check the truth condition for… 
- 
		3 votes1 answer2149 viewsA: What is the difference between type and dtype?type is an embedded name of the Python language - is a call that either identifies the type of an object, or creates a new type. dtype is the name of a parameter/object member of the numpy numeric… 
- 
		1 votes1 answer766 viewsA: Creating Python objects from the databaseIn general you don’t want instantiating your object in Python to have the side effect of issuing a query to the database - The "default" way would then be to have a function __init__ which receives… 
- 
		7 votes1 answer104 viewsA: Always prefer xrange above range?In fact, in Python 3 there is no longer the equivalent of the "range" of Python 2 - the "range" is now what used to be the old xrange. But in Python 2 code, yes, there is no reason to use the normal… 
- 
		28 votes3 answers14315 viewsA: Pythonic way of defining setters and gettersLet’s go in pieces: When "the whole Internet" says one thing and you don’t want to do the same - who do you think is going the other way? In Python there is no custom of using getters and setters,… 
- 
		2 votes3 answers691 viewsA: Python 3.6 regular expression for inteitra phrase extraction(1) Regular expressions are not the most suitable tool to extract HTML content - it is best to use an HTML parser that does this -like the beautifulsoup listed in Miguel’s response, or the… 
- 
		1 votes1 answer128 viewsA: I wanted to improve the performance of my programIdeally put the function that takes time to calculate (even if "time" is 0.2s - is enough for the interface to appear non-responsive) into a separate thread. In this way, while in the main thread,… 
- 
		3 votes1 answer753 viewsA: How to create a pause method and one that resumes a Thread?There is not much magic possible, apart from some data care shared between the various threads. In your thread daughter, the only code running is the one in the "run" function and all other methods… 
- 
		4 votes1 answer901 viewsA: Store password in databaseThe normal in these cases is that the secret configuration is a token - which will be used as a symmetric password for DB - which will be available in a file or in a server environment variable. Of… 
- 
		1 votes2 answers2098 viewsA: Handling of Python Network SettingsI think this one pyroute2 does what you’re asking. If it doesn’t work, and you can identify shell commands that make the configuration you need, using Python to run these commands can be better… 
- 
		4 votes1 answer338 viewsA: Registration errorIn this stretch here: for record in result: if usuario != record[0]: print(record) return 'Usuario incorreto' elif senha != record[1]: print(record) return 'Senha incorreta' else:… 
- 
		5 votes3 answers809 viewsA: C program "eating" characters when executedPeople have already identified the mistake and put the right way - but I think it’s worth explaining what was happening: When placing the line: printf("insira a idade do aluno %d" + (i + 1)); The… 
- 
		3 votes1 answer1445 viewsA: python (on/off key)Unfolding your question Python is a generic language - it’s good for anything. Only to do anything, she has to be able to connect to inputs and outputs with the data she wants to process. A Python… 
- 
		0 votes4 answers4955 viewsA: Questions about Python functionsProgram 1: you fill the full rectangle filled, not with the inside of the blank rectangle Program 2: Your check function does not test "n" number - will go wrong when n is prime. Program 3: The… 
- 
		1 votes3 answers176 viewsA: Is there a difference between "str(my_object)" and "my_object. __str__()" in Python?Apart from the other two answers, which are correct, it is worth mentioning that the standard implementation of __str__ - classy object, from which all Python objects derive, make a call to the… 
- 
		1 votes1 answer1157 viewsA: Django does not render static files that are in subfolders within /Static/Static purchases are only automatically served by Django himself in the development environment. In the production environment, you must configure your front-end web server to serve the static files… 
- 
		3 votes2 answers498 viewsA: How to assemble a list of generic objects in C?So - C is a statically typed language, with no static support for objects. on the other hand, it gives you control over almost everything you want to do, and provides a kind of "generic" data -… 
- 
		2 votes2 answers2038 viewsA: How do one class that is inside another inherit an instantiated variable from the last one in python?Without understanding your problem is a complicated question to answer. The question doesn’t make much sense. But come on - why do you want to declare one inner class to another? The class statement… 
- 
		2 votes1 answer81 viewsA: Doubt about Regular ExpressionThis regular expression here solves: "^\s*?(?P<numero>(\d\.)+)\s*(?P<titulo>.*)$" You did not say what tool you will use to apply the regular expression - this may have something… 
- 
		5 votes2 answers1056 viewsA: Class return key and value of my attributesYes - there are several ways to do this, and the wisest ones will work in conjunction with your need to assign multiple fields from a formatted line. Of course objects in Python have the attribute… 
- 
		3 votes1 answer86 viewsA: Game of life, what’s wrong?OK - Your question is not well formulated in the sense that it does not speak exactly what the error is. How I’m half a fan of game of life, persisted a little - it was only when I created a… 
- 
		2 votes2 answers911 viewsA: How can I use two methods in one line in python?It is not a matter of "using two methods on the same line" - it is just that "Sort" does not return any value: it sorts the list internally. But Python also has built-in function sorted- it creates… 
- 
		2 votes1 answer1135 viewsA: Function to mount query from table and add array in function(I answer your question, but the best ways to proceed are at the end) Python has several - maybe more than 10 - different ways of formatting strings interpolating with values. Staying in the… 
- 
		18 votes5 answers1106 viewsA: Is SOAP safer than REST?SOAP has more bureaucracy than REST. Basically the difference is that in SOAP, all data types have to be pre-defined in the interface contract - so the SOAP layer itself will already issue an error,… 
- 
		0 votes1 answer29 viewsA: Reading variables from an object that was created in anotherYou are creating the variable Lv1 inside MonsterCriado, but it doesn’t really save that value anywhere. (Well, actually, as it did not state the variable Lv1 it is believed in the global scope,… 
- 
		4 votes2 answers3050 viewsA: Scroll through a Dict until it is empty in PythonWow - - too complacent for something that looks very simple in Python. Dictionaries have the methods keys, valuesand items that allow access to its members, and the powerful list-comprehension… 
- 
		1 votes2 answers1916 viewsA: When generating a soup of letters with random letters how to place the words without matching?As you have already noticed, only with the information constant in the grid if it is already filled in, it is not possible (or very difficult, but possible) for the "by word" function to notice if… 
- 
		2 votes1 answer88 viewsA: How to list the synopsis of classes?As it is in the comments - the text that is displayed when the help Python is what is defined in modules, classes or functions as "docstring" - it becomes available as the attribute __doc__ of the… 
- 
		8 votes1 answer1482 viewsA: What is the difference between __init__ and __new__?The __new__ is called by Python before of the object being effectively built: that is, having memory allocated to it, initialized pointers, and possivelment a few more things - all these things are… 
- 
		18 votes1 answer5427 viewsA: How to configure apache2 for python 3.5.2Understanding why CGI is no longer used This setup you want isn’t so hard - but I reserve the right not to answer it right away (in an update, I added this information at the end of the reply)… 
- 
		2 votes1 answer325 viewsA: How can I access a hard drive sectorYou don’t do it. Not as a user-level program: The operating system does not allow programs (in contrast to device drivers) to have access to the hardware - but allows access to layers abstracted… 
- 
		13 votes1 answer1015 viewsA: What is the purpose of __slots__?The __slots__ is a very special attribute for classes - when it is not present, for each new instance of the class, Python creates a new dictionary, but it does not do this if the class defines… 
- 
		0 votes2 answers584 viewsA: Python socket keeps open even using CloseTo documentation do Python diz: "close() releases the Resource Associated with a Connection but does not necessarily close the Connection immediately. If you want to close the Connection in a Timely… 
- 
		1 votes1 answer898 viewsA: Python sockets disconnect clientHave you ever just tried conexão.close()? In fact the documentation says that to close immediately you can also use the method shutdown before the close: conexão.shutdown() conexão.close()… 
- 
		9 votes2 answers8927 viewsA: In Python, what is the difference between == and the is command?To complement Maniero’s response - the is only compares if the objects are the same. O == compare if they are the same. A lot of people fall into the use trap is to compare strings - but sometimes,… 
- 
		2 votes2 answers156 viewsA: How to Ensure Writing File on a Single Disk Block?"Is there any way to do it?" Not. Unless you use a raw partition and implement, in practice, your own file system. On Linux systems, partitions can be accessed as normal files in the /dev folder,… 
- 
		2 votes1 answer241 viewsA: Accent problem when running python script straight from C#What happens is that when you run a Python script straight through the command, it can detect the terminal encoding (which is "cp-852") and encode the output accordingly. When you run from another… 
- 
		2 votes1 answer5595 viewsA: What is the best way to perform a menu with submenus ( while with breaks or calling the menus in functions )?When they invented programming functions, it’s because they’re MUCH BETTER to organize the program and its contents - and this includes organizing the menu structure: you should not think that only… 
- 
		12 votes1 answer148 viewsA: When it comes to Python’s "list", is it wrong to call it an "array"?Yes, technically it is wrong - and it is worth commenting when the terms are used without differentiation. The first factor is that exist Python arrays - both in the standard library, in the module… 
- 
		4 votes1 answer513 viewsA: Exception handling (Try) error in python"Try does not treat the exception" for the simple reason that there is no exception - as you can see in the terminal, you have "warnings", no exceptions. You can change the context of Numpy so that… 
- 
		2 votes1 answer62 viewsA: Query with parameterThis - I didn’t see the video with audio, but yes, this code is wrong. The parameter instance is mandatory and is not passed on - maybe it was an example of code created by live while the video was… 
- 
		3 votes1 answer3202 viewsA: Problems with accentuation - PythonWhen you have a little time, read this here. The title might scare you a little bit -but it’s the best introduction to accent and special characters I’ve ever seen. That being said, what happens is… 
- 
		2 votes1 answer80 viewsA: When a 'cloned' struct is changed it changes all the othersThe problem is that C, unlike higher-level languages with native object orientation support, does not "create" independent objects for you just with language syntax - you have to do this manually.… 
- 
		5 votes1 answer278 viewsA: Importing specific modules is faster/performative than importing everything (with the asterisk)?Time is exactly the same - the difference is in the readability that your own code will have - In the example you set yourself from biblioteca import * ... # 300 linhas depois ... for elemento in a:… 
- 
		1 votes2 answers936 viewsA: Chained list: how to modify data from a list without changing the others?So - what you want to do is confused How Voce is doing is confusing (you put a code "more or less like this", but it doesn’t have everything that is happening) - and you could have given some… 
- 
		6 votes1 answer2127 views
- 
		4 votes1 answer7101 viewsA: How to read PDFReading a PDF is a much more complicated process than it sounds. If you just want to extract the text, this library slate that you are caring is what makes it - only that in your attempt you even…