python-3.4

python 3.x shutil.copy FileNotFoundError

自闭症网瘾萝莉.ら 提交于 2021-02-19 08:47:07
问题 system Windows 8.1 Python 3.4 Repeatedly get FileNotFound Errno2 , attempting to copy all files in a directory. import os import shutil source = os.listdir("C:\\Users\\Chess\\events\\") for file in source : shutil.copy(file, "E:\\events\\") yields FileNotFoundError : [Errno2] No such file or directory 'aerofl03.pgn'. Although 'aerofl03.pgn' is first in the source list ['aerofl03.pgn', ...] . Same result if a line is added: for file in source : if file.endswith('.pgn') : shutil.copy(file, "E:\

Eval scope in Python 2 vs. 3

让人想犯罪 __ 提交于 2021-02-18 08:52:07
问题 I came across bizarre eval behavior in Python 3 - local variables aren't picked up when eval is called in a list comprehension. def apply_op(): x, y, z = [0.5, 0.25, 0.75] op = "x,y,z" return [eval(o) for o in op.split(",")] print(apply_op()) It errors in Python 3: ▶ python --version Python 3.4.3 ▶ python eval.py Traceback (most recent call last): File "eval.py", line 7, in <module> print(apply_op()) File "eval.py", line 5, in apply_op return [eval(o) % 1 for o in op.split(",")] File "eval.py

Proper usage of `tf.scatter_nd` in tensorflow-r1.2

▼魔方 西西 提交于 2021-02-16 19:08:09
问题 Given indices with shape [batch_size, sequence_len] , updates with shape [batch_size, sequence_len, sampled_size] , to_shape with shape [batch_size, sequence_len, vocab_size] , where vocab_size >> sampled_size , I'd like to use tf.scatter to map the updates to a huge tensor with to_shape , such that to_shape[bs, indices[bs, sz]] = updates[bs, sz] . That is, I'd like to map the updates to to_shape row by row. Please note that sequence_len and sampled_size are scalar tensors, while others are

Proper usage of `tf.scatter_nd` in tensorflow-r1.2

╄→гoц情女王★ 提交于 2021-02-16 19:07:29
问题 Given indices with shape [batch_size, sequence_len] , updates with shape [batch_size, sequence_len, sampled_size] , to_shape with shape [batch_size, sequence_len, vocab_size] , where vocab_size >> sampled_size , I'd like to use tf.scatter to map the updates to a huge tensor with to_shape , such that to_shape[bs, indices[bs, sz]] = updates[bs, sz] . That is, I'd like to map the updates to to_shape row by row. Please note that sequence_len and sampled_size are scalar tensors, while others are

Unable to login with python selenium error:NoSuchElementException error

这一生的挚爱 提交于 2021-02-11 13:02:48
问题 I have tried locating the submit button by id and xpath but none of them worked and checked in the page source ,the id is same.I have no idea why this is happening even though I am giving the correct Id or xpath URL : https://moodle.niituniversity.in/moodle/login/index.php from pyvirtualdisplay import Display from selenium import webdriver from selenium.webdriver.common.keys import Keys display = Display(visible=0, size=(1024, 768)) display.start() driver = webdriver.Firefox() #driver.set

Python .pyw extension does not work

与世无争的帅哥 提交于 2021-02-11 01:32:54
问题 I'm trying to run a program without cmd window pop-up when I double click it or when I make it exe. So I wanted to save it as .pyw extension but when I double click to script, shell can't run it. It says I need to select the program to run it or search online. How can I fix this? Windows- Python 3.4 It was okay in 3.5 when I use .pyw extension. First time I see this problem. 回答1: I always have this problem whenever I reinstall Python. Very simple fix (at least on Windows): 1) Create a .pyw

How to fix the order of dictionary handling in Python 3?

ぐ巨炮叔叔 提交于 2021-02-10 11:51:45
问题 Is there a way to reliably fix the order of dictionary handling in Python 3, i.e. establish iteration over keys and values with a predictable order? For debugging purposes and to reproduce a failure that, supposedly, is based on dictionary access in python 3.3 and 3.4, I need to somehow make the iteration over dictionaries predictable. What I mean is I want to fix the way any iteration is performed at the start of the Python program. Such that starting the program many times, calls to dict

“No Module named sqlalchemy” after having just installed it from IPython prompt

久未见 提交于 2021-02-10 05:51:09
问题 I am unable to import sqlalchemy. I searched and found few solutions like installing flask or flask_sqlalchemy etc. None of these helped. What am I missing? 回答1: Sometimes, you need to restart ipython for it to find freshly-installed modules. I believe this holds for modules that add to sys.path . As per Can I zip all the python standard libs and the python still able to import it? , site.main() should work, too. It, among other things, scans site-packages directories for .pth files and adds

“No Module named sqlalchemy” after having just installed it from IPython prompt

喜欢而已 提交于 2021-02-10 05:51:08
问题 I am unable to import sqlalchemy. I searched and found few solutions like installing flask or flask_sqlalchemy etc. None of these helped. What am I missing? 回答1: Sometimes, you need to restart ipython for it to find freshly-installed modules. I believe this holds for modules that add to sys.path . As per Can I zip all the python standard libs and the python still able to import it? , site.main() should work, too. It, among other things, scans site-packages directories for .pth files and adds

Removing a selection from a listbox, as well as remove it from the list that provides it

匆匆过客 提交于 2021-02-09 01:51:35
问题 How can I use the following code to delete a selection from a listbox and removing it from the list the contains it also? The selections in the listbox are dictionaries which I store in a list. .................code.............................. self.frame_verDatabase = Listbox(master, selectmode = EXTENDED) self.frame_verDatabase.bind("<<ListboxSelect>>", self.OnDouble) self.frame_verDatabase.insert(END, *Database.xoomDatabase) self.frame_verDatabase.pack() self.frame_verDatabase.config