python-3.4

Changing one dict changes all dicts in a list of dicts [duplicate]

情到浓时终转凉″ 提交于 2020-01-30 09:13:13
问题 This question already has answers here : List of lists changes reflected across sublists unexpectedly (13 answers) Closed 4 months ago . I have a list of dicts for storing data. When I make change in one dict, that change is reflected in all dicts. students = [{"marks": [], "subjects": 0}]*3 specific_student = 2 print("Before updating", students) students[specific_student]["marks"].append(50) students[specific_student]["subjects"] += 1 print("After updating", students) I was expecting that,

Disabling user from deleting text in tkinter scrolledtext

跟風遠走 提交于 2020-01-30 03:15:31
问题 If this has already been posted and answered I couldn't find it by searching. I am trying to use a tkinter scrolledtext widget to serve as a basic text display for file operations the script I'm writing will perform. Why would I want to do this? I don't like how the terminal limits how far you can scroll, how it looks, and I think this looks much more streamlined into a simple GUI. I know we can create a simple scrolledtext widget like so and also disable user input and deleting with setting

Disabling user from deleting text in tkinter scrolledtext

断了今生、忘了曾经 提交于 2020-01-30 03:15:29
问题 If this has already been posted and answered I couldn't find it by searching. I am trying to use a tkinter scrolledtext widget to serve as a basic text display for file operations the script I'm writing will perform. Why would I want to do this? I don't like how the terminal limits how far you can scroll, how it looks, and I think this looks much more streamlined into a simple GUI. I know we can create a simple scrolledtext widget like so and also disable user input and deleting with setting

Disabling user from deleting text in tkinter scrolledtext

女生的网名这么多〃 提交于 2020-01-30 03:15:27
问题 If this has already been posted and answered I couldn't find it by searching. I am trying to use a tkinter scrolledtext widget to serve as a basic text display for file operations the script I'm writing will perform. Why would I want to do this? I don't like how the terminal limits how far you can scroll, how it looks, and I think this looks much more streamlined into a simple GUI. I know we can create a simple scrolledtext widget like so and also disable user input and deleting with setting

Using PythonService.exe to host python service while using virtualenv

旧街凉风 提交于 2020-01-20 04:05:14
问题 I've got a Windows 7 environment where I need to develop a Python Windows Service using Python 3.4. I'm using pywin32's win32service module to setup the service and most of the hooks seem to be working ok. The problem is when I attempt to run the service from source code (using python service.py install followed by python service.py start ). This uses PythonService.exe to host service.py - but I'm using a venv virtual environment and the script can't find it's modules (error message

pandas reading .csv files

允我心安 提交于 2020-01-17 02:37:13
问题 I have a small script to read and print a .csv file using pandas generated from MS Excel. import pandas as pd data = pd.read_csv('./2010-11.csv') print(data) now this script runs in Python 2.7.8 but in Python 3.4.1 gives the following error. Any ideas why this might be so? Thanks in advance for any help with this. Traceback (most recent call last): File "proc_csv_0-0.py", line 3, in <module> data = pd.read_csv('./2010-11.csv') File "/usr/lib64/python3.4/site-packages/pandas/io/parsers.py",

Python 3.4 setuptools namespace setup does not work

馋奶兔 提交于 2020-01-15 05:00:09
问题 I am trying to create namespace packages for a modular project. The core system has the following packages homie homie.api homie.events homie.mods I want to install the respective modules as sub-packages of homie.mods . Therefor I provided the respective homie.__init__.py and homie.mods.__init__.py with the following content: from pkg_resources import declare_namespace declare_namespace(__name__) My testing module is structured as follows: homie homie/__init__.py homie/mods homie/mods/__init_

using serial port in python3 asyncio

♀尐吖头ヾ 提交于 2020-01-13 08:18:31
问题 i'm trying and, so far, failing to use python asyncio to access a serial port. i'd really appreciate any tips on using the new python async framework on a simple fd. Cheers! James 回答1: It's other way using FD import asyncio import serial s = serial.Serial('/dev/pts/13', 9600) def test_serial(): ''' read a line and print. ''' text = "" msg = s.read().decode() while (msg != '\n'): text += msg msg = s.read().decode() print(text) loop.call_soon(s.write, "ok\n".encode()) loop = asyncio.get_event

How to check to see if a folder contains files using python 3

南楼画角 提交于 2020-01-09 03:43:24
问题 I've searched everywhere for this answer but can't find it. I'm trying to come up with a script that will search for a particular subfolder then check if it contains any files and, if so, write out the path of the folder. I've gotten the subfolder search part figured out, but the checking for files is stumping me. I have found multiple suggestions for how to check if a folder is empty, and I've tried to modify the scripts to check if the folder is not empty, but I'm not getting the right

Import Image using Pillow : No module named 'PIL'

梦想的初衷 提交于 2020-01-07 03:17:06
问题 Several posts were advising to import Pillow using pip, after having uninstalled both PIL and Pillow, what i did : python -m pip uninstall Pillow (worked) python -m pip uninstall PIL (PIL was not installed) python -m pip install Pillow (worked, i guess it was fine already) Then, according to these posts, using "from PIL import Image" in python should work. I get the error "ImportError: No module named 'PIL'". I tried "import Image" and "from Pillow import Image" but none of that works either.