python-3.2

SQLAlchemy session: how to keep it alive?

谁说胖子不能爱 提交于 2019-12-23 06:01:08
问题 I have a session object that gets passed around a whole lot and at some point the following lines of code are called (this is unavoidable): import transaction transaction.commit() This renders the session unusable (by closing it I think). My question is two part: How do I check if a session is still alive and well? Is there a quick way to revitalize a dead session? For 2: The only way I currently know is to use sqlalchemy.orm.scoped_session, then call query(...)get(id) many times to recreate

PyFile_Type replaced by ..?

試著忘記壹切 提交于 2019-12-22 10:12:59
问题 I'm tyring to compile Yenc for Python 3.2. I noticed that gcc complained about a non-declared function PyString_Type , so I replaced it with its replacement PyBytes_Type as according to the documentation. However, gcc also complained about an undeclared function called PyFile_Type . I googled a bit and found: Python 3.x replaces the PyFile_Type extension type with an abstract interface and specific implementation types. Unfortunately it doesn't make any of this directly available with a C

How do I change a Gtk3 Entry text color in Python3?

筅森魡賤 提交于 2019-12-22 08:35:49
问题 I have a list of Gtk.Entry() in my application, and I would like to change the color of the text of some of them. I tried the following : #!/usr/bin/python3 # Filename: mywindow.py from gi.repository import Gtk from gi.repository import Gdk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="My window") self.mainGrid = Gtk.Grid() self.add(self.mainGrid) self.myOkEntry = Gtk.Entry() self.myOkEntry.set_text("This is OK (green)") self.myOkEntry.override_color(Gtk

How do you make an installer for your python program

纵然是瞬间 提交于 2019-12-22 06:32:21
问题 Im new to python, but I was thinking about making a program with python to give to my friends. They don't know much about computers so if I asked them to install python by them selves they couldn't do it, but what if I could make an installer that downloads some version of python that only has what is needed for my file to run and make an exe file that would run the .py file in its own python interpreter . I also did a Google search and saw the freezing applications I could use to make the

How do you make an installer for your python program

▼魔方 西西 提交于 2019-12-22 06:31:11
问题 Im new to python, but I was thinking about making a program with python to give to my friends. They don't know much about computers so if I asked them to install python by them selves they couldn't do it, but what if I could make an installer that downloads some version of python that only has what is needed for my file to run and make an exe file that would run the .py file in its own python interpreter . I also did a Google search and saw the freezing applications I could use to make the

idle-python3.2 not starting: complains of NameError: name 'Tk' is not defined

喜夏-厌秋 提交于 2019-12-20 05:40:28
问题 running linux mint 13 idle-python3.2 did work from the terminal before, now it does not. Calling idle-python3.2 from the terminal throws the error below BUT I can run Idle by double clicking on the script! Here's the very simple script that broke it all(?) http://pastebin.com/pP9An3UU FWIW, the script does not appear to work either (nothing happens when I run it). Here's the error in the terminal when trying to run Idle3.2 from the terminal: File "tkinter.py", line 2, in <module> tk = Tk()

Python 3.2 logging with config file results in KeyError: 'formatters' on Raspbian

假装没事ソ 提交于 2019-12-20 03:52:15
问题 I equipped my Python application with logging capability and it works flawlessly on my Windows system with Python 3.4. But when I deploy the application on my Raspberry Pi with Raspbian and Python 3.2, I receive the following error: Traceback (most recent call last): File "aurora/aurora_websocket.py", line 265, in <module> logging.config.fileConfig('logging.conf') File "/usr/lib/python3.2/logging/config.py", line 70, in fileConfig formatters = _create_formatters(cp) File "/usr/lib/python3.2

Call to GetModuleHandle on kernel32 using Python C-types

倖福魔咒の 提交于 2019-12-19 09:02:35
问题 I'm trying to use Python's C-Types to call GetModuleHandleA on the kernel32 library. I'd like to get a handle to the library so I can use it to call GetProcAddress for LoadLibraryA. Below is my code... import sys from ctypes kernel32 = windll.kernel32 print("The kernel32 is %s" % kernel32) #The kernel32 is <WinDLL 'kernel32', handle 765b0000 at 1c2a9f0> h_kernel32 = kernel32.GetModuleHandleA("C:\\Windows\\System32\\kernel32.dll") if h_kernel32 == False: error = GetLastError() print("ERROR: %d

Python3 AttributeError: 'list' object has no attribute 'clear'

和自甴很熟 提交于 2019-12-18 20:16:02
问题 I am working on a Linux machine with Python version 3.2.3. Whenever I try to do list.clear() I get an exception >>> l = [1, 2, 3, 4, 5, 6, 7] >>> l.clear() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'clear' At the same time on my Mac with Python 3.4.3 the same code runs smoothly. Can it be due to the difference between Python versions or is there something I'm missing? 回答1: list.clear was added in Python 3.3. Citing

Python3 AttributeError: 'list' object has no attribute 'clear'

一个人想着一个人 提交于 2019-12-18 20:14:09
问题 I am working on a Linux machine with Python version 3.2.3. Whenever I try to do list.clear() I get an exception >>> l = [1, 2, 3, 4, 5, 6, 7] >>> l.clear() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'clear' At the same time on my Mac with Python 3.4.3 the same code runs smoothly. Can it be due to the difference between Python versions or is there something I'm missing? 回答1: list.clear was added in Python 3.3. Citing