Posts by tovmeod • 666 points
19 posts
-
4
votes2
answers2160
viewsA: How to install Pip for a particular version of Python?
I recommend running the script get-Pip.py as described in documentation of them. Simply download the file and run using the python you want to have Pip: python get-pip.py or python3 get-pip.py or…
-
2
votes1
answer78
viewsA: Version control of dependencies
I have seen some projects using external service Badges like the https://requires.io/ They have free plans for open source projects and paid plans. You can also run pip list -o that will list the…
-
0
votes1
answer203
viewsA: How to exit a timeout input in Python
You can use the Signal.Alarm to implement a timeout or select. import sys, select TIMEOUT = 10 i, o, e = select.select([sys.stdin], [], [], TIMEOUT) if i: print("Você digitou: ",…
-
0
votes1
answer932
viewsA: How I create 2 Foms simultaneously Django
The context passed to the render function is a dictionary, you can pass as many arguments as you want and with the name that suits you. For example: def Idioma(request): form_idioma = IdiomaForm()…
-
2
votes2
answers14521
viewsA: Sort dictionary by Python value
A python dictionary has no order, in most cases it makes no sense to maintain the order of the dictionary items. But there is the Ordereddict (also in python 2). Alternatively you can sort a list…
-
2
votes1
answer1500
viewsA: Unused import statement - Pycharm
Simply because you are not using the module you import, use it somewhere in the code and Warning should be gone soon.
-
1
votes2
answers94
viewsA: Refactoring generation of random datetime (Python)
import datetime import random def random_datetime(start, end): assert isinstance(start, datetime.datetime) assert isinstance(end, datetime.datetime) start = (start -…
-
-1
votes2
answers1817
viewsA: Is there any way to write code for the web without a python framework?
Yes, you can use the module SimpleHTTPServer. You can rotate simply: python -m SimpleHTTPServer 8000 or put this in your code: import SimpleHTTPServer import SocketServer PORT = 8000 Handler =…
-
3
votes4
answers12261
viewsA: How to know which version in use of a particular package is installed via Pip?
To see the installed version of a specific package use: pip show pelican this command will show the installed version and other package information. To list the version of all installed packages…
-
0
votes1
answer503
viewsA: Which language performs best for the multithread webcrawler using parallelism
It depends on which tool you are going to use, and it depends on whether you need to emulate a browser and whether you need to emulate as well. I have written many crawlers/webscrappers in python…
-
4
votes2
answers11102
viewsA: How to import an xls file to Python?
You will need external libraries like the xlrd to do this, take a look at www.python-excel.org In any case I suggest saving the file as csv from excel and using the python csv module, will save you…
-
1
votes2
answers376
viewsA: Problems with Javascript, urllib and Beautifulsoup
Neither urlib nor beautifulsoup interpret/execute javascript. Some options are: Selenium: it will use a real browser like Chrome or firefox, if Voce is using linux it can do this using a headless…
-
0
votes3
answers271
viewsA: How to allow only one instance of a certain class?
Without wanting to belittle the other answers and although they are correct and solve the specific case, maybe in an even better way, also without getting into merits if Singleton is a good design…
-
2
votes1
answer697
viewsA: Django Legacy Database Authentication
You need to create a custom backend Authentication, see https://docs.djangoproject.com/en/dev/topics/auth/customizing/ You can copy and paste the Django template, and specify in your template the…
-
0
votes2
answers2098
viewsA: Handle windows events using Python
I’ve already made a python application that captures and sends windows events, in my case keyboard and mouse and used the pywin32 Although the name has version for python 64 bit also. The library is…
-
17
votes3
answers44347
viewsA: How to create a python " *.exe" executable?
I’d like to record my suggestion to Pyinstaller or else cx_Freeze. In any case none of them have to ensure that it will run on any windows desktop. First of all if Voce is using windows 7 64 bit for…
-
2
votes4
answers11584
viewsA: How to put a Python module in a different folder than my script?
Configure the environment variable PYTHONPATH and include (append if it already exists) the directory pasta3: export PYTHONPATH = /pasta2/modules/python/pasta3 In any case, you can use the full path…
-
1
votes3
answers304
viewsA: Crawler that detects changes on a page and saves screenshots
I’ve used the Ghost py.. It is a Fork of the phantom from when they decided not to support python anymore and as the name suggests and a lib for those using python. Internally it uses the Webkit…
-
6
votes3
answers15049
viewsA: How to check if a file exists using Python
You can use exists: import os.path os.path.exists('nome.ext') But it will also return True for directories, if you want to make sure it’s a really use file isfile: import os.path…