python-2.x

Can someone please explain this error - “Runtime error: dictionary size changed during iteration”? [closed]

ⅰ亾dé卋堺 提交于 2019-12-25 01:55:57
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . def find_the_best_solution(shipping_request, list, current_solution, best_shipping_solution): if shipping_request == {}: return current_solution for item

SyntaxError print(*args, **kwargs)

安稳与你 提交于 2019-12-25 01:00:14
问题 I've got an error as a traceback below: Traceback (most recent call last): File "setup_rouge.py", line 7, in <module> from files2rouge import settings File "/home/cerdas/files2rouge/files2rouge/__init__.py", line 2, in <module> from files2rouge.files2rouge import main File "/home/cerdas/files2rouge/files2rouge/files2rouge.py", line 17, in <module> from files2rouge import utils File "/home/cerdas/files2rouge/files2rouge/utils.py", line 14 print(*args, **kwargs) ^ SyntaxError: invalid syntax

Make input and run loop to create custom number of objects

删除回忆录丶 提交于 2019-12-25 00:58:26
问题 I have been trying to learn how to code for Maya for a while. And here I am making a rock generator using reduce face, quad-mesh, smooth in a loop. Now I would like to make an input so user can specify how many rock they want to make. Like if you input 5, it would make 5 rocks. However I am currently stuck with the naming, like if I created the polyPlatonicSolid with rock#, the loop got confused and said something like rock# is invalid , so I am just looking for a simple solution for that.

Python - Split strings into words within a list of lists

浪子不回头ぞ 提交于 2019-12-25 00:33:34
问题 I have the following list of lists (): [[u' why not giving me service'], [u' option to'], [u' removing an'], [u' verify name and '], [u' my credit card'], [u' credit card'], [u' theres something on my visa']] and I have the following questions: First, what are these u' appearing in front of every of my sublists? Second, how can I plit my sublists into separate words, i.e. have something like this: [[why, not, giving, me, service], [option, to], [removing, an], [verify, name, and], [my, credit

Threading issue with Pygame

笑着哭i 提交于 2019-12-25 00:23:11
问题 I am developing a small game for learning purposes. I have created a simple animation for the title screen. Since there is also a function for full screen in the code, I wanted to create a title screen that: Displayed the animation Turned into full screen when the key was activated Continued the animation at the point it was before activating full screen In order to do this, I resorted to threading . However, this is the first time I tried to do any multi-threading, and I don´t know what did

How can I get 2.x-like sorting behaviour in Python 3.x?

你说的曾经没有我的故事 提交于 2019-12-24 20:44:43
问题 I'm trying to replicate (and if possible improve on) Python 2.x's sorting behaviour in 3.x, so that mutually orderable types like int , float etc. are sorted as expected, and mutually unorderable types are grouped within the output. Here's an example of what I'm talking about: >>> sorted([0, 'one', 2.3, 'four', -5]) # Python 2.x [-5, 0, 2.3, 'four', 'one'] >>> sorted([0, 'one', 2.3, 'four', -5]) # Python 3.x Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError:

opening a file with an accented character in its name, in Python 2 on Windows

拟墨画扇 提交于 2019-12-24 19:24:32
问题 In a directory in Windows I have 2 files, both of them with an accented character in its name: t1û.fn and t2ű.fn ; The dir command in the Command Prompt shows both correctly: S:\p>dir t*.fn Volume in drive S is q Volume Serial Number is 05A0-8823 Directory of S:\p 2017-09-03 14:54 4 t1û.fn 2017-09-03 14:54 4 t2ű.fn 2 File(s) 8 bytes 0 Dir(s) 19,110,621,184 bytes free Screenshot: However, Python can't see both files: S:\p>python -c "import os; print [(fn, os.path.isfile(fn)) for fn in os

How do you temporary run your code as 'root'?

你说的曾经没有我的故事 提交于 2019-12-24 18:09:55
问题 RELATED: Python multiprocessing: Permission denied I want to use Python's multiprocessing.Pool import multiprocessing as mp pool = mp.Pool(3) for i in range(num_to_run): pool.apply_async(popen_wrapper, args=(i,), callback=log_result) I get OSError File "/usr/local/lib/python2.6/multiprocessing/__init__.py", line 178, in RLock return RLock() File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 142, in __init__ SemLock.__init__(self, RECURSIVE_MUTEX, 1, 1) File "/usr/local/lib

Caesar Cipher in python

天涯浪子 提交于 2019-12-24 12:35:09
问题 The error which i am getting is Traceback (most recent call last): File "imp.py", line 52, in <module> mode = getMode() File "imp.py", line 8, in getMode mode = input().lower() File "<string>", line 1, in <module> NameError: name 'encrypt' is not defined Below is the code. # Caesar Cipher MAX_KEY_SIZE = 26 def getMode(): while True: print('Do you wish to encrypt or decrypt a message?') mode = input().lower() if mode in 'encrypt e decrypt d'.split(): return mode else: print('Enter either

pyplot to 3d pdf

只谈情不闲聊 提交于 2019-12-24 11:34:55
问题 How can I save a 3d pyplot image so that I can still rotate it in my pdf viewer? I know pdfs can be saved so that the 3d image can be rotated (I've had files like this before) - how can I accomplish this using pyplot? The motivation for this question is that I want to share images which others can rotate - it is not sufficient for me to rotate the image in the python viewer, taking 2d snapshots. Here is my example code. I cannot rotate the image in the pdf which this generates. import numpy