CherryPyWSGIServer multi-threading

2010-10-13 Thread Bart Ogryczak
I'm trying to create multi-threaded WSGI server. But somehow I'm getting single threaded. What am I doing wrong? #start myapp.py from cherrypy.wsgiserver import CherryPyWSGIServer def my_app(environ, start_response): print my_app import time for i in range(10): print i

CherryPyWSGIServer multi-threading

2010-10-13 Thread Bart Ogryczak
I'm trying to create multi-threaded WSGI server. But somehow I'm getting single threaded. What am I doing wrong? #start myapp.py from cherrypy.wsgiserver import CherryPyWSGIServer def my_app(environ, start_response): print my_app import time for i in range(10): print i

Re: Bug in __init__?

2008-01-22 Thread Bart Ogryczak
On 2008-01-22, citizen Bruno Desthuilliers testified: from copy import copy ### see also deepcopy self.lst = copy(val) What makes you think the OP wants a copy ? I´m guessing he doesn´t want to mutate original list, while

Re: Bug in __init__?

2008-01-20 Thread Bart Ogryczak
On 2008-01-18, citizen Zbigniew Braniecki testified: It's really a nice pitfall, I can hardly imagine anyone expecting this, AFAIR, it's described in Diving Into Python. It's quiet elegant way of creating cache. def calculate(x,_cache={}): try: return _cache[x]

Re: too long float

2008-01-20 Thread Bart Ogryczak
On 2008-01-18, citizen J. Peng testified: hello, why this happened on my python? a=3.9 a 3.8999 a = 3.9 print a 3.9 bart -- PLEASE DO *NOT* EDIT or poldek will hate you. - packages.dir (PLD) http://candajon.azorragarse.info/ http://azorragarse.candajon.info/ --

Re: Bug in __init__?

2008-01-20 Thread Bart Ogryczak
On 2008-01-18, citizen Zbigniew Braniecki testified: I found a bug in my code today, and spent an hour trying to locate it and then minimize the testcase. Once I did it, I'm still confused about the behavior and I could not find any reference to this behavior in docs. testcase: class

Re: Bug in __init__?

2008-01-20 Thread Bart Ogryczak
On 2008-01-20, citizen Arnaud Delobelle testified: On Jan 20, 3:39 pm, Bart Ogryczak [EMAIL PROTECTED] to.invalid wrote: On 2008-01-18, citizen Zbigniew Braniecki testified: It's really a nice pitfall, I can hardly imagine anyone expecting this, AFAIR, it's described in Diving Into Python

SPARQL server in Python?

2008-01-19 Thread Bart Ogryczak
Hi, I'm trying to migrate some RD I've done with PHP and RAP[1] to Python. But I've got hard time finding Python RDF/SPARQL server. Most things I find are SPARQL clients. Do you know of a Python library, that could do the job? [1] http://sites.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/ bart --

Re: sentance containg the string or symbol Ω

2007-08-23 Thread Bart Ogryczak
On 23 ago, 13:20, yadin [EMAIL PROTECTED] wrote: how can i print a sentance containg the string or symbol Ω in python and also lambda? Well, you can use this dictionary to find out its unicode code point: from htmlentitydefs import name2codepoint unichr(name2codepoint['Omega']) u'\u03a9'

Re: programmatically define a new variable on the fly

2007-08-10 Thread Bart Ogryczak
On 10 ago, 00:11, Lee Sander [EMAIL PROTECTED] wrote: Hi, I would like to define a new variable which is not predefined by me. For example, I want to create an array called X%s where %s is to be determined based on the data I am processing. So, for example, if I the file I'm reading has g

Re: lists and dictionaries

2007-07-12 Thread Bart Ogryczak
On 11 jul, 21:08, Ladislav Andel [EMAIL PROTECTED] wrote: Hi, I have a list of dictionaries. e.g. [{'index': 0, 'transport': 'udp', 'service_domain': 'dp0.example.com'}, {'index': 1, 'transport': 'udp', 'service_domain': 'dp1.example.com'}, {'index': 0, 'transport': 'tcp', 'service_domain':

Re: lists and dictionaries

2007-07-12 Thread Bart Ogryczak
On 12 jul, 04:49, anethema [EMAIL PROTECTED] wrote: li = [ {'index': 0, 'transport': 'udp', 'service_domain': 'dp0.example.com'}, {'index': 1, 'transport': 'udp', 'service_domain': 'dp1.example.com'}, {'index': 0, 'transport': 'tcp', 'service_domain':

Re: Lists in classes

2007-07-12 Thread Bart Ogryczak
On 12 jul, 17:23, Jeremy Lynch [EMAIL PROTECTED] wrote: Hello, Learning python from a c++ background. Very confused about this: class jeremy: list=[] def additem(self): self.list.append(hi) return temp = jeremy()

Re: Lists in classes

2007-07-12 Thread Bart Ogryczak
On 12 jul, 17:23, Jeremy Lynch [EMAIL PROTECTED] wrote: Hello, Learning python from a c++ background. Very confused about this: class jeremy: list=[] You've defined list (very bad choice of a name, BTW), as a class variable. To declare is as instance variable you have

Re: How to get the demension of a video file?

2007-03-30 Thread Bart Ogryczak
On Mar 30, 11:56 am, seppl43 [EMAIL PROTECTED] wrote: Hello there, does anybody know, how to get the dimension values (width/height) of a quicktime (.mov) and/or a avi-file? Is there perhaps a module which can do this job? Identify from ImageMagick. There is a Python binding (PythonMagick,

Re: PyPy 1.0: JIT compilers for free and more

2007-03-29 Thread Bart Ogryczak
On 28 mar, 23:36, Jarek Zgoda [EMAIL PROTECTED] wrote: Carl Friedrich Bolz napisa³(a): Welcome to the PyPy 1.0 release - a milestone integrating the results of four years of research, engineering, management and sprinting efforts, concluding the 28 months phase of EU co-funding! So it

Re: Fortran vs Python - Newbie Question

2007-03-26 Thread Bart Ogryczak
On Mar 26, 3:20 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: OK... I've been told that Both Fortran and Python are easy to read, and are quite useful in creating scientific apps for the number crunching, but then Python is a tad slower than Fortran because of its a high level language

Re: Printing __doc__

2007-03-22 Thread Bart Ogryczak
On Mar 21, 8:47 pm, gtb [EMAIL PROTECTED] wrote: Greetings, Don't know the daily limit for dumb questions so I will ask one or more. In a function I can use the statement n = sys._getframe().f_code.co_name to get the name of the current function. Given that I can get the name how can I

Re: Technical Answer - Protecting code in python

2007-03-21 Thread Bart Ogryczak
On Mar 21, 2:36 pm, flit [EMAIL PROTECTED] wrote: Now the technical question: 1 - There is a way to make some program in python and protects it? I am not talking about ultra hard-core protection, just a simple one that will stop 90% script kiddies. Freeze. That should be hard enough for 99%

Re: why brackets commas in func calls can't be ommited? (maybe it could be PEP?)

2007-03-21 Thread Bart Ogryczak
On Mar 21, 3:38 pm, dmitrey [EMAIL PROTECTED] wrote: Hi all, I looked to the PEPs didn't find a proposition to remove brackets commas for to make Python func call syntax caml- or tcl- like: instead of result = myfun(param1, myfun2(param5, param8), param3) just make possible using result =

Re: Communicating with a DLL under Linux

2007-03-13 Thread Bart Ogryczak
On Mar 13, 5:59 pm, Mikael Olofsson [EMAIL PROTECTED] wrote: If the vendor claims that the DLL is for Windows, is it reasonable to assume that it can be made to work under Linux, from Python, that is? No. It's reasonable to assume, that there is no *easy* way to get Win32's DLL working under

Re: Is this right? Multiple imports of same module.

2007-03-09 Thread Bart Ogryczak
On Mar 9, 3:30 pm, Lou Pecora [EMAIL PROTECTED] wrote: Then mymodule is imported only once, but each module has access to it through the module name (mod1 and mod2) and the alias MM (mod3). Is that right? Yes, it is. I was concerned about multiple imports and efficiency. If the module is

Re: opinion needed

2007-03-09 Thread Bart Ogryczak
On Mar 9, 4:27 pm, azrael [EMAIL PROTECTED] wrote: id like to hear your opinion about something. I just started using Prolog yesterday and i have my doubts about it, but it seems to me something like object oriented. so i wanted to ask you how usefull prolog is. It's very useful for Logic

Re: How to Read Bytes from a file

2007-03-05 Thread Bart Ogryczak
On Mar 5, 10:51 am, Piet van Oostrum [EMAIL PROTECTED] wrote: Bart Ogryczak [EMAIL PROTECTED] (BO) wrote: BO Any system with 8-bit bytes, which would mean any system made after BO 1965. I'm not aware of any Python implementation for UNIVAC, so I BO wouldn't worry ;-) 1965? I worked with non

Re: Dictionary of Dictionaries

2007-03-05 Thread Bart Ogryczak
On Mar 5, 11:22 am, [EMAIL PROTECTED] wrote: messagesReceived = dict.fromkeys((one,two), {}) This creates two references to just *one* instance of empty dictionary. I'd do it like: messagesReceived = dict([(key, {}) for key in (one,two)]) --

Re: How to Read Bytes from a file

2007-03-02 Thread Bart Ogryczak
On Mar 1, 7:36 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mar 1, 12:46 pm, Bart Ogryczak [EMAIL PROTECTED] wrote: This solution looks nice, but how does it work? I'm guessing struct.unpack will provide me with 8 bit bytes unpack with 'B' format gives you int value equivalent

Re: finding out the precision of floats

2007-03-01 Thread Bart Ogryczak
On Feb 28, 10:29 pm, John Machin [EMAIL PROTECTED] wrote: On Mar 1, 4:19 am, BartOgryczak [EMAIL PROTECTED] wrote: On Feb 28, 3:53 pm, John Machin [EMAIL PROTECTED] wrote: On Feb 28, 10:38 pm, BartOgryczak [EMAIL PROTECTED] wrote: [1] eg. consider calculating interests rate, which

Re: How to Read Bytes from a file

2007-03-01 Thread Bart Ogryczak
On Mar 1, 7:52 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: It seems like this would be easy but I'm drawing a blank. What I want to do is be able to open any file in binary mode, and read in one byte (8 bits) at a time and then count the number of 1 bits in that byte. I got as far as

Re: How to Read Bytes from a file

2007-03-01 Thread Bart Ogryczak
On Mar 1, 4:58 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mar 1, 8:53 am, Bart Ogryczak [EMAIL PROTECTED] wrote: On Mar 1, 7:52 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: It seems like this would be easy but I'm drawing a blank. What I want to do is be able to open any

Re: finding out the precision of floats

2007-02-28 Thread Bart Ogryczak
On Feb 27, 7:58 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: On 27 Feb, 14:09, Bart Ogryczak [EMAIL PROTECTED] wrote: On Feb 27, 1:36 pm, Facundo Batista [EMAIL PROTECTED] wrote: Arnaud Delobelle wrote: (and I don't want the standard Decimal class :) Why? Why should you

cPickle FU on Solaris

2007-02-28 Thread Bart Ogryczak
It seems, that on Solaris cPickle is unable to unpickle some values, which it is able to pickle. import cPickle cPickle.dumps(1e-310) 'F9.9694e-311\n.' cPickle.loads(_) Traceback (most recent call last): File stdin, line 1, in ? ValueError: could not convert string to float

Re: finding out the precision of floats

2007-02-28 Thread Bart Ogryczak
On Feb 28, 3:53 pm, John Machin [EMAIL PROTECTED] wrote: On Feb 28, 10:38 pm, BartOgryczak [EMAIL PROTECTED] wrote: [1] eg. consider calculating interests rate, which often is defined as math.pow(anualRate,days/365.0). In what jurisdiction for what types of transactions? I would have

Re: finding out the precision of floats

2007-02-28 Thread Bart Ogryczak
On Feb 28, 6:34 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: So as long as you're dealing with something like invoices, Decimal does just fine. When you start real calculations, not only scientific, but even financial ones[1], it doesn't do any better then binary float, and it's bloody

Re: finding out the precision of floats

2007-02-27 Thread Bart Ogryczak
On Feb 27, 1:36 pm, Facundo Batista [EMAIL PROTECTED] wrote: Arnaud Delobelle wrote: (and I don't want the standard Decimal class :) Why? Why should you? It only gives you 28 significant digits, while 64-bit float (as in 32-bit version of Python) gives you 53 significant digits. Also note,

Re: Help on object scope?

2007-02-27 Thread Bart Ogryczak
On Feb 25, 10:25 pm, [EMAIL PROTECTED] wrote: Hello everybody, I have a (hopefully) simple question about scoping in python. I have a program written as a package, with two files of interest. The two files are /p.py and /lib/q.py My file p.py looks like this: --- from lib import q def

Re: python notation in new NVIDIA architecture

2007-02-26 Thread Bart Ogryczak
On Feb 26, 2:03 pm, Daniel Nogradi [EMAIL PROTECTED] wrote: Something funny: The new programming model of NVIDIA GPU's is called CUDA and I've noticed that they use the same __special__ notation for certain things as does python. For instance their modified C language has identifiers such as

Re: How to test whether a host is reachable?

2007-02-22 Thread Bart Ogryczak
On Feb 22, 3:22 pm, Fabian Steiner [EMAIL PROTECTED] wrote: Now I am wondering if there isn't any better method which would be more general. In fact, I think of something like a python version of ping which only tries to send ICMP packets. Server or a firewall in between most probably will

Re: eval('000052') = 42?

2007-02-21 Thread Bart Ogryczak
On Feb 21, 5:09 am, Astan Chee [EMAIL PROTECTED] wrote: Hi, I just tried to do eval('00052') and it returned 42. Is this a known bug in the eval function? Or have I missed the way eval function works? It works just fine. Read up on integer literals. 52 #decimal 52 052 #octal 42 0x52

Re: why I don't like range/xrange

2007-02-16 Thread Bart Ogryczak
On Feb 16, 4:30 pm, stdazi [EMAIL PROTECTED] wrote: for (i = 0; some_function() /* or other condition */ ; i++) C's for(pre,cond,post) code is nothing more, then shorthand form of pre; while(cond) {code; post;} Which translated to Python would be: pre while cond: code post --

Re: output to console and to multiple files

2007-02-16 Thread Bart Ogryczak
On Feb 14, 11:28 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I searched on Google and in this Google Group, but did not find any solution to my problem. I'm looking for a way to output stdout/stderr (from a subprocess or spawn) to screen and to at least two different files. eg.

Re: How much memory used by a name

2007-02-15 Thread Bart Ogryczak
On Feb 14, 9:41 pm, Bernard Lebel [EMAIL PROTECTED] wrote: This is taking a long time, and I'm looking for ways to speed up this process. I though that keeping the list in memory and dropping to the file at the very end could be a possible approach. It seems, that you're trying to reinvent

Re: list of range of floats

2007-02-15 Thread Bart Ogryczak
On Feb 14, 6:12 pm, Steve [EMAIL PROTECTED] wrote: I'm trying to create a list range of floats and running into problems. I've tried it the easy way. Works. map(float,range(a,b)) -- http://mail.python.org/mailman/listinfo/python-list

Re: UNIX shell in Python?

2007-02-09 Thread Bart Ogryczak
On Feb 9, 8:49 am, Deniz Dogan [EMAIL PROTECTED] wrote: Hello. I was thinking about writing a UNIX shell program using Python. Has anyone got any experience on this? Is it even possible? Use the Google, Luke. http://sourceforge.net/projects/pyshell/ --

Re: Repr or Str ?

2007-02-06 Thread Bart Ogryczak
On Feb 6, 11:47 am, Johny [EMAIL PROTECTED] wrote: Where and when is good/nescessary to use `repr` instead of `str` ? Can you please explain the differences Thanks RTFM. http://docs.python.org/ref/customization.html __repr__( self) Called by the repr() built-in function and by string

Re: Python cheatsheets

2007-02-06 Thread Bart Ogryczak
On Jan 7, 10:11 pm, Jussi Salmela [EMAIL PROTECTED] wrote: gonzlobo kirjoitti: Curious if anyone has a python cheatsheet* published? I'm looking for something that summarizes all commands/functions/attributes. Having these printed on a 8 x 11 double-sided laminated paper is pretty cool.

Re: Python cheatsheets

2007-02-06 Thread Bart Ogryczak
On Jan 7, 10:03 pm, gonzlobo [EMAIL PROTECTED] wrote: Curious if anyone has a python cheatsheet* published? I'm looking for something that summarizes all commands/functions/attributes. Having these printed on a 8 x 11 double-sided laminated paper is pretty cool. * cheatsheet probably isn't

Re: Why less emphasis on private data?

2007-02-05 Thread Bart Ogryczak
On Jan 7, 1:07 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Coming from a C++ / C# background, the lack of emphasis on private data seems weird to me. I've often found wrapping private data useful to prevent bugs and enforce error checking.. It appears to me (perhaps wrongly) that Python

Re: division by 7 efficiently ???

2007-02-02 Thread Bart Ogryczak
On Feb 1, 3:42 am, [EMAIL PROTECTED] wrote: How to divide a number by 7 efficiently without using - or / operator. We can use the bit operators. I was thinking about bit shift operator but I don't know the correct answer. It´s quiet simple. x == 8*(x/8) + x%8, so x == 7*(x/8) + (x/8 + x%8)

Re: newbie/ merging lists of lists with items in common

2007-02-02 Thread Bart Ogryczak
On Feb 2, 2:55 pm, ardief [EMAIL PROTECTED] wrote: Hi everyone Here is my problem: I have a list that looks like this - [['a', '13'], ['a', '3'], ['b', '6'], ['c', '12'], ['c', '15'], ['c', '4'], ['d', '2'], ['e', '11'], ['e', '5'], ['e', '16'], ['e', '7']] and I would like to end up with

Re: newbie/ merging lists of lists with items in common

2007-02-02 Thread Bart Ogryczak
On Feb 2, 3:19 pm, Larry Bates [EMAIL PROTECTED] wrote: l=[x for x in d.items()] d.items() is not an iterator, you don´t need this. This code is equivalent to l = d.items(). -- http://mail.python.org/mailman/listinfo/python-list

Re: division by 7 efficiently ???

2007-02-02 Thread Bart Ogryczak
On Feb 1, 2:00 pm, Nicko [EMAIL PROTECTED] wrote: precision and the answer that they were looking for was: a = (b * 045L) 32 Note that the constant there is in octal. 045L? Shouldn´t it be 044? Or more generally, const = (1bitPrecision)/7 a = (b *

SWIG overhead

2007-02-01 Thread Bart Ogryczak
Hi, I´m looking for some benchmarks comparing SWIG generated modules with modules made directly with C/Python API. Just how much overhead does SWIG give? Doing profile of my code I see, that it spends quiet some time in functions like _swig_setattr_nondinamic, _swig_setattr, _swig_getattr. --

Re: SWIG overhead

2007-02-01 Thread Bart Ogryczak
On Feb 1, 12:12 pm, Phil Thompson [EMAIL PROTECTED] wrote: On Thursday 01 February 2007 10:21 am, Bart Ogryczak wrote: Hi, I´m looking for some benchmarks comparing SWIG generated modules with modules made directly with C/Python API. Just how much overhead does SWIG give? Doing profile

Re: SWIG overhead

2007-02-01 Thread Bart Ogryczak
On Feb 1, 12:48 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Yeah, found that one googling around. But I haven´t fund anything more up to date. I imagine, that the performance of all of these wrappers has been improved since then. But the performance of Python/C API would too? Anyways,

Re: Question about a single underscore.

2007-02-01 Thread Bart Ogryczak
On Feb 1, 5:52 pm, Steven W. Orr [EMAIL PROTECTED] wrote: I saw this and tried to use it: --8--- const.py- [...] sys.modules[__name__]=_const() __name__ == 'const', so you´re actually doing const = _const() --

suppresing error pop-ups in Win32 app

2006-12-05 Thread Bart Ogryczak
Hi, I'm developing mixed Python/C app which runs on WinNT server. When something fails in Python, that´s not a problem, prints a traceback to the log and thats it. When something fails within the C code, the error message window pops up. To kill it I´ve got to access server with VNC. I´ve tried

Re: pickle and infinity

2006-11-30 Thread Bart Ogryczak
Grant Edwards wrote: On 2006-11-29, Bart Ogryczak [EMAIL PROTECTED] wrote: Fredrik Lundh wrote: Bart Ogryczak wrote: I´ve got this problem with pickle, it seems it doesn´t handle correctly infinite values (nor does Python return overflow/underflow error). Python 2.X relies

pickle and infinity

2006-11-29 Thread Bart Ogryczak
Hello, I´ve got this problem with pickle, it seems it doesn´t handle correctly infinite values (nor does Python return overflow/underflow error). What could I do about it? Example code: x = 1e310 #actually it would be a result of calculations type(x) type 'float' x 1.#INF import pickle

Re: pickle and infinity

2006-11-29 Thread Bart Ogryczak
To make things more interesting -- Solaris version: x = 1e310 x Infinity import pickle pickle.dumps(x) 'FInfinity\n.' pickle.loads(_) Infinity pickle.dumps(x,1) [...] SystemError: frexp() result out of range -- http://mail.python.org/mailman/listinfo/python-list

Re: How to refer to Python?

2006-11-29 Thread Bart Ogryczak
Sebastian Bassi wrote: I am writing a paper where I refer to Python. Is there a paper that I can refer the reader to? Or just use the Python web page as a reference? I´d refer to The Python Language Reference Manual, Guido Van Rossum, Fred L., Jr. Drake Network Theory Ltd (September 2003),

Re: pickle and infinity

2006-11-29 Thread Bart Ogryczak
Fredrik Lundh wrote: Bart Ogryczak wrote: I´ve got this problem with pickle, it seems it doesn´t handle correctly infinite values (nor does Python return overflow/underflow error). Python 2.X relies on the C library to serialize floats, and, as you've noticed, some C libraries can

Re: sharing persisten cache between modules

2006-10-24 Thread Bart Ogryczak
Dennis Lee Bieber wrote: f-i-* creates local names initially bound to the objects inside a module, but any assignment to such a name later results in the name being rebound to the new object -- disconnecting from the original. Great! That was it. Thank you! :-) --

sharing persisten cache between modules

2006-10-23 Thread Bart Ogryczak
Hi, I´ve got a problem creating persistent cache, that would be shared between modules. There a supermodule, which calls submodules. I´d like submodules to use cache created in the supermodule. The only way I see right now, is to pass it as function argument, but that would require a change in

Re: sharing persisten cache between modules

2006-10-23 Thread Bart Ogryczak
Fredrik Lundh wrote: Bart Ogryczak wrote: I´ve got a problem creating persistent cache, that would be shared between modules. There a supermodule, which calls submodules. I´d like submodules to use cache created in the supermodule. The only way I see right now, is to pass it as function

Which KDE IDE for Python?

2006-08-04 Thread Bart Ogryczak
Hi, Rigth now I'm using two IDEs for Python, KDevelop and Eric. Both have drawbacks. KDevelop is a multilanguage IDE, and doesn't really have anything special for Python. There's no Python debugger, no PyDOC integration, it's class browser doesn't display attributes. On the other side there's

Re: Which KDE IDE for Python?

2006-08-04 Thread Bart Ogryczak
Diez B. Roggisch wrote: Bart Ogryczak schrieb: Hi, Rigth now I'm using two IDEs for Python, KDevelop and Eric. Both have drawbacks. KDevelop is a multilanguage IDE, and doesn't really have anything special for Python. There's no Python debugger, no PyDOC integration, it's class browser