python-3.x

How to prevent *.exe from installing into all my pyvenv3.5 venv (and what describes their purpose)?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 19:51:33
问题 An initial pyvenv3.5 venv at create time is about 9.5MB on disk, before adding any custom content. Over 9% (!) of the venv disk-overhead are *.exe files, but all lack execute permission mode. One example: lib/python3.5/site-packages/setuptools/gui-32.exe . The linux file command says they are: executable for MS Windows . It looks like an obscure OS I'm certain my many pyvenv will never run on, and on which I'm unable to test. What are the repercussions if I just delete them? In initial tests

difference between [] and list() in python3

时光总嘲笑我的痴心妄想 提交于 2021-02-10 19:49:18
问题 I thought that [] and list() were two equal ways to create a list. But if you want a list with dictionnary keys, var = [a_dict.keys()] doesn't work since type(var) is [dict_keys] , correct syntax is : var = list(a_dict.keys()) I couldn't find an good explanation on this behaviour. Do you have one ? 回答1: TL;DR: list() is the same as [] list(obj) is not the same as [obj] a_dict.keys() is a dictionary view object, it returns an object which can be iterated to yield the keys of a_dict . So this

difference between [] and list() in python3

时间秒杀一切 提交于 2021-02-10 19:47:58
问题 I thought that [] and list() were two equal ways to create a list. But if you want a list with dictionnary keys, var = [a_dict.keys()] doesn't work since type(var) is [dict_keys] , correct syntax is : var = list(a_dict.keys()) I couldn't find an good explanation on this behaviour. Do you have one ? 回答1: TL;DR: list() is the same as [] list(obj) is not the same as [obj] a_dict.keys() is a dictionary view object, it returns an object which can be iterated to yield the keys of a_dict . So this

Memory increases with matplotlib and tkinter

别来无恙 提交于 2021-02-10 18:49:09
问题 Problem: I have a tkinter window with a matplotlib graph showing some lines (part of a much larger program). Periodically I add a new line, deleting an oldest one to limit the number of lines shown. Unfortunately the program grows in size continuously. I've seen this on both Windows and Linux. Question: How should I write a long-running graph frame to show the last n lines which doesn't use up all my memory? Preferably by tweaking the code below, but I'm prepared for a complete re-write if

Pandas find max column, subtract from another column and replace the value

只愿长相守 提交于 2021-02-10 18:47:40
问题 I have a df like this: A | B | C | D 14 | 5 | 10 | 5 4 | 7 | 15 | 6 100 | 220 | 6 | 7 For each row in column A,B,C, I want the find the max value and from it subtract column D and replace it. Expected result: A | B | C | D 9 | 5 | 10 | 5 4 | 7 | 9 | 6 100 | 213 | 6 | 7 So for the first row, it would select 14(the max out of 14,5,10), subtract column D from it (14-5 =9) and replace the result(replace initial value 14 with 9) I know how to find the max value of A,B,C and from it subctract D,

Memory increases with matplotlib and tkinter

旧时模样 提交于 2021-02-10 18:46:31
问题 Problem: I have a tkinter window with a matplotlib graph showing some lines (part of a much larger program). Periodically I add a new line, deleting an oldest one to limit the number of lines shown. Unfortunately the program grows in size continuously. I've seen this on both Windows and Linux. Question: How should I write a long-running graph frame to show the last n lines which doesn't use up all my memory? Preferably by tweaking the code below, but I'm prepared for a complete re-write if

Pandas find max column, subtract from another column and replace the value

一笑奈何 提交于 2021-02-10 18:46:28
问题 I have a df like this: A | B | C | D 14 | 5 | 10 | 5 4 | 7 | 15 | 6 100 | 220 | 6 | 7 For each row in column A,B,C, I want the find the max value and from it subtract column D and replace it. Expected result: A | B | C | D 9 | 5 | 10 | 5 4 | 7 | 9 | 6 100 | 213 | 6 | 7 So for the first row, it would select 14(the max out of 14,5,10), subtract column D from it (14-5 =9) and replace the result(replace initial value 14 with 9) I know how to find the max value of A,B,C and from it subctract D,

Receiving RTCM Data via NTRIP but can't translate the machincode

一笑奈何 提交于 2021-02-10 18:44:46
问题 I wrote a python script that send and receives data from an NTRIP Server (RTK) . But I don't know how to translate the machine code. For example I get this: b'3E\r\n\xd3\x008?]\x0c\xe5^;\x834I\x0c\xa0\x01Hy\x00\nDh\x00Q\xf6\xc0\x19\x10&\x00\xc8~\xb0%\x83\xfd\x00\x19\x1f\xf8\x00\xc9\x00@\x06H\r\x01,@x\tb\x05@2\x10\x17\x19@\xbaU\xca\r\n' I've tried to decode it with ascii , utf8 , latin1 . pwd = base64.b64encode("{}:{}".format(username, password).encode('ascii')) pwd = pwd.decode('ascii') try:

Threading in Jupyter notebook

和自甴很熟 提交于 2021-02-10 18:30:00
问题 I tried running the following code snippet in a Jupyter notebook: import threading import time def worker(): print(threading.current_thread().getName(), 'Starting') time.sleep(0.2) print(threading.current_thread().getName(), 'Exiting') def my_service(): print(threading.current_thread().getName(), 'Starting') time.sleep(0.3) print(threading.current_thread().getName(), 'Exiting') t = threading.Thread(name='my_service', target=my_service) w = threading.Thread(name='worker', target=worker) w2 =

django2: How to use different templates?

可紊 提交于 2021-02-10 18:29:38
问题 Say I created a django project called django_site . I created two sub-projects: site1 and polls . You see that I have two index.html in two sub-projects directories. However, now, if I open on web browser localhost:8000/site1 or localhost:8000/polls , they all point to the index.html of polls . How can I configure so when I open localhost:8000/site1 it will use the index.html of site1 ? My settings.py in django_site directory: .. TEMPLATES = [ { 'BACKEND': 'django.template.backends.django