Posts by jsbueno • 30,668 points
811 posts
-
4
votes1
answer159
viewsA: Why does this instance variable never take False value?
Your __eq__ calls Len(self) which in turn uses prperty data that resets the order_stability - since you have detected the problem in the IDE, what may be happening is that the IDE is comparing its…
-
1
votes1
answer81
viewsA: Concurrent.Utures and Class Object
Your problem is that when creating a task in your Executor you are calling the function, when you use the expression run_single(). In this case the question is not very well posed, or that has…
-
1
votes1
answer1154
viewsA: Game Snake in pygame: Snake growth function
Without actually studying all your code - Snake’s idea is that all the time you don’t have to worry about the "middle" segments of the snake - (except to check for collision) With each game status…
-
0
votes3
answers225
viewsA: Update Python on LE 4.0 (Ubuntu 10)
If you change the Python _do_system_ by changing the minor-version, you will basically crash your system and need to reformat. Microversion updates (from 2.6.5 to 2.6.6) should work automatically…
-
3
votes3
answers7867
viewsA: Instantiate a Python class using an object as argument
I answered your other question in Restrict __setattr__ when the attribute does not exist within the Python instance with something that should solve your problem. has some concept errors in how you…
-
5
votes2
answers205
viewsA: Restrict __setattr__ when the attribute does not exist within the Python instance
Maybe you don’t need to declare the __setattr__ - Python object model defines special attribute __slots__ which, being declared in one class and in all the superclasses, restricts the attributes…
-
1
votes3
answers706
viewsA: virtualenv with kivy
So - the PIP inside and a virtualenv solves all of the Python package applications inside - but some Python packages rely on compiling C code for their installation, others rely on native system…
-
1
votes1
answer416
viewsA: Reinstalling Python on Ubuntu 14.04
Well, at this point, it’s more likely that you need to re-install your Ubuntu. Python2 is an integral part of a modern Linux system (not just Ubuntu), and as you noticed, the system can’t function…
-
0
votes1
answer393
viewsA: Problem calling DLL in Python ctype windows
I would say that the problem is how you are converting your Python data to pass to C++ - You do not show how to declare your variables Entrada, iv and chave - but the ctypes.cast does not convert a…
-
5
votes2
answers182
viewsA: Exit multiple loops without using goto
In C it is possible to have a control variable that is part of the expression of for - you arrow it into the innermost loop, and this leaves false expressions of the most external loops. Only that…
-
7
votes3
answers1045
viewsA: Fibonacci with parallel execution? Threads?
This implementation is not paralyzable "for real", besides being a "catastrophe". Yes, you want to know how to calculate different fibonaccis in parallel threads or processes - the answer to that…
-
2
votes1
answer397
viewsA: error: invalid use of Undefined type 'struct Fila'
extern indicates functions or variables that are in other files - but gives no hint to the compiler of which is the signature of a function, or, in the case of structs, its size and its actual…
-
4
votes1
answer2424
viewsA: running split() to form a list within another list
You want something like: novo_conjunto = [] for a in lldir: nova_lista = [] for b in a: nova_lista.append(b.split(', ')) novo_conjunto.append(nova_lista) a = novo_conjunto If you want in one line: a…
-
1
votes2
answers245
viewsA: ignore in function call if empty
If a list is empty, and the function is to use the list elements, you do not need to do and - the body of the for which will use the list will simply not be executed. def funcao(x): for lista in x:…
-
4
votes2
answers3574
viewsA: Abstract Python class, how to choose implementation
The simplest way to choose which unstable object depending on some condition of the program is to use a function for it. The name "complicated" is "Factory Function" or "Factory method". In some…
-
0
votes3
answers257
viewsA: Program executable problem created in c
Passing parameters by refection - with pointers, using * - is not magic! it is necessary to understand what she does - In C we indicate that a function receives a pointer, with "*", practically only…
-
1
votes1
answer65
viewsA: Segmentation Fault in Double Chained Lists
You do not initialize L1 and L2 in main to NULL - thus calling to inserir pdoe assume that there is already a list, and simply try to put a pointer to the new node in the middle of the random…
-
2
votes1
answer56
viewsA: what is the error of this code
Study the coemnet done, and try to improve the issue - but looking at the code, even without knowing the message you see, one wrong thing is that the method _init_ should be __init__ (with two…
-
1
votes1
answer1247
viewsA: Solve duplicate items in Dict in Python 3
You didn’t say the most important thing: what to do when you find duplicate keys! A dictionary has to have distinct keys - but nothing prevents each value from being itself another tuple, or even…
-
0
votes2
answers74
viewsA: Choosing an index from a list
Just pass a subset of the list to Random.Choice: random.choice(l[6:14])
-
0
votes1
answer102
viewsA: Python 3 dicts and zip problem
Your list "x" is used as a key for dictionaries: the keys of dictionaries are unique - any repeated value of x there goes over-write the previously stored key/value pair. What is happening is that…
-
1
votes1
answer624
viewsA: Is it necessary to close Mongodb connections with Pymongo?
A scalable WEB application should not open a connection to fulfill each request - instead, the practice is to have a set (Poll) of active connections that are reused to each web request. As you are…
-
10
votes4
answers1231
viewsA: Very interesting switch/case on Swift - What other languages support this?
In Python there was an intense discussion about this in the forums where we discuss the future of language at the beginning of the year - but the inclusion of a specialized command equivalent to…
-
1
votes2
answers1808
viewsA: Assign a value to the pointer and multiply (directly)
&a is not a value - is the address where is the value that was typed in the scanf - the same address as its variable "a". Each address can only have one value - so even if some gymnastics you…
-
1
votes1
answer1352
viewsA: How to fill a heart?
The answer is unfortunately a little more complicated than you would like. For the following reason: your program does not draw - your program calls the "gnuplot" which does the drawing externally.…
-
1
votes1
answer56
viewsA: When I edit a spreadsheet with pyexcel it loses its appearance
It is in the description of the Pyexcel package - Known constraints: Fonts, Colors and Charts are not supported. That is, this package, although convenient, currently simply discards the appearance…
-
0
votes1
answer132
viewsA: Python. Picking up a substring in a formatted text
Despite being a simple example of taking the data or filtering the lines or using regular expressions - as the text is a valid XML, the recommendation is to use the XML tools to get the desired…
-
0
votes2
answers256
viewsA: Insert Into Array Problem
Your problem is in this class class statement, along with a mistake common with anyone coming from Java to Python: class Turma: nome = None sigla = None alunos = [] def __init__(self, _nome,…
-
2
votes1
answer594
viewsA: C Language: Manipulating a vector of structs within functions
The problem is only that the compiler arrives at the so-called "exchange" function in its "main" function before "seeing" the "exchange" statement - then assumes it is a function that returns a int…
-
1
votes1
answer100
viewsA: Error sending - get request.
The error must happen on the line s.send(req) - the socket.send method expects a string (or a buffer, not a "path" - will be that you transcribed the message incorrectly?). What happens is that on…
-
1
votes1
answer590
viewsA: Python -->Valueerror: incomplete format
The "Valueerror incomplete format" error is due to the fact that Python did not recognize a replacement sequence starting with % at some point where you used the operator % for substitution. If you…
-
1
votes1
answer396
viewsA: How to Reverse Engineer MYSQL Database with Sqlalchemy?
Having tables in memory as Pythonicos objects is something Sqlalchemy does alone. However, if appropriate, generate a '.py' file with the templates themselves, is something that needs to be done…
-
6
votes2
answers467
viewsA: Iterate a list inside a switch
update 2021: In version 3.10 of Python the construction is being introduced match/case, which can also function as the switch/case of C, although it is not the main objective. Check in: How Python…
-
1
votes1
answer245
viewsA: Database in Tupla
The simplest way is to use the OrderedDict instead of the dict inlaid - OrderedDict is a data structure similar to a dictionary, available in the module collections standard library - but unlike a…
-
3
votes2
answers121
viewsA: Turn cycle into higher order function
In Python that’s a line: sorted(i[3] for i in x if i[0] == y) Forget the use of "map" in general it is more complicated than the "Generator Expressions" and "list comprehensions" that we have…
-
2
votes2
answers3669
viewsA: Decoding of file in Python
The "b'" prefix in the representation of your object shows that the text you have at that point in your program is an object bytes, not a text string. In Python 3 the two things are different -…
-
1
votes1
answer2321
viewsA: Fetchall() limited in python
It is possible to do this yes - I wonder if it will be useful to simply store the values in a text file: in general recover the desired data in the database and process them directly is better than…
-
2
votes1
answer124
viewsA: Problem to install RPM on Ubuntu
And why you want to install RPM packages on your Ubuntu? Don’t do this - install native Ubuntu packages from an appropriate repository - if you need a Python library that doesn’t happen to be in the…
-
1
votes1
answer40
viewsA: Error in libpython, installing Trac, running apache 2.4
Yes -the solution is not to use mod_python - According to the Trac documentation - https://trac.edgewall.org/wiki/TracInstall - mod_python would be one of the options - however the development of…
-
0
votes1
answer702
viewsA: How to separate each sequence of equal numbers from a string?
You have to think about how it’s done and write the code - should be able to do with regular expressions, or do in a single line with map/reduce techniques - but the explicit code in some lines is…
-
2
votes2
answers928
viewsA: Typeerror: Incorrect padding
You are having an error saying that formatting your value in Base64 is incorrect - now, I find that hardly your decrypted password in the "AES" library would be in Base64 (it is at this return value…
-
1
votes2
answers1819
viewsA: How to calculate the percentage of items performed in a data tree in the list format?
Python is a cool language because it doesn’t usually come between "you and the problem" - in this case, I think it took me longer to understand how you came to this 45.83% than to think of a way to…
-
3
votes2
answers156
viewsA: What to use instead of "-use-mirrors" in the PIP?
Nothing. Just don’t put the option - leave pip install -r test-infra/requirements.txt Today there are no mirrors from the original Pypi Store - I suppose the improved scalability of networked…
-
2
votes1
answer226
viewsA: How to use python files
At first glance, there is no problem in the program that would justify an error in the line you indicate - but there are several other problems in building the program, which will make it not work…
-
3
votes1
answer532
viewsA: Starting in Python Django
Your question is not entirely on-topic - but come on: I am web programmer working with Zendphp OS linux Ubuntu and solved migrate to python. I have some questions. Python is a language performed!…
-
5
votes2
answers125
viewsA: Why does the list show the first two elements?
The system of slices - Python slices work intuitively, and to this day the best way I have found to explain how it works is to make analogy with a ruler. Imagine that you have a ruler, in…
-
2
votes1
answer676
viewsA: Obtaining numerical values of mathematical graphs with python
No, that’s not a trivial thing to do - and I don’t know any packages that can do that automatically. Given a specific graphic image, it is possible to do this, of course, by taking some "handmade"…
-
2
votes1
answer256
viewsA: Is reading files in Python updated in real time?
The short answer is: you need to reopen the file and read its contents again. Whenever a file is read - not only in Python, but in any language on conventional operating systems, the system makes a…
-
3
votes2
answers1014
viewsA: What is the data obtained by scipy.io.wavfile read?
The data of an uncompressed sound wave, as represented in a file ". wav", (and available in an array after reading) do not symbolize the frequency at that point, but rather the amplitude - that is,…
-
4
votes2
answers12681
viewsA: How to resolve accentuation problems when using the setlocale function?
This has to do with file encoding and output encoding of your program. The problem won’t just go away alone - you need to understand Unicode. I suggest you read this article - the most classic piece…