New PPCEncoder available (v00.34)
PPCEncoder The xViD encoder for a PocketPC like aparatus has new features. - IconTray in minimize - Set Processing priority. Very handy If you want to convert movies and still be able to work on you PC during the conversion This application Encodes video to PocketPC DivX format and size. With PPCEncoder you can encode and optimize your movies for the size of your PocketPC screen and memory card Check it out here: http://IvoNet.nl -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Ironpython book?
Who's the ruling hierarchy? I guess I just meant the congnoscenti. Them that knows what's what. I'm a Mac fan, with Linux a close second I suspected. I've played with Linux distros, but never a Mac. That takes more $$ than M$, and Apple is even more proprietary than MS, if you ask me. It interests me how many Open Source advocates and anti-Microsoft folks are willing to pay top dollar for Macs, which I guess means that, for them, it's less a Cathedral vs. Bazaar thing and more about It Works vs. It Doesn't? I'm no Microsoft lover, but XP doesn't crash on my machines. So I continue using it, along with Python, Firefox and whatever else I please. Anyway, thanks for the info. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you guys print out a binary tree?
Hi, 1 2 3 4 5 0 7 8 9 10 0 0 13 14 15 0 0 0 19 20 0 0 0 0 25 Look at the triangle represented by the non-zero integers. This triangle is a binary tree if we take 5 as the root and walk down on both sides. Are you sure? Is 9 a child of 4 or 10? A binary tree can have up to 2^n - 1 nodes. A matrix can have up to n^2 values, in your case of a half-empty matrix about (n-1)^2. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you guys print out a binary tree?
A half-empty matrix will of course have (n+1)* n * 1/2 elements. -- http://mail.python.org/mailman/listinfo/python-list
Re: Upgrading and modules
Lawrence Oluyede [EMAIL PROTECTED] writes: (despite the ongoing Pypi project and Eby's efforts in setuptools) you have to do it manually :) Great, there is progress in this. How many modules do you really use? It's a matter of minutes. Yes, but 60 minutes make an hour. I installed 2.4 some days ago. I then needed ctypes and mySQLdb. Both of them had had some updates in addition to the version change. What could have been seconds did take a while because of this. Of course it is because I try to do both steps in one installation. -- Brian (remove the sport for mail) http://www.et.web.mek.dtu.dk/Staff/be/be.html http://www.rugbyklubben-speed.dk -- http://mail.python.org/mailman/listinfo/python-list
how to use socks5 proxy in pycurl?
import pycurl c = pycurl.Curl() c.setopt( pycurl.URL, 'http://www.test.com/test.html' ) import StringIO b = StringIO.StringIO() c.setopt( c.WRITEFUNCTION, b.write ) c.setopt( c.FOLLOWLOCATION, 1 ) c.setopt( c.MAXREDIRS, 5 ) c.setopt(c.PROXY,'www.test.com:1080') #c.setopt(c.PROXYTYPE,'SOCKS5') c.setopt(c.PROXYUSERPWD, 'user:pass') c.perform() print b.getvalue() how to use socks5 proxy in pycurl? -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
You don't actually *need* a libglade/pyGtk IDE: glade will be more than enough :-) By its very nature glade will enable you to design the GUI and define the signals. Then you'll load the glade file in python, and use whatever editor you feel comfortable with. -- Have fun, Renato Ramonda -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
[EMAIL PROTECTED] wrote: Kun assuming that my date column is 2, how would i parse out the date? No parsing required. Just get its date: d = record[2].date() The str() of a datetime.date object is a string in -MM-DD form. or, in other words, change: for col in range(0, numcols): print td, record[col], /td to # convert to list, so we can replace columns, if needed record = list(record) # fix the date column record[2] = record[2].date() # add other fixups here # print it out for col in range(0, numcols): print td, record[col], /td the last two lines are of course better written as for col in record: print td, col, /td /F -- http://mail.python.org/mailman/listinfo/python-list
Re: freakin out over C++ module in python
and so, i guess the main question i have is is there a module or program that will parse these classes and duplicate them for a python module ? Some kind of code translator ? Or is that just way out there? No, there isn't. i would go thru it line by line, but i just dont know enough about C++, how it pulls off a socket connection, etc.. and some of the things i dont know how to do in python. like how to make an unsigned long init. Use module struct. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
BartlebyScrivener wrote: I'll let somebody jump in and say, You're crazy! But it seems to me the interest in IronPython on this list is pretty subdued. Maybe because most people are running on Linux or Macs? umm. CPython runs just fine on Windows, and can talk to most Windows- specific stuff via the win32 extensions and ctypes and python for .net: http://www.zope.org/Members/Brian/PythonNet /F -- http://mail.python.org/mailman/listinfo/python-list
Error using tkinter
Hi, I am making a gui, in which specifiction are taken from user, which are wriiten to a file. and that file will bw executed. finalstr is a string f = open('crossManual.sh','w') f.write(finalstr) f.close() I am getting the error Exception in Tkinter callback Traceback (most recent call last): File /usr/lib/python2.3/lib-tk/Tkinter.py, line 1345, in __call__ return self.func(*args) File gui.py, line 248, in writescript f = open('crossManual.sh','w') TypeError: an integer is required Couldn't understand what it means Plz tell me how to correct it. Thanx in advance -- http://mail.python.org/mailman/listinfo/python-list
Shell like syntax for subprocess.Popen # overloading , , |
Hi, I use python quite a bit to couple different programs together. Doing so has been a _lot_ easier since subprocess came around, but would really like to be able to use the succinct shell syntax; , , | That really shouldn't be too hard to wrap in a class, but so far I didn't succeed to do so this well, since I'm facing some trouble with operator precedence that I do not know how to overcome. Consider the following: A = 'inputString' B = Process('process.exe') C = cStringIO.StringIO() # output bucket A B C A is being piped to B and processed, but the output of B is not being piped to C executing A B; B C works as expected however. Which is disappointing, since what I'm trying to achieve is a sugar syntax for Popen processes, where directly sees the chain of commands... Any suggestions to overcome this issue are greatly appreciated! cheers, -jelle - class Process(Popen, object): def __init__(self, commandString, wait=False): assert isinstance(commandString, str) cmd = commandString.split() self.cmd= commandString self.exe= cmd.pop(0) ##self.args = cmd self.process = Popen(self.cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=False) self.stdout = self.process.stdout self.stderr = self.process.stderr def __repr__(self): return 'Process instance ( %s ) ' % (self.exe) def __or__(self, other): # PIPE ''' returns the output of Process A - Process B takes a Process instance as argument ''' assert isinstance(other, Process), '%s\n is not a Process instance' % (other) print 'PIPE' self other def __lt__(self, other): # STDIN ''' takes a StringIO, file or string objectas argument ''' print '' print 'STDIN' if isinstance(other, str): self.process.communicate(other) else: self.stdout, self.stderr = self.process.communicate(other.read()) self.process.wait() def __gt__(self, other): # STDOUT ''' takes a StringIO, file or string object as argument returns the result of an external process ''' print '' print 'STDOUT' assert hasattr(other, 'write') or isinstance(other, str) if isinstance(other, str): other += self.stdout else: other.write(self.stdout) - -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
#includepython.h char code[] = print 'hello moshe'; void main(...) { Py_ExecString(code); } I don't get this, with python 2.4 there is no function called Py_ExecString in any of the header files. I found something that might do the job PyRun_SimpleString( ) in pythonrun.h, but couldn't get it to work either. So what is really the way to execute python code in a string from a C program? -- http://mail.python.org/mailman/listinfo/python-list
Another SimpleXMLRPCServer question.
Let's hope this is my last question on the matter. I'm implementing a SimpleXMLRPCServer, and last week I had a problem John helped me solve. The thing is that my server is to be called from a remote machine, so when declaring the instance, the line (localhost, 8000) wouldn't work because it would only listen on 127.0.0.1. Next thing I tried was the line ('', 8000) (two simple quotes). That way it worked just fine, because now the server listens on all interfaces. My question now is: is this the way SimpleXMLRPCServers are implemented? All the examples I've found use the simple quotes, without providing any other aditional examples. I want to know if there are any security risks that raise from the fact that it listens on all interfaces. I haven't been able to find any information on this. If you need more info regarding my question, please ask. Thank you very much in advance. Jose Carlos. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
This article in Guido van Rossum's blog might be interesting for this thread http://www.artima.com/weblogs/viewpost.jsp?thread=92662 -- Pablo -- http://mail.python.org/mailman/listinfo/python-list
Re: piping question
In article [EMAIL PROTECTED], Biggmatt [EMAIL PROTECTED] wrote: The problem is that i want it to get the stdout as the program runs, not hold it all till it's finished. This has been discussed before. If the program you're trying to control buffers its output and gives no option to disable that, then you're stuck with the way it works. -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
[EMAIL PROTECTED] wrote: I've traditionally been a Java developer, although I play around with LISP. I recently migrated to Linux and I was exploring Mono as an option for development on Linux. However, I've had some problems with the maturity and support when working with Mono. So I was considering Python as an alternative development language. Is Python actively developed and supported on Linux? Yes. In fact, all distros I know ships with (and often depends on) Python. Would it be a viable option for cross-platform application development? Yes. Python runs on most platforms, and wxPython runs on Windows, MacOS X, and most Unices Can anyone recommend an open source IDE for Python that runs on Linux? Emacs ?-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Error using tkinter
JyotiC wrote: I am getting the error Exception in Tkinter callback Traceback (most recent call last): File /usr/lib/python2.3/lib-tk/Tkinter.py, line 1345, in __call__ return self.func(*args) File gui.py, line 248, in writescript f = open('crossManual.sh','w') TypeError: an integer is required Couldn't understand what it means let me guess: gui.py contains the line from os import * ? this means that open refers to os.open, which is not the same thing as the built-in open function. the solution? use import os, and add os. in front of all functions from that module. never use from-import in application code, unless you have very good reasons: http://effbot.org/zone/import-confusion.htm#which-way-should-i-use /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
okay, i got the name wrong. i wasn't trying to provide production-level code, just a snippet. the function you want is PyRun_SimpleString( const char *command) #include python.h char secret_code[] = print 'moshe'; int main() { return PyRun_SimpleString(secret_code); } and you need to link with python24.lib or whatever the object file is for your platform. -tomer -- http://mail.python.org/mailman/listinfo/python-list
Re: Error using tkinter
Thanx a lot, that was the problem -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
#include python.h char secret_code[] = print 'moshe'; int main() { return PyRun_SimpleString(secret_code); } and you need to link with python24.lib or whatever the object file is for your platform. Are you sure? On a linux platform I tried linking with libpython2.4.so (I assume this is the correct object file) but it segfaults in PyImport_GetModuleDict( ). -- http://mail.python.org/mailman/listinfo/python-list
Re: scanning through page and replacing all instances of 00:00:00.00
Kun wrote: Fredrik Lundh wrote: Kun wrote: I have a python-cgi file that pulls data from an sql database, i am wondering what is the easiest way to remove all instances of '00:00:00.00' in my date column. how would i write a python script to scan the entire page and delete all instances of '00:00:00.00', would i use regular expressions? umm. if you're using a database, why not filter out uninteresting dates either in the SQL statement, or when you're building the page ? because in my sql database, the date is only 'date' (as in -mm-dd), only when i extract it with my python-cgi does the date turn into (-mm-dd 00:00:00.00), thus i figured the best way to fix this problem is to parse it after the matter. It sounds like the problem is with the way you format the date for output. Just omit the time. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
Daniel Nogradi wrote: char secret_code[] = print 'moshe'; int main() { return PyRun_SimpleString(secret_code); } and you need to link with python24.lib or whatever the object file is for your platform. Are you sure? On a linux platform I tried linking with libpython2.4.so (I assume this is the correct object file) but it segfaults in PyImport_GetModuleDict( ). I still don't understand why you think that embedding the *source code* in a variable named secret will do a better job than just putting the byte code in some non-obvious packaging, but if you insist on embedding the code, reading the documentation might help: http://docs.python.org/ext/embedding.html At the very least, you have to call the function Py_Initialize() http://docs.python.org/ext/high-level-embedding.html (minimal PyRun_SimpleString example) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Why new Python 2.5 feature class C() return old-style class ?
Fredrik Lundh wrote: why are you using an IDE that doesn't understand Python syntax ? /F Because I don't like using a whole new editor for every new language I'm using (as you would not use a new hammer for each nail) and jedit just plain rocks. I guess it could be made to recognize class statements ... but its python mode works well enough, so I'll rather stick to that and create python magic. ok, on to the next useless post ... ;) wildemar -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
Paul McGuire [EMAIL PROTECTED] (PM) wrote: PM Jonathan Amsterdam [EMAIL PROTECTED] wrote in message PM news:[EMAIL PROTECTED] If you don't want to call it deadlock, fine, but the program execution I describe will make no progress to the end of time. Thread 2 can never put anything in the queue, because Thread 1 holds M, and Thread 1 will never release M because that can only happen if someone puts something on the queue. PM Ah, I get it now, and yes as you describe it, this is a deadlock. But why PM do you need both mutex M and a Queue, then? You should release M before PM calling Queue.get(). Then if you need to, you should reacquire it PM afterward. What Jonathan says is that in his example M and the mutex for the Queue should be the same to solve the problem. And that the Queue API should allow you to do that. I think he is right. -- Piet van Oostrum [EMAIL PROTECTED] URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
char secret_code[] = print 'moshe'; int main() { return PyRun_SimpleString(secret_code); } and you need to link with python24.lib or whatever the object file is for your platform. Are you sure? On a linux platform I tried linking with libpython2.4.so (I assume this is the correct object file) but it segfaults in PyImport_GetModuleDict( ). I still don't understand why you think that embedding the *source code* in a variable named secret will do a better job than just putting the byte code in some non-obvious packaging, but if you insist on embedding the code, reading the documentation might help: http://docs.python.org/ext/embedding.html At the very least, you have to call the function Py_Initialize() http://docs.python.org/ext/high-level-embedding.html (minimal PyRun_SimpleString example) Well, I was not the original poster in this thread I just picked up the idea of executing python code that is assigned to a string from within C and tried to do it with no particular goal, that's all. And thanks a lot for the links, the docs are pretty clear, I should have checked them before -- http://mail.python.org/mailman/listinfo/python-list
Re: Translate Cpp into python code
Alle 21:36, lunedì 17 aprile 2006, Ravi Teja ha scritto: If you are looking for ways to access C++ code in Python, there are several (Boost, SIP, CXX, SWIG, Weave etc). This way I knew about it. People usually convert higher level languages to lower level languages for performance Frankly I'm not looking for performances, but a viable python script which won't be tied up to a single platform. Those parts of the code which are calling proprietary functions will be removed. Probably the first step to make a port on a multiplatform concept. Another point will be a better chance to learn programming once I got the translation. F -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
[EMAIL PROTECTED] wrote: How can a proprietary software developer protect their Python code? People often ask me about obfuscating Python bytecode. They don't want people to easily decompile their proprietary Python app. Do they ask the same thing for Java or .NET apps ?-) I suppose another idea is to rewrite entire Python app in C if compiled C code is harder to decompile. Do you really think native code is harder to reverse-engineer than Python's byte-code ? Any ideas? I'm afraid that the only *proven* way to protect code from reverse-engineering is to not distribute it *at all*. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
bruno at modulix [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Do they ask the same thing for Java or .NET apps ?-) If you Google for bytecode obfuscation, you'll find a large number of products already exist for Java and .Net -- http://mail.python.org/mailman/listinfo/python-list
[OT] Any Python lullabies?
Since there have been python limmericks, are there any Python lullabies that I can sing to my newborn son (actually, born yesterday)? I tried to murmur some select parts from the tutorial, but he somehow wasn't very interested :) -- TZOTZIOY, I speak England very best. Dear Paul, please stop spamming us. The Corinthians -- http://mail.python.org/mailman/listinfo/python-list
Tokens?
In the invaluable 'Dr. Dobb's Python-URL! - weekly Python news and links' of April 17 Peter Otten writes: Michele Simionato's little script lets you search for a name in Python scripts, avoiding false positives that a standard tool like grep would yield. Can someone explain why this is so? I have attached the script below. import sys, tokenize, token def count_name(name, script): Count the occurrences of a Python name in a script counter = 0 for tok_code, tok_value, (srow, scol), (erow, ecol), line in \ tokenize.generate_tokens(file(script).readline): if tok_code == token.NAME and tok_value == name: counter += 1 print 'line %s: %s' %(srow, line), if counter: print '*** %s ***\n' % script return counter if __name__ == '__main__': name = sys.argv[1] scripts = sys.argv[2:] total = sum(count_name(name, script) for script in scripts) print 'Found %d occurrences of %r' % (total, name) jab--who laments the day that Doctor Dobbs' Journal of Computer Callisthenics and Orthodontics changed its name. -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
Richard Brodie wrote: Do they ask the same thing for Java or .NET apps ?-) If you Google for bytecode obfuscation, you'll find a large number of products already exist for Java and .Net and if you google for python obfuscator, you'll find tools for python. including tools that use psychologically inspired techniques to produce extra confusion in human readers (probably by inserting small snippets of Perl here and there...). /F -- http://mail.python.org/mailman/listinfo/python-list
semi-[OT]: adding a reply-to line to these mails?
I've noticed that I replied to individual posters' private addresses several times now ... So a quick note to the admin(s): see topic ;) Hey, maybe I'm just too dumb to use Thunderbird; I haven't figured out a way to reply comfortably to list posts (take this as a half asses excuse to why some of you got private mail from me ;)) bye wildemar -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Any Python lullabies?
On Tue, 18 Apr 2006 14:12:14 +0300, Christos Georgiou [EMAIL PROTECTED] wrote: Since there have been python limmericks, are there any Python lullabies that I can sing to my newborn son (actually, born yesterday)? I tried to murmur some select parts from the tutorial, but he somehow wasn't very interested :) Then isn't that the perfect lullaby material? ;-) Regards, Dan -- Dan Sommers http://www.tombstonezero.net/dan/ I wish people would die in alphabetical order. -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list
Re: Shell like syntax for subprocess.Popen # overloading , , |
On 18 Apr 2006 01:37:03 -0700, rumours say that jelle [EMAIL PROTECTED] might have written: Hi, I use python quite a bit to couple different programs together. Doing so has been a _lot_ easier since subprocess came around, but would really like to be able to use the succinct shell syntax; , , | That really shouldn't be too hard to wrap in a class, but so far I didn't succeed to do so this well, since I'm facing some trouble with operator precedence that I do not know how to overcome. [snip] Overload the __or__ special function (ie the 'pipe' operator) instead of the __gt__ operator. I remember I have seen such a proposition (mentioning pump, filters and sinks) but I couldn't find it in google.groups.com --I think Aahz had something to do with it, but ICBW. Ah, I found it: http://mail.python.org/pipermail/python-dev/2004-April/044205.html I don't know why I remembered Aahz about it :) Check this too: http://groups.google.gr/group/comp.lang.python/browse_thread/thread/674a821ed7003b69/777efd4d3aa490ed?lnk=stq=python+overload+pipe+syntaxrnum=1hl=en#777efd4d3aa490ed -- TZOTZIOY, I speak England very best. Dear Paul, please stop spamming us. The Corinthians -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
I V wrote: To use interfaces in python, just what you would do in Java, except don't use interfaces. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list
Re: freakin out over C++ module in python
ok, well enough, looked at struct and it does seem to be what i am after. for that anyway. thanks, guess i will just have to take the time and pull it apart. cheers sk -- http://mail.python.org/mailman/listinfo/python-list
Re: Tokens?
BBands wrote: In the invaluable 'Dr. Dobb's Python-URL! - weekly Python news and links' of April 17 Peter Otten writes: Michele Simionato's little script lets you search for a name in Python scripts, avoiding false positives that a standard tool like grep would yield. Can someone explain why this is so? consider grepping for main in this script: def main(): # this is the main function print hello, main if __name__ == __main__: main() a standard grep will find five instances. a word grep will find four. a name token grep will find two. /F -- http://mail.python.org/mailman/listinfo/python-list
genexp reduce syntax in 2.5a1
On the python3000 mailing list there was some discussion of a comprehension syntax for reduce. This inspired me the following proof-of-concept in pure python 2.5a1, although I don't know if it relies on an intended feature or a(n unintended) bug. Cheers, BB -- def ireduce(gen) : Generator expression syntax for reduce and generalizations Usage examples: - (yield) nothing as below if there is no seed value *and* the expression consists of a single arithmetic op ireduce(x+(yield) for x in range(101)) # famous Gauss example 5050 ireduce(x*(yield) for x in range(1,6)) 120 - if there is a seed, yield it (unless it's None) ireduce(x*(yield 2) for x in range(1,6)) # 2*1*2*3*4*5 240 ireduce(x*(yield 2) for x in range(2,6)) # 2*2*3*4*5 240 ireduce(x*(yield 2) for x in range(6)) # 2*0*1*2*3*4*5 0 - if the seed is None, (yield INone) instead ireduce((x,(yield INone)) for x in for all good men.split()) ('men', ('good', ('all', ('for', None ireduce([(yield INone),x] for x in for all good men.split()) None, 'for'], 'all'], 'good'], 'men'] - do as below if you want no special seed and the operation to reduce isn't a simple arithmetic operation ireduce((x,(yield Seed(x))) for x in for all good men.split()) ('men', ('good', ('all', 'for'))) ireduce(x+' '+(yield Seed(x)) for x in for all good men.split()) 'men good all for' ireduce({ x : (yield Seed(x))} for x in for all good men.split()) {'men': {'good': {'all': 'for'}}} - and notice these for a comparison ireduce({ x : (yield x)} for x in for all good men.split()) {'men': {'good': {'all': {'for': 'for' ireduce({ x : (yield Seed(None))} for x in for all good men.split()) {'men': {'good': {'all': None}}} cumulate = gen.next() if cumulate is None : cumulate = Neutral() elif cumulate is INone : cumulate = None elif isinstance(cumulate,Seed) : cumulate = cumulate.seed gen.send(cumulate) gen.next() try : while True : cumulate = gen.send(cumulate) gen.next() except StopIteration : return cumulate class Neutral : def __coerce__(self,other) : self.other = other return (self,self) def __getattr__(self,attr) : return lambda *x,**y : self.__dict__['other'] class INone : pass class Seed : def __init__(self,seed) : self.seed = seed -- http://mail.python.org/mailman/listinfo/python-list
Re: freakin out over C++ module in python
On Apr 18, 2006, at 4:43 AM, [EMAIL PROTECTED] wrote: ok, well enough, looked at struct and it does seem to be what i am after. for that anyway. thanks, guess i will just have to take the time and pull it apart. I recommend you also take a look at http://pyconstruct.sourceforge.net/ It has the same purpose as 'struct', but is MUCH more Pythonic. I've described Contstruct as the replacement for 'struct' I've been looking for since I started coding in Python. Jay P. -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
If you are interested in a pure managed-code implementation of the Python language, you should check out the IronPython project There's the rub. I don't know what pure managed-code means. But I'll definitely look into CPython. Thanks rd -- http://mail.python.org/mailman/listinfo/python-list
Re: Shell like syntax for subprocess.Popen # overloading , , |
Hi Christos, Thanks for your pointers there, impressive to see -that a 12 year old thread still can make an interesting read -you being able to remember trace it... impressive... Thanks for your pointers. I think the input process output Syntax is more powerful , since it would let you build chaining commmands in a more readable fashion. The goal of this class would be to construct command chains such as: input processA | processB ouput Something which wouldn't be possible if only one operator is overloaded. I'm curious to see if its doable via overloading, since no __rgt__ methods exists... -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Any Python lullabies?
Since there have been python limmericks, are there any Python lullabies that I can sing to my newborn son (actually, born yesterday)? I tried to murmur some select parts from the tutorial, but he somehow wasn't very interested :) Well, you might start with Twinkle, Twinkle, Little Asterisk or: Blind Mice * 3 you is self.sunshine [horse for horse in horses if horse.pretty] for baby in tree.top.babies: ...if wind.blows(): baby.cradle.rock() ...if tree.bough.breaks(): ...fall([baby, cradle, all]) ... and last, and certainly worst: Mary had a Little Lambda While you're at it, if you want them to learn Vim, you can hum them Bram's Lullaby... (groan) Okay...that's a bad enough starter :) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: semi-[OT]: adding a reply-to line to these mails?
Wildemar Wildenburger wrote: I've noticed that I replied to individual posters' private addresses several times now ... So a quick note to the admin(s): see topic ;) (Ab)using Reply-To like that is undeservedly controversial. See the section The Great Reply-To Debate in Karl Fogel's book _Producing Open Source Software_: http://producingoss.com/html-chunk/mailing-lists.html#reply-to Hey, maybe I'm just too dumb to use Thunderbird; I haven't figured out a way to reply comfortably to list posts (take this as a half asses excuse to why some of you got private mail from me ;)) OTOH, I am a big fan of a properly munged Reply-To for mailing lists, which I tend to treat like USENET newsgroups. These days, I read the python-list and many other mailing lists through the appropriate GMane newsgroup gateway, in this case, gmane.comp.python.general . Now, python-list does have a gateway to the regular USENET through comp.lang.python, but I can't access my home ISP's news server at work, so I use GMane instead. -- Robert Kern [EMAIL PROTECTED] I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: freakin out over C++ module in python
[EMAIL PROTECTED] wrote: i would go thru it line by line, but i just dont know enough about C++, how it pulls off a socket connection, etc.. and some of the things i dont know how to do in python. like how to make an unsigned long init. The networking code in C++ should be at least vaguely similar to the appropriate Python code using the socket module. Python's socket module is a fairly thin wrapper around BSD sockets; its method names, etc. match the socket system calls. If the C++ is using plain berkely-ish socket code, you'll find connect(), send(), recv() calls (or something similar - I don't know what Winsock calls them for sure); these map to appropriate methods and functions in the socket module. If the C++ code is using some C++ sockets wrapper, I don't know; it still would probably be somewhat similar. Or similar enough that you can read it. Unless they're somehow finagling sockets in to the iostreams library (possible, but unlikely). - Michael -- mouse, n: a device for pointing at the xterm in which you want to type. -- Fortune Visit me on the Web: http://www.elehack.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Any Python lullabies?
Tim Chase wrote: Since there have been python limmericks, are there any Python lullabies that I can sing to my newborn son (actually, born yesterday)? I tried to murmur some select parts from the tutorial, but he somehow wasn't very interested :) Well, you might start with Twinkle, Twinkle, Little Asterisk or: Blind Mice * 3 you is self.sunshine [horse for horse in horses if horse.pretty] for baby in tree.top.babies: ...if wind.blows(): baby.cradle.rock() ...if tree.bough.breaks(): ...fall([baby, cradle, all]) ... and last, and certainly worst: Mary had a Little Lambda While you're at it, if you want them to learn Vim, you can hum them Bram's Lullaby... (groan) Okay...that's a bad enough starter :) -tkc Howsabout this? import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! -- http://mail.python.org/mailman/listinfo/python-list
Simple DAV server?
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 .. Found PyDav http://www.econetwork.net/~jdavis/Software/PyDAV/readme.html, but the package is old and (crucial) webdav.ini.template is missing in that package. Found python davserver http://www.comlounge.net/webdav/ , but it doesn't run. It uses xml libs which are not anymore in recent python's. Is there something else? Or a (non-py) binary simple to set it up. robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
I suspected. I've played with Linux distros, but never a Mac. That takes more $$ than M$, and Apple is even more proprietary than MS, if you ask me. Depends. Sure, if you dive into Cocoa programming and stuff. But you have to keep in mind that under the hood it's BSD - and even runs a X-Server if you want to. So I can use all my Linux staples + have a fancy OS for multimedia-stuff. It interests me how many Open Source advocates and anti-Microsoft folks are willing to pay top dollar for Macs, which I guess means that, for them, it's less a Cathedral vs. Bazaar thing and more about It Works vs. It Doesn't? I can't comment on this in general, but on the CCC (Chaos Communication Congress, a Hacker-con) last year the notebook-distribution was like this: 30% Macs 30% ThinkPads 40% rest So - it seems that quality is important, and of course any decent Hacker will run a *nixish OS. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
I can't comment on this in general, but on the CCC (Chaos Communication Congress, a Hacker-con) last year the notebook-distribution was like this: Now THAT sounds like a fun event for a journalist to cover! I'll have to look into that one. Thanks rick -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Any Python lullabies?
On Tue, 18 Apr 2006 07:07:27 -0500, Tim Chase [EMAIL PROTECTED] wrote: [horse for horse in horses if horse.pretty] I'm familiar with this one as: all(pony for pony in ponies if pony.pretty). Never knew there was a version with horse, not pony. Jane Siberry does a nice rendition of the pony version. There's also: if brother_john.is_sleeping(): pass if brother_john.is_sleeping(): pass assert bells['morning'].is_ringing() assert bells['morning'].is_ringing() --amk -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Any Python lullabies?
Not a lullaby, but appropriate near easter(s) while 1: life.side.bright.look() -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple DAV server?
Zope presents objects/folders via WebDAV. It isn't simple, but it works and is a Python thing. On Windows you can get a demo of GroupDrive here: http://www.webdrive.com/products/groupdrive/index.html -Larry Bates 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 .. Found PyDav http://www.econetwork.net/~jdavis/Software/PyDAV/readme.html, but the package is old and (crucial) webdav.ini.template is missing in that package. Found python davserver http://www.comlounge.net/webdav/ , but it doesn't run. It uses xml libs which are not anymore in recent python's. Is there something else? Or a (non-py) binary simple to set it up. robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Any Python lullabies?
Dustan wrote: Howsabout this? import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! sung to what tune? (lite ipren-mannen-varning här, liksom) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
Diez B. Roggisch [EMAIL PROTECTED] wrote: I suspected. I've played with Linux distros, but never a Mac. That takes more $$ than M$, Find me a 2-kg, 5+ battery hours, well-heeled laptop (with wifi, 801b, etc etc) below the $999 of the iBook G4... it's hard today, it was just imposible back when I bought mine in 2003. I intended to load Linux on it (i.e., I bought it strictly for the nonpareil HW price/performance), and I know a few people who do that, but that was before I found out how well MacOSX works. IOW, Apple is very price-competitive _in the niches it plays in_ -- it just doesn't play in many cheap and nasty niches (such as, 4-kg, hardly-any-battery-life laptops;-). and Apple is even more proprietary than MS, if you ask me. Depends. Sure, if you dive into Cocoa programming and stuff. But you have to ...which is hardly more proprietary than MS, anyway, since OpenStep does live, btw;-). keep in mind that under the hood it's BSD - and even runs a X-Server if you want to. So I can use all my Linux staples + have a fancy OS for multimedia-stuff. For me, just like for most people I've discussed it with, the reasoning is similar. For example, Chip Turner (once of RedHat, and a major contributor to RPM tools, now a colleague at Google) blogs at http://other-eighty.blogspot.com/ and has a few notes on the matter (e.g. there's nothing like sitting in the middle of a meeting and having the ONLY WORKING LAPTOP in the room. Wireless AND suspend, both working... -- that's about his Powerbook;-). I'd say Chip mostly switched from Linux to Mac for the same reason he mostly switched from Perl to Python though he was a CPAN contributor too. Others feel even more strongly: e.g., Rob Pike, another colleague, apparently just dislikes Linux technically (mostly, I think, X11, but not just that) and that's why he uses Macs (Windows isn't even in the picture, of course). It interests me how many Open Source advocates and anti-Microsoft folks are willing to pay top dollar for Macs, which I guess means that, for them, it's less a Cathedral vs. Bazaar thing and more about It Works vs. It Doesn't? I can't comment on this in general, but on the CCC (Chaos Communication Congress, a Hacker-con) last year the notebook-distribution was like this: 30% Macs 30% ThinkPads 40% rest Not too different from what you see, e.g., at OSCON, though there may be more Macs there. At Google meetings the distribution is more like 45-45-10, since Macs and Thinkpads are the laptop brands Google gives its employees for work use (and few bother to apply for a third alternative when they can just pick up either at a tech stop). But, sure, here we're talking about people who are primarily engineers, so the main ethos is indeed it works/it doesn't. Opensource tends to work better (and indeed many of Mac's advantages come from its BSD underpinnings)... So - it seems that quality is important, and of course any decent Hacker will run a *nixish OS. Not necessarily: Tim Peters, among my top choices for top Hacker in the PSF Lifetime Award, prefers Windows. So, s/any/most/...!-) Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
BartlebyScrivener [EMAIL PROTECTED] wrote: If you are interested in a pure managed-code implementation of the Python language, you should check out the IronPython project There's the rub. I don't know what pure managed-code means. But I'll You can find much material about that on the net, e.g. http://blogs.msdn.com/brada/archive/2004/01/09/48925.aspx is the top Google hit for [managed code]. definitely look into CPython. That's a good choice: it's surely more mature than IronPython. But the latter, with Jim Hugunin at the helm, must not be discounted either: as it and Mono mature further, IronPython has the potential of becoming a favorite choice. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Any Python lullabies?
Dustan [EMAIL PROTECTED] wrote: ... Howsabout this? import this The Zen of Python, by Tim Peters Beautiful is better than ugly. ... Anna and I used it as one of our wedding's readings back in 2004 (together with other texts from Dickinson, Petrarca, Lucretius...) and I gave a lightining talk about it at OSCON that year (titled the first Pythonic marriage). I don't consider it a lullaby!-) Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you guys print out a binary tree?
--- bayerj [EMAIL PROTECTED] wrote: Hi, 1 2 3 4 5 0 7 8 9 10 0 0 13 14 15 0 0 0 19 20 0 0 0 0 25 Look at the triangle represented by the non-zero integers. This triangle is a binary tree if we take 5 as the root and walk down on both sides. Are you sure? Is 9 a child of 4 or 10? A binary tree can have up to 2^n - 1 nodes. A matrix can have up to n^2 values, in your case of a half-empty matrix about (n-1)^2. Thanks. I am not concerned about the shape of binary tree. So, let's forget about binary tree. Given a triangle like that, it does not matter which is whose children. How do we nicely present it as tree in an ascii console? __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
pywin32 : scheduled weakup from standby/hiberate ?
On Windows the task scheduler tool can program (the BIOS?) to weak up the machine from standby/hibernate at certain pre-configured times. Can this be done directly through the (py)win32 API? robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Ironpython book?
...which is hardly more proprietary than MS, anyway, since OpenStep does live, btw;-). But certainly not PyObjc bindings for that :) For me, just like for most people I've discussed it with, the reasoning is similar. For example, Chip Turner (once of RedHat, and a major contributor to RPM tools, now a colleague at Google) blogs at http://other-eighty.blogspot.com/ and has a few notes on the matter (e.g. there's nothing like sitting in the middle of a meeting and having the ONLY WORKING LAPTOP in the room. Wireless AND suspend, both working... -- that's about his Powerbook;-). I'd say Chip mostly switched from Linux to Mac for the same reason he mostly switched from Perl to Python though he was a CPAN contributor too. Others feel even more strongly: e.g., Rob Pike, another colleague, apparently just dislikes Linux technically (mostly, I think, X11, but not just that) and that's why he uses Macs (Windows isn't even in the picture, of course). I'm pretty satisfied with linux sitting on my desktop. But I totally agree with you and whomever else that it certainly is a major PITA when it comes to the niceties of mobile computing, including power-save-modes and WLAN. No, I _don't_ want to trick some M$-WLAN-Drivers into running under Linux. And spend 2 1/2 Weeks exploring unknown depths of my ACPI-Bios-support. So - it seems that quality is important, and of course any decent Hacker will run a *nixish OS. Not necessarily: Tim Peters, among my top choices for top Hacker in the PSF Lifetime Award, prefers Windows. So, s/any/most/...!-) Ok. I'll take that back then. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
I am currently working in C# after I spent about 3 years almost only in python, The way I see thinks is that for me we need interfaces in C# to allow for flexibility in using OOP because we must only pass defined and known types at all times so for us to have the flexibility of passing either a Car or a Bus to the Mechanic when we actually only need their fixIt method we need to use a common type that will accommodate the constraint of having the fixIt method. Of course this could also be implemented using an abstract base class but since in C# as well as in Java we don't have multiple inheritance it is better to use an interface for flexibility purpose (for ex. sometime you have to subclass from MarshalByRefObject in order to use the object in a distributed system so inheritance is out of the question as a means to flexibility in that case). So for good and flexible OOP in C# someone should use interfaces because it is the only way to achive the flexibility needed but in python because of duck typing you always get the flexibility without you doing anything special like trying to come up with a type that accommodates some common ground of other types, so as someone say here To use interfaces in python, just do what you would do in Java, except don't use interfaces. So to digress a little, for me the difference is that in C# you are given safety, documentation (read app. domain definitions) and track-ability (read refactoring, intelisense) but you have to code for flexibility while in python you are given flexibility but you have to code for safety and documentation and as far as for track-ability you are usually out of luck. Now many people agree that the safety you are given in C# is usually far from ideal (no app. domain logic safety given) so usually you have to code for that as well as in python, and my opinion is that the documentation provided by type definition wile ok, for best maintainability you have to provide comments anyway about their app. domain means just like you do in python, so the only think that is different is that the lack of track-ability in python is sometime annoying for me now when I'm going back to python after a little bit of C#, but the annoyance is even bigger when in C# I always have to think ahead of time how to make sure that my code if flexible enough to support easy changing. Gheorghe Milas -- http://mail.python.org/mailman/listinfo/python-list
Re: Why new Python 2.5 feature class C() return old-style class ?
(OT) I don't have the same issue with Syntax highlighting, and I use jEdit as my main Python editor (Though some of the dedicated Python IDE's have some nice refactoring/code completion stuff, none has the raw editing power of jEdit). I'm using jEdit 4.3 pre3 - though I don't recall any problems with 4.2 (and it was only a week ago I changed). The Jython plugin enables Structure browsing if you haven't already got it installed. -- http://mail.python.org/mailman/listinfo/python-list
Speed abilities
Ive read a few comments, the usual about it being slower,sometimes vastly slower than a C++ written item but I was wondering if its 'slow' incomparison with what I need. I'm looking at taking two arrays of 12 bytes over an ethernet connection, comparing them, recieving correction data (single byte) from another module over a pipe at approximately 900Hz and using all these with a fairly complex set of algorithms to generate a new set of 12 byte data. This has to be done in a very short time, preferably the same rate of throughput as the 900Hz. Am i asking too much of Python? I find C++/MFC fairly complex and python looked like a great alternative if it hadnt been 'flagged' as slow. Cheers J -- http://mail.python.org/mailman/listinfo/python-list
Re: A 'Box' Function
[EMAIL PROTECTED] wrote: Hey guys. I should warn you, first off, that I'm relatively new to Python. Basically, what I'm trying to do is create a word-wrapping function with the added complication that it add a character at the beginning and end of each line, so that it encloses the text in a sort of 'box': | Like this | The word-wrapping function I'm working with is similar to the one given here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/148061 Does anyone have any ideas on how it could be modified? Am I approaching it the right way? Thanks a bunch! Rather than rewriting wrap(), I would suggest wrapping it with a new function, wrap_box(), that adds the header, line endings and trailer to the lines returned from wrap(). Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading problem
Here the error message: Exception in thread Thread-1: Traceback (most recent call last): File C:\Program Files\Python\lib\threading.py, line 442, in __bootstrap self.run() File G:\Robot teleskop\VRT\test\test2.py, line 25, in run Document.OpenFile('F:/Images/VRT/'+name) File C:\Program Files\Python\Lib\site-packages\win32com\client\dynamic.py, line 496, in __getattr__ raise AttributeError, %s.%s % (self._username_, attr) AttributeError: MaxIm.Document.OpenFile Seems that you think it should doesn't impress the COM-object of type MaxIm.Document very much. Play around with that w/o threads if it works. Diez -- http://mail.python.org/mailman/listinfo/python-list
How to stop winpdb programatically
How can i stop winpdb at a special point in a file? I know that there is set_trace() in pdb which stops execution in the debugger, but how to do this in winpdb? Thanks for hints, Uwe -- http://mail.python.org/mailman/listinfo/python-list
Plug-Ins In A Python Application
Its the Java developer again... I'm working on an application framework that I would like to implement in Python. Part of the application framework is a plug-in model that is similar to the one used in Eclipse. Is it possible to load and use modules containing plug-in code written by third party developers into a running instance of the framework? How would I do this? Do I need to dynamically load the module at runtime? (I will scan a folder in the application direcotry for XML files containing information about the plug-ins, including the modules that implement them.) Thanks, Scott Huey -- http://mail.python.org/mailman/listinfo/python-list
2.5 excitement (was Re: Java Developer Exploring Python)
In article [EMAIL PROTECTED], Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: Consider for example that one of the additions to Python 2.5 (currently in alpha stage) is the inclusion in the Python standard library of ctypes Indeed, I think the inclusion of ctypes is far and away the most exciting thing in 2.5. Really? More than pysqlite? -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- http://mail.python.org/mailman/listinfo/python-list
Re: Plug-Ins In A Python Application
[EMAIL PROTECTED] wrote: Its the Java developer again... I'm working on an application framework that I would like to implement in Python. Part of the application framework is a plug-in model that is similar to the one used in Eclipse. Is it possible to load and use modules containing plug-in code written by third party developers into a running instance of the framework? How would I do this? Do I need to dynamically load the module at runtime? (I will scan a folder in the application direcotry for XML files containing information about the plug-ins, including the modules that implement them.) Thanks, Scott Huey Look at the imp module. Any module can be imported at any time in your code. The import statement is usually used to the top of a file, making it *look* like a declaration, but in fact it may be executed anywhere. The import statements does, however, hard code its module's name. For a plugin system, you'll probably want to import a module given a string containing its name. The imp module provides this as well as access to many of the features of the import mechanism. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Updated PEP 359: The make statement
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class name tuple: __metaclass__ = callable block so that you don't have to lie to your readers when you're not actually creating a class. I've also added some new examples and expanded the discussion of the old ones to give the statement some better motivation. And I've expanded the Open Issues discussions to consider a few alternate keywords and to indicate some of the difficulties in allowing a ``__make_dict__`` attribute for customizing the dict in which the block is executed. PEP: 359 Title: The make Statement Version: $Revision: 45366 $ Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $ Author: Steven Bethard [EMAIL PROTECTED] Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 05-Apr-2006 Python-Version: 2.6 Post-History: 05-Apr-2006, 06-Apr-2006, 13-Apr-2006 Abstract This PEP proposes a generalization of the class-declaration syntax, the ``make`` statement. The proposed syntax and semantics parallel the syntax for class definition, and so:: make callable name tuple: block is translated into the assignment:: name = callable(name, tuple, namespace) where ``namespace`` is the dict created by executing ``block``. This is mostly syntactic sugar for:: class name tuple: __metaclass__ = callable block and is intended to help more clearly express the intent of the statement when something other than a class is being created. Of course, other syntax for such a statement is possible, but it is hoped that by keeping a strong parallel to the class statement, an understanding of how classes and metaclasses work will translate into an understanding of how the make-statement works as well. The PEP is based on a suggestion [1]_ from Michele Simionato on the python-dev list. Motivation == Class statements provide two nice facilities to Python: (1) They execute a block of statements and provide the resulting bindings as a dict to the metaclass. (2) They encourage DRY (don't repeat yourself) by allowing the class being created to know the name it is being assigned. Thus in a simple class statement like:: class C(object): x = 1 def foo(self): return 'bar' the metaclass (``type``) gets called with something like:: C = type('C', (object,), {'x':1, 'foo':function foo at ...}) The class statement is just syntactic sugar for the above assignment statement, but clearly a very useful sort of syntactic sugar. It avoids not only the repetition of ``C``, but also simplifies the creation of the dict by allowing it to be expressed as a series of statements. Historically, type instances (a.k.a. class objects) have been the only objects blessed with this sort of syntactic support. The make statement aims to extend this support to other sorts of objects where such syntax would also be useful. Example: simple namespaces -- Let's say I have some attributes in a module that I access like:: mod.thematic_roletype mod.opinion_roletype mod.text_format mod.html_format and since Namespaces are one honking great idea, I'd like to be able to access these attributes instead as:: mod.roletypes.thematic mod.roletypes.opinion mod.format.text mod.format.html I currently have two main options: (1) Turn the module into a package, turn ``roletypes`` and ``format`` into submodules, and move the attributes to the submodules. (2) Create ``roletypes`` and ``format`` classes, and move the attributes to the classes. The former is a fair chunk of refactoring work, and produces two tiny modules without much content. The latter keeps the attributes local to the module, but creates classes when there is no intention of ever creating instances of those classes. In situations like this, it would be nice to simply be able to declare a namespace to hold the few attributes. With the new make statement, I could introduce my new namespaces with something like:: make namespace roletypes: thematic = ... opinion = ... make namespace format: text = ... html = ... and keep my attributes local to the module without making classes that are never intended to be instantiated. One definition of namespace that would make this work is:: class namespace(object): def __init__(self, name, args, kwargs): self.__dict__.update(kwargs) Given this definition, at the end of the make-statements above, ``roletypes`` and ``format`` would be namespace instances. Example: gui objects In gui toolkits, objects like frames and panels
Re: 2.5 excitement (was Re: Java Developer Exploring Python)
Aahz wrote: In article [EMAIL PROTECTED], Roy Smith [EMAIL PROTECTED] wrote: Indeed, I think the inclusion of ctypes is far and away the most exciting thing in 2.5. Really? More than pysqlite? To me much more. After all, why would I need pysqlite if I use PostgreSQL? ;-) /me remembering the old days of Clipper Summer '87, when he'd use DBFs all over... ;-) -- Jorge Godoy [EMAIL PROTECTED] Quidquid latine dictum sit, altum sonatur. - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
[EMAIL PROTECTED] wrote: I'm coming from a Java background, so please don't stone me... I see that Python is missing interfaces. The concept of an interface is a key to good programming design in Java, but I've read that they aren't really necessary in Python. I am wondering what technique I can use in Python to get the same benefits to a program design that I would get with interfaces in Java. For example, if I want to have a program with a Car object, and a Bus object. I want both of these objects to present a common group of methods that can be used by Mechanic objects, but slightly different methods that can be used by Driver objects. In Java I would accomplish this by defining an IFixable interface that would be implemented by both the Car and Bus objects. Mechanic objects would work with any object implementing this interface. How would I approach this problem in Python? I think I would use an abstract class instead of an interface for IFixable, since Python supports multiple inheritance, but I'm not sure this is correct. Thanks for any suggestions. Scott Huey Everyone is getting off track here. Java has interfaces because it doesn't support multiple inheritance. Python supports MI, so you don't need to use the seperate concept of an interface. You're right that an abstract class is the equivilent of an interface. Just create a ABC that raises NotImplementedExceptions for each of the methods, and use that class as one of the base classes. Of course, like a lot of stuff in python, this won't throw an exception at 'compile-time', only when you try to invoke a method that has no implemenation. The general wisdom is that Abstract Base Classes aren't pythonic though. If you want to be pythonic, just implement the methods for your 'interface', and (if necessary) check for their existance with hasattr before calling (or even just call the method and you'll get an attribute error anyway). This is referred to as duck-typing. If it looks like a duck, and quacks like a duck, then for all practical purposes it supports the 'duck' interface. -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5 excitement (was Re: Java Developer Exploring Python)
In article [EMAIL PROTECTED], Jorge Godoy [EMAIL PROTECTED] wrote: Aahz wrote: In article [EMAIL PROTECTED], Roy Smith [EMAIL PROTECTED] wrote: Indeed, I think the inclusion of ctypes is far and away the most exciting thing in 2.5. Really? More than pysqlite? To me much more. After all, why would I need pysqlite if I use PostgreSQL? ;-) Heh. Since we're just finally turning in our 100% first draft of Python for Dummies, I tend to think more in terms of what a Python newbie will find useful. On that front, I think that pysqlite is much more important because it finally gets rid of the excuse for using Berkeley for simple database purposes. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5 excitement (was Re: Java Developer Exploring Python)
Aahz wrote: Heh. Since we're just finally turning in our 100% first draft of Python for Dummies, I tend to think more in terms of what a Python newbie will find useful. On that front, I think that pysqlite is much more important because it finally gets rid of the excuse for using Berkeley for simple database purposes. You're right Aahz. It is more useful. I was just being smart with you :-) Now it will be easier to provide that classic phone book example in your book :-) -- Jorge Godoy [EMAIL PROTECTED] Quidquid latine dictum sit, altum sonatur. - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: Plug-Ins In A Python Application
On Apr 18, 2006, at 9:58 AM, [EMAIL PROTECTED] wrote: Its the Java developer again... I'm working on an application framework that I would like to implement in Python. Part of the application framework is a plug-in model that is similar to the one used in Eclipse. Is it possible to load and use modules containing plug-in code written by third party developers into a running instance of the framework? How would I do this? Do I need to dynamically load the module at runtime? (I will scan a folder in the application direcotry for XML files containing information about the plug-ins, including the modules that implement them.) Well, the state of the art in Python plugins is moving towards Eggs: http://peak.telecommunity.com/DevCenter/PythonEggs Though that might be a bit much for you to jump into considering you're just starting out in Python. However, if you do learn it now, you won't have to learn it again later when everyone's using it :) Jay P. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Any Python lullabies?
Christos Georgiou wrote: Since there have been python limmericks, are there any Python lullabies that I can sing to my newborn son (actually, born yesterday)? I tried to murmur some select parts from the tutorial, but he somehow wasn't very interested :) There is something near the end of the Camel book (p. 552ff). This isn't exactly python, but the baby probably won't see the difference. SCNR, Ralf -- http://mail.python.org/mailman/listinfo/python-list
RE: Slicing matrix
In Chinese, we say cutting Tofu. Cheese is really much harder to cut than Tofu. :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Anthony Liu Sent: Monday, April 17, 2006 8:44 PM To: python-list@python.org Subject: Re: Slicing matrix Hi, James, I just realized that my English is so good that I can joke with slangs. Hopefully it isn't that offensive. Otherwise, I am sorry. --- James Stroud [EMAIL PROTECTED] wrote: Anthony Liu wrote: I figure it out, too. NumArray is so flexible, it's like cutting the cheese. Some idioms do not translate so well. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Plug-Ins In A Python Application
[EMAIL PROTECTED] wrote: Is it possible to load and use modules containing plug-in code written by third party developers into a running instance of the framework? How would I do this? Do I need to dynamically load the module at runtime? (I will scan a folder in the application direcotry for XML files containing information about the plug-ins, including the modules that implement them.) a simple approach is to do something like for file in list_of_plugins: ns = {} execfile(file, ns) # pick up interesting objects from the namespace dictionary # e.g. callback = ns[callback] where individual plugins might look something like # my plugin def callback(event): pass # do something here You can prepopulate the namespace to make application-specific objects available for the plugins: context = MyContext() for file in list_of_plugins: ns = dict(context=context) execfile(file, ns) which allows the plugins to do e.g. # my plugin def callback(event): pass context.register(callback) or you can use a plugin initialization function: context = MyContext() for file in list_of_plugins: ns = {} execfile(file, ns) setup = ns[setup] setup(context) where the plugins look like: def callback(event): pass def setup(context): context.register(callback) and so on. To learn more about this, look up exec/execfile and __import__ in the library reference. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
[EMAIL PROTECTED]: If it looks like a duck, and quacks like a duck, then for all practical purposes it supports the 'duck' interface. The problem with that of course, is that there's much more to being a duck than being called 'duck'. public interface JarFile { void explode(); } public interface NuclearBomb { void explode(); } http://www.beust.com/weblog/archives/000269.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 359: The make Statement
Carl class some_attribute: Carl __metaclass__ = PropertyMaker Carl def get(self): Carl whatever Carl def set(self,value): Carl whatever Carl But the thing is, if I did that, I'd be lying bastard With Carl the make statement, I could instead write: Carl make property some_attribute: Carl def get(self): Carl # etc. Carl Then I'm not lying about it, and I'm using a more straightforward Carl syntax. I agree. For the specific example of creating properties, you could probably dream up some other syntax, but I suspect this notion will pop up again. Even if you comment the heck out of a lying class definition, tools like pylint and pychecker will think you're creating a class anyway and incorrectly apply their class heuristics to your whatever-it-is. Skip -- http://mail.python.org/mailman/listinfo/python-list
indirect import of standard module
I know this must have been answered a hundred times, but I must be searching on the wrong terminology. Let's say I have a module foo.py that imports os. I make another script called bar.py that imports foo.py and now I want to use, say, os.walk in bar.py. Which is faster or more correct or whatever: Do I import os at the top of bar.py and use foo's functions? Or do I call os.walk by writing foo.os.walk? Sorry for lack of proper terminology. I read the module parts of the Tutorial but couldn't find it there. Rick -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5 excitement (was Re: Java Developer Exploring Python)
In article [EMAIL PROTECTED], Aahz wrote: On that front, I think that pysqlite is much more important because it finally gets rid of the excuse for using Berkeley for simple database purposes. Apologies if I'm being obtuse, but how does including the pysqlite wrapper module change anything? You still need to download and install SQLite, so what's the point of including a wrapper for something you may or may not have? Why is pysqlite included, for example, and not MySQL-Python or postgresql or whatever? -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5 excitement (was Re: Java Developer Exploring Python)
Jon Ribbens wrote: Apologies if I'm being obtuse, but how does including the pysqlite wrapper module change anything? You still need to download and install SQLite I'm pretty sure the distributors will do this for you, just as they've included zlib, dbm, tcl/tk, openssl, and many other standard libraries over the years. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
This is quite possibly one of the funniest examples of how Duck Typing can break down that I have ever seen!On 4/18/06, Rene Pijlman [EMAIL PROTECTED] wrote: [EMAIL PROTECTED]:If it looks like a duck, and quacks like a duck, then for all practicalpurposes it supports the 'duck' interface.The problem with that of course, is that there's much more to being a duck than being called 'duck'.public interface JarFile {void explode();}public interface NuclearBomb {void explode();}http://www.beust.com/weblog/archives/000269.html --René Pijlman--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
datetime question
Hi, I need to get the date and time under Windows and Linux but need the information visible to the user (cannot find my words) not the sytem information (ex: a PC setup on greenwich but the date/time displayed are relative to some other place. Regards, Philippe -- http://mail.python.org/mailman/listinfo/python-list
difference between class and static methods?
I've been reading up on them, but I don't quite understand how they differ in practice. I know how each is implemented, and from C# I already know what a static method is. But I won't assume that it's the same in Python. And on top of that, both the class and static methods of Python seem to do what a C# static method does, so I don't see the difference yet. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Fredrik Lundh schrieb: Jonathan Daugherty wrote_ # In Python, you would simply call the functions you need. No need to # make things that rigidly defined. Except when you need to handle exceptions when those methods don't exist. I think interfaces can definitely be useful. so with interfaces, missing methods will suddenly appear out of thin air ? He probably means that with interfaces one could test compliance with the interface as a whole instead of testing each member and each signature as a single piece. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
2.5a1 import of .dlls
I've re-built an extension module (as a .dll) using the 2.5a1 release. Unexpectedly, I'm not able to simply import it (not the way I can when building it for 2.3). Using imp.load_dynamic() the import succeeds. import minx # Implemented in a .dll - fails Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named minx import imp# Workaround import os minx = imp.load_dynamic('minx', os.getcwd() + '\\minx.dll') I couldn't find anything to indicate this is by design in 2.5a1 (I did read the PEP 328: Absolute and Relative Imports) - am I doing something wrong? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Roy Smith schrieb: Python is a very dynamic language. Java is a very static language. What is the difference between static and very static? Is Java more static than Fortran I? ;) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime question
Philippe Martin wrote: Hi, I need to get the date and time under Windows and Linux but need the information visible to the user (cannot find my words) not the sytem information (ex: a PC setup on greenwich but the date/time displayed are relative to some other place. Something like this? import datetime datetime.datetime.now() datetime.datetime(2006, 4, 18, 16, 19, 42, 159000) print datetime.datetime.now() 2006-04-18 16:19:45.245053 dir(datetime.datetime.now()) ['__add__', '__class__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__str__', '__sub__', 'astimezone', 'combine', 'ctime', 'date', 'day', 'dst', 'fromordinal', 'fromtimestamp', 'hour', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'microsecond', 'min', 'minute', 'month', 'now', 'replace', 'resolution', 'second', 'strftime', 'time', 'timetuple', 'timetz', 'today', 'toordinal', 'tzinfo', 'tzname', 'utcfromtimestamp', 'utcnow', 'utcoffset', 'utctimetuple', 'weekday', 'year'] -- Jorge Godoy [EMAIL PROTECTED] Quidquid latine dictum sit, altum sonatur. - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Rene Pijlman wrote: [EMAIL PROTECTED]: If it looks like a duck, and quacks like a duck, then for all practical purposes it supports the 'duck' interface. The problem with that of course, is that there's much more to being a duck than being called 'duck'. public interface JarFile { void explode(); } public interface NuclearBomb { void explode(); } http://www.beust.com/weblog/archives/000269.html -- René Pijlman Not that I disagree with you, but interfaces don't really guarantee any semantics either. You'd probably need to use Eiffel if you really want to design by contract. public class EarFile implements JarFile { void explode() { HackerTools.WipeHardDrive(); } } -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5a1 import of .dlls
[EMAIL PROTECTED] wrote: I've re-built an extension module (as a .dll) using the 2.5a1 release. Unexpectedly, I'm not able to simply import it (not the way I can when building it for 2.3). Using imp.load_dynamic() the import succeeds. import minx # Implemented in a .dll - fails Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named minx import imp# Workaround import os minx = imp.load_dynamic('minx', os.getcwd() + '\\minx.dll') I couldn't find anything to indicate this is by design in 2.5a1 (I did read the PEP 328: Absolute and Relative Imports) - am I doing something wrong? Extension modules for 2.5 can no longer have the '.dll' extension, they must have a '.pyd' extension. I don't know why this isn't documented somewhere (although I would expect it in Misc/NEWS instead of in PEP 328) - you should filke a bug report. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Any Python lullabies?
Christos Georgiou napisał(a): Since there have been python limmericks, are there any Python lullabies that I can sing to my newborn son (actually, born yesterday)? I tried to murmur some select parts from the tutorial, but he somehow wasn't very interested :) Your son is too small to understand all the good that comes with Python. Let him be a usual newborn, but prepare a harness like I did for my daughter (now nearly 2 y.o.): Tuxpaint. Now it's a big time to add Python scripting to this proggie. ;) Let our children see that programming can be straight and easy. Let them express their thoughts as programs, if they wish to do so. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue can result in nested monitor deadlock
No redesign necessary. I simply make M be the Queue's mutex, via the LQueue class I posted. I am making the modest suggestion that this feature be documented and exposed in the Queue class. -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing backwards compatible code - when?
Is there a list of all of the Python commands and modules that tell when (what version) they were added to Python? I was hoping the new Essential Reference would have it, but it doesn't. Thanks! Bob -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Peter Maas [EMAIL PROTECTED] wrote: He probably means that with interfaces one could test compliance with the interface as a whole instead of testing each member and each signature as a single piece. All interfaces (as implemented by Java) prove is that your class has a bunch of methods with the right names and signatures. It doesn't prove that those methods do the right things. It's like having a bouncer in front of a nightclub stopping people saying, You can't come in here unless you tell me you're over 21 and aren't wearing scruffy jeans. OK, I'm happy to tell you that, but if you don't check to make sure it's true, you're going to have a lot of scruffy 18 year olds crashing your party. -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
[EMAIL PROTECTED] napisał(a): Is Python actively developed and supported on Linux? Would it be a viable option for cross-platform application development? Yeas and yeas. Yeas. (That's how we pronounce yes here, in Poland, East Europe). Can anyone recommend an open source IDE for Python that runs on Linux? Komodo. But in most cases you don't need any IDE, just good text editor would make it go. Like Kate, jEdit or similar. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Mouse control in OS X
Hi, I'd like to be able to use python to control the mouse cursor in OS X. ( i.e. programmatically move it around, click things, etc...) Anyone know the best way to do it on a Mac? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Developer Exploring Python
Jarek Zgoda wrote: [EMAIL PROTECTED] napisał(a): Is Python actively developed and supported on Linux? Would it be a viable option for cross-platform application development? Yeas and yeas. Yeas. (That's how we pronounce yes here, in Poland, East Europe). Can anyone recommend an open source IDE for Python that runs on Linux? My favorite IDE: vi Komodo. But in most cases you don't need any IDE, just good text editor would make it go. Like Kate, jEdit or similar. -- Carl J. Van Arsdall [EMAIL PROTECTED] Build and Release MontaVista Software -- http://mail.python.org/mailman/listinfo/python-list
Re: 2.5 excitement (was Re: Java Developer Exploring Python)
In article [EMAIL PROTECTED], Jon Ribbens [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Aahz wrote: On that front, I think that pysqlite is much more important because it finally gets rid of the excuse for using Berkeley for simple database purposes. Apologies if I'm being obtuse, but how does including the pysqlite wrapper module change anything? You still need to download and install SQLite, so what's the point of including a wrapper for something you may or may not have? Why is pysqlite included, for example, and not MySQL-Python or postgresql or whatever? SQLite will be included with the Windows distribution. Not sure about Macs; as Fredrik pointed out, most Linux/BSD distros should make that simple. As for why SQLite, there seems to be a consensus that it's the only truly zero-admin SQL solution that provides decent SQL compatibility and performance. For more about the decision, I suggest you read the python-dev archives. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- http://mail.python.org/mailman/listinfo/python-list
Re: Speed abilities
Coyoteboy [EMAIL PROTECTED] writes: Ive read a few comments, the usual about it being slower,sometimes vastly slower than a C++ written item but I was wondering if its 'slow' incomparison with what I need. I'm looking at taking two arrays of 12 bytes over an ethernet connection, comparing them, recieving correction data (single byte) from another module over a pipe at approximately 900Hz and using all these with a fairly complex set of algorithms to generate a new set of 12 byte data. This has to be done in a very short time, preferably the same rate of throughput as the 900Hz. Am i asking too much of Python? I find C++/MFC fairly complex and python looked like a great alternative if it hadnt been 'flagged' as slow. Cheers J There is no way to tell from this info. This is a real-time problem. If you assume 1GHZ CPU, 10 clks/instruction, 1 instructions/event then you require 0.001 sec/event. 900Hz event rate means you only have 0.0011 sec/event available, which is the same order of magnitude. Chances are, variation in the event rate or in the OS response time would violate this small safety factor, even if the assumptions were dead on. So you need a faster machine or fewer instructions. Some instructions will be used in the OS and interface stack, no matter what language you use. Some will be used in your fairly complex set of algorithms. You may have used up your 1 instructions without getting around to Python. Even assembler might be too slow. If you did implement in Python and found it was too slow by a moderate factor (e.g., you could only handle 500Hz event rate), then you can stay in python to explore alternative implementations. E.g., multiple processors in parallel, more efficient algorithms, ctypes or pyrex to speed up the python. In terms of the overall project notion-to-delivery duration, implementing in Python might be the right first step on your way to an assembler implementation. -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list