Re: indentation
I can't remember having seen any other standard so far. there is this meme flowing around: Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. I Allways thought that was some of the interpretations of the ZEN of Python, so, who can enlighten me of the origin? Harald -- http://mail.python.org/mailman/listinfo/python-list
messages from pylint - need some reasoning
Hello, I am pylinting some software of mine. Now pylint throws messages, and I know of pylint --help-msg to get some more text. What is missing out are explanation, WHY some things are bad, so I am searching for explanations and ways to improve my code: Example: 1st) to many local variables I searched big G, and found: many local variables make it harder to refactor, as all those variables will have to be passed to the factored-out function. Even worse when the local variables are mutable, and have to be passed back. Similiar explanations I am searching for 2nd) to many statements (in function / method) okay, shorter functions are easier to grasp. Is there any more reason? 3rd) space before operators, space after operators, space after , that's just readability, or is there some deaper reasoning? 4th) maximum line length yeah, more then 80 chars suck when outputting to punching cards; but any 21century reason for this default? (can and have made it higer) 5th) Too many branches Used when a function or method has too many branches, making it hard to follow. So what is the preferred way of repairng this? Especially if the branches are something like: if checkforcondition1(): # inlinecode # to handlecondition1 if checkforcondition2(): # inlinecode # to handlecondition1 [...] and multiple conditions can be present at the same time. Something like mytodolist=[ (tester1, handler1), (tester2, handler2), ...] and for tester, handler in mytodolist: if tester(situation): handler(situation) would get rid of the branches; BUT... I cannot see how that is really easier to follow. Who can give me some hints to improve my code or arguments to switch of that warnings? best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
translating create Semaphore to Linux
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,stringincludinginterfaceandport) rt=win32event.WaitForSingleObject (hSem, 0) if rt != win32event.WAIT_TIMEOUT: really_do_start_my_app() else: print application allready running to make sure that only ONE instance of the application is running at a time. (as it implements a local webserver, that is necessary. Two webservers listening on one port is bad) Now I am going to make this application run on Linux. How can I get similiar behaviour on Linux? I know of the .pid files that get written by some server processes ... BUT they do not get cleaned up on unclean shutdown of the application. is there some better method? Or some module which wraps the details of .pid-files quite nicely? (like trying to remove to check if other instance is still running, failing properly on missing write privs etc.) best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: translating create Semaphore to Linux
Tim, ... why use a Semaphore rather than a Mutex? as much as I understood the documentation at MSDN http://msdn.microsoft.com/en-us/library/ms686927(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms686946(VS.85).aspx a mutex seems to be nothing else than a special case of a semaphore? That is, a semaphore can be created to allow MAX_SEM_COUNT concurrent runners, and MUTEX defaults to one and only one ... The other api-spells are identical, like wait_for_...; so propably I stumbled on the working Semaphore Code before, or in some ancient win32 wrapper createMutex was not documented or something in that aspect:) Or why notsimply use the bound socket as its own mutex? I know Windows won't allow you to rebind the same socket to the same addr/port in two different processes (unless perhaps you play some trickery with the socket options). My experience was that this is correct for certain values of allow and trickery. Sometimes the binding seems to get allowed but does not work. Main reason is that the socket-bind happens somewhere in medusa or someotherhttpsserverframeworkiuse; so to use it as a semaphore I would have to dig there. I am not totally sure what trickery on socket is played down there; and I prefer to stay as far away as possible from that area. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Corrupted images after attempting to store PNG images as BLOBs in MySQL?
Keith, still becoming familiar with python. Originally we were not using the database to store images, but we started testing out storing images there as well as meta-data. just a remark: I am using PostgreSQL to store BLOB-Data as there are Images, PDFs, Microsoft Office Files. The system (application, network, database) is working quite okay up to around 10 Megabytes per file. And that for around 7 years now. The database itself comfortably works with up to 1Gig per object, just the database drivers / network stack / bandwith / users patiance for answers really gets... unreliable above 10 Meg per file. Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to add a property to an instance?
Does anyone know if it is possible to add a property to an instance at runtime? I didn't see anything about it in the standard library's new module, google hasn't turned up much either. yes. You need nothing special, just add it: class fish(object): pass a=fish() a.legs=4 print a.legs (or print (a.legs) on Python 3.0 and above) so you add a property to an instance and proove that Darwin was right in one go. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)
Evan, I hear this problem is fixed in 0.6.8, but unfortunately there's no standalone installer for py2exe 0.6.8 - the most recent version that Maybe you can solve your problem via updating the build_exe.py after installing py2exe 0.6.6 So: a) use the 0.6.6 installer b) update the build_exe.py from 0.6.8 Possible? Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Success stories
Which big aplications are written in python. I see its development, There are no big applications written in Python. Big applications are written in JAVA or COBOL or C# or other legacy programming systems. If you programm in Python, your applications become quite small. Only frameworks in Python are big. best wishes Harald Join us @ EuroPython 2008 in Vilnius to have more fun with Python Submit your talk NOW www.europython.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-by-example - new online guide to Python Standard Library
Tobu, I like this idea. Deducting from an example is really another way to wisdom. What struck me as most diffuclt to understand: abs(-5.5) - 5.5 - you are using - as symbol for will give the result, which is really, really hard to parse. Take something else, please. Unicode has THAT many cool symbols. Or just - or -= or whatever. Thanks for sharing that work! Harald -- http://mail.python.org/mailman/listinfo/python-list
how long do the different python-vm bytecodes take?
I looked at the virtual machine bytecode of python programs: def f(whatever): text=Hallo+whatever return text import dis dis.dis(f) 2 0 LOAD_CONST 1 ('Hallo') 3 LOAD_FAST0 (whatever) 6 BINARY_ADD 7 STORE_FAST 1 (text) 3 10 LOAD_FAST1 (text) 13 RETURN_VALUE and now I am curious: how long does one LOAD_FAST take? I am thinking of something like back in the assembler-world, where there existed tables like: LDA - 2 cycles BNE - 2 cycles, 3 on branch of course, the real time is dependand on many factors, esp. the speed of the processor. But ... is there a relative scale somewhere? Somehting like LOAD_CONST 1 arbitraryUnit LOAD_FAST 1.9 arbitraryUnits RETURN_VALUE 8.0 arbitraryUnits ??? my Google queries did not reveal anything usefull so far. Any hints? -- http://mail.python.org/mailman/listinfo/python-list
Re: app runs fine with interpreter, but not under py2exe
Doug, as I quickly noticed that library.zip does NOT contain ANY .pyd files. I'm guessing that they can't be in library.zip for a reason (i.e., they are DLL files, essentially, and thus must be readily available to be loaded into memory). .dll and .pyd files CAN be within library.zip and even within the single-file-exe. There is some Hellermagic within _memimporter.pyd that loads the .dll and .pyd from a zipfile. When you scan the build_exe.py, you will explicitely find: print *** finding dlls needed *** dlls = self.find_dlls(extensions) self.plat_finalize(mf.modules, py_files, extensions, dlls) dlls = [item for item in dlls if os.path.basename(item).lower() not in self.dll_excludes] # should we filter self.other_depends in the same way? Is there a work-around for this, then? -rwxr-xr-x 1 morse None 26624 Nov 28 2006 dist/multiarray.pyd -rwxr-xr-x 1 morse None 348160 Nov 8 16:16 dist/numpy/core/ multiarray.pyd -rwxr-xr-x 1 morse None 192512 Nov 8 16:16 dist/numpy/core/ umath.pyd -rwxr-xr-x 1 morse None 54272 Nov 28 2006 dist/umath.pyd let's try: your mission is, should you chose to accept it, to make a py2exed application to load two different multiarray.pyd, who are on the visible level only different by their place in the file system. So, please make a minimal script: import multiarray import numpy.core.multiarray as ncmultiarray and, using Peters test from multiarray import zeros assert zeros((1,), 1) == array([0], '1') and check, if those multiarrays are the correct ones. If yes, you can try to build upon this by making all imports explicit as described above. (Yes, I know, that's not necessary in plain python ... but it saved me in some weird import from .zip and import from database situations.) (a) tell py2exe how to *correctly* handle multiple multiarray.pyd and umath.pyd files somewhere deep inside I have a BAAAD feeling about to files having the same name but very very different content - but that's not your call in this situation. Are you able to build that libraries yourself? Then you could move down and build the multiarray.pyd as ncmultiarray.pyd and adjust all imports accordingly. (lots of work) manual create the stub-like .pyc files that py2exe creates to point to these alternate .pyd files and then place these stubs in library.zip/numpy/core? As much as I know there is only one central loader stub, which ensures that .dlls get imported from memory, see above. py2exe does not create something like p2elma.py containing import multiarray.pyd best luck, and please take your time to scan the py2exe.org wiki, there are many similiar challanges with various packages, maybe you get another workaround-idea (and, if we find one, PLEASE put it down there for others to learn) best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: app runs fine with interpreter, but not under py2exe
Doug, Precision.py is part of the Numeric package. AFAIKT, the problem is during the module initialization. The first lines of Precision.py are: from multiarray import zeros import string [.] and your program is crashing on the lst.append( (zeros( (1,), t ).itemsize()*8, t) ) -- Line 18 line... Please, try the following: import multiarray from multiarray import zeros import string (adding the line import multiarray before zeros are imported from it) I used this workaround with various packages I py2exed - maybe it also works for you? please keep us updated, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2exe and Multi Treading problem.
Farsheed Ashouri , Here is my script #** #** import threading import socket def openSocket(portNum): mySocket = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) mySocket.bind ( ( '', portNum ) ) mySocket.listen ( 1 ) channel, details = mySocket.accept() msg = channel.recv(4096) class CmdPortThread( threading.Thread ): def run( self ): openSocket(6000) def fakeCommandPort(): CmdPortThread().start() fakeCommandPort() If works perfect with python 2.5.2. Now I want to convert it to standalone program. but the .exe file fails to run without any error. are you sure that it fails to run? I expect it to run, and exit immediately after fakeCommandPort(). That is: there is nothing more to do in the main thread, so the application exits. To learn more, add prints and use the usual if __name__=='__main__' class CmdPortThread( threading.Thread ): def run( self ): print Thread CmdPortThread running openSocket(6000) if __name__=='__main__': print Mese running fakeCommandPort() print Mese done starting Thread Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: app runs fine with interpreter, but not under py2exe
Doug, File VisionTrainer.py, line 49, in module File SessionController.pyc, line 53, in module File VisionEgg\__init__.pyc, line 42, in module File VisionEgg\ParameterTypes.pyc, line 28, in module File Numeric.pyc, line 93, in module File Precision.pyc, line 26, in module File Precision.pyc, line 23, in _fill_table File Precision.pyc, line 18, in _get_precisions TypeError: data type not understood to my knowledge, data type not understood is a message not from core Python, but rather thrown from your code. What is happening around Precision.py, line 18? What does trigger that exception? My guess is, you are dealing with some custom imported modules which define data types. (PIL does something similiar for supported images)... that is, some module is trying to import all definitions from a specific directory. That dynamic importing fails within py2exe --- all the importing has to be definit at py2exing-time. Please ready http://www.py2exe.org/index.cgi/PIL_and_py2exe and the other receipe on py2exe.org and try to adapt that knowledge to your application. Harald Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: translating Python to Assembler...sorry if this is duplicated...it's unintentional
My expertise, if any, is in assembler. I'm trying to understand Python scripts and modules by examining them after they have been disassembled in a Windows environment. Maybe you could also profit from diassembling Pythons bytecode into MNEmonics of the Python Virtual Machine ? http://docs.python.org/lib/module-dis.html Because disassembling python scripts with any other disassembler will not likely lead to something usefull: a) the .pyc and pyo files are in Python Bytecode, that is assembler for the Python Virtual Machine Processor, disassemble with the mentioned module b) python2x.dll is in i386-Assembler, but contains the virtual machine. Understanding that will you will learn a lot of great programming concepts from some of the most brilliant minds on this planet; but will give you no hint to understand Python scripts, as they are running on top of that VM. Like disassembling the Hybrid Power Drive of a Lexus GS450h will teach you nothing about navigating from Berlin to Paris. Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: building psycopg2 on windows using mingw, cannot find -lpq
The compile works, BUT linking fails: 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build -Lc:/postgres/83RC2/lib Are you sure using forward slashes in the path works here? Not at all. But that commandline is generated by setup.py, not by me : ( and setup.py extracts the paths from pg_config so: I have no idea how to make it use backslash :( Thanks for the idea, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: building psycopg2 on windows using mingw, cannot find -lpq
I use psycopg2 all the time on windows. I use the binary installer instead of source. Works great for me. -Tom Me2. Just in 7 out of 200 it does not work with the currently available binary installer, on some startups, so I decided to follow a recommendation out of the psycopg2 list to compile it from trunk :( Harald -- http://mail.python.org/mailman/listinfo/python-list
building psycopg2 on windows using mingw, cannot find -lpq
The compile works, BUT linking fails: 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build \lib.win32-2.5\psy copg2\_psycopg.pyd c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lpq collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 if I google for the error ld.exe: cannot find -lpq there is allways the information that the lib-dir of libpq is missing; but : -Lc:/postgres/83RC2/lib is clearly in the commandline, and within c:/postgres/83RC2/lib there is one libqp.lib What am I missing? any hints? Best wishes, Harald (complete output: c:\mingw\bin\gcc.exe -mno-cygwin -shared -s build \temp.win32-2.5\Release\psycopg \psycopgmodule.o build\temp.win32-2.5\Release\psycopg\pqpath.o build \temp.win32- 2.5\Release\psycopg\typecast.o build\temp.win32-2.5\Release\psycopg \microprotoco ls.o build\temp.win32-2.5\Release\psycopg\microprotocols_proto.o build \temp.win3 2-2.5\Release\psycopg\connection_type.o build\temp.win32-2.5\Release \psycopg\con nection_int.o build\temp.win32-2.5\Release\psycopg\cursor_type.o build \temp.win3 2-2.5\Release\psycopg\cursor_int.o build\temp.win32-2.5\Release\psycopg \lobject_ type.o build\temp.win32-2.5\Release\psycopg\lobject_int.o build \temp.win32-2.5\R elease\psycopg\adapter_qstring.o build\temp.win32-2.5\Release\psycopg \adapter_pb oolean.o build\temp.win32-2.5\Release\psycopg\adapter_binary.o build \temp.win32- 2.5\Release\psycopg\adapter_asis.o build\temp.win32-2.5\Release\psycopg \adapter_ list.o build\temp.win32-2.5\Release\psycopg\adapter_datetime.o build \temp.win32- 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build \lib.win32-2.5\psy copg2\_psycopg.pyd c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lpq collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Intranet Project - Rad Or Waterfall
Option 1 - Waterfall I recommend to google waterfall. First hit after those beatifull pictures will be: http://en.wikipedia.org/wiki/Waterfall_model Within the first paragraph there is: Ironically, Royce was actually presenting this model as an example of a flawed, non-working model.(Royce 1970) So I cannot fight the feeling of seeing the realisation of a xkcd- strip when reading about waterfall models... Harald -- http://mail.python.org/mailman/listinfo/python-list
create pywintypes.CreateGuid() compatible guids on Linux ?
Hello, I created lots of guids via pywintypes.CreateGuid() on windows. Now I would like to run the same software on Linux / Solaris / FreeBSD. So I should produce compatible GUIDS on that systems. compatible having the meaining: Providing similiar likelehood of collisions. of course google python guid leads directly to http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/163604, but ... will it blend? any ideas what could help me to research? Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: OPLC purchase period extended
[http://laptopgiving.org/en/terms-and-conditions.php] I'm sure that some people would be willing to serve as middleware... So, which US-Pythoneer is willing to serve as middleware for my buying of the XO? Please contact me. Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Straße 49 70435 Stuttgart 0173/9409607 fx 01212-5-13695179 - EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned! -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
Michele, At work we are shopping for a Web framework, so I have been looking at the available options on the current market. just because you were involved in creating an own version of Python does NOT free you from the social obligation to create your own Python web framework. So stop shopping and start announcing your own pwf like all other Python programmers do. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: import data.py using massive amounts of memory
Note that once it has made the .pyc file the subsequent runs take even less memory than the cpickle import. Could that be the compiler compiling? Without knowing to much details about that process, but from 2.4 to 2.5 the compiler was totally exchanged, whatever to AST. That would explain the drop from 8Meg - 2.2 Meg. Harald -- http://mail.python.org/mailman/listinfo/python-list
EuroPython: Draft program posted, today last day of early registration
Dear Pythonistas! On www.euroypython.org the draft program and timetable has been posted! http://www.europython.org/sections/tracks_and_talks/draft-timetable Do a click and check out the fabulous talks. Then check in, best today, the 8th of June, the last day of early bird registration. EuroPython 2007 will take place at the Reval Hotel Lietuva in Vilnius, Lithuania from Monday 9th July to Wednesday 11th July. See you there! Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
EUROPYTHON: Talk submission deadline extended up to Friday, 25th of May
We took longer then planned to open the registration. Some potential speakers came in late. To make it even, we extended talk submission deadline for ONE WEEK. New deadline is Friday, 25th of May 2007. So, if you made a fortune with Python: tell others about it at EuroPython. If you have a great distributed revision control system, which has been stable on 9.3 for months, submit a talk to EuroPython and announce 1.0 there! If you have a fantastic new keyword, graphic library or web framework for Python: submit your talk to EuroPython. If you are doing something interesting with Python - grab the chance to visit Lithuania and tell Europe about it. And if you do not wanna give a talk: block 9-11 July 2007 in your calendar, adjust your budget, tell your customers that you will be in Vilnius. Again: Talk submission deadline of EuroPython 2007 extended to Friday, 25th of May 2007 Submit your talk @ www.europython.org For the EuroPython 2007 organizers Harald Armin Massa -- http://mail.python.org/mailman/listinfo/python-list
Re: While we're talking about annoyances
Steven, def index(sequence): decorated = zip(sequence, xrange(len(sequence))) decorated.sort() return [idx for (value, idx) in decorated] would'nt that be equivalent code? def index(sequence): return [c for _,c in sorted((b,a) for a, b in enumerate(sequence))] tested, gave same results. But worsens your doc2code ratio :) Harald Armin Massa -- -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle and unicode data
loo ping, But it's not what I call a 'clean' solution and I suppose that it must exist another way to force the client DB to use UTF8, or another solution to get my data. I share your feeling. I asked a similiar question ~1 year ago; and: your solution is the only one. The oracle-libs get their encoding from the environment. I also learned that it often is helpfull to first set the environment and THEN import cx_Oracle (which loads the oci.dll) import os os.environ[NLS_LANG] = .UTF8 import cx_Oracle cur.execute(select DESCRIPTION from DEC_DESCRIPTION where DEC_DESCRIPTION_ID = 1792528) Additionally: UTF8 has different numbers of bytes per character. Your select will only succeed for the time that DESCRIPTION encoded in UTF8 is shorter or equal to length(DESCRIPTION) I got into the habbit to cast those fields to NVARCHAR2(as big as I think it may get) Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Questions about app design - OOP with python classes
if hmmCurrentHeight = hinCriticalHeight: then you should instantly recognise that there's a problem. all civilized nations but one use metric systems. Of course there is a problem if you spot inches somewhere. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: New Pythin user looking foe some good examples to study
Johnny, look no further than your harddrive. The Python Standard Lib is full of code examples of Python programming for various uses. Just find where your packagemanager has installed them; within windows it is usually python24/lib or python25/lib I suspect them to be below usr/lib on linux. best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: win32com.client
rzed, 1) In your browser, enter this URL:http://sourceforge.net/projects/pywin32/ [...] Try those steps, then try importing win32com again. man, you are SO 2005. Could'nt you please make a screen cap video, upload it to youtube and give a pointer to it on your blog? *wink* Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: win32com.client
btw... the statement with youtube was a joke. I really applaud rzed you for giving this detailed descriptions, people like him make the spirit of c.l.p.: People get help here WAY over what commercial support usually gets you. Thanks for doing that, rzed! best wishes, HArald -- http://mail.python.org/mailman/listinfo/python-list
sheeps be carefull of Python
sometimes Python is more dangerous than documented: http://news.nationalgeographic.com/news/2006/09/060915-python-ewe.html Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Roundtrip SQL data especially datetime
One side effect of this being third party code is that hosting services may not have it available, even when they have both Python and MySQL up. This is never a problem with Perl or PHP, so that's a negative for Python. I for one think it is a good thing to not have MySQL adapters integrated into Python core. Neither the philopsophie, nor the licence of the two products fit together. But maybe that's because I am a PostgreSQL zealot - and PostgreSQL and Python is really a match made in heaven. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: codecs - where are those on windows?
Fredrik Lundh schrieb: If your installation directory is C:\Python25, then look in C:\Python25\lib\encodings that's only the glue code. the actual data sets are provided by a bunch of built-in modules: import sys sys.builtin_module_names ('__builtin__', '__main__', '_ast', '_bisect', '_codecs', '_codecs_cn', '_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr', '_codecs_tw', ... So, it should be possible to do a custom build of python24.dll / python25.dll without some of those codecs, resulting in a smaller python24.dll ? It will be some time untill my apps must support Chinese and Japanese... Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?
robert, Interprocess communication is tedious and out of questio [...] I expect to be able to directly push around Python Object-Trees between the 2 (or more) interpreters by doing some careful locking. Please do yourself a favour and have a look at pyro. pyro makes InterComputer and InterProcess Communication a snap. And it allows you to push around Python Objects not only between processes, but computers. Maybe it solves your problem much easier and even more than you want to solve it now by being able to use more then one computer. Harald -- http://mail.python.org/mailman/listinfo/python-list
codecs - where are those on windows?
I stumbled apon a paragraph in python-dev about reducing the size of Python for an embedded device: In my experience, the biggest gain can be obtained by dropping the rarely-used CJK codecs (for Asian languages). That should sum up to almost 800K (uncompressed), IIRC. So, my question is: on Windows. where are those CJK codecs? Are they by any chance included in the 1.867.776 bytes of python24.dll ? Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Maybe the application should use sets instead of lists for these collections. What would sets do for me over lists? searching for an element in a list is O(n) searching for an element in a set is O(1) (for reasonable distributed elements) Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: python html rendering
Pierre, Hi, Im looking for a way to display some python code in html: with correct indentation, possibly syntax hiliting, dealing correctly with multi-line comment, tongue - in - cheek - mode the usual way is to create your own web-framework /tongue - in - cheek - mode If it is just some Python code and you have to do it once, just look at scite. Scite can colour your code, and you can export it as HTML. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
walterbyrd, Answer: Yes. Definitely. And, to be correct, there are some who earn a rather comfortable living programming in Python. If so, I doubt there are many. depending on your definition of many. if many is something around 1% of population of earth, you are right. If many is more than 1000, than you are wrong. I formyself earn the major part of my income doing Python - combined with database knowledge, of course. I wonder why that is? There seems to be a challenge to have more people programm Python: to hire people with Python knowledge. Maybe the recruiters of Google can enlighten you on the prospects of Python programmers on the market :) Java is educated in a kind of vocational training in universities; but at the moment only the elite gets in touch with Python. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Talking to marketing people about Python
Roy Smith schrieb: Can anybody suggest some good material I can give to him which will help explain what Python is and why it's a good thing, in a way that a marketing/product management person will understand? please also look for the Python success stories There is also a aviation control system running with Python / using Python bindings. Google offers Python bindings and has employed the BDFL and at least one ~bot. I think nobody would doubt that Google has the most knowledge about online services - maybe there is something about Python? You can also point out that Python is especially suited for secure online applications, with more web frameworks than keywords it offers a very high security through diversity, as no single vulnerabilitie can be exploited across a big enough ecosphere. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: When is it a pointer (aka reference) - when is it a copy?
Magnus Lycka schrieb: http://effbot.org/zone/python-objects.htm may be useful for those who haven't already seen it. Shouldn't it be incorporated into the standard tutorial? I think it's very helpful for people who are used to the way C etc handles variables. That would also be a good headline. information for those coming from C, and it should be possible to grow similiar sections for those comming from Java or PERL. At least it belongs into the FAQ :) Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Python programs always open source?
Guy Fawkes schrieb: I don't want my program to be open-source and so far all the Python programs I've seen included the source code. That's one of the great freedoms of Python and its licence: You are free to chose the licence for your product. No GPLish you must be as free as we, more BSDish: Do what you want, do not come crying Is it possible to make an executable with only bytecode? I use py2exe with its new (~1 year) single file feature with great success. I even succeeded in including a virtual static directory for a webserver within that file. To be exact, it is not really 1 file, but 2, as you often have to distribute msvcr71.dll with it - except for those computers having i.e. MS Office 11 installed, there it is allready present. Combining py2exe's single file distributable and upx compression I achieve fairly compact just drop and use applications without a real need for installation. I do not care about people decompiling (customers get the source code on request, if they are interested). It would be possible - but those who have the time and knowledge to dissect and decompile those upxed py2exed files and still make a profit would probably not see a reason to buy my software anyway :) Harald -- http://mail.python.org/mailman/listinfo/python-list
PIL 2.5 win32 binaries?
On the PIL website I read: The current free version is PIL 1.1.5, which has been tested with Python 1.5.2 and newer, including 2.3 and 2.5. but in downloads I cannot see any binaries for windows and Python 2.5 Are they somewhere available? Best wishes, Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: PostgreSQL, psycopg2 and OID-less tables
Dale, Now that OIDs have been deprecated in PostgreSQL, how do you find the key of a newly inserted record? using OIDs as primary key was no good idea for some PostgreSQL versions allready ... i.e. they really make dump restore much more challenging. So usually us have something along: CREATE TABLE feuser ( id_user serial NOT NULL, name text, CONSTRAINT feuser_pkey PRIMARY KEY (id_user), CONSTRAINT feuser_name_key UNIQUE (name) ) WITHOUT OIDS; which automatically creates a sequence for you and rewrites the serial id_user with a default of nextval('feuser_id_user_seq'::regclass) So, to get the key of a record inserted, basically there are two methods. (from now on cs is a DB-API 2.0 compliant cursor object, i.e. from psycopg2 cn=psycopg2.connect() cs=cn.cursor() a) get id first, then insert cs.execute(select nextval('feuser_id_user_seq'::regclass)) newid=cs.fetchone()[0] cs.execute(insert into feuser (id_user, name) values (%(id_user)s, %(name)s), dict(id_user=newid, name=Karl Napf) cs.commit() - now newid contains your new id. b) create a serverside function on PostgreSQL: CREATE OR REPLACE FUNCTION insfeuser (text) RETURNS integer AS $BODY$ DECLARE result int4; BEGIN select nextval('feuser_id_user_seq'::regclass) into result; insert into feuser (id_user, name) values (result, $1); RETURN result; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE; within python: cs.execute(select insfeuser(%(name)s), dict(name=Karl Napf)) newid=cs.fetchone()[0] Hope that helps, Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Reinsburgstraße 202b 70197 Stuttgart 0173/9409607 -- http://mail.python.org/mailman/listinfo/python-list
accessing the DHCP Server Management API
Hello, I need to get a list of active leases on a windows dhcp server. Experts from Microsoft statet: A: Go to the Address leases of each scope in the DHCP snap-in and dump the leases to a text file from the DHCP server snap-in. The text file gives you all the information for every active lease. You might also want to query the DHCP server management API: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcpenumsubnetclients.asp. (http://www.microsoft.com/technet/community/chats/trans/windowsnet/wnet_05_0303.mspx) Option A is not really an option for programmatic access :) So my question: Has anyone accessed the DHCP Server Management API from Python before? I googled my browser smoking with hopes that that API might be accessible via WMI, but to no avail for me. Any recommendation how to access this information via Python? pyDHCPSMA anyone? Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: programming with Python 3000 in mind
Steven, you ask good questions! (2) Will there be automated tools for converting source code from Python 2 to Python 3000? If you would have been to the EuroPythom 2006, you may have heard the plans for PyPy 2.0; which may have per-module-switchable syntax compatibility for Py 2.2-3000. So by trusting the PyPy team, you can stay very very relaxed concerning Python 3000. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
Mc Osten schrieb: Yes it is. But of course you can't sat that Python is faster than C++. Of course not. Python is faster then assembler. Proofed @ EuroPython 2006 in CERN, near the LHC Beta, in the same room many Nobel laurates gave their presentations before. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling wxPython app for Windows; Single EXE
Daniel, I am using py2exe since more then 4 years, so I am rather biased. I read PyInstaller page and was positively impressed by the manual and all the good words. There is one major difference which will keep me with py2exe: with PyInstaller and single file there is: When first started, it finds that it needs to extract these files before it can run for real. and with py2exe: Changes in 0.6.1: * py2exe can now bundle binary extensions and dlls into the library-archive or the executable itself. This allows to finally build real single-file executables. The bundled dlls and pyds are loaded at runtime by some special code that emulates the Windows LoadLibrary function - they are never unpacked to the file system. this they are never unpacked to the file system is the USP of py2exe to me at the moment. What is less then optimal with both packages, is that MSVCR71.DLL needs to be distributed separately :( Harald -- http://mail.python.org/mailman/listinfo/python-list
win32 load icon not from file, but from something
I have found a make a icon in traybar skript, and it loads its Icon from a file hinst = win32gui.GetModuleHandle(None) iconPathName= c:/myapp/myapp.ico icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE hicon = win32gui.LoadImage(hinst, str(iconPathName), win32con.IMAGE_ICON, 0, 0, icon_flags) that works great. But now I have to distribute that icon together with the application - that is one file more to take track. I would like to load this image from something with something being a string / a cStringIO / something pickled The obvious cPickle.dumps(hicon) leads to nothing, cause it only gets the ID of the hicon :( Any ideas / recommendations / tipps? Harald -- http://mail.python.org/mailman/listinfo/python-list
need hint for refactoring
I have a bunch of function like: def p2neufrage(_): create new element anfrage,ergebnis=getanfrage() if ergebnis.get(status,ok) == ok: wert=anfrage[feld] # do something # unique here ergebnis[innerHTML]=. something # return simplejson.dumps(ergebnis, skipkeys=False, ensure_ascii=False, check_circular=True, allow_nan=True) so, everywhere there is the same beginning: anfrage,ergebnis=getanfrage() I analyze some transmitted jason-document; check for errors then I take the values out of the request, process it and fill the slots of a result (ergebnis) dictionary, which is returned. So the beginning and the end of the function is allways repeated. It would be great to factor it out ... i startet with that ...getanfrage() call. Is there anything more possible? Thanks for any hint Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: need help of regular expression genius
Paul, text = ... input source text ... from pyparsing import SkipTo,Literal,replaceWith ign1 = $$ + SkipTo($$) + $$ ign2 = $_$ + SkipTo($_$) + $_$ semi = Literal(;).setParseAction( replaceWith(; ***) ) print (ign1 | ign2 | semi).transformString(text) Thank you very much! this really looks beautifull and short! How could I forget about pyparsing? Old loves are often better then adventures with RE. :) Two questions remain: 1) I did not succeed in finding a documentation for pyparsing. Is there something like a full list of Classes and their methods ? 2) as of missing 1) :)): something like setParseAction(splithereandreturnalistofelementssplittedhere) ? Thanks again! Harald (of course, I can .split(***) the transformedString :) -- http://mail.python.org/mailman/listinfo/python-list
Re: need help of regular expression genius
Paul, Pyparsing ships with JPG and PNG files containing class diagrams, plus an htmldoc directory containing epydoc-generated help files. There are also about 20 example programs included (also accessible in the wiki). Yes. That's what I have been missing. Maybe you could add: please also download the .zip file if you use the windows installer to find the documentation :))) You could also look into using scanString instead of transformString thats what I found: from pyparsing import SkipTo,Literal,replaceWith ign1 = $$ + SkipTo($$) + $$ ign2 = $_$ + SkipTo($_$) + $_$ semi = Literal(;) von=0 befehle=[] for row in (ign1 | ign2 | semi).scanString(txt): if row[0][0]==;: token, bis, von2=row befehle.append(txt[von: von2]) von=von2 I knew that for this common kind of problem there MUST be better solution then my homebrewn tokenizer (skimming through text char by char and remembering the switch to escape mode ... brr, looked like perl) Thanks for the reminder of pyparsing, maybe I should put in a reminder in my calender ... something along the lines if you think of using a RE, you propably have forgotton pyparsing every 3 months :) Best wishes and thank you very much for pyparsing and the hint Harald -- http://mail.python.org/mailman/listinfo/python-list
need help of regular expression genius
I need to split a text at every ; (Semikolon), but not at semikolons which are escaped within a pair of $$ or $_$ signs. My guess was that something along this should happen withing csv.py; but ... it is done within _csv.c :( Example: the SQL text should be splitted at split here (of course, those split heres are not there yet :) set interval 2; split here CREATE FUNCTION uoibcachebetrkd(bigint, text, text, text, text, text, timestamp without time zone, text, text) RETURNS integer AS $_$ DECLARE result int4; BEGIN update bcachebetrkd set name=$2, wieoftjds=$3, letztejds=$4, njds=$5, konzern=$6, letztespeicherung=$7, betreuera=$8, jdsueberkonzern=$9 where id_p=$1; IF FOUND THEN result:=-1; else insert into bcachebetrkd ( id_p, name, wieoftjds, letztejds, njds, konzern, letztespeicherung, betreuera, jdsueberkonzern ) values ($1, $2, $3, $4, $5, $6, $7, $8, $9); result:=$1; END IF; RETURN result; END; $_$ LANGUAGE plpgsql; split here CREATE FUNCTION set_quarant(mylvlquarant integer) RETURNS integer AS $$ BEGIN perform relname from pg_class where relname = 'quara_tmp' and case when has_schema_privilege(relnamespace, 'USAGE') then pg_table_is_visible(oid) else false end; if not found then create temporary table quara_tmp ( lvlquara integer ); else delete from quara_tmp; end if; insert into quara_tmp values (mylvlquarant); return 0; END; $$ LANGUAGE plpgsql; split here Can anybody hint me in the right direction, how a RE looks for all ; but not those ; within $$ ? Harald -- http://mail.python.org/mailman/listinfo/python-list
Last Call - proposals for talks in the business and application track at EP 2006
In 2006, EuroPython will be from the 3rd to the 5th of July at CERN, near Geneva in Switzerland. In business applications we want to hear about how you made your fortune with Python. Show us YOUR interesting released Python applications. Describe your fabulous business models with Open Source Software. Report about your pub cashier solution in Python and how you solved the challenges of longer opening hours. Narrate the background stories about your next generation search engine which has just gone live. Explain us the technique, tell us the story, paint your business model! Show us how YOU got affluent, opulent, pecunious, proliferative, prosperous and wealthy - all using Python! Do you use Python to make big business in the lumber sawing or porn industrie? Let us know how! Move up to http://www.europython.org/sections/tracks_and_talks/announcements/call-for-proposals and submit your proposal. DEADLINE is 2006-05-31 - so do not hesitate any further! All who still need to know how to get rich and improve their love life using Python: you are heartly invited to register for EuroPython 2006 via the website http://www.europython.org The normal fee is 190 for three days of seminars and a fine conference dinner. In addition to our great conference, you have the possibility to visit CERN! Maybe you read about it in Angel Demons (Illuminati in German) from Dan Brown; maybe you know that Sir Tim Berners-Lee invented the World Wide Web there. You will have the chance to eat in canteens with the highest probability anywhere in the world to stand in queue with a future or past Nobel Prize Winner. You can learn about the technologies that will power Web 2.5 and above at the place where Web 0.1 up to Web 1.0 were developed. CERN says about itself: The world's largest particle physics laboratory ... where the web was born!. As a German you are culturally obligued to go the place where they try to find out was die Welt / in ihrem innersten zusammenhält. (So that I may perceive whatever holds / The world together in its inmost folds (Faust I)) - learn about that place at www.cern.ch Harald Armin Massa persuadere et programmare -- http://mail.python.org/mailman/listinfo/python-list
propose extension of mimetypes
Hello, mimetypes lacks the guessing of .svg as image/svg+xml mimetypes.add_type(image/svg+xml,.svg, True) maybe this can be added to python 2.5 standard library Harald -- http://mail.python.org/mailman/listinfo/python-list