Re: python connect to db2

2005-01-14 Thread Jacek
yuzx wrote: anyone can help me ? this might help: http://www6.software.ibm.com/reg/devworks/dw-db2pylnx-i?S_TACT=104AHW03&S_CMP=EDU jacek -- http://mail.python.org/mailman/listinfo/python-list

memoru usage of process

2005-09-27 Thread Jacek Popławski
I need to know how much memory uses child process (after subprocess.Popen), so I want function: get_memory_usage(pid) I found two ways: - call "ps" and analyze its output - this is not portable (different output on Linux, Cygwin and QNX) - use resource.getrusage - but it works for self/childr

Re: memoru usage of process

2005-09-28 Thread Jacek Popławski
MrJean1 wrote: > Yes, I have seen it in archive, but I was searching for Python way, and it's not Python related at all (it is just reading system file), and won't work on QNX. -- http://mail.python.org/mailman/listinfo/python-l

SNMPV3

2005-12-06 Thread Jacek Popławski
Do you have any experience with Python in SNMPv3 area? I just realized that pySNMP we are using supports only v1 and v2c, development version probably supports SNMPv3 but I am unable to find any v3-specific documentation, could you help me? Is there any other solution than pySNMP? -- http://ma

Re: Optional Static Typing

2005-01-04 Thread Jacek Generowicz
[EMAIL PROTECTED] (Alex Martelli) writes: > I've always liked the (theoretical) idea that assertions (including of > course contracts) could be used as axioms used to optimize generated > code, rather than (necessarily) as a runtime burden. E.g. (and I don't > know of any implementation of this c

Re: Cookbook 2nd ed Credits (was Re: The Industry choice)

2005-01-05 Thread Jacek Generowicz
[EMAIL PROTECTED] (Alex Martelli) writes: > ...but each still gets ONE free copy...!-) Who gets Luther Blissett's copy ? :-) And are all the Luther Blissetts the same Luther Blisset ? -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: spacing of code in Google Groups

2005-01-05 Thread Jacek Generowicz
Peter Hansen <[EMAIL PROTECTED]> writes: > Grant Edwards wrote: > > I always rather liked line numbers (a-la 'can -n'). That also > > makes discussion of the code easier: > > That, unfortunately, is somewhat harder to remove without > using a regular expression... You mean to say that your edit

Re: OT: spacing of code in Google Groups

2005-01-06 Thread Jacek Generowicz
Peter Hansen <[EMAIL PROTECTED]> writes: > Why the heck would I ever have to do "rectangle operations" on a > regular basis? ;-) Well, given that all editors are cat equivalent[*], you don't _have_ to use any of their features :-) But just like Python (particularly in the hands of a skilled Pyt

Re: OT: spacing of code in Google Groups

2005-01-07 Thread Jacek Generowicz
Peter Hansen <[EMAIL PROTECTED]> writes: > Jacek Generowicz wrote: > > Peter Hansen <[EMAIL PROTECTED]> writes: > >>Why the heck would I ever have to do "rectangle operations" on a > >>regular basis? ;-) > > Well, given that all editors ar

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread Jacek Generowicz
"Anna" <[EMAIL PROTECTED]> writes: > Having taken some calculus (derivatives, limits, some integrals) but > never even heard of lambda calculus, to me, lambda means absolutely > NOTHING. Less than nothing. And before you took calculus, the chances are that derivatives, limits and integrals meant

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread Jacek Generowicz
Nick Coghlan <[EMAIL PROTECTED]> writes: > Jacek Generowicz wrote: > > [*] Funnily enough, getting them to understand that "lambda x: fn(x)" > > is just a very silly way of writing "fn", can be quite a struggle > > at times ... but

Re: Securing a future for anonymous functions in Python

2005-01-10 Thread Jacek Generowicz
"Anna" <[EMAIL PROTECTED]> writes: > With class and def, I at least have a *name* to start with - class > Square pretty obviously is going to have something to do with > geometric shapes, I would hope (or maybe with boring people...). Or maybe with multiplying something by itself. Or maybe the au

Re: Securing a future for anonymous functions in Python

2005-01-10 Thread Jacek Generowicz
Nick Coghlan <[EMAIL PROTECTED]> writes: > > Usually one or two have trouble grasping that "int" would be perfectly > > adequate in this situation. > > The ability to pass around functions at run-time was probably the > hardest thing to get my head around when I started with Python, And I suspec

Re: Securing a future for anonymous functions in Python

2005-01-10 Thread Jacek Generowicz
"Anna" <[EMAIL PROTECTED]> writes: > Jacek Generowicz wrote: > > "Anna" <[EMAIL PROTECTED]> writes: > > > > > With class and def, I at least have a *name* to start with - class > > > Square pretty obviously is going to have somethi

Re: Securing a future for anonymous functions in Python

2005-01-11 Thread Jacek Generowicz
Jeff Shannon <[EMAIL PROTECTED]> writes: > Jacek Generowicz wrote: > > "Anna" <[EMAIL PROTECTED]> writes: > > > >>But first, wouldn't something like: > >> > >>[x+1 for x in seq] > >> > >>be even clearer? >

Re: Securing a future for anonymous functions in Python

2005-01-11 Thread Jacek Generowicz
Steve Holden <[EMAIL PROTECTED]> writes: > Well, I suspect that Church originally chose lambda precisely because > of its meaninglessness, IAANM, Church didn't choose lambda at all. He chose to put a "hat" (like a circumflex accent) above the bound name. Then, because of some typesetting difficul

Re: The limitation of the Photon Hypothesis

2005-01-11 Thread Jacek Generowicz
Steve Holden <[EMAIL PROTECTED]> writes: > Steve Horsley wrote: > > > Also, I think you probably accidentally posted to the wrong > > newsgroup. > > No, he deliberately posted to the wrong newsgroup. Heh ... I initially read the subject line as "The limitation of the Python Hypothesis". -- http

Re: Securing a future for anonymous functions in Python

2005-01-12 Thread Jacek Generowicz
Jeff Shannon <[EMAIL PROTECTED]> writes: > I guess we'll have to agree to disagree Indeed :-) > I find that reading a lambda requires mentally pushing a stack frame > to parse the lambda and another to translate map() into a loop, > whereas a list comp's expression doesn't require such a shift

Re: Securing a future for anonymous functions in Python

2005-01-12 Thread Jacek Generowicz
Donn Cave <[EMAIL PROTECTED]> writes: > List incomprehensions do not parse well in my eyes. Are you familiar with the Haskell syntax for list comprehensions? For example: http://www.zvon.org/other/haskell/Outputsyntax/listQcomprehension_reference.html Does their striking similarity to mathem

from __future__ import decorators

2005-01-13 Thread Jacek Generowicz
I have some code, which makes copious use of the @decorator syntax which was introduced in Python2.4. Now I find myself in a situation where I have to run the code under Python 2.3. However, I would like to keep developing the code with the new syntax. How could I best automate the process of maki

Re: from __future__ import decorators

2005-01-13 Thread Jacek Generowicz
Thomas Heller <[EMAIL PROTECTED]> writes: > Jacek Generowicz <[EMAIL PROTECTED]> writes: > > > I have some code, which makes copious use of the @decorator syntax > > which was introduced in Python2.4. Now I find myself in a situation > > where I have to run t

Re: from __future__ import decorators

2005-01-13 Thread Jacek Generowicz
Peter Otten <[EMAIL PROTECTED]> writes: > Have a look at Bill Mill's redecorate utility: > > http://llimllib.f2o.org/files/redecorate.py Heh, this is exactly the sort of thing I wanted do avoid writing, as it would be difficult to get right. Looks like it's author has similar feelings. However,

Re: from __future__ import decorators

2005-01-13 Thread Jacek Generowicz
Skip Montanaro <[EMAIL PROTECTED]> writes: > Jacek> Crazy idea ... would it be possible to shadow 2.3's parser with > Jacek> one stolen from 2.4 ? > > If you're willing to go to that much trouble, why not just upgrade to 2.4? *I* upgraded to 2.4 somet

Re: from __future__ import decorators

2005-01-17 Thread Jacek Generowicz
Tim Roberts <[EMAIL PROTECTED]> writes: > Jacek Generowicz <[EMAIL PROTECTED]> wrote: > > > >I have some code, which makes copious use of the @decorator syntax > > I'm very curious to know what kind of application you are writing in which > "copious

Re: variable declaration

2005-02-01 Thread Jacek Generowicz
"Michael Tobis" <[EMAIL PROTECTED]> writes: > In fact, I'd recommend a paragraph early in the Nutshell book saying > "there are no declarations, no use strict, no implicit none, sorry, > forget it", It would have to be a pretty long paragraph, if it were to list all the things that you do NOT fin

Re: Python's idiom for function overloads

2005-02-01 Thread Jacek Generowicz
Philippe Fremy <[EMAIL PROTECTED]> writes: > Hi Frans, > > > Since Python doesn't have static typing, how is the same result as > > traditional function overloads results in acheived? > > > With dynamic typing obviously. :-) > > You can not reproduce the C++ overload idiom Of course you

Re: Python's idiom for function overloads

2005-02-01 Thread Jacek Generowicz
"F. GEIGER" <[EMAIL PROTECTED]> writes: > As Philippe already said, use objects that support the protocol or decide > what to do with it after having checked its type. I do that, if I have to, > like so: > > 1 def doIt(arg): > 2if type(arg) == type([]): > 3map(doIt, arg) > 4 else

Re: Next step after pychecker

2005-02-01 Thread Jacek Generowicz
Paul Rubin writes: > Philippe Fremy <[EMAIL PROTECTED]> writes: > > I would like to develop a tool that goes one step further than > > pychecker to ensure python program validity. The idea would be to get > > close to what people get on ocaml: a static verification of al

Re: type of simple object

2005-02-01 Thread Jacek Generowicz
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > How do I know type of simple object is tuple or list or integer, for > example my function should understand what is the object type passed in > its argument Answers ordered in decreasing degree of Pythonicity: 1) You are mistaken, the function

Re: Python's idiom for function overloads

2005-02-01 Thread Jacek Generowicz
Philippe Fremy <[EMAIL PROTECTED]> writes: > Enforcing types also brings the benefit that the program is more > deterministic. In my experience, there is a lot more benefits to have > an object whose type is clearly identified than to have function that > accepts generic objects. > > > I would g

Re: type of simple object

2005-02-01 Thread Jacek Generowicz
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > The result > How can I check it since it is not a string right? It is a type, which is a first-class object in its own right. type('hello') == str However, I reiterate, you almost certainly don't really care about what the actual type is. T

Re: type of simple object

2005-02-01 Thread Jacek Generowicz
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Thank you guys. > > My function should multiply every element of a list, for example > "something" > and "something" can be an integer or another list. > If it deals with integer than it is ok, but > If it deals with list than it become false for

Re: type of simple object

2005-02-01 Thread Jacek Generowicz
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hello Jacek, > > Thanks for the answer, > > Can you tell me how can I check if an object is a sequence (you are > right, this is actually what I want)? You try to use it as a sequence. If it works, then

telnet.read_until() from telnetlib

2005-08-26 Thread Jacek Popławski
I have strange problem with telnetlib. r=self.telnet.read_until(expected,timeout) It works in most cases (hundrets of iterations), but sometimes "r" doesn't contain "expected", first I thought that server is responding incorrectly, then I realized that read_until doesn't wait timeout seconds! ex

Re: telnet.read_until() from telnetlib

2005-08-29 Thread Jacek Popławski
my newsreader told me that [EMAIL PROTECTED] wrote: > Please post the minimum code necessary to duplicate the problem. It's impossible, because I am writting performance tests for big commercial project, I am trying to understand why they sometime fail. By definition of "read_until()" it should re

Re: telnet.read_until() from telnetlib

2005-08-29 Thread Jacek Popławski
I have same problem with expect :-( I am calling: l=[expected] result=self.telnet.expect(l,timeout) it works in most cases, but sometimes (with exacly same "expected" value) it returns -1,Nil,"some text" the point is, that: - connection is still active, so it should read more! - it doesn't wait

Re: telnet.read_until() from telnetlib

2005-08-31 Thread Jacek Popławski
my newsreader told me that [EMAIL PROTECTED] wrote: > "If end of file is found and no text was read, raise EOFError. > Otherwise, when nothing matches, return (-1, None, text) where text is > the text received so far (may be the empty string if a timeout > happened). " What if: - exception has not

killing thread after timeout

2005-09-06 Thread Jacek Popławski
Hello. I am going to write python script which will read python command from socket, run it and return some values back to socket. My problem is, that I need some timeout. I need to say for example: os.system("someapplication.exe") and kill it, if it waits longer than let's say 100 seconds I

Re: killing thread after timeout

2005-09-06 Thread Jacek Popławski
After reading more archive I think that solution may be to raise an Exception after timeout, but how to do it portable? -- http://mail.python.org/mailman/listinfo/python-list

popen in thread on QNX

2005-09-08 Thread Jacek Popławski
I am still in the process of creating my script which will run command received from socket. My scripts works perfectly on Linux, but doesn't work on QNX! File "/usr/lib/python2.4/popen2.py", line 108, in __init__ self.pid = os.fork() OSError: [Errno 89] Function not implemented When I t

Re: popen in thread on QNX

2005-09-08 Thread Jacek Popławski
It works when I use os.system() instead os.popen3(), but with os.system() I have no access to stdout and stderr :-( -- http://mail.python.org/mailman/listinfo/python-list

Re: popen in thread on QNX

2005-09-08 Thread Jacek Popławski
Laszlo Zsolt Nagy wrote: > os.popen already creates a new process. So what if you try to call > os.popen from your main thread, then pass the file descriptors to your > thread? > It is just an idea... But I need to run command from thread, that's the main reason to create new thread :) -- http

Re: killing thread after timeout

2005-09-08 Thread Jacek Popławski
Bryan Olson wrote: > First, a portable worker-process timeout: In the child process, > create a worker daemon thread, and let the main thread wait > until either the worker signals that it is done, or the timeout > duration expires. It works on QNX, thanks a lot, your reply was very helpful! > I

Re: killing thread after timeout

2005-09-08 Thread Jacek Popławski
Paul Rubin wrote: > Maybe the child process can just use sigalarm instead of a separate > thread, to implement the timeout. Already tried that, signals works only in main thread. > To get even more OS-specific, AF_UNIX sockets (at least on Linux) have > a feature called ancillary messages that al

Re: popen in thread on QNX

2005-09-08 Thread Jacek Popławski
Laszlo Zsolt Nagy wrote: > - one of your worker threads wants to run a command > - it creates the argument list and puts it into a message queue > - woker thread starts to sleep > - main thread processes the message queue -> it will run popen, put back > the file descriptors into the message and w

subprocess solved all my problems

2005-09-09 Thread Jacek Popławski
In the last week I was working to create script which will read command from socket, call it, return result, stdout, stderr and kill it after timeout. After playing with threads, processes, spawns and popens I found subprocess module. To call command I use following construction:

read stdout/stderr without blocking

2005-09-12 Thread Jacek Popławski
Popen from subprocess module gives me access to stdout, so I can read it. Problem is, that I don't know how much data is available... How can I read it without blocking my program? example: import subprocess import time comman

Re: read stdout/stderr without blocking

2005-09-12 Thread Jacek Popławski
Adriaan Renting wrote: > Check out the select module, for an example on how to use it: > pexpect.sourceforge.net Two problems: - it won't work on Windows (Cygwin) - how much data should I read after select? 1 character? Can it block if I read 2 characters? -- http://mail.python.org/mailman/listi

Re: read stdout/stderr without blocking

2005-09-12 Thread Jacek Popławski
> ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s > for file in ready[0]: > try: > text = os.read(file, 1024) How do you know here, that you should read 1024 characters? What will happen when output is shorter? -- http://mail.python

Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Grant Edwards wrote: > On 2005-09-12, Jacek Pop?awski <[EMAIL PROTECTED]> wrote: > >>>ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s >>>for file in ready[0]: >>>try: >>>text = os.read

Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Only solution which works for now is to redirect stderr to stdout, and read stdout on thread. Code without thread or with read() or read(n) (when n>1) can block. Code with select() and read(1) works, but it is very slow. -- http://mail.python.org/mailman/listinfo/python-list

Re: popen in thread on QNX

2005-09-13 Thread Jacek Popławski
Laszlo, I can't reply your mails, your address doesn't work, please try jacekpoplawski-at-gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Grant Edwards wrote: > You're right. I must have been remembering the behavior of a > network socket. Apparently, you're supposed to read a single > byte and then call select() again. That seems pretty lame. I created another thread with single read(), it works, as long as I have only one PI

Re: read stdout/stderr without blocking

2005-09-16 Thread Jacek Popławski
Donn Cave wrote: > I don't recall the beginning of this thread, so I'm not sure > if this is the usual wretched exercise of trying to make this > work on both UNIX and Windows, It is used in "test framework" which runs on Linux, Windows (Cygwin) and QNX. I can't forget about Windows. -- http://

Re: Python 2.4 removes None data type?

2005-03-09 Thread Jacek Generowicz
Warren Postma <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: > > > I just read in the 'What's New in Python 2.4' document that the None > > data type was converted to a constant: > > http://python.org/doc/2.4/whatsnew/node15.html > > Implication: A long standing wart in Python now gone.

Logging global assignments

2005-03-11 Thread Jacek Generowicz
I am dealing with an application which reads in configurations by calling (a wrapper around) execfile. Any configuration file may itself execfile other configuration files in the same manner. I would like to create a log containing all global assignments made in these files. Comparing the globals

Re: Logging global assignments

2005-03-11 Thread Jacek Generowicz
Larry Bates <[EMAIL PROTECTED]> writes: > Suggestion: > Use ConfigParser to set your globals instead and you can track > your assignments over each file, section and option in the file. I would dearly love to go down this sort of route but, unfortunately, they are not _my_ configuration files, an

Re: Lisp-likeness

2005-03-16 Thread Jacek Generowicz
"Carl Banks" <[EMAIL PROTECTED]> writes: > Michele Simionato wrote: > > Carl Banks: > > > If Python did it the way Scheme did, this would be pretty useless. > > > > But notice that Scheme has no problems whatsoever: > > > > (define (toplevel) > > (define a 1) > > (define (f) > > (display a

Re: simultaneous copy to multiple media

2005-03-20 Thread Jacek Trzmiel
he > source file first to the first media, then to the > second, etc.? Use 'tee' command from shell: tee /dest1/file /dest2/file Or run two copies in parallel (one of them probably will read file from cache): cp file /dest1/file & cp file /dest2/file -- Jacek. -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators ?

2004-12-01 Thread Jacek Generowicz
BJörn Lindqvist <[EMAIL PROTECTED]> writes: > I think the essence of decorators is that it makes it possible to do > in Python what you in other languages do with method qualifiers. I find it fascinating that the addition of a bit of syntax sugar gives the perception that a whole range of new and

Re: pre-PEP generic objects

2004-12-06 Thread Jacek Generowicz
Jp Calderone <[EMAIL PROTECTED]> writes: > When the class object is created, the namespace is scanned for > instances of . For those and only those, a > descriptor is created which will produce bound and unbound methods. This isn't quite correct. A descriptior is any object which has callable at

Re: pre-PEP generic objects

2004-12-07 Thread Jacek Generowicz
Carlos Ribeiro <[EMAIL PROTECTED]> writes: > On 06 Dec 2004 10:09:25 +0100, Jacek Generowicz > <[EMAIL PROTECTED]> wrote: > [great explanation about function descriptors] > > Thanks. Now I know more about function descriptors than I ever wanted > to :-) With a lit

Re: Python Docs. Hardcopy 2.4 Library Reference, interested?

2004-12-09 Thread Jacek Generowicz
"Brad Clements" <[EMAIL PROTECTED]> writes: > Is anyone interested in purchasing a hardcopy version of the Python 2.4 > Library reference? > > That is, assuming it was NOT a direct print of current html/pdf versions. > > So, nicely formatted for a printed book (spiral bound probably), with > se

Re: simultaneous copy to multiple media

2005-03-20 Thread Jacek Trzmiel
Claudio Grondi wrote: > I am on a Widows 2000 box using the NTFS file system. > Both up to now suggested approaches as > - tee.exe (where I used the http://david.tribble.com/dos/tee.exe > DOS-port with redirecting stdout to NULL) and > - parallel copy (hoping caching does the job) are by far > slo

Re: simultaneous copy to multiple media

2005-03-21 Thread Jacek Trzmiel
> > This is small tool I've wrote, that does use large memory buffers with > > asynchronous I/O to copy file. Claudio Grondi wrote: > Thank you! > This (with a drawback of blocking the entire system) does it! > ( dzień dobry i dziękuję za tą konstruktywną odpowiedź > na moje pytanie ) :) > From

Re: application console with window

2015-01-07 Thread jacek pozniak
adam wrote: > Is in here maybe someone who speak Polish? > > I would like to write application witch looks like this > http://linuxiarze.pl/obrazy/internet1/ceni1.png Jeśli chodzi Ci o przeniesienie na wersję okienkową to na przykład: tkinter. jp > > I'm looking for some libs, tutorials, or ot

Re: application console with window

2015-01-08 Thread jacek pozniak
skryptów pythona o ile zajdzie taka potrzeba. jp > > Adam > > jacek pozniak wrote: > >> adam wrote: >> >>> Is in here maybe someone who speak Polish? >>> >>> I would like to write application witch looks like this >>> http://linuxi

Re: regular expression concatenation with strings

2007-06-22 Thread Jacek Trzmiel
(os.path.join(dir,p)) and filenameRx.match(p) ]: file, ext = os.path.splitext(picture) im = Image.open (picture) im.thumbnail(size, Image.ANTIALIAS) im.save(file + ".thumbnail." + extension) jpg = re.compile(".*\.(jpg|jpeg)", re.IGNORECASE) thumbnail

Re: regular expression concatenation with strings

2007-06-22 Thread Jacek Trzmiel
es that does match the pattern. Best regards, Jacek. -- http://mail.python.org/mailman/listinfo/python-list

Re: database design help

2007-06-23 Thread Jacek Trzmiel
ers), > ('type',str), > ('project',project)) Split document into separate document and revision concept, i.e. something like this: documents.create(('type',str), ('project',project)) revisions.create

Re: newbie tcp/ip question

2007-06-24 Thread Jacek Trzmiel
; to a specific ip address. How do I do that in python? Google for: python socket example Best regards, Jacek. -- http://mail.python.org/mailman/listinfo/python-list

Re: Which coding style is better? public API or private method inside class definition

2011-01-05 Thread Jacek Krysztofik
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Sorry for OT, but this is actually a question of mine > if numbers % 2 == 0: wouldn't the following be faster? > if numbers & 1 == 0: JK -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using G