Posts by jsbueno • 30,668 points
811 posts
-
6
votes3
answers5080
viewsA: Clear C buffer with fflush() or __fpurge()
The best is to understand that the scanf is a function written in the 70s to read tokens from streams. It may be convenient to extract integers, or strings into an interactive porgram - but it comes…
-
1
votes1
answer470
viewsA: PSYCOPG2 - Pagination
in Python we use a maxim: "Premature Optimization is the root of all evil": You don’t know, and there’s no way to know a priori, before your system works if you’re gonna have a memory bottleneck or…
-
3
votes1
answer1203
viewsA: Send . txt file from one pc to another using http service
Receiving an HTTP file as a web request without using a framework is not so trivial: To ensure the passage of the file data, along with other possible form data, and other things that go in an HTTP…
-
2
votes3
answers4285
viewsA: Use of colon character ":" in Python
As I commented above, I don’t think it’s a very helpful kind of question - but come on, there are four uses that I’m remembering now, and one that doesn’t happen that’s worth mentioning: : indicates…
-
11
votes1
answer2699
viewsA: How does list assignment work using range?
The interval on the left side of the assignment indicates that that interval (before the change) will be replaced by whatever comes after the assignment (which must be a sequence or an iterable)…
-
1
votes2
answers481
viewsA: Doubt of C++ loop do-while
The reading of the standard input can be a bit boring sometimes - the scanf and printf functions were written more than 30 years ago, when the capacity of the terminals (and interface to the…
-
2
votes1
answer147
viewsA: Why doesn’t kwargs accept a keyword? [keyword can’t be an Expression]
It is not possible to properly understand what you are calling "kwargs" - but rather, in Python it is possible to specify optional arguments in a function and select the arguments by keyword - this…
-
4
votes2
answers1833
viewsA: Error: Object of type 'float' has on Len
Unlike C, the size that Python objects occupy in memory is abstracted, and at first a Python program does not need to know the same. Of course it is good to have a notion - and eventually you can…
-
0
votes1
answer342
viewsA: ANSI codes are not working on a Qtextedit
If you’re in a dirty warrant, stick to the specs. If it is determined to be "ANSI" colors - these are related to terminal use - your provavelemtne project has to have a terminal output, not a…
-
4
votes1
answer8777
viewsA: How to connect one struct to the other?
In C you can either have a struct of another type "embedded" in your original struct, or you can use "pointers" - a pointer is a reference to another structure in memory - And in practice, compared…
-
2
votes1
answer99
viewsA: What is the best method of compressing a 2500 ppi image?
There is no difference of algorithms that depend on the resolution of the image. Resolution is just a parameter that maps the number of pixels in the image to physical units of measurement -…
-
2
votes1
answer1698
viewsA: Assigning values to dynamic variables
In Python, the separation of what is given (text strings, for example) and what is code is very rigid - what differentiates it from PHP, Perl and Shel Script. So, you can create dynamic variable…
-
16
votes2
answers40971
viewsA: Problem using Switch Case in Python 3
Update 2020: Is being considered for inclusion in Python 3.10 (~October 2021) the functionality of "Pattern matching" with commands match and case. The main purpose allow "destructure" data: that…
-
3
votes1
answer57
viewsA: How to add new python encodings?
you should not install "pybraces" - if you want to learn Python, I recommend learning Python and not installing a modification to the language that will change it to non-standard. If you realemtne…
-
0
votes2
answers208
viewsA: Problem with threaded list pointer offset
One problem there (I can’t guarantee it is the only one) is that when there is an item removal, you advance twice to the next no: when doing the removal and another at the end of the while. If the…
-
1
votes2
answers141
views -
1
votes1
answer2229
viewsA: Coordinates of a Pygame image
After you place an image in the main image (screen) using a call to the "blit" method as this code does, the image becomes part of the main image: Blit is like stamping a piece of paper: what you…
-
2
votes2
answers1697
viewsA: Remove element from a chained list
Your code is confused in some ways - but to answer what you want, just rewrite the second if so: else if(atual->info == n) { ant->prox = atual->prox; free(atual); atual = ant->prox;…
-
1
votes1
answer373
viewsA: Remove value from an array
When you have an error, always see the error message that appears on the terminal. If you don’t find out what’s going on there, when asking a question, include the error message along with your…
-
1
votes2
answers552
viewsA: I cannot print a variable that receives the value of a list position
The logic of your program is correct - you have apparently only confused about the nature of the blocks in Python - all the lines indented forward, after a command that ends in : are part of a block…
-
7
votes2
answers70082
viewsA: How to concatenate multiple Strings in Python?
Python has long had several schemes of formatting strings, with data interpolation, so that give the user enough control and separation of what is given and what is code. This is sure what you want…
-
1
votes1
answer201
viewsA: Spyder can’t read serial port
So - the problem is just that you don’t have permission on the serial device. Have you noticed that all the commands you type test you type "sudo" before - ie, applications access serial port as…
-
3
votes1
answer766
viewsA: I cannot change the state of an Entry() widget in Python and Tkinter
Yes - what happens is that when we program to respond to desktop applications (and modern web applications, with asynchronous requests) - the thing changes a little of the programming to terminal.…
-
1
votes1
answer220
viewsA: Open python text set to apply functions (Len, set, colocations, etc.). Unicodedecorror
As your error mensgaem says, you have a file that is an invalid text in UTF-8: i.e., although your directory name is "no accents", you have accented text there yes. And the encoding of accents is…
-
0
votes2
answers70
viewsA: Limit motion copy on specific axes
Updating: If the property is a sequence of three elements, just replicate the first two and force the third one to zero: mov2.worldOrientation = [mov1.worldOrientation[0], mov1.worldOrientation[1],…
-
1
votes2
answers54
viewsA: I can’t delete key in dbm
Tested here, and using direct in interactive mode works the del (although the documentation of this module is very weak and does not mention the del and neither did he show up at the dir of object…
-
2
votes1
answer86
viewsA: Error with the asyncio module
If you called your file asyncio.py it has more priority to be loaded than the asyncio from the standard library. (The folder of the current file always stays before in Python Path). So when you do…
-
2
votes2
answers2037
viewsA: Insert widget into binary search tree
At no point in this code do you add the new created branches to the top branches of the tree. That’s - you call the function adiciona recursively correctly, the function adiciona creates a new…
-
1
votes2
answers521
viewsA: Is there a way to set up a Domain Record in the.br registry for a particular URL folder?
If your system is PHP or some technolgoia otura in which you work only through the file system - (that is, your only access to the server is by FTP, or other technology to put files there) - the…
-
1
votes3
answers476
viewsA: How do I convert snake_case to camelCase (and vice versa) in Python?
To convert to Camelcase, simply break the string into the "_" and capitalize the first letter - and this can be done in a single reasonably readable expression (without the need to declare function,…
-
37
votes5
answers63261
viewsA: How to clean the console in Python?
Simply press ctrl + L (works on the shell too - you don’t even need to write clear). This in the terminal. In a program, you can simply print a number of blank lines larger than the terminal size:…
-
1
votes2
answers686
viewsA: how to use exactly Sleep and wakeup in python3?(multithread)
Using a Queue as drgarcia suggests is a higher-level solution to a real problem. Your situation however is didactic - and this is what I think is going wrong: you call the set and the clear of Event…
-
0
votes2
answers1336
viewsA: Modules in Python linux
S and its system came with Python 2.7, it is possible to keep it with Python 2.7.10. and your system came with Python 2.6, there is no way to change the Python system standard to 2.7: you will…
-
9
votes4
answers3572
viewsA: How can I distribute the . py program without the user having to install all libraries?
Python has a package management ecosystem (the libraries) integrated both in the language and in its own packages. PIP - a much needed tool that has become part of the new Python installations since…
-
2
votes3
answers392
viewsA: Why in Python can we define an index of a Dict as a Tuple?
Python dictionaries do not have to have restrictions on how data structures are implemented in other languages. The constraints for an object to be used as a dictionary key are: the object must…
-
1
votes1
answer112
views -
11
votes2
answers54909
viewsA: Encoding utf-8 allows accents?
The encoding declaration line #encoding: utf-8 allows the Python parser to understand the accents in the source code - that is, placing any accented character is no longer a "syntax error" in Python…
-
2
votes1
answer64
viewsA: Problem in the supply function
This is a porbluff that although simple, has no magic to solve: is a simple algorithm, which we can think of and understand how to solve "manually" - and the way is to understand the algorithm, and…
-
1
votes1
answer646
viewsA: How to convert a "Sqlite3 Object cursor" to a list (Python)
The call to the method execute - both a database connection, and a Python cursor object does not return results immediately. This is done on purpose, so that it is easier to create applications…
-
0
votes1
answer70
viewsA: Editing in Linked Lists
The problem is that you return the pointer to the list you received -and it is pointing to the end of the list at the end of the run. This pointer to the end of the list is effectively an empty list…
-
6
votes2
answers4646
viewsA: How to print a txt file in Python
Python is a generic programming language - and has no relation to how the operating system makes its peripherals or print Apis available for use in programs. In Windows, these calls typically…
-
3
votes2
answers157
viewsA: Programming in Python
If you are right at the beginning, the biggest difference you will find regarding the documentation for Python 2 is from the "print" command - it ceases to be a command and becomes a -function So in…
-
4
votes1
answer1443
viewsA: What is the difference between dump and dumps from the Pickle module in Python?
dump, and load - each take as parameter an open file (or other object with the file interface) - and save the serialized content of the object in that file; (or load it, in the case of load). The…
-
3
votes1
answer639
viewsA: String error in a Python 3 function
The error shows exactly what is happening: in Python, strings are immutable objects - this is in contrast to C, for example where "strings" are just a convenient name for a memory region that is…
-
3
votes2
answers1020
viewsA: Does Netbeans support Django?
I apologize in advance - I will not answer your question. But I will put back some questions: Why do you need an "IDE for Django"? Who uses Python the longest, emg eral does not use an IDE even for…
-
1
votes2
answers1558
viewsA: Does the passage of objects in Java simulate passage by reference?
Almost all object-oriented languages - (if not all) actually pass at all times "by reference" objects - This is -everything that the methods or functions that receive objects as parameters receive…
-
2
votes2
answers1745
viewsA: Threads in python 3.4
The output near the point where you are, in this case, is to keep a "record" of how many threads you have already fired, and only add new threads when you hear "space". Your program creates a…
-
2
votes1
answer117
viewsA: Editing Exif of an image
Apparently, a good option is piexif - https://pypi.python.org/pypi/piexif/1.0.1 I did a quick test here, just installed and read the information from an image. The examples in the documentation show…
-
2
votes1
answer424
viewsA: Angularjs ng-click event does not work when configured in an element coming from an asynchronous request
Angularjs compiles its Angular template (which without Angular would be static HTML) when the page is loaded into the browser. It is at this moment that he recognizes the directives and makes the…
-
0
votes2
answers674
viewsA: How to use an iterator twice within an understanding?
""" Simple is Better than Complex. """ mylist = [(1,1), (1,2), (1,3), (2,6), (2,4), (3,1), (3,2)] group = {} for key, val in mylist: group[key] = (min(group[key][0], val), max(group[key][1], val))…