Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Two solutions come into my mind: 1. Do not inherit from DatabaseConnection, but pass a DatabaseConnection object as a parameter to the FireBirdConnection's __init__function. After this you can delegate the necessary functionality to the DatabaseConnection (by using __getattr__). This introduce

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
2. Maybe the layering of your application is wrong. If DatabaseConnection provides common functionality to the different Adapters, it should be on the same layer or one beneath the Adapters. Another notice. If I put 'DatabaseConnection' under 'Adapters' then it means that 'DatabaseConnection'

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
' under 'Adapters' then it means that 'DatabaseConnection' is an adapter. But it is not. :-) In the other direction, Adapters are deeper, so adapters should can DatabaseConnection-s (and in fact they are). Spelled: In the other direction, Adapter is deeper, so adapters should _be_ DatabaseCon

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Paul Clinch wrote: I get: import Lib Traceback (most recent call last): File "", line 1, in ? ImportError: No module named Lib I guess there's a Lib/__init__.py. You are totally right. I was trying to create an example but Python found something on my PYTHONPATH. Sorry for the

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Here is the example: http://designasign.biz/Lib2.zip Please extract the file and try to import Lib2 Although \Lib2\Client\Db\DatabaseConnection.py and \Lib2\Server\Db\DatabaseConnection.py have the same class name but they are in a different sub-package. From a programmer's view, I hope this is

Re: curious problem with large numbers

2005-04-07 Thread Laszlo Zsolt Nagy
I thought it will be the same for FreeBSD, but here are the results: FreeBSD 4.8 with Python 2.3.4 Python 2.3.4 (#2, Nov 10 2004, 05:08:39) [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4 Type "help", "copyright", "credits" or "license" for more information. >>> inf = 1e308*2 >>> inf Inf >>> float('Inf

Parent module idea dropped? [WAS: import statement - package visibility problem]

2005-04-07 Thread Laszlo Zsolt Nagy
But onto the point you're making. I think its possibly a mis-viewing of the package idea in Python. A package creates a name space. If you create Lib/Server/Db with all the __init__.py files, its because you want to import Lib.Server.Db, rather than a way of organising your source files. I wen

__builtins__ wreidness

2005-04-08 Thread Laszlo Zsolt Nagy
Given this module "test.py": print type(__builtins__) I ran into a wreid thing. Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> __builtins__ >>> type(__builtins__) >>> import test >>> What

Re: __builtins__ wreidness

2005-04-08 Thread Laszlo Zsolt Nagy
__builtins__ (plural form) is a CPython implementation detail. if you want to access the __builtin__ module, import it as usual: import __builtin__ f = __builtin__.open(...) if you're interested in CPython implementation details, study the CPython source code. Ok, I agree. I was an idio

Re: Parent module idea dropped? [Python import parent package]

2005-04-08 Thread Laszlo Zsolt Nagy
So finally I got the answer: there was a "parent package" feature in the ni module but it was dropped of its awkwardness. This is not a big loss but this is exatly the feature that I need. Is there a person on this list who was against the "parent package" idea? He must know the answer or a wo

Re: python modules in home dir

2005-04-11 Thread Laszlo Zsolt Nagy
[EMAIL PROTECTED] wrote: set the PYTHON_PATH to include your home directory Its correct name is 'PYTHONPATH'. Under C shell: setenv PYTHONPATH /home/yourlogin/pythonlibs Under bourne/bash: set PYTHONPATH=/home/yourlogin/pythonlibs export PYTHONPATH --

Re: Programming Language for Systems Administrator

2005-04-12 Thread Laszlo Zsolt Nagy
Hello, I have some answers but for some of your questions, there are many (possibly good) answers. 1)Can i build web applications in Python ? If so how. I am planning to build a web application for intranet use which deals with workflow of Internal office communication. I believe you want som

Re: modules and namespaces

2005-04-19 Thread Laszlo Zsolt Nagy
However it doesn't work until I import the string module into m1 and m2 modules. I found in the manual that imported modules will be searched in the container module first. Is it more efficient to import the string module into main and m1 and m2 than importing only into m1 and m2? I bet the mos

Re: Python instances

2005-04-20 Thread Laszlo Zsolt Nagy
Guess i shouldn't think of the __init__(self) function as a constructor then. __init__ is THE constructor in Python -- _ Laszlo Nagy web: http://designasign.biz IT Consultantmail: [EMAIL PROTECTED

Re: Faster os.walk()

2005-04-20 Thread Laszlo Zsolt Nagy
fuzzylollipop wrote: I am trying to get the number of bytes used by files in a directory. I am using a large directory ( lots of stuff checked out of multiple large cvs repositories ) and there is lots of wasted time doing multiple os.stat() on dirs and files from different methods. Do you need

Re: logging to two files

2005-04-20 Thread Laszlo Zsolt Nagy
Tor Erik Sønvisen wrote: Hi Have the following code: import logging logging.basicConfig(level = logging.DEBUG, format = '[%(levelname)-8s %(asctime)s] %(message)s', filename = 'rfs.log', filemode = 'w') When u

instance + classmethod question

2005-12-11 Thread Laszlo Zsolt Nagy
Hello, Is it possible to tell, which instance was used to call the classmethod that is currently running? Background: I have a class called DatabaseConnection and it has a classmethod called process_create_tables. This method should create some database tables defined by a database definiti

Re: instance + classmethod question

2005-12-11 Thread Laszlo Zsolt Nagy
method. All right, it is a "ClassOrInstanceMethod". Amazing! Probably Python is the only language that is flexible enough to do this. :-) Thanks again! Laszlo Steven Bethard wrote: >Laszlo Zsolt Nagy wrote: > > >> Hello, >> >>Is it possible to tell

Re: instance + classmethod question

2005-12-12 Thread Laszlo Zsolt Nagy
Mike Meyer wrote: >Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: > > >>Is it possible to tell, which instance was used to call the >>classmethod that is currently running? >> >> > >Ok, I read through what got to my nntp server, and I'm s

Developing a network protocol with Python

2005-12-12 Thread Laszlo Zsolt Nagy
Hello, I would like to develop a new network protocol, where the server and the clients are Python programs. I think to be effective, I need to use TCP_NODELAY, and manually buffered transfers. I would like to create a general messaging object that has methods like sendinteger recvinteger se

Re: Developing a network protocol with Python

2005-12-13 Thread Laszlo Zsolt Nagy
Tom Anderson wrote: >>I think to be effective, I need to use TCP_NODELAY, and manually >>buffered transfers. >> >> >Why? > Because of the big delays when sending small messages (size < 1500 bytes). >Personally, i'd steer clear of doing it like this, and try to use an >existing, language-ne

Re: Developing a network protocol with Python

2005-12-14 Thread Laszlo Zsolt Nagy
>Try Pyro http://pyro.sourceforge.net >before rolling your own Python-specific protocol. > > You are right. I wanted to use pyro before, because it is well tested and it has nice features. Unfortunately, it is not good for me. :-( I already have my own classes. My objects are in object owners

Re: Developing a network protocol with Python

2005-12-14 Thread Laszlo Zsolt Nagy
Paul Rubin wrote: >Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: > > >>I already have my own classes. My objects are in object ownership >>trees, and they are referencing to each other (weakly and >>strongly). These classes have their own streaming methods,

Re: Developing a network protocol with Python

2005-12-15 Thread Laszlo Zsolt Nagy
Paul Rubin wrote: >Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes: > > >>But how can I transfer pure python objects otherwise? Pyro also uses >>Pickle and it also transfers bytecode. >> >> >Pyro in the past used pickle in an insecure way. I'd h

Re: _bsddb on NetBSD

2006-01-17 Thread Laszlo Zsolt Nagy
Miki Tebeka wrote: >Hello All, > >I can't seem to build Python2.4.2 with bsddb on NetBSD. >bsddb seems to be missing from the pkg_add installation as well. > > Please look at the message that you get when you execute pkg_add -r python You will see that tkinter, bsddb, gdbm and some other libs

Numerical solver

2006-02-28 Thread Laszlo Zsolt Nagy
Hello, I would like to use a numerical solver for a specific problem. My problem looks like this: 1. I have numeric constants, named A,B,C etc. 2. I have numeric variables, named x,y,z etc. 3. I have functions, like f1(x), f2(x), f3(x,y), f4(y) etc. 4. I have constraints like f1(x

Re: Numerical solver

2006-03-01 Thread Laszlo Zsolt Nagy
Robert Kern wrote: >In [7]: scipy.optimize.fmin_cobyla? > >Type: function >Base Class: >String Form: >Namespace: Interactive >File: >/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy- >0.4.7.1607-py2.4-macosx-10.4-ppc.egg/scipy/optimize/cob

Convert dictionary to HTTP POST

2006-03-03 Thread Laszlo Zsolt Nagy
Hello, How can I convert a dictionary into a HTTP POST string? I have an example below, but this is not working correctly for special characters. (" ' and others). In other words, if I use "Bessy's cat" instead of "Bessy" then the http server will parse that to "Bessy's cat" Probably the prob

Re: Convert dictionary to HTTP POST

2006-03-03 Thread Laszlo Zsolt Nagy
> > >See urllib.urlencode(). No idea why they don't include it in urllib2 as >well, but there you go. > > >>> from urllib import urlencode > >>> urlencode({'a':'& "Simple string"', 'b': '<>[EMAIL PROTECTED]&*()_+='}) >'a=%26+%22Simple+string%22&b=%3C%3E%21%40%23%24%25%5E%26%2A%28%29_%2B%3D' > >>>

Re: Convert dictionary to HTTP POST

2006-03-03 Thread Laszlo Zsolt Nagy
> Well I don't understand what's encoding the apostrophe as an encoded > entity anyway. That's only supposed to be done for HTML content, not > form content. You are right. I was wrong. The problem was not with quote. It was reading out the VALUE of an INPUT from HTML source. > How about an

Re: Convert dictionary to HTTP POST

2006-03-05 Thread Laszlo Zsolt Nagy
>>The values of some inputs are encoded using html entities. >>How can I decode a string like "Bessy's cat" in "Bessy's cat"? >> >> > >this snippet might help: > >http://effbot.org/zone/re-sub.htm#strip-html > > Thank you, worked like a charm. :-) Laszlo -- http://mail.python.org/m

Re: Calculating md5 checksums.

2006-03-05 Thread Laszlo Zsolt Nagy
Rajesh Sathyamoorthy wrote: > I tried the script and had to get a hexdigest to get the value provided > > My test: > SimplyMEPIS-3.3.1-1.iso > checksum: 41a19060d3bb37bd596708ba77964491 > i got: 41a19060d3bb37bd596708ba77964491 > > Do people normally provide md5 checksum in a *hexadecimal string?

EpyDoc problem

2005-05-17 Thread Laszlo Zsolt Nagy
Hello, I would like to create documentation for my lib using EpyDoc. I do not see how to report bugs on the EpyDoc home page. When I try to create documentation, I get this error: Internal error: Expected a pointer Unhandled exception in thread started by At the end of the traceback: wx\_mi

Re: EpyDoc problem

2005-05-17 Thread Laszlo Zsolt Nagy
> >At the end of the traceback: > >wx\_misc.py line 3665, in _eq_ >return _misc_.DateTime.__eq__(*args) >TypeError: Expected a pointer > >I have no clue what does it mean but I guess it is an EpyDoc bug. >Does anyone ran into the same problem? Any ideas? > > Looks like it is a problem with w

Re: super() and automatic method combination

2005-05-18 Thread Laszlo Zsolt Nagy
> >I have the impression that this is supposed to call the f method >in both A and B, so it should print > > Not really true. The first parameter of 'super' should be a type, not an instance. > A > B > C >or maybe > B > A > C >depending on the resolution order. However, it only calls

Re: super() and automatic method combination

2005-05-18 Thread Laszlo Zsolt Nagy
>The trick is that C.f only calls A.f, but A.f needs to end up calling B.f >when it is used in a C. > > I believe your response only applies to single inheritance. For classes with muliple bases classes, you need to call the base methods one by one. BTW I prefer to call the base methods in th

Re: super() and automatic method combination

2005-05-18 Thread Laszlo Zsolt Nagy
>Which is fine so long as nobody else tries to add further subclasses later: > >class C(B): ... >class Mine(AB,C): ... > >Mine().f() > >Using super throughout this works (it calls f in Mine, AB, A, C, B, and >then Base), but your explicit call to the base classes means that if you >don't call C.

Re: EpyDoc problem

2005-05-18 Thread Laszlo Zsolt Nagy
>Looks like it is a problem with wxWidgets. There is no problem if I do >not import wx. How to overcome this problem? >Currently I cannot document modules that import wx. :-( > > I found the answer on the wxPython-users list. It is disappointing that the standard documentation tool has no suppo

Re: EpyDoc problem

2005-05-19 Thread Laszlo Zsolt Nagy
>EpyDoc is hosted in Sourceforge. This alone may answer your question >about a bug-tracker: > >http://sourceforge.net/tracker/?atid=405618&group_id=32455&func=browse > > Well, I wrote to the bug tracker some days ago but no answer so far. -- http://mail.python.org/mailman/listinfo/python-list

Manipulating mailboxes

2005-05-23 Thread Laszlo Zsolt Nagy
Hi All, I need to create a daemon that sits on a server and forwards some e-mails. (Well not only that, it needs to change header information before forwarding and also insert messages into a database). The mailbox module is fine but I do not see a way to delete/add messages - it is ready on

Re: Manipulating mailboxes

2005-05-23 Thread Laszlo Zsolt Nagy
Maksim Kasimov wrote: >change header information, insert messages into a database, delete/add >messages, should not store passwords for all users, ... and any things else >you wish to do - if your OS is UNIX - just forward mail messages of some users >to your python script (you don't need to wr

minidom and DTD

2005-05-23 Thread Laszlo Zsolt Nagy
Hi All, How can I put the thing into an XML created by xml.dom.minidom? Of course I can parse the generated XML file and insert the DOCTYPE string but there must be a standard way to do this... Best, Laci 2.0 -- http://mail.python.org/mailman/listinfo/python-list

Re: minidom and DTD

2005-05-23 Thread Laszlo Zsolt Nagy
Martin v. Löwis wrote: >Laszlo Zsolt Nagy wrote: > > >>How can I put the >> >> >> >>thing into an XML created by xml.dom.minidom? >> >> > >You should put a DocumentType node into your >DocumentNode, and pass a qualifiedN

Re: idiom for constructor?

2005-06-01 Thread Laszlo Zsolt Nagy
Mac wrote: >Is there a nice Python idiom for constructors which would expedite the >following? > >class Foo: > def __init__(self, a,b,c,d,...): >self.a = a >self.b = b >self.c = c >self.d = d >... > >I would like to keep the __init__ parameter list explicit, as is, >rather tha

Re: idiom for constructor?

2005-06-01 Thread Laszlo Zsolt Nagy
>You could try: > >class Foo: > def __init__(self,a,b,c,d): > args = locals() > for arg in args.keys(): > if name!='self': > self.__dict__[arg] = args[arg] > > Should be: if arg!='self' Also it is not perfect. For example: class Foo: def __init__(self,

Re: About size of Unicode string

2005-06-06 Thread Laszlo Zsolt Nagy
Frank Abel Cancio Bello wrote: >Hi all! > >I need know the size of string object independently of its encoding. For >example: > > len('123') == len('123'.encode('utf_8')) > >while the size of '123' object is different of the size of >'123'.encode('utf_8') > >More: >I need send in HTTP reques

Re: Difference between a library and a module...

2006-03-07 Thread Laszlo Zsolt Nagy
sophie_newbie wrote: >OK this might seem like a retarded question, but what is the difference >between a library and a module? > >If I do: > >import string > >am I importing a module or a library? > > I'm not a guru, but... I think that modules are things that live inside the Python language. I

Re: Send email notification

2006-03-07 Thread Laszlo Zsolt Nagy
Ernesto wrote: >Is there a special module for mail ? > >I'd like to send an email [to 'n' unique email addresses] from a python >script. > > http://www.justfuckinggoogleit.com/search.pl?python+smtp -- http://mail.python.org/mailman/listinfo/python-list

<    1   2