Imitating "tail -f"
I'm trying to simply imitate what "tail -f" does, i.e. read a file, wait until it's appended to and process the new data, but apparently I'm missing something. The code is: 54 f = file(filename, "r", 1) 55 f.seek(-1000, os.SEEK_END) 56 ff = fcntl.fcntl(f.fileno(), fcntl.F_GETFL) 57 fcntl.fcntl(f.fileno(), fcntl.F_SETFL, ff | os.O_NONBLOCK) 58 59 pe = select.poll() 60 pe.register(f) 61 while True: 62 print repr(f.read()) 63 print pe.poll(1000) The problem is: poll() always returns that the fd is ready (without waiting), but read() always returns an empty string. Actually, it doesn't matter if I turn O_NDELAY on or off. select() does the same. Any advice? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to modify meaning of builtin function "not" to "!"?
grbgooglefan wrote: > I am creating functions, the return result of which I am using to make > decisions in combined expressions. > In some expressions, I would like to inverse the return result of > function. > > E.g. function contains(source,search) will return true if "search" > string is found in source string. > I want to make reverse of this by putting it as: > if ( ! contains(s1,s2) ): > return 1 > > I found that "!" is not accepted by Python & compile fails with > "invalid syntax". > Corresponding to this Boolean Operator we've "not" in Python. > > How can I make "not" as "!"? "not" is a perfectly valid boolean operator in Python and means just what "!" means in C. The equivalent binary operator is "~", just like in C. >>> print not True False >>> print not 1 False >>> print not 0 True >>> print ~1 -2 >>> print ~0 -1 signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
SimpleXMLRPCServer to fastcgi via WSGI?
Hi, Is there a straightforward way to convert an XML-RPC server application (written for SimpleXMLRPCServer) to use WSGI so that it can be used as s fastcgi server? By "straightforward" I mean something simple, without using some external framework. Alternatively, I don't really care about WSGI, so something that makes it work as fastcgi directly will also be ok. -- http://mail.python.org/mailman/listinfo/python-list
Re: Poor python and/or Zope performance on Sparc
joa2212 wrote: > We have a Sun T1000 with 8 cores and 8 GB of RAM. First, I installed > Solaris 10 because I know this OS better than Debian Linux. Result: > poor Performance. After that I decided to migrate to debian: Do you know the architecture of this machine? It's extremely streamlined for data throughput (IO) at the expense of computational ability. In particular: - it runs at a relatively small clock speed (1 GHz - 1.4 GHz) - it's terrible for floating-point calculations because there is only one FPU shared by all 32 logical processors While it will be screamingly fast for serving static content, and pretty decent for light database jobs, this not an optimal platform for dynamic web applications, especially for Python since the language's so dynamic and it doesn't support SMP. Since it's so optimized for a certain purpose, you can freely consider it a special-purpose machine, rather than a general-purpose one. Even if you manage to get Zope to spawn parallel request handlers (probably via something like fastcgi), if the web application is CPU-intensive you won't be happy with its performance (for CPU-intensive tasks you probably don't want to spawn more than 8 handlers, since that's the number of physical cores in the CPU). signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Python "with"
Laurent Pointal wrote: The ugly part is the 'tmp' name, try to choose a name with a proper meaning about what it is really, and it become clean and readable: filerefs = some.big.structure.or.nested.object.with.file.references filerefs.encoding = "utf-8" filerefs.name = "MyFileName.txt" filerefs.use_quotes = True Isn't it ? Well, no, but this might be due to personal tastes. At least, I don't think it's better then some other alternatives. For example, in C99 you can do: static struct option_s foo_option = { .name = "foo", .type = O_STRING, .def_value = "default" }; At least to me, this looks even better than the Pascal's syntax. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Python "with"
Hi, I'm looking for a construct that's similar to (Turbo) Pascal's "with" statement. I read about the Python's new "with" statement, but I was dissapointed to learn that it does something different (I still don't see how it's better than try..except..finally, but that's not my question). Is there something similar to what I want that's Pythonic enough? (If you're not familiar with Pascal, here's how it works: with some.big.structure.or.nested.objects.element do begin member1 := something; member2 := something; end; which exactly translates to this equivalent: some.big.structure.or.nested.objects.element.member1 := something; some.big.structure.or.nested.objects.element.member2 := something; i.e. it's a wrist-saver. I think a similar feature exists in C99, for structs. I know it can be almost always done by using a temporary variable: tmp = some.big.structure.or.nested.objects.element tmp.member1 = something tmp.member2 = something but this looks ugly to me.) signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Parallel/Multiprocessing script design question
Amit N wrote: About 800+ 10-15MB files are generated daily that need to be processed. The processing consists of different steps that the files must go through: -Uncompress -FilterA -FilterB -Parse -Possibly compress parsed files for archival You can implement one of two easy straightforward approaches: 1 - Create one program, start N instances of it, where N is the number of CPUs/cores, and let each process one file to completion. You'll probably need an "overseer" program to start them and dispatch jobs to them. The easiest is to start your processes with first N files, then monitor them for completion and when any of them finishes, start another with the next file in queue, etc. 2 - Create a program / process for each of these steps and let the steps operate independently, but feed output from one step to the input of the next. You'll probably need some buffering and more control, so that if (for example) "FilterA" is slower then "Uncompress", the "Uncompress" process is signaled to wait a little until "FilterA" needs more data. The key is that, as long as all the steps run at approximatly the same speed, they can run in parallel. Note that both approaches are in principle independent on whether you use threads or processes, with the exception of communication between the steps/stages, but you can't use threads in python if your goal is parallel execution of threads. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3K or Python 2.9?
Bruno Desthuilliers wrote: TheFlyingDutchman a écrit : Python user and advocate Bruce Eckel is disappointed with the additions (or lack of additions) in Python 3: http://www.artima.com/weblogs/viewpost.jsp?thread=214112 I'd say Mr Eckel fails to graps some of the great points about Python's object model - the rant about the use of 'self' is a sure clue. What does "self" have to do with an object model? It's an function/method argument that might as well be hidden in the compiler without ever touching the role it has (if not, why?). I agree that it's needless noise in a language. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
Mark Dickinson wrote: > That's because the call to abs() usually collapses two values to one > (e.g. -2 and 2 both end up being 2), > but there's only one integer n for which abs(n) == 0. Ah. Need to sleep more. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
Jeffrey Barish wrote: > If you take the difference between two uniformly distributed random > variables, the probability density function forms an isosceles triangle > centered at 0. Take the absolute value of that variable and the pdf is a > straight line with maximum value at 0 tapering to 0 at max. Thus, > > z = abs(randint(0, max) - randint(0, max)) > > ought to do the trick. It's elegant :) I've noticed something interesting in my test: the value 0 appears less often than other values (which behave as they should). I wrote this test script: from random import randint map = {} for x in xrange(11): map[x] = 0 for a in xrange(500): x = abs(randint(0, 10) - randint(0, 10)) map[x] += 1 print map and here are some results: > python a.py {0: 49, 1: 66, 2: 72, 3: 73, 4: 64, 5: 55, 6: 40, 7: 36, 8: 18, 9: 18, 10: 9} > python a.py {0: 34, 1: 90, 2: 77, 3: 61, 4: 56, 5: 52, 6: 42, 7: 34, 8: 27, 9: 15, 10: 12} > python a.py {0: 33, 1: 80, 2: 84, 3: 62, 4: 52, 5: 46, 6: 51, 7: 31, 8: 35, 9: 16, 10: 10} > python a.py {0: 50, 1: 100, 2: 69, 3: 53, 4: 63, 5: 47, 6: 41, 7: 26, 8: 30, 9: 11, 10: 10} > python a.py {0: 31, 1: 84, 2: 70, 3: 70, 4: 74, 5: 50, 6: 38, 7: 28, 8: 31, 9: 15, 10: 9} > python a.py {0: 43, 1: 101, 2: 79, 3: 66, 4: 41, 5: 59, 6: 37, 7: 30, 8: 26, 9: 15, 10: 3} > python a.py {0: 44, 1: 108, 2: 74, 3: 50, 4: 53, 5: 54, 6: 39, 7: 34, 8: 28, 9: 13, 10: 3} > python a.py {0: 42, 1: 72, 2: 70, 3: 72, 4: 61, 5: 54, 6: 41, 7: 36, 8: 30, 9: 15, 10: 7} If I ignore the case when the delta is 0, it works fine, but I don't understand why should the 0-case happen less often than others. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Biased random?
Hi, I have a list of items, and need to choose several elements from it, "almost random". The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the "envelope" of probability looks like at this point - can be linear). I see that there are several functions in Python standard libraries for various distribution, but is there an easy pythonic way to make them do what I need? signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: high performance/threaded applications in Python - your experiences?
Jay Loden wrote: > I was hoping for some experiences that some of you on the list may have had > in dealing with Python in a high performance and/or threaded environment. In > essence, I'm wondering how big of a deal the GIL can be in a real-world > scenario where you need to take advantage of multiple processor machines, > thread pools, etc. How much does it get in the way (or not), and how > difficult have you found it to architect applications for high performance? I > have read a number of articles and opinions on whether or not the GIL is a > good thing, and how it affects threaded performance on multiple processor > machines, but what I haven't seen is experiences of people who have actually > done it and reported back "it was a nightmare" or "it's no big deal" ;) The theory: If your threads mostly do IO, you can get decent CPU usage even with Python. If the threads are CPU-bound (e.g. you do a lot of computational work), you'll effectively only make use of one processor. In practice, I've noticed that Python applications don't scale very much across CPUs even if they're doing mostly IO. I blame cache trashing or similar effect caused by too many global synchronization events. I didn't measure but the speedup may even be negative with large-ish number of CPUs (>=4). OTOH, if you can get by with using forking instead of threads (given enough effort) you can achieve very good scaling. -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
PyGTK and HTML rendering?
Hi! Is there an easy off-the-shelf way to get HTML formatting inside the TextArea widget? I've looked at TextBuffer but it appears to have only support for manual applying of attributes to portions of text. I don't need anything complex, bold, italic and font-size would be enough. -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ for instances?
Bruno Desthuilliers wrote: >> The error (not an exception, only the message appears and the handler >> doesn't work): >> >> ** (finstall.py:7551): WARNING **: handler for 'on_button_next_clicked' >> not callable or a tuple > > Is this the full message, or did you skip the preceding lines ? The full message. >> (the file has some 20 lines, not 7551) >> > Is "finstall.py" the name of your file ? If yes, I'd suspect something > wrong with your sys.path or like... This is the name of my file - and it IS executed, only the error message is weird. -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ for instances?
Bruno Desthuilliers wrote: >> "WARNING: "on_button_clicked" not callable or a tuple" > > Please post the relevant code and the full traceback. The code: Class W: def __init__(self): self.xml = gtk.glade.XML("glade/mainwin.glade") self.window = self.xml.get_widget("mainwin") self.xml.signal_autoconnect(self) w = W() gtk.main() The error (not an exception, only the message appears and the handler doesn't work): ** (finstall.py:7551): WARNING **: handler for 'on_button_next_clicked' not callable or a tuple (the file has some 20 lines, not 7551) -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI tutorial
John K Masters wrote: > Can someone point me in the direction of a good tutorial on programming > python with a GUI? I'm just starting out with python and have written a > few scripts successfully but would like to add a graphical front end to > them to make it easier for my work colleagues, most of whom have never > used a command line, to use. If you're using Linux or some other unix-like platform, try PyGTK: http://www.pygtk.org/pygtk2tutorial/index.html (Yes, it can run on Windows, but it tends to be more complicated there). -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ for instances?
Bruno Desthuilliers wrote: > You're not doing anything wrong, that's just how Python works. "methods" > are wrapper objects around function objects attributes. The wrapping > only happens at lookup time, and returns different kind of "method" > wrapper (resp. unbound or bound methods) if the attribute is looked up > on an instance or a class (there are also the staticmethod/classmethod > things, but that's not your problem here). Got it, thanks for the explanation! -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ for instances?
Marc Christiansen wrote: > Nope, at least for PyGTK 2 :) See below. Aaah, but! > [...] >> This looks like it should be easy, but I can't find the solution :( > > Use the doc, Luke, oops, Ivan :) > Citing the gtk.glade.XML.signal_autoconnect documentation: > def signal_autoconnect(dict) > dict: a mapping or an instance > I should have mentioned - I tried it already and it didn't work. The specific error I get is: "WARNING: "on_button_clicked" not callable or a tuple" once for each handler when I call autoconnect. And I've got a recent version of pyGTK (2.10.4) so it should. -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: __dict__ for instances?
[EMAIL PROTECTED] wrote: > I think you want "dir(instance)" __dict__ returns the instance Part of the problem is that dir(instance) returns a list of strings, so iterating the dir(instance) gets me strings, not methods. Alternatively, is there a way to get a "bound" instance by its name - some introspection function perhaps? > variables and values as a dictionary, but doesn't return methods. It does on a Class :( -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
__dict__ for instances?
While using PyGTK, I want to try and define signal handlers automagically, without explicitly writing the long dictionary (i.e. I want to use signal_autoconnect()). To do this, I need something that will inspect the current "self" and return a dictionary that looks like: { "method_name" : self.method_name } Class.__dict__ does something very similar, but when I use it, either I'm doing something wrong or it doesn't return methods bound to "self", and python complains a wrong number of arguments is being passed to the methods (one instead of two). instance.__dict__ on the other hand returns an empty dictionary. This looks like it should be easy, but I can't find the solution :( -- (\__/) (O.o) (> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination! signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
wxWindows off-screen?
Is it possible to draw a widget or a window in an off-screen buffer? What I'm trying to do is capture rendered HTML to a bitmap (in other words, something like html2bitmap) by using wxWindows' HTML widget. If anyone has a different way of doing it, I'd be glad to hear it... -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I add users using Python scripts on a Linux machine
Sebastian 'lunar' Wiesner wrote: > Carsten Haese <[EMAIL PROTECTED]> typed >> I don't think that that has anything to do with Linux or not. The >> script is not the actual executable, hence its suid bit is irrelevant. > > I don't think so. From what I know, the script is passed as executable > to the kernel loader, which interprets the shebang and feeds the script > through the correct interpreter. So the kernel loader sees the script > itself as executable instead of the interpreter binary. I've heard of > other Unix systems, which handle this differently (meaning that the > SUID bit on scripts has an effect), but I may be wrong. Yes, the kernel parses #! but the suid-ness is still controlled by the target interpreter (i.e. python executable). At least BSD systems also behave this way. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I add users using Python scripts on a Linux machine
Ramdas wrote: > Well, > > I need to add users from a web interface for a web server, which runs > only Python. I need to add users, set quotas and in future even look at > managing ip tables to limit bandwidth. > > I know os.system(), but this has to be done through a form entry > through a web interface. > > Anyways thanks, do advise if there more pythonic solutions What you're looking for is actually a pretty complex thing. You *could* in theory manage /etc/passwd (and its "shadow" file) - you can find crypto primitives like MD5 and DES on the 'net, but note that you must run your script under the 'root' account in order to write (and even read!) the passwd database. The same goes for using os.system and the built-in OS utility. Be aware of security implications if you're running your web server under the root account. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do this?
Duncan Booth wrote: > print "There are"+number+"ways to skin a"+furryanimal > > or at least something equivalent to it. If I try to make the same mistake > with a format string it jumps out to me as wrong: > > "There are%sways to skin a%s" % (number, furryanimal) Related to this, formatting with sequences is also much more readable when there are complex interpunction and quoting characters present, like this: print "'"+var1+"','"+var2'"+","+var3 the above is much more readable as print "'%s', '%s', %s" % (var1, var2, var3) -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Python on a 64-Bit OS
Nico Grubert wrote: > Is there anything special I have to care about or is installing Python > on a 64 Bit OS just as easy as installing it on a 32-Bit OS? It is as easy. Look around, you'll probably find a pre-built binary package for your OS. -- http://mail.python.org/mailman/listinfo/python-list
Re: Slow network reading?
Andrew MacIntyre wrote: >> That's only because I need the .readline() function. In C, I'm using >> fgets() (with the expectation that iostream will buffer data). > > The readline method of the file object lookalike returned by makefile > implements all of the line splitting logic in Python code, which is very > likely where the extra process CPU time is going. Note that this code is Heh, I didn't know that - you're probably right about this being a possible bottleneck. > in Python for portability reasons, as Windows socket handles cannot be > used as file handles the way socket handles on Unix systems can be. I think they actually can in NT and above... but no, I'm doing it on Unix. > Given your comments above about how much data is actually involved, I'm > a bit surprised that the tweaked version actually produced a measurable > gain. I didn't do statistical analysis of the results so the difference actually could be negligable IRL. Anyway, thanks for the advice - I'll leave it as it is, as the Python client is not used currently. -- Things Mr Welch Cannot Do During An RPG: 274. I cannot commune with the Gods during peak hours. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] PanDAV on SourceForge.net
Around three weeks ago there was a thread about Python WebDAV servers, and I mentioned my "PanDAV" work (old homepage: http://ivoras.sharanet.org/projects/pandav.html). There was some interest in continuing the development and merging patches made by its users, so I requested a SourceForge project for it. Due to some internal delay in SourceForget it took a while until the project was created, but now it's there! The project's home is http://sourceforge.net/projects/pandav/. If any of the thread's original posters (or anyone else) are interested, please create a SourceForge.net account and contact me. The current version in CVS contains code and patches (for better compatibility with Windows XP) which is not present in the original package. -- http://mail.python.org/mailman/listinfo/python-list
Re: Slow network reading?
Andrew MacIntyre wrote: > Comparative CPU & memory utilisation statistics, not to mention platform > and version of Python, would be useful hints... During benchmarking, all versions cause all CPU to be used, but Python version has ~1.5x more CPU time allocated to it than PHP. Python is 2.4.1 > Note that the file-like object returned by makefile() has significant > portions of heavy lifting code in Python rather than C which can be a > drag on ultimate performance... If on a Unix platform, it may be worth > experimenting with os.fdopen() on the socket's fileno() to see whether > the core Python file object (implemented in C) can be used in place of > the lookalike returned from the makefile method. That's only because I need the .readline() function. In C, I'm using fgets() (with the expectation that iostream will buffer data). > Even without that, you are specifying a buffer size smaller than the > default (8k - see Lib/socket.py). 16k might be even better. The benchmark is such that all of data is < 200 bytes. I estimate that in production almost all protocol data will be < 4KB. > Although they're only micro-optimisations, I'd be interested in the > relative performance of the query method re-written as: The change (for the better) is minor (3-5%). -- http://mail.python.org/mailman/listinfo/python-list
Slow network reading?
I have a simple network protocol client (it's a part of this: http://sqlcached.sourceforge.net) implemented in Python, PHP and C. Everything's fine, except that the Python implementation is the slowest - up to 30% slower than the PHP version (which implements exactly the same logic, in a class). In typical usage (also in the benchmark), an object is created and .query is called repeatedly. Typical numbers for the benchmark are: For Python version: Timing 10 INSERTs... 5964.4 qps Timing 10 SELECTs... 7491.0 qps For PHP version: Timing 10 inserts... 7820.2 qps Timing 10 selects... 9926.2 qps The main part of the client class is: import os, socket, re class SQLCacheD_Exception(Exception): pass class SQLCacheD: DEFAULT_UNIX_SOCKET = '/tmp/sqlcached.sock' SC_VER_SIG = 'sqlcached-1' SOCK_UNIX = 'unix' SOCK_TCP = 'tcp' re_rec = re.compile(r"\+REC (\d+), (\d+)") re_ok = re.compile(r"\+OK (.+)") re_ver = re.compile(r"\+VER (.+)") def __init__(self, host = '/tmp/sqlcached.sock', type = 'unix'): if type != SQLCacheD.SOCK_UNIX: raise self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sock.connect(host) self.sf = self.sock.makefile('U', 4000) self.sf.write("VER %s\r\n" % SQLCacheD.SC_VER_SIG) self.sf.flush() if self.sf.readline().rstrip() != '+VER %s' % SQLCacheD.SC_VER_SIG: raise SQLCacheD_Exception("Handshake failure (invalid version signature?)") def query(self, sql): self.sf.write("SQL %s\r\n" % sql) self.sf.flush() resp = self.sf.readline().rstrip() m = SQLCacheD.re_rec.match(resp) if m != None: # only if some rows are returned (SELECT) n_rows = int(m.group(1)) n_cols = int(m.group(2)) cols = [] for c in xrange(n_cols): cols.append(self.sf.readline().rstrip()) rs = [] for r in xrange(n_rows): row = {} for c in cols: row[c] = self.sf.readline().rstrip() rs.append(row) return rs m = SQLCacheD.re_ok.match(resp) if m != None: # no rows returned (e.g. INSERT/UPDATE/DELETE) return True raise SQLCacheD_Exception(resp) My question is: Am I missing something obvious? The C implementation is (as expected) the fastest with result of 1:15000, but somehow I expected the Python one to be closer to, or even faster than PHP. I tried using 'r' mode for .makefile() but it had no significant effect. -- http://mail.python.org/mailman/listinfo/python-list
Fastest quoting
What is the fastest way (execution speed) to backslash-escape characters from a specific set? Specifically: \r, \n and \0? (i.e. I need "some\r\nstring\0" to become "some\\r\\nstring\\0") -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
Kyler Laird wrote: > Ivan's been working on a problem I've been experiencing with Windows XP > ("failure to launch"). He sent a new version my way today. I'm going > to test it tomorrow when I've got some XP users available. If it works > I'm going to work on putting my changes into a subclass. > > I don't see this being a full-featured fully-compliant DAV server > immediately but I'm betting that it will provide adequate service for my > users soon. Most of the problems are probably because I didn't mean it to be a fully-compliant WebDAV server, but to serve my need at the time :) I'm still waiting for SourceForge to approve the project so there's a proper place to integrate all the patches. One thing I insist on is the separation of davserver and fsdav (e.g. no contamination of knowledge between the two). -- http://mail.python.org/mailman/listinfo/python-list
Re: freebsd thread problem
Dorian Mcfarland wrote: > Hi there, > I have installed python(2.4.3) & trac(0.9.4) on freebsd(4.8) from the > ports collection and I seem to have an underlying problem with the > thread module. > Salling 'import thread' from the python prompt yields the same result. > > I have a 'threading.py' and a 'dummy_thread.py' in my > /usr/local/lib/python2.4 folder and I only have one version of python > installed. How did you install python? By default, if built from ports, it should pop up a configuration dialog in which one of the options is to enable thread support. If you have a bad configuration record, you can do a "make config" in /usr/ports/lang/python to re-create it. (if there's no such option, then maybe using threads with python is disabled in 4.x) -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
robert wrote: > maybe thats a good idea to put it on sf.net to boil out all bugs. > Yet I like it in that simple default manner, maybe switch on those > additional creation functions with commandline switches (or config class > instance passed to run..(config=None) ) I'm thinking of making a small separation between the actual WebDAV server (server.py) and the library/libraries that do the actual protocol (davserver.py & fsdav.py). This way, we can still have a simple server (server.py), libraries with new features, and possibly an advanced server (possibly called server_advanced.py or something like that) that can use all those new features. I'll submit a project request, and will post here when it's processed, so stay tuned :) If you don't have it already, you can open a SourceForge.net account now... -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
Kyler Laird wrote: > I added the ability to create and delete collections (directories), > delete members (files), authenticate users, and run per-user setuid/ > setgid. It works well with Cadaver but I'm waiting for some MS users > to report how it works under Windows. > > The only thing on my list right now is to make it report the times for > collections (directories). Already it's looking like a nice solution > for my needs. And it was *so* much easier to hack than Apache. Thank you for such a nice response :) If you or anybory else (robert?) is interested, I can set up a SourceForge project for it so patches & contribution can be easily managed? -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
robert wrote: > > thanks, that's exactly to the point: > > python server.py 8080 mydavrootfolder Thanks for the patch, I assume it's free to incorporate it into the original archive? Also, see my reply to "Kyler Laird"... -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
robert wrote: > For testing purposes I'm looking for a simple DAV server - best a python > thing serving a folder tree. Don't want to install/change/setup the > complex apache dav .. > You can try this one: http://ivoras.sharanet.org/projects/pandav.html It's been a while since I last updated it so no guarantees :) -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Caching my DB
Siah wrote: > I just launched my django site for a client. My problem is something > is caching my db data in a bizzar way. Here are some of the behaviours > I get: > > - I login, and every other page it makes me login again for a 5 minutes > or so and then it remembers that I am logged in. > - I add a record, it reflects it to the site in close to 5 minutes from > now > - Every other DB related change takes some time to reflect Some general points/ideas: - AFAIK mysql can be setup to do SQL query cache, so maybe it's returning stale data somewhere - If the web server is actually a cluster (e.g. multiple web servers under one DNS address) then it may be misconfigured not to share session data (I know this happens on SourceForge.net with PHP). - Apache can also be set up to cache HTML (for example, if used as a proxy). - Your browser may be caching HTML also, if you don't send Cache-control and Pragma headers. I'm not familiar with django, so these points may or may not be applicable :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
James Stroud wrote: > The reasons given in the blog were fairly precise. I think "only on > vague[...]" is misleading here. The idea of the article was to educate a > Java user how to change his or her frame of reference to better use Python. > > The author was not being territorial as you are implying. What triggered me is the presence of lots of absolute statements like "XML is not the answer. It is not even the question.", "In Python, XML is something you use for interoperability, not your core functionality, because you simply don't need it for that." and similar. Though the author says at the end "There are also other, very rare, architectural reasons to need XML" he then proceeds to say "Trust me, they don't apply to your app." instead of educating the reader what they are and make him conclude that for himself. The article is actually quite good, but in this particular section the author doesn't explain his advices well. Personally, I the approach "X is good because of Y, except when Z and W, when it's the other way around" better, since IRL it's always so. Mentioning (again, not explaining!) LISP to state XML is laughable is kind of lame, especially since the focus of the article are Python and Java. Again, it's good, but I'd like more explanations and conditionals in that paragraph :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic gui format?
Gregory Petrosyan wrote: > I have to write _simple_ gui library, for embedding into game. My > first attempt was to use XML ... > But after reading "Python Is Not Java" > http://dirtsimple.org/2004/12/python-is-not-java.html (BTW I'm not a > Java programmer) I realised that it is actually not cute at all :) (am > I wrong here?) Don't do that :) Don't listen to recommendations for or against a technology based only on vague "this is not how we do things around here" reasons. If XML suits your need, than use it. It seems it will work fine in situations where you need to edit/extend the GUI by external means. If you do it in code, you risk that you'll need to change the code every time you want to reposition a GUI element. It doesn't matter much if you invent your own file format because eventually you'll have to extend it, or write support for it, so you could as well use XML from the start. XML parsing can be a little tedious, but there are many tools that make it easier (I've even written one: http://ivoras.sharanet.org/xmldict.py.gz). -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and memory
Lee Leahu wrote: > However, I have encountered the following error after I have started my 381st > thread: This number (actually, ~380) is suspicious when seen with threads because it almost always means running out of process address space. As threads are part of a single process, and that process has (usually today) 32bit address space, and modern Linux systems allocate huge amounts of memory per-thread (8 MB for threads' stack!), and the kernel reserves ~1MB in the address space for itself, you can easily reach > 4GB of total allocated memory. This *doesn't* mean you are actually using 4GB of memory (i.e. storing values to it), only that the process gets "assigned" this memory. Python doesn't support specifying thread attributes AFAIK, so you should find a way to specify default thread stack size, possibly with an environment variable (see manual page for "pthread" library calls). Try 64k - your task seems simple enough :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread imbalance
Dennis Lee Bieber wrote: > FYI: That's GLOBAL Interpreter Lock Yes, sorry about the confusion. -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread imbalance
Aahz wrote: > > When did Perl gain threads? At least in 2001: http://mail.python.org/pipermail/python-dev/2001-August/017079.html http://www.xav.com/perl/lib/Pod/perlthrtut.html > If you read Bruce Eckel, you also know that > the Java threading system has been buggy for something like a decade. I'm sure precisely this is the reason why all Java Enterprise systems (J2EE) are threaded network servers :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread imbalance
Neil Hodgson wrote: >Lua has coroutines rather than threads. It can cooperate with > threading implemented by a host application or library. I mentioned it because, as far as I know the Lua's intepreter doesn't do implicit locking on its own, and if I want to run several threads of pure Lua code, it's possible if I take care of data sharing and synchronization myself. -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread imbalance
Peter Hansen wrote: > Ivan, what makes you say that Python is bad for threads? Did the > qualifcation "concurrently executing/computing" have some significance > that I missed? Because of the GIL (Giant interpreter lock). It can be a matter of opinion, but by "good threading implementation" I mean that all threads in the application should run "natively" on the underlying (p)threads library at all times, without implicit serialization. For example, Java and perl do this, possibly also lua and C#. Python and Ruby have a giant interpreter lock which prevents two threads of pure python code (not "code written in C" :)) ) in one interperter process executing at the same time. Much can be said about "at the same time" part, but at least in one case it is unambiguous: in multiprocessor machines. Someone writing a multithreaded server application could get in trouble if he doesn't know this (of course, it depends on the exact circumstances and the purpose of the application; for example system calls which block, such as read() and write() can execute concurrently, while two "while True: pass" threads cannot). This is not new information, it's available in many forms in this newsgroup's archives. I think it would also make implicit problems in the situation like that of the OP, where there's a "watchdog" thread monitoring some job or jobs, and the job(s) intefere(s) with the GIL by contenting for it, possibly when there are lots of threads or frequent spawning of processes or threads. I don't have the intention to badmouth Python, but to emphasize that one should be familira with all the details of the tool one's using :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread imbalance
Tuvas wrote: > waits for a lul in the computing process. How can I ensure that this > does not happen? This thread uses little processing power, so it could > be set to a high priority, if there is a way to do this. Thanks! Python is bad for concurrently executing/computing threads, but it shouldn't be that bad - do you have lots of compute-intensive threads? If you are running on a unix-like platform, see documentation for signal() and SIGALRM - maybe it will help your task. -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
Ivan Voras wrote: > Because "bar and aba happen to be parts of extension library" :) To end this disussion: I meant "doing it in C" as a colloquial expression, not a technical one. The expression holds true for every case where a function/class/module/etc is implemented in a lower-level language, and "C" was used only as an example. -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
Fredrik Lundh wrote: > > uhuh? so why did you just argue that > > if foo.bar(): > bar.aba() > > means "doing it in C" if bar and aba happens to be parts of an extension > library ? Because "bar and aba happen to be parts of extension library" :) -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
Terry Hancock wrote: > To me, "doing it in C" implies that I must write some C > code. Ok, perhaps it is a bit imprecise :) > In this case, that won't be required at all. Everything the > OP wants to do can be done exclusively by writing Python > code. He will, of course, be *using* some extension > libraries which might in turn have been written in C (or > Fortran, assembly language, or ADA for that matter -- but > practically speaking, C). > > This will be true whether he uses PyMedia, PyGame, Numeric > or all three. This, of course, is what I am talking about. Python is a great glue language, but not exactly suitable for lots of bit twiddling or DSP by itself (itself=only with modules from the standard distribution) :) -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
Grant Edwards wrote: > On 2006-02-03, Ivan Voras <[EMAIL PROTECTED]> wrote: > >>[EMAIL PROTECTED] wrote: >> >>>Actually, manipulating and mixing audio samples can be both fast and >>>elegant, in Python, if you use Numeric or a similar library. >> >>... at which point you're actually doing it in C, not pure python... :) > > If that's the way you want to look at it, there is nothing that > can be done in pure python. I think people who say that deliberately misunderstand the point. Python is suitable for some things, not for others. So is C. -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
Fuzzyman wrote: > Only in as much as doing anything in Python is *really* doing it in C, > surely ? > > Come to that, you're **really** doing it in machine code... I've yet to see someone calling if a == '5': print "it's 5" machine code. It's the distinction on which level the program's logic is implemented, not at which level it's executed. -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
[EMAIL PROTECTED] wrote: > Actually, manipulating and mixing audio samples can be both fast and > elegant, in Python, if you use Numeric or a similar library. ... at which point you're actually doing it in C, not pure python... :) -- http://mail.python.org/mailman/listinfo/python-list
Re: would it be feasable to write python DJing software
Levi Campbell wrote: > Hi, I'm thinking about writing a system for DJing in python, but I'm > not sure if Python is fast enough to handle the realtime audio needed > for DJing, could a guru shed some light on this subject and tell me if > this is doable or if I'm out of my fscking mind? Any and all mixing would probably happen in some sort of multimedia library written in C (it would be both clumsy to program and slow to execute if the calculations of raw samples/bytes were done in python) so there shouldn't be a noticable performance hit. -- http://mail.python.org/mailman/listinfo/python-list
Re: writing large files quickly
Jens Theisen wrote: > cp bigfile bigfile2 > > cat bigfile > bigfile3 > > du bigfile* > 8 bigfile2 > 1032bigfile3 > > So it's not consumings 0's. It's just doesn't store unwritten data. And I Very possibly cp "understands" sparse file and cat (doint what it's meant to do) doesn't :) >>I read somewhere that it has a use in database software, but the only >>thing I can imagine for this is when using heap queues >>(http://python.active-venture.com/lib/node162.html). > > That's an article about the heap efficient data structure. Was it your > intention to link this? Yes. The idea is that in implementing such a structure, in which each level is 2^x (x="level" of the structure, and it's depentent on the number of entries the structure must hold) wide, most of blocks could exist and never be written to (i.e. they'd be "empty"). Using sparse files would save space :) (It has nothing to do with python; I remembered the article so I linked to it; The sparse-file issue is useful only when implementing heaps directly on file or in mmaped file). -- http://mail.python.org/mailman/listinfo/python-list
Re: Using non-ascii symbols
Rocco Moretti wrote: > Could it be APL? No, it was much newer... someone did it as a hobby language. -- http://mail.python.org/mailman/listinfo/python-list
Re: writing large files quickly
Jens Theisen wrote: > Ivan wrote: >>Yes, but AFAIK the only "modern" (meaning: in wide use today) file >>system that doesn't have this support is FAT/FAT32. > > I don't think ext2fs does this either. At least the du and df commands > tell something different. ext2 is a reimplementation of BSD UFS, so it does. Here: f = file('bigfile', 'w') f.seek(1024*1024) f.write('a') $ l afile -rw-r--r-- 1 ivoras wheel 1048577 Jan 28 14:57 afile $ du afile 8 afile > Actually I'm not sure what this optimisation should give you anyway. The > only circumstance under which files with only zeroes are meaningful is > testing, and that's exactly when you don't want that optimisation. I read somewhere that it has a use in database software, but the only thing I can imagine for this is when using heap queues (http://python.active-venture.com/lib/node162.html). -- http://mail.python.org/mailman/listinfo/python-list
Re: writing large files quickly
Steven D'Aprano wrote: > Isn't this a file system specific solution though? Won't your file system > need to have support for "sparse files", or else it won't work? Yes, but AFAIK the only "modern" (meaning: in wide use today) file system that doesn't have this support is FAT/FAT32. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using non-ascii symbols
Robert Kern wrote: > On OS X, > > ≤ is Alt-, > ≥ is Alt-. > ≠ is Alt-= Thumbs up on the unicode idea, but national keyboards (i.e. non-english) have already used almost every possible not-strictly-defined-in-EN-keyboards combination of keys for their own characters. In particular, the key combinations above are reprogrammed to something else in my language/keyboard. But, the idea that Python could be made ready for when the keyboards and editors start supporting such characters is a good one (i.e. keep both <= and ≤ for several decades). It's not a far-out idea. I stumbled about a year ago on a programming language that INSISTED on unicode characters like ≤ as well as the rest of mathematical/logical symbols; I don't remember its name but the source code with characters like that looked absolutely beautiful. I suppose that one day, when unicode becomes more used than ascii7, "old" code like current C and python will be considered ugly and unelegant in appearance :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiway Branching
[EMAIL PROTECTED] wrote: > inefficient. Since these data are coming from an OMR scanner at 9600 bps (or > faster if I can reset it programmatically to 38K over the serial cable), I > want a fast algorithm. It depends on your actual environment, of course, but 38kbps is usually not considered "fast" today - given a modern CPU (or even one from a few years back), 21 (or 42) short string comparisons in an interprated language should be trivially fast. (I'm not saying that using a different approach such as dictionaries isn't good because of other reasons :) ) -- http://mail.python.org/mailman/listinfo/python-list
ANN: xmldict 1.1
As it seems that few people are actually using this, I've made a small update to xmldict library, available here: http://ivoras.sharanet.org/xmldict.py.gz Some border-cases involving empty tags and atributes are resolved, and examples are updated. WHAT IS IT -- It's a very small (8KB, possibly < 6KB without comments & examples) pure python parser for XML data. It doesn't care about fancy things like validation, and will probably break in silly ways on malformed input. Its only goal is to convert simple XML into nested dictionary-like structures. You'd be crazy to use it instead of a real parser for arbitrary XML, but it's perfect for parsing configuration files and the occasional XML-based network protocol. It uses only sys and re libraries, but can easily be reworked to be self-sufficient. Again, test carefully before use, no gurantees that it will work, etc. Happy hollidays! -- http://mail.python.org/mailman/listinfo/python-list
Re: Still Loving Python
Mike Meyer wrote: >>A GUI builder is more pleasant to work with, at least >>with a good one like Delphi or Qt designer. > > That is your opinion, and I'm sure it's true for you. It isn't true > for me. Not trying to start a war here, but I consider this discussion something like using regular expressions vs coding string matchers by hand. Of course a "real language" is Turing-complete and thus without doubt more powerful than regular expressions, and certainly there are people who always code string parsers in their language of choice, but for those who know how to use it, regular expressions simplify the work a lot. It's more "natural" to see: if str.matches("\d\d\d\d"):... than to code if str[0] in digits && str[1] in digits && str[2] in digits && str[3] in digits: ... And in C, it's even more uglier. The point is: somebody had to code the RE parser and at the end, it will all fall back to the code written in C, for both RE and visual designer generated code. People are visual creatures and GUI designers are simply easier to work with. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Still Loving Python
Lawrence Oluyede wrote: > Python *does* have GUI, you only have to decide which one you prefer. > > ps. the customer wants Windows as a platform, we develop on Linux using > PyGTK, postgre and sql server for some old data. This is the true power of > cross-platform :) Maybe the OP really wants a GUI builder. More than 5 years ago, i programmed in Visual Basic and Delphi and I still miss the wonderful ease of graphically creating the user interface in WYSIWYG mode. If you haven't tried it, you don't know what you're missing :) I only know about Glade and similar GUI builders (Boa) and they are not even close to the robustness & ease of use. Are there any easy GUI builders for any Python-supported toolkits? -- http://mail.python.org/mailman/listinfo/python-list
Re: Let My Terminal Go
Mike Meyer wrote: > The easy way to do all these things - from C, anyway - is with > daemon(3). That isn't wrapped as part of the Python library. The > easiest way to solve your problem may be write a wrapper for that > call. If daemon exists on enough systems, submitting your wrapper as a > patch to the os modulee would be appropriate. I think the deamon() library call only exists on the BSDs. Anyway, there it is implemented with a fork() call and some additional code to close std descriptors, so there's no practical difference between calling deamon() and fork() by yourself... -- http://mail.python.org/mailman/listinfo/python-list
Re: Using '__mul__' within a class
Gerard Flanagan wrote: > def Square( self ): > self *= self You probably mean return self * self > A = FibonacciMatrix() > A.Square() Make this A = A.Square() -- http://mail.python.org/mailman/listinfo/python-list
Re: How to decompile an exe file compiled by py2exe?
Thomas Jollans wrote: > interpreter. This is based on the assumption that py2exe really > generates a pure exe and not an exe that interprets bytecode python. > be that the case, it may yield decent results, but ugly nontheless. It is - py2exe embeds python bytecodes. It seems it does it in the "library.zip" file (if I'm reading http://starship.python.net/crew/theller/moin.cgi/Py2Exe correctly). Bytecode files extracted should be decompilable to something resembling original python code by a python decompiler (quick Googling finds "decompyle": http://www.crazy-compilers.com/). -- http://mail.python.org/mailman/listinfo/python-list
Re: Best dbm to use?
[EMAIL PROTECTED] wrote: > I'm creating an persistant index of a large 63GB file > containing millions of peices of data. For this I would > naturally use one of python's dbm modules. But which is the > best to use? BDB4, but consider using sqlite - it's really simple, holds all data in a single file and it's more supported (in the sense: there are bindings for sqlite for almost any language/environment out there, and the file format is stable). It's also very fast and you can later add more information you want to store (by adding more fields to table). -- http://mail.python.org/mailman/listinfo/python-list
Re: PostgreSQL & Python vs PHP
Luis P. Mendes wrote: > I need to build it from the server and also client side. > > For the client side I'll be using Python. > > But for the server side, I would like to hear some opinions. Is it worth > learning Php? If you know Python and don't know PHP, there's little benefit from spending the time learning it. But, PHP is extremely simple to work with and you can produce results VERY quickly. Part of the reason is that it's already intended to be a web-embedded language and doesn't reqire additonal frameworks, libraries or configuration like Python does. One thing that botheres me when using Python in php-like way is that the "indentation is significant" property becomes a nuisance when you intertwine HTML and code (which you shouldn't be doing anyway ;) ). The benefit of Python is that is a much cleaner language with well defined interfaces and you'll probably maintain a large application easier if it's in Python. There are no significant performance differences, and no really significant differences in programming approach. -- http://mail.python.org/mailman/listinfo/python-list
Re: Software licenses and releasing Python programs for review
poisondart wrote: > Ultimately I desire two things from the license (but not limited to): > - being able to distribute it freely, anybody can modify it > - nobody is allowed to make profit from my code (other than myself) GPL does something like this, except it doesn't forbid anyone to sell the software. Also, you do realize that if you make it freely distributable and modifiable, you could get into the situations where potential customers say "so why should we buy it from him when we can get it free from X"? -- http://mail.python.org/mailman/listinfo/python-list
processing a large utf-8 file
Since the .encoding attribute of file objects are read-only, what is the proper way to process large utf-8 text files? I need "bulk" processing (i.e. in blocks - the file is ~ 1GB), but reading it in fixed blocks is bound to result in partially-read utf-8 characters at block boundaries. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows distribution suggestions?
Paul Rubin wrote: >>your active code is then in some library.zip shared between the >>three, and you need never change alice.exe, bob.exe, and carol.exe > > I think I understand what you're saying and it sounds like a very > good idea. Thanks. One thing about updating files - sorry if I'm stating general and universal knowledge, but beware that on Windows you can't delete and/or replace a file if it's opened by any process. -- http://mail.python.org/mailman/listinfo/python-list
Re: Resizing VListBox on parent (wxPython)
Solved - I didn't know the importance of "proportion" parametar. -- http://mail.python.org/mailman/listinfo/python-list
Re: Resizing VListBox on parent (wxPython)
Ivan Voras wrote: > - panel, vertical BoxSizer > - a single VListBox Forgot to mention it - I'm using wx.GROW flag on both of them. -- http://mail.python.org/mailman/listinfo/python-list
Resizing VListBox on parent (wxPython)
I hava a hierarhical sizer layout in which there's a panel in the upper part of a window with some buttons, and another panel with wxVListBox that's meant to occupy all the remaining space in the window. Both panels are put inside a vertical BoxSizer, and the VListBox in its panel is also in BoxSizer. The hierarchy is like this: - window, vertical BoxSizer - panel, horizontal BoxSizer - some buttons - panel, vertical BoxSizer - a single VListBox (the VListBox is alone in its panel for "future compatibility" - I plan to add more controls to the panel) I want the lower panel and the VListBox to automatically resize and fill all the remaining space in the window. I can get this to work in the horizontal direction by default, but not in vertical. When I set the vertical size of VListBox to -1, it only displays one line; I can set it to a fixed vertical size, but I really need it to adapt its size to that of the window (something like "Center" layout option in Java BorderLayout). (The items in VListBox are generated at program runtime, and are not available during window controls creation stage) Can somebody explain why is this happening and how to do what I want? I have almost no experience in wxWindows. -- http://mail.python.org/mailman/listinfo/python-list
Re: stop a thread safetely
Peter Hansen wrote: > call to recv() does not guarantee that the full 608 bytes of data is Does read() have that guarantee? -- http://mail.python.org/mailman/listinfo/python-list
Re: Encryption with Python?
Blake T. Garretson wrote: > I want to save some sensitive data (passwords, PIN numbers, etc.) to > disk in a secure manner in one of my programs. What is the > easiest/best way to accomplish strong file encryption in Python? Any > modern block cipher will do: AES, Blowfish, etc. I'm not looking for > public key stuff; I just want to provide a pass-phrase. There's a pure python Blowish implementation at: http://bofh.concordia.ca/blowfish.py (It looks like you'll have to divide your data in 8 byte blocks yourself, and pad the last block) -- http://mail.python.org/mailman/listinfo/python-list
wxPython custom list drawing?
Does wxPython (actually, the wx toolkit) support setting up ListCtrls or similar to allow custom element drawing? Something like generating an 'OnPaint()' event in which I could paint whatever I like in a listbox element. (example from some other toolkits) -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2Exe security
Grant Edwards wrote: > On 2005-05-03, mahasamatman <[EMAIL PROTECTED]> wrote: >>password = pasword.decode("base64") > > That will delay the attacker for a few minutes. True, but a script kiddie that only knows about the 'strings' program will be forever baffled :) Though deprecated, I think the enigma cipher (rotor) is still present in python - it could find its use in simple cases like this. -- http://mail.python.org/mailman/listinfo/python-list
Re: So many things that need to be decided....
Heather Stovold wrote: > I still need to decide on a database I've really only used Access, > and my SQL skills aren't that great. It would also need to be free As many others have suggested, if you're comming from Access, SQLite or Gadfly would probably be good starting points, because - they both store data as files in the filesystem (as Access does), so you don't have to maintain a database server - they are easy to setup and use, there's lots of documentation on them. My personal suggestion would be to go with SQLite because it's a standard database which can be used with large number of other tools and languages. Keep in mind that such simple database systems have limits. Mostly, you'll encounter performance problems if you have multiple users writing data to the database at the same time (so if you're into web applications or business systems, use something more powerful, like PostgreSQL or Firebird). As for report generating features, I don't know of any free report generators that are as easy to use like the one in Access (e.g. point-and-click). Same goes for GUI tools. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reusing object methods?
Jp Calderone wrote: I want to 'reuse' the same method from class A in class B, and without introducing a common ancestor for both of them - is this possible in an elegant, straightforward way? This is what sub-classing is for. If it makes you feel better, call it "mixing in" instead. You can share this method between two classes without inheritance (by defining a free function and then ...), but using a common base class really is just the right way to do it. Ok. -- http://mail.python.org/mailman/listinfo/python-list
Reusing object methods?
Can this be done: (this example doesn't work) class A: def a_lengthy_method(self, params): # do some work depending only on data in self and params class B: def __init__(self): self.a_lengthy_method = A.a_lengthy_method # I know that data in "self" of class B object is compatible # with that of class A object I want to 'reuse' the same method from class A in class B, and without introducing a common ancestor for both of them - is this possible in an elegant, straightforward way? -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
Grant Edwards wrote: Huh? wxPythonGTK requires GTK runtimes as well: He was probably talking about Windows, where wx toolkit uses native (more or less...) controls. But then, installing GTK runtime libraries on Windows is a one-click job, there are automated installers for it. -- http://mail.python.org/mailman/listinfo/python-list
Re: HTML cleaner?
M.-A. Lemburg wrote: Not true: mxTidy integrates tidy as C lib. It's not an interface to the command line tool. Thanks, I'll look at it again! -- http://mail.python.org/mailman/listinfo/python-list
HTML cleaner?
Is there a HTML clean/tidy library or module written in pure python? I found mxTidy, but it's a interface to command-line tool. What I'm searching is something that will accept a list of allowed tags and/or attributes and strip the rest from HTML string. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting into Python, comming from Perl.
Mage wrote: foo = dict() or: foo = {} -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode problems, yet again
John Machin wrote: Just a thought: I noticed from the traceback that you are running this on a Windows box. Profound apologies in advance if this question is an insult to your intelligence, but you do know that Windows code page 1250 (Latin 2) -- which I guess is the code page that you would be using -- is *NOT* the same as iso-8859-2, don't you? Yes, I know. The reason I'm doing it on Windows is that the app's supposed to be multiplatform, so I'm doing part of development on Windows, part on FreeBSD... The agreed-upon codepage is iso8859-2 for both. (about the "latin2" term - it really sucks that it's used incosistently - for example, PostgreSQL (and I think MySQL) use "latin2" when they mean iso8859-2). need to deal with Unicode, then set up the encoding explicitly on a per-file or per-socket basis. The default ASCII encoding is then there I didn't know that! ... looks at the manual ... oh, it was introduced in 2.3. I wonder if it would work for sockets (though I don't plan to use it now - I've got explicit encodings/decodings set up). -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode problems, yet again
John Machin wrote: (Does anyone else feel that python's unicode handling is, well... suboptimal at least?) Your posting gives no evidence for such a conclusion. Sorry, that was just steam venting from my ears - I often get bitten by the "ordinal not in range(128)" error. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode problems, yet again
Jp Calderone wrote: You don't have a string fetched from a database, in iso-8859-2, alas. That is the root of the problem you're having. What you have is a unicode string. Yes, you're right :) I actually did have iso-8859-2 data, but, as I found out late last night, the data got converted to unicode along the way. Thanks to all who replied so quickly :) (Does anyone else feel that python's unicode handling is, well... suboptimal at least?) Hmm. Not really. The only problem I've found with it is misguided attempt to "do the right thing" by implicitly encoding unicode strings, and this isn't so much of a problem once you figure things out, because you can always do things explicitly and avoid invoking the implicit behavior. I'm learning that, the hard way :) One thing that I always wanted to do (but probably can't be done?) is to set the default/implicit encoding to the one I'm using... I often have to deal with 8-bit encodings and rarely with unicode. Can it be done per-program? -- http://mail.python.org/mailman/listinfo/python-list
Unicode problems, yet again
I have a string fetched from database, in iso8859-2, with 8bit characters, and I'm trying to send it over the network, via a socket: File "E:\Python24\lib\socket.py", line 249, in write data = str(data) # XXX Should really reject non-string non-buffers UnicodeEncodeError: 'ascii' codec can't encode character u'\u0161' in position 123: ordinal not in range(128) The other end knows it should expect this encoding, so how to send it? (Does anyone else feel that python's unicode handling is, well... suboptimal at least?) -- http://mail.python.org/mailman/listinfo/python-list
Re: XML parsing per record
Irmen de Jong wrote: XML is not known for its efficiency Surely you are blaspheming, sir! XML's the greatest thing since peanut butter! I'm just *waiting* for the day someone finds its use on the rolls of toilet paper... oh the glorious day... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
Dennis Lee Bieber wrote: On Sat, 19 Mar 2005 14:36:02 +0100, Ivan Voras <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: Hey, IIRC, old Turbo Assembler (tasm, by Borland) had those. Much of it was still manual, by it supported semi-automatic vtables and such :) I'd suspect through a rather elaborate "macro" capability. Probably... don't remember any more, but it was prominent in the manuals :) The standard assembler used in my college classes didn't even understand the native instruction set of the machine -- until you LD std,1 AFA(1),'04'x, CF(2),AF(1) cool, these look like microinstructions :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple XML-to-Python conversion
[EMAIL PROTECTED] wrote: I've been searching high and low for a way to simply convert a small XML configuration file to Python data structures. I came across gnosis XML tools, but need a built-in option for doing something similar. I too needed such thing, and made this simple parser: http://ivoras.sharanet.org/projects/xmldict.py.gz It's really quick and dirty. It doesn't even use standard parsers such as dom or sax, but improvises its own. It's also very likely to fail in mysterious ways when it encounters invalid XML, but for quick and dirty jobs, it's very nice and easy. See the bottom of the file for some quick examples. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
Dennis Lee Bieber wrote: You know of an assembly language that does Object Oriented? My... The world has been waiting with bated breath for that. Hey, IIRC, old Turbo Assembler (tasm, by Borland) had those. Much of it was still manual, by it supported semi-automatic vtables and such :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
Cappy2112 wrote: Eric3 has been compiled for Windows, without Cygwin and Without a commercial license Can it be downloaded from somewhere? (where from?) Or is it forbidden by the license? -- http://mail.python.org/mailman/listinfo/python-list
Re: 64 bit Python
Mathias Waack wrote: As I stated I wrote a simple C-program before. The c-program was able to allocate a bit more than 900MB in 32 bit mode. Sorry, I should've paid more attention :) -- http://mail.python.org/mailman/listinfo/python-list
Re: 64 bit Python
Mathias Waack wrote: amounts of data. I figured out that a 32 bit application on HP-UX cannot address more than 1 GB of memory. In fact (I think due to the overhead of memory management done by python) a python application cannot use much more than 500 MB of "real" data. For this reason I don't thik this is likely. Don't know about HP-UX but on some platforms, FreeBSD for example, there is a soft memory-cap for applications. By default, a single application on FreeBSD cannot use more than 512MB of memory, period. The limit can be modified by root (probably involves rebooting). -- http://mail.python.org/mailman/listinfo/python-list