Posts by adinanp • 368 points
14 posts
-
2
votes2
answers2549
viewsA: How to set Python 3 as default in linux?
Man, I wouldn’t change the system’s default python for the simple fact that things the system uses and depend on python 2 would break if you changed. A good practice is to use virtual environments,…
-
0
votes1
answer826
viewsA: Stack several txt files using pandas
The list under which you are iterating, is the list that contains the names of the files without the extension .txt so, these files don’t really exist on your path. Try to change: for f in filelist:…
-
0
votes2
answers1413
viewsA: Remove blank lines in a csv
Good morning, Given the "document" and the example code, in this excerpt: if line[1] == 'pt': ... An Exception of the type IndexErrorwould be raised to the blank lines contained in the document. The…
-
2
votes4
answers725
viewsA: Function that returns the element with more characters from a list
Considering the title of your question Function that returns the element with more characters from a list The built-in function max python does what you need. l = ['A', 'ABCDEFG', 'ABC'] max(l,…
-
3
votes3
answers3591
viewsA: How to use "while not in" in Python?
A simple solution, which avoids the errors already mentioned as ValueError in the case of trying to convert a non-numeric character to int, it would validate if the input is a digit, that is, if…
-
1
votes2
answers174
viewsA: Doubt when ranking using Jango!
Good evening, I believe an "enumerate" can help you, and according to Django’s documentation, you would have one available through the variable {{ forloop.counter }} inside your block for, That’s…
-
0
votes1
answer196
viewsA: How to filter an Apiview to show messages related to a user?
The error you are receiving is a Python syntax error as you are trying to use normaluser in the statement of normaluser without having previously created normaluser, basically! On the filter you…
-
0
votes1
answer143
viewsA: Add footer with xhtml2pdf on specific pages with Django
If I understand, what you want to do is insert a specific footer in the pages that can be reentered as PDF, correct? If that’s right, you can use {% include %} and {% if %} within the templates of…
-
0
votes2
answers997
viewsA: filter list in Django admin Foreign key field
Ronaldo, I believe the library Django-smart-selects can help you. I’ve used this lib on a project and it worked well. Including the example below (extracted from the README of the same), exemplifies…
-
3
votes1
answer130
viewsA: How to open a csv created in Python without opening an import screen?
Filipe, as commented above, I don’t think it’s a problem related to python or how you generate the file, but to Libreoffice. Anyway a possible solution for this, would be to save its contents in one…
-
2
votes1
answer906
viewsA: Customize Django Admin
Bianca, if I understood what you would like to do, it would be something in this sense, correct? If yes, what I did to get this result is much simpler than it looks, see: Just write the method…
-
1
votes1
answer247
viewsA: Create date condition in UNIX format Timestamp - Django
If I understood the doubt, given the following model: from django.db import models class Log(models.Model): timecreated = model.BigIntegerField() You can assemble your Queryset using the argument…
-
3
votes2
answers531
viewsQ: python packages with dependency installation
I wonder if as in packages . deb for example, it is possible in my setup.py i configure the dependencies for my package, and when running: $ sudo python setup.py install They are installed…
-
4
votes1
answer102
viewsQ: Exceptions.py file
I program in python about a year ago, and I’ve always seen in some projects that I see on the web, an archive called exceptions.py. I can handle exceptions within my codes, this is not my doubt. I…