python-3.4

Gdal_rasterize nodata_value does not work

Gdal_rasterize nodata_value does not work Question: I want to rasterize a source layer made of polygons. No matter what value I assign to “NoData_value”, the outcome in my array is always = 0. I am using python 3.4. Can anyone help me understand please ? source_srs = source_layer.GetSpatialRef() x_min, x_max, y_min, y_max = source_layer.GetExtent() # …

Total answers: 1

How to scrape football results from livescores?

How to scrape football results from livescores? Question: I have this project am working on using python 3.4. I want to scrape livescore.com for football scores (result) e.g getting all the scores of the day (England 2-2 Norway, France 2-1 Italy, etc). I am building it with python 3.4, windows 10 64bit os. I have …

Total answers: 2

Please explain "Task was destroyed but it is pending!" after cancelling tasks

Please explain "Task was destroyed but it is pending!" after cancelling tasks Question: I am learning asyncio with Python 3.4.2 and I use it to continuously listen on an IPC bus, while gbulb listens on the DBus. I created a function listen_to_ipc_channel_layer that continuously listens for incoming messages on the IPC channel and passes the …

Total answers: 4

Get a random sample of a dict

Get a random sample of a dict Question: I’m working with a big dictionary and for some reason I also need to work on small random samples from that dictionary. How can I get this small sample (for example of length 2)? Here is a toy-model: dy={‘a’:1, ‘b’:2, ‘c’:3, ‘d’:4, ‘e’:5} I need to perform …

Total answers: 6

Python type hinting without cyclic imports

Python type hinting without cyclic imports Question: I’m trying to split my huge class into two; well, basically into the "main" class and a mixin with additional functions, like so: main.py file: import mymixin.py class Main(object, MyMixin): def func1(self, xxx): … mymixin.py file: class MyMixin(object): def func2(self: Main, xxx): # <— note the type hint …

Total answers: 8

PyQt5 draggable frameless window

PyQt5 draggable frameless window Question: I found an example to set borders on a frameless window, however it’s not draggable. How can I make a frameless window draggable? Especially if I can see an example it’ll be awesome. Here is my example code(normally the code is longer, that’s why there are much libraries just don’t …

Total answers: 6

python import multiple times

python import multiple times Question: I suppose this is a general question so sorry if not posted in the right place. Say for instance, I have a function a which imports os. If I was to call this function from another file multiple times I am assuming that the import would be done multiple times …

Total answers: 1

Pyautogui TypeError: 'NoneType' object is not iterable

Pyautogui TypeError: 'NoneType' object is not iterable Question: I’m trying to use locateCenterOnScreen() function of PyAutoGUI, however it raises : Traceback (most recent call last): File “C:UserswindowsDesktopasd.py”, line 3, in <module> buttonx, buttony = pyautogui.locateCenterOnScreen(‘who.jpg’) TypeError: ‘NoneType’ object is not iterable My code is: import pyautogui buttonx, buttony = pyautogui.locateCenterOnScreen(‘who.jpg’) pyautogui.doubleClick(buttonx,buttony) How can I fix …

Total answers: 4

How to print non-ascii characters as uXXXX literals

How to print non-ascii characters as uXXXX literals Question: # what I currently have print(‘你好’) # 你好 # this is what I want print(‘你好’) # uXXXX uXXXX How do I do this? I want to print all non-ascii characters in strings as unicode escape literals Asked By: AlanSTACK || Source Answers: You can convert strings …

Total answers: 3

What is a DynamicClassAttribute and how do I use it?

What is a DynamicClassAttribute and how do I use it? Question: As of Python 3.4, there is a descriptor called DynamicClassAttribute. The documentation states: types.DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None) Route attribute access on a class to __getattr__. This is a descriptor, used to define attributes that act differently when accessed through an instance and through a …

Total answers: 2