Py2 + PY3 transform a project (git submodule) to a clean package (with setup.py)

2016-01-15 Thread Gelonida N
Hi, I'm having a git project which contains functionality, that I use in many of my projects. For this posts sake let's call it mylib. if mylib is in the python path, it can be used for quite some convenience function in many of my projects. Examples: from mylib.logging import

Re: while loop - multiple condition

2014-10-13 Thread Gelonida N
On 10/12/2014 07:08 PM, Shiva wrote: while ans.lower() != 'yes' or ans.lower()[0] != 'y': ans = input('Do you like python?') I personally consider double negations less intuitive than following: while not( ans.lower() == 'yes' and ans.lower()[0] == 'y' ): Reading this line yoy would

Re: how to add custom importer after the normal imports

2014-10-10 Thread Gelonida N
On 10/09/2014 04:14 PM, Ian Kelly wrote: I have a use case where I would like to add a custom importer *AFTER* all other import methods have failed. On Oct 9, 2014 6:53 AM, Gelonida N gelon...@gmail.com mailto:gelon...@gmail.com wrote: I'm using Puthon 2.7 for the given project

Re: CLI framework using python

2014-10-10 Thread Gelonida N
On 10/10/2014 10:43 AM, Rustom Mody wrote: On Thursday, October 9, 2014 9:31:39 PM UTC+5:30, gelonida wrote: For calling commands in a slightly nicer way than os.system / sybprocess.Popen you might look at sh or plumbum https://pypi.python.org/pypi/sh https://pypi.python.org/pypi/plumbum

Re: how to add custom importer after the normal imports

2014-10-09 Thread Gelonida N
On 10/9/2014 12:44 AM, Ian Kelly wrote: On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N gelon...@gmail.com wrote: Hi, I just read about sys.meta_path, which allows to install custom importers *BEFORE* the default importers. However I have a use case where I would like to add a custom importer

Re: virtualenv question: include just a few site packages

2014-10-09 Thread Gelonida N
On 10/09/2014 03:19 PM, Jean-Michel Pichavant wrote: - Original Message - virtualenv has the switch --system-site-packages (including all system site pacgaes) and the switch --no-site-packages (to expclude all site packages) Does anyone know an easy way to include just a few

Re: CLI framework using python

2014-10-09 Thread Gelonida N
On 10/09/2014 05:25 PM, Unix SA wrote: Hello, Go for Optparse.. Look at below docs on how to use it. http://pymotw.com/2/optparse/ For newer projects I'd suggest argparse (part of Python since 2.7 and can be downloaded / installed for 2.5 / 2.6).

Re: Pythonic way to iterate through multidimensional space?

2014-10-08 Thread Gelonida N
On 10/7/2014 1:01 PM, Ned Batchelder wrote: On 10/7/14 2:10 AM, Gelonida N wrote: Disadvantage of itertools.product() is, that it makes a copy in memory. Reason ist, that itertools also makes products of generators (meaning of objects, that one can't iterate several times through

how to add custom importer after the normal imports

2014-10-08 Thread Gelonida N
Hi, I just read about sys.meta_path, which allows to install custom importers *BEFORE* the default importers. However I have a use case where I would like to add a custom importer *AFTER* all other import methods have failed. Does anybody know how to do this. One way of implementing this

Re: operator module functions

2014-10-08 Thread Gelonida N
On 10/8/2014 9:09 PM, Terry Reedy wrote: On 10/8/2014 6:57 AM, Steven D'Aprano wrote: According to the documentation, operator.__add__ is the official function, and operator.add is just there for convenience. You are paraphrasing The function names are those used for special class methods;

virtualenv question: include just a few site packages

2014-10-08 Thread Gelonida N
virtualenv has the switch --system-site-packages (including all system site pacgaes) and the switch --no-site-packages (to expclude all site packages) Does anyone know an easy way to include just a few site-packages? for example (PySide, but not PyQt) The reason I'm asking is following. Some

Re: Pythonic way to iterate through multidimensional space?

2014-10-07 Thread Gelonida N
On 8/6/2014 1:39 PM, Tim Chase wrote: On 2014-08-06 11:04, Gayathri J wrote: Below is the code I tried to check if itertools.product() was faster than normal nested loops... they arent! arent they supposed to be...or am i making a mistake? I believe something like this was discussed a while

embedding ipython kernel in a thread

2014-06-09 Thread Gelonida N
Hi, I'd like to embed an ipython kernel in an appliction, such, that I can use ipython console --existing kernel-pid.json lateron to connect to it and to look at some values Due to various reason I don not want to start it in the main thread. If you look at following example you will see,

Re: embedding ipython kernel in a thread

2014-06-09 Thread Gelonida N
On 6/9/2014 3:34 PM, Carlos Anselmo Dias wrote: On 06/09/2014 01:59 PM, Gelonida N wrote: Hi, I'd like to embed an ipython kernel in an appliction, such, that I can use ipython console --existing kernel-pid.json lateron to connect to it and to look at some values Due to various reason I

change webcam settings for v4l linux webcams

2013-02-20 Thread Gelonida N
Hi, I'd like to write some code to capture images from a web cam. I found opencv and videocapture. However it seems, that the python opencv API is quite limited. I don't seem to be able to set all parameters (focus,contrast,exposure,. . . ) of a web cam via opencv. Is there any python

windows question: default click action points to wrong python version

2012-11-21 Thread Gelonida N
Hi, I installed python 2.6 and python 2.7 on a windows 7 machine. At the moment Python 2.7 is the interpreter being used if I 'start' a python script without explicit interpreter. I always thought, that 'repairing' Python 2.6 (reinstalling it) would set the default settings back to Python

Re: windows question: default click action points to wrong python version

2012-11-21 Thread Gelonida N
Hi Tim, Thanks a lot for your answer. On 11/21/2012 10:34 AM, Tim Golden wrote: On 21/11/2012 08:23, Gelonida N wrote: Hi, I installed python 2.6 and python 2.7 on a windows 7 machine. At the moment Python 2.7 is the interpreter being used if I 'start' a python script without explicit

Re: SSH Connection with Python

2012-10-29 Thread Gelonida N
On 10/29/2012 04:18 PM, David Robinow wrote: On Sun, Oct 28, 2012 at 4:09 PM, Gelonida N gelon...@gmail.com wrote: The only thing I'm concerned about paramiko is, that I don't see any activity on the paramiko site and that one library it depends on is not available is windows binary package

Re: SSH Connection with Python

2012-10-29 Thread Gelonida N
On 10/29/2012 02:10 PM, Roy Smith wrote: In article mailman.2977.1351455364.27098.python-l...@python.org, Gelonida N gelon...@gmail.com wrote: The sh module looks intersting, but it's not supported for Windows platforms. The X module looks interesting but it's not supported for Windows

Re: SSH Connection with Python

2012-10-28 Thread Gelonida N
On 10/28/2012 02:35 AM, Cameron Simpson wrote: On 27Oct2012 14:18, Gelonida N gelon...@gmail.com wrote: | On 10/27/2012 02:21 AM, Roy Smith wrote: | In article mailman.2915.1351294793.27098.python-l...@python.org, |Gelonida N gelon...@gmail.com wrote: | | Another problem is, that paramiko

Re: SSH Connection with Python

2012-10-28 Thread Gelonida N
On 10/26/2012 05:22 AM, Jason Friedman wrote: how can i create a SSH-Connection with python? I have to send some commands to the remote host and parse their answers. Consider also the sh module: http://amoffat.github.com/sh/tutorials/2-interacting_with_processes.html. Just a minor comment:

Re: SSH Connection with Python

2012-10-27 Thread Gelonida N
On 10/27/2012 02:21 AM, Roy Smith wrote: In article mailman.2915.1351294793.27098.python-l...@python.org, Gelonida N gelon...@gmail.com wrote: Another problem is, that paramiko depends on pycrypto 2.1+ which doesn't exist as binary release for python 2.7 I'm running paramiko-1.7.6

Re: attaching names to subexpressions

2012-10-27 Thread Gelonida N
On 10/27/2012 04:42 AM, Steve Howell wrote: I have been reading the thread while expression feature proposal, and one of the interesting outcomes of the thread is the idea that Python could allow you to attach names to subexpressions, much like C allows. In C you can say something like this:

Re: SSH Connection with Python

2012-10-26 Thread Gelonida N
On 10/25/2012 12:47 PM, Kamlesh Mutha wrote: You can use paramiko module. Very easy to use. I also use paramiko for a small script. However I'm a little hesitant to use paramik for new code. The web page says: last updated 21-May-2011 and the github url http://github.com/robey/paramiko/

Re: templating performance

2012-09-27 Thread Gelonida N
On 09/27/2012 02:17 AM, alex23 wrote: On Sep 27, 7:50 am, Gelonida N gelon...@gmail.com wrote: http://mindref.blogspot.fr/2012/07/python-fastest-template.html This is already being discussed on the list. See the thread Fastest template engine. Apologies everybody, I wanted to 'bookkmark

mimetypes.guess_type broken in windows on py2.7 and python 3.X

2012-09-26 Thread Gelonida N
Hi, I'm still experiencing the pleasure of migrating legacy code from Python 2.6. to 2.7 which I expected to be much less painful. (In fact migration on Linux is rather smooth, but Windows is another story) Let's take the simple command import mimetypes print mimetypes.guess_type('a.jpg')

Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-26 Thread Gelonida N
On 09/25/2012 02:42 PM, alex23 wrote: On Sep 25, 6:25 pm, Gelonida N gelon...@gmail.com wrote: So it seems to be safe to use either Christoph' binary PIL distribution or to use Pillow. The fact, that pillow is accessable via PyPi / easy_install / PIP pushes me slightly towards pillow. I

templating performance

2012-09-26 Thread Gelonida N
http://mindref.blogspot.fr/2012/07/python-fastest-template.html -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-25 Thread Gelonida N
On 09/25/2012 01:38 AM, alex23 wrote: On Sep 25, 6:04 am, Gelonida N gelon...@gmail.com wrote: This all does not sound very comforting. Why is there no fix on the official site? Has a bug been logged about the issue? The Plone community keeps a fairly up-to-date fork called Pillow, we've had

PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread Gelonida N
Hi, I'm trying to migrate a project with legacy code from 2.6 (with PIL 1.1.6) to 2.7 with (PIL 1.1.7) The SW should run on Windows. PIL fails with an error concering '_imagingft' This seems to be a known issue. http://code.google.com/p/pythonxy/issues/detail?id=300 and the bug was never

portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. If not, is there a portable way of splitting the environment variable PATH? Thanks for any sugestions

Re: portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
On 09/21/2012 12:21 AM, Chris Angelico wrote: On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux

Re: portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if

Re: Comparing strings from the back?

2012-09-08 Thread Gelonida N
On 09/06/2012 10:33 AM, Steven D'Aprano wrote: On Wed, 05 Sep 2012 22:47:14 +, Oscar Benjamin wrote: I may have been overly-conservative earlier when I said that on average string equality has to compare half the characters. I thought I had remembered that from a computer science textbook,

Re: Comparing strings from the back?

2012-09-08 Thread Gelonida N
On 09/07/2012 06:06 AM, Steven D'Aprano wrote: On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote: Also of some interest is the best case: O(1) for unequal strings (they differ at the first character) and O(N) for equal strings. The worst case is O(N) or N characters the average case is

Re: how to run python2.6 module with absolute imports stand alone

2012-09-08 Thread Gelonida N
On 09/08/2012 02:13 AM, Mark Lawrence wrote: On 07/09/2012 23:04, Gelonida N wrote: Hi, many of my modules contain following section at the end def main(): do_something() if __name__ == '__main__': main() This allows me to run some basic example code or some small test in a stand

how to run python2.6 module with absolute imports stand alone

2012-09-07 Thread Gelonida N
Hi, many of my modules contain following section at the end def main(): do_something() if __name__ == '__main__': main() This allows me to run some basic example code or some small test in a stand alone mode. My new modules contain following line at the beginning: from __future__

Re: Looking for an IPC solution

2012-09-06 Thread Gelonida N
On 08/31/2012 11:05 PM, Antoine Pitrou wrote: Laszlo Nagy gandalf at shopzeus.com writes: How about the standard multiprocessing module? It supports shared memory, remote processes, and will most probably work under PyPy: http://docs.python.org/library/multiprocessing.html I always

Re: Looking for an IPC solution

2012-09-06 Thread Gelonida N
On 08/31/2012 11:05 PM, Antoine Pitrou wrote: Laszlo Nagy gandalf at shopzeus.com writes: How about the standard multiprocessing module? It supports shared memory, remote processes, and will most probably work under PyPy: http://docs.python.org/library/multiprocessing.html I always

Re: Looking for an IPC solution

2012-09-06 Thread Gelonida N
On 08/31/2012 11:05 PM, Antoine Pitrou wrote: Laszlo Nagy gandalf at shopzeus.com writes: How about the standard multiprocessing module? It supports shared memory, remote processes, and will most probably work under PyPy: http://docs.python.org/library/multiprocessing.html I always

Re: Does anyone have an activate script for portable python?

2012-08-13 Thread Gelonida N
On 08/13/2012 02:12 AM, alex23 wrote: On Aug 12, 9:09 am, Gelonida N gelon...@gmail.com wrote: In Pythons installed with virtualenv there is on windows an activate.bat script, that can be used to setup the cmd-shell such, that the search path for python and pythor elated tools (pip

Re: suggesting a launcher wrapper script for portable python

2012-08-12 Thread Gelonida N
Hi Thomas, On 08/12/2012 09:05 PM, Thomas Jollans wrote: On 08/12/2012 02:49 AM, Gelonida N wrote: One minor drawback of my suggested script would be, that a console window pops up for a few seconds when starting a .pyw file. (I'm no expert but) This should be avoidable if you use

Re: suggesting a launcher wrapper script for portable python

2012-08-12 Thread Gelonida N
On 08/12/2012 09:52 PM, Mark Lawrence wrote: On 12/08/2012 01:49, Gelonida N wrote: I think it would be great if the official portable python release contained some upport for launching scripts. Perhaps it exists alrady and I just didn't find it? If not,then I wouldn't mind if my script

Does anyone have an activate script for portable python?

2012-08-11 Thread Gelonida N
Hi, In Pythons installed with virtualenv there is on windows an activate.bat script, that can be used to setup the cmd-shell such, that the search path for python and pythor elated tools (pip / easy_install) is setup properly. Further there is the deactivate script to set the environment

suggesting a launcher wrapper script for portable python

2012-08-11 Thread Gelonida N
I just started looking at portable Python and was rather surprised, that I didn't find any recommended method in the documentation of how to launch scripts with portable python. Creating py2exe scripts on ones own USB drive seems to be kind of overkill. So here my own thoughts / suggestsions.

Re: save dictionary to a file without brackets.

2012-08-09 Thread Gelonida N
On 08/09/2012 10:11 PM, giuseppe.amatu...@gmail.com wrote: Hi, I have a dict() unique like this {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} and i want to print to a file without the brackets comas and semicolon in order to obtain something like this? 4 5 1 5 4 1 4 4 2 2 3 1 4 3 2

Re: find out whether a module exists (without importing it)

2012-08-07 Thread Gelonida N
- except[ - else ] try: import mymodule except ImportError: # NOW YOU KNOW it does not exist #+ and you may react properly ?? * Gelonida N gelon...@gmail.com [2012-08-06 22:49]: Is this possible. let's say I'd like to know whether I could import the module 'mypackage.mymodule

find out whether a module exists (without importing it)

2012-08-06 Thread Gelonida N
Is this possible. let's say I'd like to know whether I could import the module 'mypackage.mymodule', meaning, whther this module is located somewhere in sys.path i tried to use imp.find_module(), but it didn't find any module name containing a '.' Am I doing anything wrong? Is there another

Re: find out whether a module exists (without importing it)

2012-08-06 Thread Gelonida N
On 08/06/2012 11:58 PM, Miki Tebeka wrote: imp.find_module(), but it didn't find any module name containing a '.' The docs (http://docs.python.org/library/imp.html#imp.find_module) clearly say: This function does not handle hierarchical module names(names containing dots). Thanks, Well this

Re: howto do a robust simple cross platform beep

2012-07-24 Thread Gelonida N
On 07/15/2012 03:15 AM, rantingrickjohn...@gmail.com wrote: On Friday, July 13, 2012 8:00:05 PM UTC-5, gelonida wrote: I just want to use a beep command that works cross platform. [...] I just want to use them as alert, when certain events occur within a very long running non GUI application.

howto do a robust simple cross platform beep

2012-07-13 Thread Gelonida N
Hi, I just want to use a beep command that works cross platform. I tried the simplest approach (just printing the BEL character '\a' chr(7) to the console. This fails on my Ubuntu 12.04 host, as the pcspkr is in the list of the blacklisted kernel modules. I found another snippet trying

Re: Conditional decoration

2012-06-19 Thread Gelonida N
On 06/19/2012 02:23 AM, Rob Williscroft wrote: Roy Smith wrote in news:jro9cj$b44$1...@panix2.panix.com in gmane.comp.python.general: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view

Re: Finding absolute path of imported module?

2012-06-19 Thread Gelonida N
On 06/19/2012 09:32 PM, Christian Heimes wrote: Am 19.06.2012 19:55, schrieb Roy Smith: So, the question is, is there any way to dump all the *absolute* pathnames of all the imported modules? I can iterate over sys.modules.values(), but that doesn't give me absolute pathnames, so I can't tell

Re: lazy evaluation of a variable

2012-06-18 Thread Gelonida N
On 06/17/2012 11:35 PM, Gelonida N wrote: Hi, I'm not sure whether what I ask for is impossible, but would know how others handle such situations. I'm having a module, which should lazily evaluate one of it's variables. Meaning that it is evaluated only if anybody tries to use this variable

lazy evaluation of a variable

2012-06-17 Thread Gelonida N
Hi, I'm not sure whether what I ask for is impossible, but would know how others handle such situations. I'm having a module, which should lazily evaluate one of it's variables. Meaning that it is evaluated only if anybody tries to use this variable. At the moment I don't know how to do

how to typecast a ctypes pointer to another one

2012-06-02 Thread Gelonida N
Hi, I have a result from a call to a ctypes function of type c_void_p. Now I'd like to convert it to a pointer to one of the structures, that I defined. result = library.c_function(params) class MyStruct(ctypes.Structure): _fields_ = [ ('fourbytes', ctypes.c_char * 4) ]

Re: How to suppress exception printing to console?

2012-05-31 Thread Gelonida N
On 05/31/2012 09:57 AM, Qi wrote: Hi guys, I have an application that embedding Python into C++. When any exception occurred in C++ code, PyErr_SetString will be called to propagate the exception to Python. The problem is, some unit tests trigger exception on intention. So it's OK to have the

Re: Smallest/cheapest possible Python platform?

2012-05-27 Thread Gelonida N
On 05/27/2012 05:37 PM, Colin J. Williams wrote: On 26/05/2012 12:25 PM, Paul Rubin wrote: Roy Smithr...@panix.com writes: The Rasberry Pi certainly looks attractive, but isn't quite available today. Can you run Python on an Arduino? No. YOu want a 32-bit platform with an OS and perhaps 1

virtualenv and jython on Ubuntu 12.04

2012-05-22 Thread Gelonida N
Hi, I wanted to do some first experiments with Jython (which should now be able to run django apps) Thus I wanted to create a virtualenv setup for jython with following command: virtualenv -p jython --no-site-packages ~/mypy However this fails with following output: Running virtualenv

Install python 2.6 and python 2.7 on Windows

2012-05-22 Thread Gelonida N
I'd like to install python 2.6 and 2.7 on Windows? In fact I have already 2.6 installed and would like to additionally install 2.7 When clicking on .py file I'd like to execute it with python 2.6 If I really wanted to run 2.7 I'd call the code with %SystemDrive%\Python27\Python

install python 2.6 on Ubuntu 12.04

2012-05-22 Thread Gelonida N
Hi, On Ubuntu 12.04 python 2.7 is the default version I'd like to install python 2.6 parallel to 2.7 and create a virtualenv for it. The reason is, that I have to write some code, that will be executed under 2.6 and I want to be sure, that I don't accidentally write code, that would no

Re: best way to create warning for obsolete functions and call new one

2012-03-28 Thread Gelonida N
Hi Dan, On 03/26/2012 11:24 PM, Dan Sommers wrote: On Mon, 26 Mar 2012 22:26:11 +0200 Gelonida N gelon...@gmail.com wrote: As these modules are used by quite some projects and as I do not want to force everybody to rename immediately I just want to warn users, that they call functions

Re: best way to create warning for obsolete functions and call new one

2012-03-28 Thread Gelonida N
Hi Chris, On 03/26/2012 11:50 PM, Chris Angelico wrote: On Tue, Mar 27, 2012 at 7:26 AM, Gelonida N gelon...@gmail.com wrote: One option I though of would be: def obsolete_func(func): def call_old(*args, **kwargs): print func is old psl use new one return func(*args

best way to create warning for obsolete functions and call new one

2012-03-26 Thread Gelonida N
Hi, I'm working on a module, which needs rather heavy renaming of functions and methods (naming style, change of functionality, understandability, orthography) As these modules are used by quite some projects and as I do not want to force everybody to rename immediately I just want to warn

Re: Is there a ConfigParser which keeps comments

2012-03-15 Thread Gelonida N
On 03/15/2012 10:42 PM, Cameron Simpson wrote: On 14Mar2012 13:13, Tim Chase python.l...@tim.thechases.com wrote: | On 03/14/12 12:06, Terry Reedy wrote: | On 3/14/2012 6:07 AM, Gelonida N wrote: | Now I'm looking for a library, which behaves like config parser, but | with one minor

Is there a ConfigParser which keeps comments

2012-03-14 Thread Gelonida N
Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep existing comments. Does anybody know or implement

Re: How to know that two pyc files contain the same code

2012-03-11 Thread Gelonida N
On 03/11/2012 08:06 AM, Steven D'Aprano wrote: What if one merely changed the order of definition? Instead of: def foo(): pass def bar(): pass one had this? def bar(): pass def foo(): pass It depends on why the OP cares if they are identical. I can imagine use- cases where the

How to know that two pyc files contain the same code

2012-03-10 Thread Gelonida N
Hi, I want to know whether two .pyc files are identical. With identical I mean whether they contain the same byte code. Unfortunately it seems, that .pyc files contain also something like the time stamp of the related source file. So though two pyc files contain the same byte code, they will

How to know that two pyc files contain the same code

2012-03-10 Thread Gelonida N
Hi, I want to know whether two .pyc files are identical. With identical I mean whether they contain the same byte code. Unfortunately it seems, that .pyc files contain also something like the time stamp of the related source file. So though two pyc files contain the same byte code, they will

Re: How to know that two pyc files contain the same code

2012-03-10 Thread Gelonida N
Hi Steven, On 03/10/2012 11:52 PM, Steven D'Aprano wrote: On Sat, 10 Mar 2012 15:48:48 +0100, Gelonida N wrote: Hi, I want to know whether two .pyc files are identical. With identical I mean whether they contain the same byte code. Define identical and the same. Indeed

Re: pickle/unpickle class which has changed

2012-03-07 Thread Gelonida N
On 03/07/2012 09:04 AM, Peter Otten wrote: Gelonida N wrote: If you know in advance that your class will undergo significant changes you may also consider storing more stable data in a file format that can easily be modified, e. g. json. Good point, that's what I'm partially doing. I just

Re: pickle/unpickle class which has changed

2012-03-06 Thread Gelonida N
Hi Peter, A related question. Is there anyhing like a built in signature which would help to detect, that one tries to unpickle an object whose byte code has changed? The idea is to distinguish old and new pickled data and start some 'migration code' fi required The only thing, that I

Abort an HTTP request before the request timed out

2012-02-26 Thread Gelonida N
Hi, I'm working in a small application, which tries to access data on a web server. Normally the request has a timeout of for example 60 seconds conn = httplib.HTTPConnection(server_name, server_port, timeout=60) while True: conn.request(GET, /my_url.php) try: resp =

Re: generate Windows exe on Linux

2012-02-22 Thread Gelonida N
On 02/22/2012 07:05 PM, Alec Taylor wrote: http://www.pyinstaller.org/ or http://cx-freeze.sourceforge.net/ You can also run py2exe in WINE You want to say, that I could install python 2.6 some packages like win32api PyQt and tand py2exe under Wine and then compile it. Did you try

unittest. customizing tstloaders / discover()

2011-12-11 Thread Gelonida N
Hi, I'd like to have a custom test loder, which will filter out certain tests or which just searches tests in certain directories. I'd like to use regular expresions as include / exclude rules and I would like to have another filter function, which would check for the existence of certain

Re: unittest. customizing tstloaders / discover()

2011-12-11 Thread Gelonida N
On 12/12/2011 12:27 AM, Thomas Bach wrote: Gelonida N gelon...@gmail.com writes: I'd like to use regular expresions as include / exclude rules and I would like to have another filter function, which would check for the existence of certain metavariabels in test suite files Did you have

Re: order independent hash?

2011-12-03 Thread Gelonida N
On 12/02/2011 07:39 PM, Dave Angel wrote: On 12/01/2011 08:55 AM, Neal Becker wrote: Gelonida N wrote: On 11/30/2011 01:32 PM, Neal Becker wrote: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash

Re: Python 2 or 3

2011-12-03 Thread Gelonida N
On 12/03/2011 04:54 AM, Antti J Ylikoski wrote: I'm in the process of learning Python. I already can code objet-oriented programs with the language. I have in my hands the O'Reilly book by Mark Lutz, Programming Python, in two versions: the 2nd Edition, which covers Python 2, and the 4th

Re: order independent hash?

2011-12-01 Thread Gelonida N
On 11/30/2011 01:32 PM, Neal Becker wrote: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive to the order of the words. Any ideas? Do youmean hash like digest like md5sum /

Re: Reading twice from STDIN

2011-12-01 Thread Gelonida N
On 12/01/2011 11:01 AM, janedenone wrote: Hi, I would like to read from a pipe, parse the input and ask the user what to do next: message = sys.stdin.read() With above line you said, that you want to read ALL data from stdin, so it's obvious that any following command will be unable to

Re: lxml precaching DTD for document verification.

2011-11-28 Thread Gelonida N
Thanks Stefan, On 11/28/2011 08:38 AM, Stefan Behnel wrote: Gelonida N, 27.11.2011 18:57: I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD

lxml precaching DTD for document verification.

2011-11-27 Thread Gelonida N
Hi, I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and over from the net. What

Re: lxml precaching DTD for document verification.

2011-11-27 Thread Gelonida N
On 11/27/2011 10:33 PM, John Gordon wrote: In roy-6f0fd0.15291227112...@news.panix.com Roy Smith r...@panix.com writes: In article mailman.3078.1322420265.27778.python-l...@python.org, Gelonida N gelon...@gmail.com wrote: I'd like to verify some (x)html / / html5 / xml documents from

Is there any way to unimport a library

2011-11-20 Thread Gelonida N
I wondered whether there is any way to un-import a library, such, that it's occupied memory and the related shared libraries are released. My usecase is following: success = False try: import lib1_version1 as lib1 import lib2_version1 as lib2 success = True except ImportError:

Re: Is there any way to unimport a library

2011-11-20 Thread Gelonida N
Steven, Mika, Thanks for your answers. It's always good to know which options exist. It makes it easier to choose the right one depending on the situation. On 11/20/2011 04:46 PM, Steven D'Aprano wrote: On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote: I wondered whether there is any

Re: Is there any way to unimport a library

2011-11-20 Thread Gelonida N
I forgot to mention, that this is at the moment more a thought experiment, than a real need. On 11/20/2011 05:53 PM, Chris Angelico wrote: On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N gelon...@gmail.com wrote: No mixing would not be possible. So either I need the first two libs or the second

Re: Get keys from a dicionary

2011-11-11 Thread Gelonida N
On 11/11/2011 02:31 PM, macm wrote: Hi Folks I pass a nested dictionary to a function. def Dicty( dict[k1][k2] ): print k1 print k2 There is a fast way (trick) to get k1 and k2 as string. Whithout loop all dict. Just it! Regards macm I think the answer to the

Re: Get keys from a dicionary

2011-11-11 Thread Gelonida N
On 11/11/2011 02:31 PM, macm wrote: Hi Folks I pass a nested dictionary to a function. def Dicty( dict[k1][k2] ): print k1 print k2 There is a fast way (trick) to get k1 and k2 as string. Whithout loop all dict. Just it! Regards macm If my guessing was

resolving module name conflicts.

2011-11-11 Thread Gelonida N
Hi, I got some code. - This code contains a package named tests - there are at least 100 references in different python files importing from above mentioned tests package. - the code also imports pytz at one place I get following warning message:

Re: resolving module name conflicts.

2011-11-11 Thread Gelonida N
On 11/11/2011 10:31 PM, Emile van Sebille wrote: On 11/11/2011 12:27 PM Gelonida N said... Is there any way to tell pytz to import it's own tests package and tell the rest of the code to import the other? Python version is 2.6.5 Thanks in advance for any suggestion. Start with http

Re: resolving module name conflicts.

2011-11-11 Thread Gelonida N
On 11/11/2011 10:51 PM, Eric Snow wrote: On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow ericsnowcurren...@gmail.com wrote: So if you run a module as a script, that empty string will be added to sys.path and all imports will first check the directory you were in when you ran Python... Yes

Re: resolving module name conflicts. (pytz version 2010b)

2011-11-11 Thread Gelonida N
On 11/12/2011 01:42 AM, Steven D'Aprano wrote: On Fri, 11 Nov 2011 23:11:38 +0100, Gelonida N wrote: Pytz is only imported by one module, so I wondered if there were any tricks to 'change sys.path' prior to importing pytz sys.path is just a list of paths. You can import the sys module

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-29 Thread Gelonida N
On 10/29/2011 03:00 AM, Steven D'Aprano wrote: On Fri, 28 Oct 2011 22:47:42 +0200, Gelonida N wrote: Hi, I would like to save many dicts with a fixed amount of keys tuples to a file in a memory efficient manner (no random, but only sequential access is required) What do you mean keys

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-29 Thread Gelonida N
On 10/29/2011 01:08 AM, Roy Smith wrote: In article mailman.2293.1319834877.27778.python-l...@python.org, Gelonida N gelon...@gmail.com wrote: I would like to save many dicts with a fixed amount of keys tuples to a file in a memory efficient manner (no random, but only sequential access

save tuple of simple data types to disk (low memory foot print)

2011-10-28 Thread Gelonida N
Hi, I would like to save many dicts with a fixed amount of keys tuples to a file in a memory efficient manner (no random, but only sequential access is required) As the keys are the same for each entry I considered converting them to tuples. The tuples contain only strings, ints (long ints)

python logging multiple processes to one file (via socket server)

2011-10-27 Thread Gelonida N
Hi, I have a rather 'simple' problem. Logging from multiple processes to the same file AND be sure, that no log message is lost, 1.) Log multiple processes to one file: -- I have a python program, which I want to log, but which forks several times.

Re: Advise on using logging.getLogger needed.

2011-10-03 Thread Gelonida N
On 10/03/2011 12:12 AM, Steven W. Orr wrote: I hope I don't sound like I'm ranting :-( I have created a module (called xlogging) which sets up logging the way I want it. I found out that if I set up my logger without a name, then it gets applied to every logger that is referenced by every

Hierarchical commnd line parsing / help texts

2011-09-26 Thread Gelonida N
Hi, So far I used optparse.OptionParser for parsing command line arguments for my python scripts. So far I was happy, with a one level approach, where I get only one help text Now I'd like to create a slightly different python script and wondered which approach / module might be best for

Re: Hierarchical commnd line parsing / help texts

2011-09-26 Thread Gelonida N
On 09/26/2011 11:10 AM, Chris Rebert wrote: On Mon, Sep 26, 2011 at 1:55 AM, Gelonida N gelon...@gmail.com wrote: Hi, So far I used optparse.OptionParser for parsing command line arguments for my python scripts. So far I was happy, with a one level approach, where I get only one help text

cProfile and name spaces.

2011-09-23 Thread Gelonida N
Hi I have following piece of code in file f1.py # f1.py starts here ### def f(): pass def main(): import profile profile.run('f()') if __name__ == '__main__': main() # -- end of f1.py executing f1.py works as expected. Now I have a file f2.py # f2.py

  1   2   >