Re: Newbie MySQLdb / MySQL version problem, I think
Hi, I'm using MySQLdb with mysql 4.1 and I've seen this too - to get around it go to the following link: http://dev.mysql.com/doc/mysql/en/Old_client.html Hope this helps, Alastair. -- http://mail.python.org/mailman/listinfo/python-list
GIL release
Hi, Does anyone know whether there is a way for a python thread to release the global interpreter lock, and let all other threads have a chance at running before re-acquiring it? Does the thread scheduling follow a round-robin method? Thanks, agb. -- http://mail.python.org/mailman/listinfo/python-list
baffled classes within a function namespace. Evaluation order.
I am completely baffled by the behavior of this code with regards to the
evaluation order of namespaces when assigning the class attributes. Both
classes are nested within a function I called whywhywhy.
I assumed that example1 and example2 classes would look first at their own
namespace, then object, then the whywhywhy func namespace then global, and
maybe module. It seems this is not the case.
def whywhywhy(first, second, third):
def print_stuff():
print("func: first=", first)
print("func: second=", second)
print("func: third=", third)
print_stuff()
class example1(object):
print("1cls: first=", first)
print("1cls: second=", second)
print("1cls: third=", third)
second = second
foo = third
class example2(object):
print("2cls: first=", first)
print("2cls: second=", second)
print("2cls: third=", third)
second = second
third = third
def second():
pass
whywhywhy(1,2,3)
The code above produces the following output
"""
func: first= 1
func: second= 2
func: third= 3
1cls: first= 1
1cls: second=
1cls: third= 3
2cls: first= 1
2cls: second=
Traceback (most recent call last):
File "error.py", line 29, in
whywhywhy(1,2,3)
File "error.py", line 18, in whywhywhy
class example2(object):
File "error.py", line 21, in example2
print("2cls: third=", third)
NameError: name 'third' is not defined
"""
In particular:
print_stuff behaves as I would expect
1cls: second #<--- Why does this look at the global namespace for second
and not the whywhywhy func namespace first.
2cls: second #<--- Why can this no longer find third, it surely hasn't hit
the line third=third
Thanks for any help you can provide. :)
Alastair
--
http://mail.python.org/mailman/listinfo/python-list
Re: baffled classes within a function namespace. Evaluation order.
Thats a good pointer to what is going on. Thank you Bas. I am familiar with error such as x=1 def foo(): x = 2 def erm(): print(x) x=3 erm() foo() UnboundLocalError: local variable 'x' referenced before assignment. It seems a bit different for classes (below), as it jumps out to get the value from the global name space, where it didn't for functions (above). x=1 def foo(): x = 2 class erm(): print(x) x = 3 foo() # This evaluates == 1 But you certainly have explained why "NameError: name 'third' is not defined" occurs. -- http://mail.python.org/mailman/listinfo/python-list
COM Server crashing when returning large arrays
Hi ... I'm using pythoncom to create a python COM server application that needs to be able to return large arrays to COM client apps. For example, I need to be able to return an array to Excel that is 500 by 10, with each element of the array holding a 32 byte string. If I run the code for smaller arrays, say 10 by 10, it works fine. If I allow the server to try to return the entire 500 by 10 array, pythonw.exe causes a memory access violation and dies and I get an "automation exception" error message in the client app. I assume I'm violating some upper limit for data transfer from pythoncom into COM. Anyone know if such limitations exist? Is there a way around them? Can anyone point me in the right direction? Thanks Alastair p.s. 1st message on comp.lang.python, indeed 1st message on any news group -- http://mail.python.org/mailman/listinfo/python-list
Re: COM Server crashing when returning large arrays
Thanks for the replies Tim & Stefan
I'm using Python 2.3.5 on XP and the PythonWin build number seems to be 201
... I'll see if I can find 207.
The following blows up on both an XP and Win2k box ... both have same build
of Python and PythonWin:
import sys
class Cache:
_public_methods_ = ['GoPop']
_reg_progid_ = 'pyTestCOM.Test'
_reg_clsid_ = '{F1CC1052-BD44-4980-8EA5-9B29CDDB5955}'
def GoPop(self):
return [["spam, eggs and spam" for i in range(0,10)] for i in
range(1,500)]
if __name__ == '__main__':
print 'Registering COM Server'
import win32com.server.register
win32com.server.register.UseCommandLine(Cache)
I'll check out the other mailing list too. This is my first foray into the
wider Python community. I've been using the language on and off for the last
few years as it is the embedded scripting language in the Front Arena
trading system. I'm now working on a data modelling project that (sadly)
requires a considerable amount of data processing to take place in
Excel/VBA. Excel is fine for presentation, but Python is much better for
many of the data processing tasks. pythoncom would offer an almost
effortless way of getting VBA and Python to interact ... if I could just
pass large chunks of data ...
--
http://mail.python.org/mailman/listinfo/python-list
Re: COM Server crashing when returning large arrays
Bingo! Downloaded release 208 and the problem is solved! "Stefan Schukat" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello Alistair, which version of pythoncom you are using? In the newer versions there is an support for a "native" safearray (the data type Excel is providing). In older versions the complete array was converted to a tuple which is very time and memory consuming. during this conversion you could run out of memory since you have the Python objects and the COM data in your process. I think in 207 the patch was included. Stefan > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Alastair Alexander > Sent: Monday, May 22, 2006 6:27 PM > To: [email protected] > Subject: COM Server crashing when returning large arrays > > Hi ... I'm using pythoncom to create a python COM server > application that needs to be able to return large arrays to > COM client apps. For example, I need to be able to return an > array to Excel that is 500 by 10, with each element of the > array holding a 32 byte string. > > If I run the code for smaller arrays, say 10 by 10, it works > fine. If I allow the server to try to return the entire 500 > by 10 array, pythonw.exe causes a memory access violation and > dies and I get an "automation exception" error message in the > client app. > > I assume I'm violating some upper limit for data transfer > from pythoncom into COM. Anyone know if such limitations > exist? Is there a way around them? > Can anyone point me in the right direction? > > Thanks > > Alastair > > > p.s. 1st message on comp.lang.python, indeed 1st message on > any news group > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
