Re: How to timeout when waiting for raw_input from user ?

2009-12-05 Thread Maxim Khitrov
On Sat, Dec 5, 2009 at 9:01 AM, Rune Strand rune.str...@gmail.com wrote: The easiest wasy is to use the Timer object in the threading module. from threading import Timer Doesn't work on Windows. - Max -- http://mail.python.org/mailman/listinfo/python-list

Re: How to timeout when waiting for raw_input from user ?

2009-12-05 Thread Maxim Khitrov
On Sat, Dec 5, 2009 at 9:11 AM, Rune Strand rune.str...@gmail.com wrote: On Dec 5, 3:07 pm, Maxim Khitrov mkhit...@gmail.com wrote: Doesn't work on Windows. - Max Yes, it does. I've used it a lot, also in Py2Exe apps.  Try the documentation example yourself def hello():    print hello

Re: How to timeout when waiting for raw_input from user ?

2009-12-04 Thread Maxim Khitrov
On Fri, Dec 4, 2009 at 6:55 PM, northof40 shearich...@gmail.com wrote: On Dec 5, 12:52 pm, northof40 shearich...@gmail.com wrote: Hi - I'm writing a *very* simple program for my kids. It asks the user to give it the answer to a maths question and says right or wrong They now want a timed

Re: Is it possible to get the Physical memory address of a variable in python?

2009-11-10 Thread Maxim Khitrov
On Tue, Nov 10, 2009 at 6:32 AM, Ognjen Bezanov ogn...@mailshack.com wrote: Hey, Thanks for all the responses guys. In hindsight I probably should have explained why on earth I'd need the physical address from an interpreted language. I'm trying to see if there is any way I can make Python

Re: comparing alternatives to py2exe

2009-11-03 Thread Maxim Khitrov
On Tue, Nov 3, 2009 at 10:58 AM, Jonathan Hartley tart...@tartley.com wrote: Hi, Recently I put together this incomplete comparison chart in an attempt to choose between the different alternatives to py2exe: http://spreadsheets.google.com/pub?key=tZ42hjaRunvkObFq0bKxVdgoutput=html Columns

Re: comparing alternatives to py2exe

2009-11-03 Thread Maxim Khitrov
On Tue, Nov 3, 2009 at 3:50 PM, iu2 isra...@elbit.co.il wrote: On Nov 3, 5:58 pm, Jonathan Hartley tart...@tartley.com wrote: Hi, Recently I put together this incomplete comparison chart in an attempt to choose between the different alternatives to py2exe:

Inconsistent raw_input behavior after Ctrl-C

2009-10-20 Thread Maxim Khitrov
Hello all, I ran into a rather strange problem when interrupting a raw_input call with Ctrl-C. This is with python 2.6.3 on Windows 7. When the call is interrupted, one of two things happen - either a KeyboardInterrupt exception is raised or raw_input raises EOFError, and KeyboardInterrupt is

Re: Inconsistent raw_input behavior after Ctrl-C

2009-10-20 Thread Maxim Khitrov
On Tue, Oct 20, 2009 at 6:09 PM, Maxim Khitrov mkhit...@gmail.com wrote: Hello all, I ran into a rather strange problem when interrupting a raw_input call with Ctrl-C. This is with python 2.6.3 on Windows 7. When the call is interrupted, one of two things happen - either a KeyboardInterrupt

Re: How can I get the line number ?

2009-07-24 Thread Maxim Khitrov
On Fri, Jul 24, 2009 at 2:51 PM, kkmaymunbe...@gmail.com wrote: Hello I am writing some Python code that runs in another application(has wrapper functions). Due to lack of debugging I am printing out alot of outputs and manual messages. I want to be able to create a function that would let

Re: no return value for threading.Condition.wait(timeout)?

2009-07-16 Thread Maxim Khitrov
On Thu, Jul 16, 2009 at 5:00 PM, Carl Bankspavlovevide...@gmail.com wrote: On Jul 16, 8:12 am, Gabriel Rossetti gabriel.rosse...@arimaz.com wrote: Hello everyone, I am using threading.Condition.wait(timeout) and was surprised to see that there is no return value nor an exception when wait()

Re: Override a method but inherit the docstring

2009-07-16 Thread Maxim Khitrov
On Thu, Jul 16, 2009 at 9:13 PM, Jean-Paul Calderoneexar...@divmod.com wrote: On Fri, 17 Jul 2009 11:01:49 +1000, Ben Finney ben+pyt...@benfinney.id.au wrote: Howdy all, The following is a common idiom::   class FooGonk(object):       def frobnicate(self):           Frobnicate this

Re: Efficient bits manipulation in Python

2009-04-28 Thread Maxim Khitrov
On Tue, Apr 28, 2009 at 7:26 AM, Li Wang li.wan...@gmail.com wrote: Hi: I have a bit-code :'1011011', how can I reverse it to '1101101'? Another question is I know how to transform the string '110' into integer 6, does anyone know how to transform integer 6 to a string '110'? Thank you

Re: OpenGL win32 Python

2009-04-17 Thread Maxim Khitrov
On Fri, Apr 17, 2009 at 9:27 AM, gintare statkute g.statk...@gmail.com wrote: Hello, i found an example for OpenGL in windows. It is incredibly helpful, but how to rewrite it to be useful in Python. How to give address of pfd in Python?: iFormat = ChoosePixelFormat( hDC, pfd );

Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Maxim Khitrov
On Tue, Mar 24, 2009 at 5:05 AM, CinnamonDonkey cinnamondon...@googlemail.com wrote: Thanx Max - your explanation sorted it :-), and a big thank you to everyone else also! From the various posts, Python considers any directory containing the __init__.py file to be a package. The top level

Re: Unit testing frameworks

2009-03-24 Thread Maxim Khitrov
On Tue, Mar 24, 2009 at 8:06 AM, grkunt...@gmail.com wrote: I am looking for a unit testing framework for Python. I am aware of nose, but was wondering if there are any others that will automatically find and run all tests under a directory hierarchy. Have you already looked at the unittest

Re: Relative Imports, why the hell is it so hard?

2009-03-24 Thread Maxim Khitrov
On Tue, Mar 24, 2009 at 8:57 PM, Istvan Albert istvan.alb...@gmail.com wrote: Does it not bother you that a module that uses relative imports cannot be run on its own anymore? $ python --help snip -m mod : run library module as a script (terminates option list) snip $ python -m some.module.name

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Maxim Khitrov
On Mon, Mar 23, 2009 at 10:16 AM, CinnamonDonkey cinnamondon...@googlemail.com wrote: Hi All, I'm fairly new to Python so I still have a lot to learn. But I'd like to know how to correectly use relative imports. Please, please... please! don't go off on rants about why you think relative

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Maxim Khitrov
On Mon, Mar 23, 2009 at 11:22 AM, CinnamonDonkey cinnamondon...@googlemail.com wrote: Looking at http://www.python.org/dev/peps/pep-0328/#guido-s-decision would suggest, unless I am completely miss-understanding the example, that '.' refers to the current level and '..' pops up a level. That

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Maxim Khitrov
On Mon, Mar 23, 2009 at 12:19 PM, CinnamonDonkey cinnamondon...@googlemail.com wrote: My applogies if this is a silly question... but what makes something a package? and does that mean that what I am trying to do is not possible ? A package is a directory that has an __init__.py file. That

Re: Script for a project inside own directory

2009-03-22 Thread Maxim Khitrov
2009/3/22 Filip Gruszczyński grusz...@gmail.com: I am having a project built like this: project   module1.py   module2.py   packages1/     module3.py etc. I have script that uses objects from those modules/packages. If I keep this script inside project directory it's ok and it works.

Re: How Get Name Of Working File

2009-03-22 Thread Maxim Khitrov
On Sun, Mar 22, 2009 at 10:58 AM, Christian Heimes li...@cheimes.de wrote: Victor Subervi schrieb: Hi; If I am writing a script that generates HTML, how do I grab the name of the actual file in which I am working? For example, let us say I am working in test.py. I can have the following code:

Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__(self): self.some_value = 0 self.another_value = None Similar effect can be achieved by

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 12:50 PM, MRAB goo...@mrabarnett.plus.com wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object):    def __init__(self

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 2:07 PM, Gary Herron gher...@islandtraining.com wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object):    def __init__

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 4:31 PM, Gary Herron gher...@islandtraining.com wrote: Perhaps a different example would help explain what I'm trying to do: class Case1(object):        def __init__(self):                self.count = 0                self.list  = []        def inc(self):          

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 5:38 PM, Matthew Woodcraft matt...@woodcraft.me.uk wrote: Gary Herron gher...@islandtraining.com writes: I think this code is in poor taste: it's clear that it will confuse people (which is what Maxim was asking about in the first place). Yes, I see that now, thanks :)

Re: py2exe automatic upgrades of a program while it is running, is that possible?

2009-03-02 Thread Maxim Khitrov
On Mon, Mar 2, 2009 at 9:18 PM, William Heath wghe...@gmail.com wrote: Hi All, I am using py2exe to create a windows executable.  I am curious if anyone knows a way to automatically upgrade a py2exe windows executable while it is running.  Is that possible?  If so how?  If it isn't possible,

Re: What functions, other than sleep(), can be interrupted by Ctrl-C?

2009-02-27 Thread Maxim Khitrov
On Thu, Feb 26, 2009 at 3:47 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: I'm looking for a function in the standard library or pywin32 package that will block until a certain condition is met or it is interrupted by Ctrl-C. For example, time.sleep() would have been perfect for my needs

What functions, other than sleep(), can be interrupted by Ctrl-C?

2009-02-26 Thread Maxim Khitrov
Greetings, I'm looking for a function in the standard library or pywin32 package that will block until a certain condition is met or it is interrupted by Ctrl-C. For example, time.sleep() would have been perfect for my needs if thread.interrupt_main() could interrupt the call from another thread

Re: Strange array.array performance

2009-02-20 Thread Maxim Khitrov
On Fri, Feb 20, 2009 at 2:42 AM, Scott David Daniels scott.dani...@acm.org wrote: Maxim Khitrov wrote: ... Here's the function that I'll be using from now on. It gives me exactly the behavior I need, with an int initializer being treated as array size. Still not as efficient as it could

Using clock() in threading on Windows

2009-02-20 Thread Maxim Khitrov
Greetings, The threading module uses time.time in _Condition and _Thread classes to implement timeouts. On Windows, time() typically has a resolution of 15.625ms. In addition, if the system clock is changed (though ntp, for example) it would reflect that change, causing the timeout to last longer

Strange array.array performance

2009-02-19 Thread Maxim Khitrov
Hello all, I'm currently writing a Python - MATLAB interface with ctypes and array.array class, using which I'll need to push large amounts of data to MATLAB. Everything is working well, but there was one strange performance-related issue that I ran into and wanted to ask about. Here's some

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-02-19 12:52, Maxim Khitrov wrote: Hello all, I'm currently writing a Python- MATLAB interface with ctypes and array.array class, using which I'll need to push large amounts of data to MATLAB. Have you taken

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 2:23 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 19 Feb 2009 16:52:54 -0200, Maxim Khitrov mkhit...@gmail.com escribió: input = array('B', range(256) * 1) # Case 1 start = clock() data1 = array('B', input) print format(clock() - start, '.10f

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 7:01 PM, Scott David Daniels scott.dani...@acm.org wrote: Maxim Khitrov wrote: On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern robert.k...@gmail.com wrote: I have, but numpy is not currently available for python 2.6, which is what I need for some other features, and I'm

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 7:01 PM, Scott David Daniels scott.dani...@acm.org wrote: Maxim Khitrov wrote: On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern robert.k...@gmail.com wrote: I have, but numpy is not currently available for python 2.6, which is what I need for some other features, and I'm

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 9:34 PM, David Cournapeau courn...@gmail.com wrote: On Fri, Feb 20, 2009 at 4:53 AM, Maxim Khitrov mkhit...@gmail.com wrote: On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-02-19 12:52, Maxim Khitrov wrote: Hello all, I'm currently

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 9:15 PM, John Machin sjmac...@lexicon.net wrote: On Feb 20, 6:53 am, Maxim Khitrov mkhit...@gmail.com wrote: On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-02-19 12:52, Maxim Khitrov wrote: Hello all, I'm currently writing

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 10:06 PM, David Cournapeau courn...@gmail.com wrote: On Fri, Feb 20, 2009 at 11:43 AM, Maxim Khitrov mkhit...@gmail.com wrote: Yes, I may have a case where one thread is still sending data, while another tries to close the connection, or two threads trying to close