Re: [Fwd: Re: How to make one program connect to more than one TCP?]

2008-06-09 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: i want to make one program that the steps like this: 1. download email from email account, for example: [EMAIL PROTECTED], saved in a file, for example: downloadedEmail.txt Can be done via the standard imaplib module. No need to use twisted. 2. parsing the downlo

Re: convert unicode characters to visibly similar ascii characters

2008-07-01 Thread Laszlo Nagy
Peter Bulychev wrote: Hello. I want to convert unicode character into ascii one. The method ".encode('ASCII') " can convert only those unicode characters, which fit into 0..128 range. But there are still lots of characters beyond this range, which can be manually converted to some visibly si

Re: convert unicode characters to visibly similar ascii characters

2008-07-01 Thread Laszlo Nagy
Peter Bulychev wrote: Thank you for you answer. If you only want this to work for a subset, please define that subset. Actually, I want to convert only punctuations (dots, commas, hyphens and so on). Then make your translation table manually and apply this method: unicode.translate Fina

Re: multithreading in python ???

2008-07-03 Thread Laszlo Nagy
Abhishek Asthana wrote: Hi all , I have large set of data computation and I want to break it into small batches and assign it to different threads .I am implementing it in python only. Kindly help what all libraries should I refer to implement the multithreading in python. You should not

Fastest way to store ints and floats on disk

2008-08-07 Thread Laszlo Nagy
Hi, I'm working on a pivot table. I would like to write it in Python. I know, I should be doing that in C, but I would like to create a cross platform version which can deal with smaller databases (not more than a million facts). The data is first imported from a csv file: the user selects

Re: Fastest way to store ints and floats on disk

2008-08-08 Thread Laszlo Nagy
Hmm... I wrote an browser based analysis tool and used the working name pyvot... Is this for the public domain? I found Numeric to provide the best balance of memory footprint and speed. I also segregated data prep into a separate process to avoid excessive memory use at run time. Turns o

numpy and filtering (was: Fastest way to store ints and floats on disk)

2008-08-08 Thread Laszlo Nagy
Attached there is an example program that only requires numpy. At the end I have two numpy array: rdims: [[3 1 1] [0 0 4] [1 3 0] [2 2 0] [3 3 3] [0 0 2]] rmeas: [[10.0 254.0] [4.0 200.0] [5.0 185.0] [5000.0 160.0] [15.0 260.0] [2.0 180.0]] I would like to use numpy to

csv.DictReader and unicode

2008-04-07 Thread Laszlo Nagy
This program fin = codecs.open(fname,"r",encoding="UTF-8") eader = csv.DictReader(fin) for values in reader: pass results in: File "run.py", line 23, in process_file for values in reader: File "/usr/local/lib/python2.5/csv.py", line 83, in next row = self.reader.next() UnicodeEnc

Re: csv.DictReader and unicode

2008-04-07 Thread Laszlo Nagy
Peter Otten wrote: > Laszlo Nagy wrote: > > >> This program >> >> fin = codecs.open(fname,"r",encoding="UTF-8") >> eader = csv.DictReader(fin) >> for values in reader: >> pass >> >> results in: >> >&g

PIL and true type fonts

2008-04-13 Thread Laszlo Nagy
Attached a screenshot from a text rendered by GIMP (left side) and PIL (right side). Same truetype font. Is this a bug in PIL? Thanks, Laszlo <>-- http://mail.python.org/mailman/listinfo/python-list

PIL font encoding

2008-04-21 Thread Laszlo Nagy
def getfnt(size): return ImageFont.truetype("cartoon.ttf",size,encoding='unic') Using the above function, I cannot draw special german characters. E.g. u'L\xfctgendorf' It will print "Lutgendorf" instead of "Lütgendorf". Much more interesting is that I can also do this: def getfnt(size):

Re: no cleanup on TERM signal

2008-05-02 Thread Laszlo Nagy
Yves Dorfsman wrote: I did a few tests with this script: class byebye: def __del__(self): print 'Bye, bye...' x = byebye() x.del() gets executed if: -I del x, then run gc.collect() -simply exit the script -get the script to abort on an exception But if I kill it with the default sign

Re: no cleanup on TERM signal

2008-05-02 Thread Laszlo Nagy
You can replace the try/finally code with a "with resource: do_something()" block if the object supporst the context manager protocol. I'm using 2.4 so... If you want to run some code during the shutdown phase of the Python process you can register a callback function in the "atexit" module

Re: Another MIDI question - soundfonts

2008-05-06 Thread Laszlo Nagy
Chuckk Hubbard wrote: Hello. I'm writing a microtonal sequencer, and I don't want to use MIDI per se, but I'd like to be able to load standard sample banks to play. The only standard format I'm familiar with is soundfont, and it seems to be the most popular; if anyone knows of others, especially

Re: SocketServer max connections

2008-08-27 Thread Laszlo Nagy
Guilherme Polo wrote: On Mon, Aug 25, 2008 at 7:20 AM, Ken Seehart <[EMAIL PROTECTED]> wrote: I'm using SocketServer to implement a local server that serves comet long-polling connections. How do I increase the maximum number of open connections? Currently it is limited to about 8 I think.

Re: import error between 2 modules

2008-08-27 Thread Laszlo Nagy
jimgardener wrote: I am new to python,and am learning from the tutorials i created 2 .py files like below and put the main in one of them empmodule.py -- from workmodule import Worker class Employer: def __init__(self,n): self.name=n self.worker=Worker() def gete

Re: max(), sum(), next()

2008-09-03 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: Empty Python lists [] don't know the type of the items it will contain, so this sounds strange: sum([]) 0 Because that [] may be an empty sequence of someobject: You are right in that sum could be used to sum arbitrary objects. However, in 99.99% of

Re: Function decorators

2008-09-04 Thread Laszlo Nagy
Aigars Aigars wrote: Good day all, I am learning Python and came up to decorators. The question is: Why does function FoodList return value None? The code in attachment. Thank you, Aigars -- http://mail.python.org/mail

Re: universal unicode font for reportlab

2008-09-08 Thread Laszlo Nagy
Laszlo Nagy <[EMAIL PROTECTED]> writes: I could not find any free TTF font that can do latin1, latin2, arabic, chinese and other languages at the same time. Is there a single font that is able to handle these languages? The GNU Unifont http://en.wikipedia.org/wiki/GNU_Unifont

universal unicode font for reportlab

2008-09-08 Thread Laszlo Nagy
I need to create multi lingual invoices from reportlab. I think it is possible to use UTF 8 strings but there is a problem with the font. I could not find any free TTF font that can do latin1, latin2, arabic, chinese and other languages at the same time. Is there a single font that is able to h

Re: universal unicode font for reportlab

2008-09-08 Thread Laszlo Nagy
The GNU Unifont http://en.wikipedia.org/wiki/GNU_Unifont> http://unifoundry.com/unifont.html> covers an impressive range of the Unicode Basic Multilingual Plane. Unifont is originally a bitmap font, but was recently made available in TrueType format http://www.lgm.cl/trabajos/unifont/index.en

Re: universal unicode font for reportlab

2008-09-08 Thread Laszlo Nagy
Iain Dalton wrote: Why don't you want to use multiple typefaces? Many programs that deal with multilingual strings use multiple fonts (cf. any Web browser and Emacs). You are right, but these PDF documents will show mixed strings. The end user can enter arbitrary strings into the database, a

Re: universal unicode font for reportlab

2008-09-10 Thread Laszlo Nagy
Ross Ridge wrote: Terry Reedy <[EMAIL PROTECTED]> wrote: Sorry, I posted the wrong name. Ariel Unicode MS is the one that seems pretty complete. ... From the MS, I would guess that is a Windows font too ;-). It's made by Microsoft, but it's not a standard Windows font. I th

Portable way to tell if a process is still alive

2009-12-29 Thread Laszlo Nagy
Suppose we have a program that writes its process id into a pid file. Usually the program deletes the pid file when it exists... But in some cases (for example, killed with kill -9 or TerminateProcess) pid file is left there. I would like to know if a process (given with its process id) is stil

Re: Python OOP Problem

2009-12-29 Thread Laszlo Nagy
Thanks for reply, but it doesn't fit to my task. If I will add later other objects(and it will be very often) - I should stop the service, but that would be very bad. I think you meant "if you add other classes". I'm not sure, if this is solution, but test passed: myimportmod = __import__(

Re: Portable way to tell if a process is still alive

2010-01-28 Thread Laszlo Nagy
Suppose we have a program that writes its process id into a pid file. Usually the program deletes the pid file when it exists... But in some cases (for example, killed with kill -9 or TerminateProcess) pid file is left there. I would like to know if a process (given with its process id) is st

Re: Q: sort's key and cmp parameters

2009-10-01 Thread Laszlo Nagy
Is this a homework? Challenge: to come up with a sorting task that cannot be achieved by passing to the sort method (or sorted function) suitable values for its key and reverse parameters, but instead *require* giving a value to its cmp parameter. Let me put up this question: how do you defin

AJAX Widget Framework

2009-10-01 Thread Laszlo Nagy
I'm looking for an open source, AJAX based widget/windowing framework. Here is what I need: - end user opens up a browser, points it to a URL, logs in - on the server site, sits my application, creating a new session for each user that is logged in - on the server site, I create windows(frames)

Re: Q: sort's key and cmp parameters

2009-10-01 Thread Laszlo Nagy
can be achieved (to a very good approximation at least) with scrambled = some_list.sort(key=lambda x: random()) Is there a real-life sorting task that requires (or is far more efficient with) cmp and can't be easily achieved with key and reverse? The core developers don't think there is

Re: Customizing Option Elements

2009-10-03 Thread Laszlo Nagy
I want to create elements within a element in which I could insert html, which, of course, is illegal (don't tell the police ;) so I'm looking at recreating the form elements using my own customized elements, that is, hacking the equivalent from scratch, but how do I proceed? I would like t

Re: No threading.start_new_thread(), useful addition?

2009-10-08 Thread Laszlo Nagy
Ulrich Eckhardt írta: Hi! I'm looking at the 'threading' module and see that other than the 'thread' module it doesn't have a simple function to start a new thread. Instead, you first have to instantiate a threading object and then start the new thread on it: t = threading.Thread(target=my_fu

Re: No threading.start_new_thread(), useful addition?

2009-10-09 Thread Laszlo Nagy
I personally find it much cleaner this way. Also, why should any code care in which thread it is executed? Why should I have to derive a class from some other only because I want to run one of its functions in a separate thread? I think you are right! Especially that you can (and probably wi

Re: Persistent Distributed Objects

2009-10-09 Thread Laszlo Nagy
I've seen evidence about this being done wrt what looks like insanely complex stuff on this list but I'm wondering if there is something to do this with any number of nodes and just farm out random classes/objects to them? Designing and opreating distributed systems is a complex thing. Esp

Re: Persistent Distributed Objects

2009-10-10 Thread Laszlo Nagy
Sorry about being interpreted as being vague. You wasn't vague. I'm sorry! `et me try to narrow it down. program a creates objects b c d which each need to use 1 disk space 2 ram 3 processor time. I would like to create a checkpoint which would save the work of the object to be later used a

Re: No threading.start_new_thread(), useful addition?

2009-10-10 Thread Laszlo Nagy
Christian Heimes wote: Laszlo Nagy wrote: IMHO it is much cleaner to implement this as a decorator. Pro: transparent passing of positional and keyword arguments, keeps function documentation. You are entitled to your opinion but I STRONGLY recommend against your decorator. You MUST

Re: id( ) function question

2009-10-14 Thread Laszlo Nagy
Andre Engels schrieb: What is going on is that a few objects that are often used, in particular the small (how small is small depends on the implementation) integers, are 'preloaded'. When one of these is then referred to, a new object is not created, but the pre-defined object is used. 10 i

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
The built-ins aren't mutable, and the singletons are each immutable and/or unique; so in no case do objects that are both different and mutable have the same ID. I know. :-) Although I have no idea how it is that `id({}) == id({})` as a prior posted showed; FWIW, I can't manage to reproduce

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
Christian Heimes írta: Chris Rebert wrote: The built-ins aren't mutable, and the singletons are each immutable and/or unique; so in no case do objects that are both different and mutable have the same ID. Correct, the fact allows you to write code like "type(egg) is str" to check if an

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
None, True, False, integers and strings are not mutable. The only time the id is the "same" between two objects is if they are the identical two objects. I'm aware of that. ;-) CPython just (as a performance optimization) re-uses the same objects sometimes even if people think they're usi

Editor for Python

2010-02-05 Thread Laszlo Nagy
Hi All, I know that this question was put up on this list a thousand times. I know that most of the editors are listed here: http://wiki.python.org/moin/PythonEditors I already tried most of them. But still, I need something that is not listed there. Requirements: * starts and works

Re: MemoryError, can I use more?

2010-02-14 Thread Laszlo Nagy
2010.02.13. 17:40 keltezéssel, Diez B. Roggisch írta: Am 13.02.10 17:18, schrieb Anssi Saari: Nobody writes: A single process can't use much more than 2GiB of RAM without a 64-bit CPU and OS. That's not really true. Even Windows XP has the /3GB boot option to allow 3 GiB per process. On PC

Instance factory - am I doing this right?

2010-03-03 Thread Laszlo Nagy
This is just an interesting code pattern that I have recently used: class CacheStorage(object): """Generic cache storage class.""" @classmethod def get_factory(cls,*args,**kwargs): """Create factory for a given set of cache storage creation parameters.""" class CacheStora

sqlite3 is sqlite 2?

2010-03-14 Thread Laszlo Nagy
gand...@ubuntu:~$ python Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> sqlite3.version '2.4.1' Is it possible to install a real sqlite version 3 somehow? I really need it b

sqlite savepoint problem (was: Re: sqlite3 is sqlite 2?)

2010-03-14 Thread Laszlo Nagy
That's the sqlite *bindings* version: >>> sqlite3.version '2.4.1' >>> sqlite3.sqlite_version '3.6.16' >>> Thanks. I tried it and RELEASE command didn't work: >>> import sqlite3 >>> conn = sqlite3.connect(':memory:') >>> with conn: ... conn.execute("BEGIN") ... conn.execute("

Re: sqlite savepoint problem

2010-03-14 Thread Laszlo Nagy
From memory you can't issue a "CREATE TABLE" statement inside a transaction, at least not at the default isolation level. Such a statement will automatically commit the current transaction. Doesn't help with your current problem but worth pointing out :-) Thank you. I'll keep in mind. Whe

Re: sqlite savepoint problem

2010-03-14 Thread Laszlo Nagy
I'm now confused. Also, I could not find anything about these isolation levels on the sqlite website. The only think I could find is "PRAGMA read_uncommited". If that is the same as setting isolation_level to None, then I don't want it. Yes, it is. Here is a test: import os import sqlite3

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Laszlo Nagy
No it doesn't. The problem is that using a connection as a context manager doesn't do what you think. It does *not* start a new transaction on __enter__ and commit it on __exit__. As far as I can tell it does nothing on __enter__ and calls con.commit() or con.rollback() on exit. With isola

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Laszlo Nagy
Annotating your example: # entering this context actually does nothing with conn: # a transaction is magically created before this statement conn.execute("insert into a values (1)") # and is implicitly committed before this statement conn.execute("SAVEPOINT sp1")

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Laszlo Nagy
#1. By using isolation_level = None, connection objects (used as a context manager) WON'T automatically commit or rollback transactions. #2. Using any isolation level, connection objects WON'T automatically begin a transaction. #3. Possibly, include your connection manager class code, to show h

sqlite version on windows

2010-03-26 Thread Laszlo Nagy
Hi All, On my Linux system: Python version: 2.6.2 sqlite3.sqlite_version: 3.6.10 On my Windows system: Python version: 2.6.5 sqlite3.sqlite_version: 3.5.9 Why is that? I wrote a program that uses SAVEPOINT/ROLLBACK to. It is only available in SQLite 3.6.8 and above. Can I install it on Windo

Re: sqlite version on windows

2010-03-26 Thread Laszlo Nagy
2010.03.26. 10:57 keltezéssel, Laszlo Nagy írta: Hi All, On my Linux system: Python version: 2.6.2 sqlite3.sqlite_version: 3.6.10 On my Windows system: Python version: 2.6.5 sqlite3.sqlite_version: 3.5.9 Why is that? I wrote a program that uses SAVEPOINT/ROLLBACK to. It is only available

Python metaclass and UML

2011-01-31 Thread Laszlo Nagy
How should I represent a Python metaclass on an UML class diagram? I know how to represent composition, aggregation and inheritance. But not sure about metaclasses. What kind of arrow or line should I use between a class and its metaclass? Is there a standard for this? Thanks, Laszlo -- h

Re: On Class namespaces, calling methods

2010-04-10 Thread Laszlo Nagy
class Uno: a=1 def m(): print "mouse" Say that I have this "silly" class. While I can then write print Uno.a I cannot write Uno.m() I get the following error message: TypeError: m() takes no arguments (1 given) As a workaround, use this pattern: >>> cl

Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Laszlo Nagy
Hi All, I'm planning to create a new visual component for wxPython, for designing, creating and printing pivot tables. Also known as: decision cube, OLAP cube. I was searching on the internet for something similar, but I could not find any open source version (or free to use, at least). The

Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Laszlo Nagy
Please note: this is not a direct answer to your question. I would personally go for a client-server model; not worrying what the server is written in or how it works. For some reason I have a scary thought of your widget pulling in 100million records and cross-tabbing two dimensions :) Don't w

Re: Pointers in Python

2010-04-27 Thread Laszlo Nagy
Hi, I can't figure out how can I change the variable type in function. In C I could do that easily by changing pointer. Please read about "mutable and immutable objects in Python". If you understand the difference between them, you will get the idea. I'll explain program anyway, showing you

Performance of list.index - how to speed up a silly algorithm?

2010-04-29 Thread Laszlo Nagy
I have some ten thousand rows in a table. E.g. columns = ["color","size","weight","value"] rows = [ [ "Yellow", "Big", 2, 4 ], [ "Blue", "Big", 3, -4 ], [ "Blue", "Small", 10, 55 ], ... ] Some columns are dimensions, others are measures. I want to convert this to an indexed vers

Re: Performance of list.index - how to speed up a silly algorithm?

2010-04-30 Thread Laszlo Nagy
The .index method does a linear search, checking on average 1/2 of the items in the list. That's why it's so slow. In order to avoid that you could build a dict of each value in dimension_values[col_idx] and its index in a single pass so that it becomes a quick lookup. For example: from

Re: Performance of list.index - how to speed up a silly algorithm?

2010-05-01 Thread Laszlo Nagy
Maybe this should be implemented in C. But I believe that the algorithm itself must be wrong (regardless of the language). I really think that I'm doing something wrong. Looks like my algorithm's processing time is not linear to the number of rows. Not even log(n)*n. There should be a more ef

duplicate temporary file?

2010-05-03 Thread Laszlo Nagy
I try to write an iterator class: class FileIterator(object): def __init__(self,file_object): self.fin = file_object # other initialization code here ... def __iter__(self): return self def next(self): # special code that reads from the file and convert

Re: Portable Python

2010-05-05 Thread Laszlo Nagy
Is there any difference in functionality between standard Python pack and portable Python? It is not so easy to install third party modules for portable Python... Why standard Python pack installation requires reboot after installation? It is not true for all operating systems. At least under

Re: running .py files on Linux

2010-05-06 Thread Laszlo Nagy
Tingting HAN írta: Dear Officer, I want to run two .py files to generate .h5 files. hantingt...@tityro:~$ python2.5 Python 2.5.4 (r254:67916, Jan 20 2010, 21:43:02) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. When

numpy - save many arrays into a file object

2010-06-30 Thread Laszlo Nagy
import numpy data = numpy.array(...) numpy.save("test.np",data) This is very good, but I want to save the data into a file object with a write() method. E.g. not a real file. (My purpose right now is to save many arrays into one binary file, while recording starting positions of the arrays.)

Sphinx cross reference question

2010-08-22 Thread Laszlo Nagy
In my shopzeus.db.pivot.convert.py file, in the run() method of my Data2Facts class, I can write this into the docstring: class Data2Facts(threading.Thread): # code here... def prepare(self,*args): # code here... # more code here def run(self): """ Star

Load TTF from pycairo under Windows

2009-09-17 Thread Laszlo Nagy
Hi All, I have a program that works under Ubuntu. It loads a TTF font into pycairo, using libfreetype. The code snippet I used was taken from here: http://cairographics.org/freetypepython/ Now I need to use the same program from Microsoft Windows. But Windows does not have "libfreetype.so"

Cross platform TTF font render from Python [was: Load TTF from pycairo under Windows]

2009-09-18 Thread Laszlo Nagy
Hi All, I need to render antialiased PNG images using TTF font files and UTF-8 text. It needs to be available at least on Linux and Windows. This is what I have tried: #1. PIL - it has some problems and I cannot use it. Specifically, the ImageFont.getsize() returns bad value for some fonts,

Re: Cross platform TTF font render from Python [was: Load TTF from pycairo under Windows]

2009-09-18 Thread Laszlo Nagy
... the reportlab graphics renderPM(_renderPM) module does most things with T1 and TTF and works linux/win32. We use freetype2 internally to extract the curves from ttf and then draw them with libart_lgpl which does anti-aliasing. I just tried reportlab and RenderPM. I got the same error

Compile kinterbasdb with mingw32 and python 2.6 - DLL load failed

2009-09-19 Thread Laszlo Nagy
This is what I did so far: #1. Install Python 2.6, Firebird 1.5 server (with libs and headers), egenix mx base and mingw C compiler #2. put "c:\MinGW\bin" on the PATH (or wherever it is) #3. extract kinterbasdb source to a temp folder #4. hack setup.cfg. Change the build section: [build] comp

Re: Pickle Encoding Errors

2009-09-20 Thread Laszlo Nagy
I'm running Python 2.5.4 on Debian Sid. If anybody understands the error please enlighten me. Very interesting! Here is a minimalist version: import pickle class PickleTest: def __init__(self): self.library={u"A": 1,u"B": 2,u"C": 3} def __del__(self): self.pickle()

Re: Compile kinterbasdb with mingw32 and python 2.6 - DLL load failed

2009-09-21 Thread Laszlo Nagy
The building and installation went find. But I cannot "import kinterbasdb" because I get a "DLL load failed" error. I figured out that has something to do with msvcr90 and "_ftime". Can you please give me some advice how to solve this problem? Download Microsoft Visual C++.2008 Express Ed

Re: Compile kinterbasdb with mingw32 and python 2.6 - DLL load failed

2009-09-21 Thread Laszlo Nagy
Christian Heimes írta: Laszlo Nagy wrote: The building and installation went find. But I cannot "import kinterbasdb" because I get a "DLL load failed" error. I figured out that has something to do with msvcr90 and "_ftime". Can you please give me some ad

<    1   2   3   4   5