ZODB 3.2.7 final released
I'm pleased to announce the release of ZODB 3.2.7 (final). This corresponds to the ZODB that will be released in Zope 2.7.6 (final) tomorrow. You can download a source tarball or Windows installer from: http://zope.org/Products/ZODB3.2 ZODB 3.2.7 fixes a critical bug in BTree conflict resolution, which could, in rare cases, lead to silent data loss. It's strongly recommended that all ZODB 3.2 users upgrade to 3.2.7 for this reason alone. There are also a small number of minor bugfixes, and new code allowing for better control of ZEO server processes on Windows. See the news file for details: http://zope.org/Products/ZODB3.2/NEWS Note that there are two Windows installers, one for use with the Python 2.3 line (2.3.5 is recommended), and one for use with the Python 2.4 line (2.4.1 is recommended). Note that Python 2.4 has not yet been certified for use with Zope, but Python 2.4.1 is supported for standalone ZODB/ZEO use. ZODB 3.2.7 can be used with Zopes in the 2.7 line, at or after Zope 2.7.3. Note that ZODB 3.2.7 does not support development on Zope 2.8, Zope X3 or Zope 3 (they require the ZODB 3.4 line now). -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Getting into Python, comming from Perl.
Nick Craig-Wood [EMAIL PROTECTED] wrote: I have had a similar experience. Actually it was Perl 6, and and particular this chart http://www.ozonehouse.com/mark/blog/code/PeriodicTable.html that made me think that Perl was leaving the rails, and it was time to jump ship (to mix my metaphors). That is truly wonderous. Are you famliar with the phrase jumping the shark? This chart might prove that, with Perl 6, Perl has now jumped the shark. -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python internal design
Emre == Emre Turkay [EMAIL PROTECTED] writes: Emre Hi Folks, Emre I am designing a tool, in which there are dynamic types and Emre variables with these types. In this respect, it is more like Emre an interpreted language design. Emre I wonder how these issues are implemented in Python are Emre there any documents or articles about it, which I can read Emre and get an idea. It's built around string lookup. obj.stuff() - look up what object is associated with string 'stuff', get the object, see how it can be called, call it. -- Ville Vainio http://tinyurl.com/2prnb -- http://mail.python.org/mailman/listinfo/python-list
Re: bytecode non-backcompatibility
Maurice LING wrote: Now I understand that Python bytecodes are only dealing with pure python source codes. However, the same question lies, how can it (set of bytecodes) be made stable, like Java bytecodes, which are pretty stable? Perhaps a better question will be, what techniques Java VM designers use that enables Java class files (and JAR files) to be stable and usable across versions that is lacking in Python? The Java class file format is not any more stable than the Python .pyc format - I think every major release of the JVM has changed details in the class file format. The difference is that the newer JVMs accept old class files, by means of separate loader code for each class file version that was ever released (and very possibly also support for class file versions that were never released). The same approach would be possible in Python, but nobody has contributed code to do so. It is unlikely that future Python versions will provide such compatibility with the current byte code format, either, unless somebody steps forward and volunteers to maintain that compatibility. Maintaining this backwards compatibiltiy is a tedious and boring task, given the many much easier alternatives, so that volunteers are unlikely to jump in. Sun manages to provide the compatibility by paying somebody to actually maintain it. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: bytecode non-backcompatibility
Maurice LING wrote: technicalities are wrong but situation remains unchanged. For C modules, it is very likely that new versions of Python will continue to break the ABI, by changing the layout of structures. The most straight-forward way to deal with it as a sysadmin or user is to install multiple versions of Python on a single machine. If Fink considers python2.4 as a replacement for python2.3, then this is a flaw in Fink. In Debian, there is a python package, which currently depends on python2.3. Sometime in the future, it will depend on python2.4. Users which update will then get python2.4, however, python2.3 will remain installed and usable, with all the extension modules that were installed for it. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: bytecode non-backcompatibility
Maurice LING [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From a technical perspective, I can accept that .pyc files are private and temporary. To a certain extend, it does helps development cycle. Every time I amend my source codes, I just run it without having to consider or needing to re-compile the source files. From a user perspective, source code is the run-time program. The idea of having to release the program or library as source files does ring alarms in many executives in corporate world. I understand that people use Python while resisting its purpose and design. But I also understand that it is *their* responsibilty to hide their code, which may possibly mean not using Python, or which may mean developing proprietary methods to translate to something designed to *not* be readable. For all we know, some of the developers have been paid to do exactly that -- and not talk about it. Python is *designed* for human readability. That is one of its big features! The same also seems somewhat true for CPython's bytecodes, especially when disassembled with the dis module that comes with the interpreter. You even get all the object names included in the code object. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: parse tree has symbols not in the grammar?
Chad Whitacre [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I've been playing around with the parser module, and based on the documentation I would expect all symbols in a parse tree to be part of the grammar.[1] For example, I find this line in the symbol module docs: Refer to the file Grammar/Grammar in the Python distribution for the definitions of the names in the context of the language grammar.[2] However, the program below gives me a human-readable parse tree (also below) that contains symbols that don't seem to be in the grammar, e.g., small_stmt, expr_stmt, factor. Is my expectation wrong? Did you not find them in grammar.txt, which you referenced, or Grammar/Grammar is the source, which you did not. Guido has said that the grammar in the ref manual, meant for human consumption, is equivalent to but not quite the same as the grammar used to generate the parser, which has to meet LL1 constraints. [1] http://python.org/doc/ref/grammar.txt [2] http://python.org/doc/lib/module-symbol.html Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of php implode
Maksim Kasimov wrote: in php-scripts, to insert data to database, i'm doing like this: ... $query_param = array( 'field0' = 1, 'field1' = 3, 'field2' = $var2, 'field3' = $var3, ); ... $sql = INSERT INTO $table (.implode(, , array_keys($query_param)).) VALUES ('.implode(',', $query_param).'); how it can be done, using python (elegantly, without cycles)? sql = INSERT INTO %s (%s) VALUES (%s) % (table, ','.params.keys()), ','.join(param.values())) should do the trick. -- -- Ola Natvig [EMAIL PROTECTED] infoSense AS / development -- http://mail.python.org/mailman/listinfo/python-list
ADODB Currency type broken in Python win32?
It looks to me like the handling of the currency type in an ADODB connecction from Python is broken. Currency data in an Access database is stored as a 64-bit integer, scaled by 1. In an ADODB recordset, this is returned as a 2-tuple, where the second element is the currency value, but the value is stored as a normal integer, not a lont integer. Thus, it fails for values greater than about $214,700 (2**32 / 10**4). Here is an example: import win32com.client conn = win32com.client.Dispatch(ADODB.Connection) conn.Open(DRIVER={Microsoft Access Driver (*.mdb)};DBQ=anydatabase.mdb) cmd = win32com.client.Dispatch(ADODB.Command) cmd.ActiveConnection = conn cmd.CommandText = SELECT CCur(25) AS myMoney; rs = cmd.Execute()[0] for f in rs.Fields: print f.Name print f.Type print f.Value One would expect myMoney 6 (0, 25L) Instead, we get: myMoney 6 (0, -1794967296) The value has wrapped at 2**31. -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python internal design
Maurice LING [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am designing a tool, in which there are dynamic types and variables with these types. In this respect, it is more like an interpreted language design. I wonder how these issues are implemented in Python are there any documents or articles about it, which I can read and get an idea. There is no single doc other that the source, but lots of bits and pieces scattered thru clp archives. The CPython interpreter, tokenizes, parses, and compiles Python to CPython bytecode. The library manual chapter on the dis module defines the stack-based CPython virtual machine. The bytecode is interpreted in a loop with a giant switch (ceval.c). Python objects have a common header and a type-specific value section. For builtin type objects, the value section is a standard set of slots for functions corresponding to the various operators and builtins. For more, see the source or persistently search Google's archive for the group. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of php implode
... but not in the case when integers are in a dictionary (please, try to execute your example by yourself first) Ola Natvig [EMAIL PROTECTED] wrote: news:[EMAIL PROTECTED] Maksim Kasimov wrote: in php-scripts, to insert data to database, i'm doing like this: ... $query_param = array( 'field0' = 1, 'field1' = 3, 'field2' = $var2, 'field3' = $var3, ); ... $sql = INSERT INTO $table (.implode(, , array_keys($query_param)).) VALUES ('.implode(',', $query_param).'); how it can be done, using python (elegantly, without cycles)? sql = INSERT INTO %s (%s) VALUES (%s) % (table, ','.params.keys()), ','.join(param.values())) should do the trick. -- -- Ola Natvig [EMAIL PROTECTED] infoSense AS / development -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or PHP?
Mike Meyer wrote: John Bokma [EMAIL PROTECTED] writes: Mike Meyer wrote: John Bokma [EMAIL PROTECTED] writes: You already showed code like: Actually, I never showed you this code. hence *like*, and yes you did, in a footnote. Yes, but *I* didn't say like, because I wanted to point out that you had purposely uglified it. your footnote: *) I still remember seeing FORTRAN programmers writing ALGOL-W conditionals as: if not condition then else begin code end mine purposely uglified version: if condition then nothing else something If you want to program in a normal language, I recommend COBOL. Natural languages have a different purpose than programming languages, which are designed to communicate algorithms clearly and concisely. In that domain, it's just bloat. I, and I am sure I am not alone, consider unless not just bloat. To me it serves a purpose: communicate algorithms clearly :-) What you created was a list. Not in Python or Perl, but in English. I doubt if any Perl programmer in the given context would have any problem with it, but lets drop it. No, let's not. It's a perfect example of why having multiple ways to do things is a bad idea. Ok, again: an obvious solution (sort a list; split a string on whitespace; pull select list elements based on a criteria of some kind; search a file for lines with a given word in them; etc.) you'd get back the same answer from almost all of them. And what makes you doubt it would be different with Perl? :-D ( sort @alist, split ' ', $astring, grep criteria, @list, etc ) I skip over your grep is wrong, should be map, and split is also wrong: The most funniest reply I ever read: You also chose the wrong way to do things globally, by leaving off the optional parens on the function invocations. That makes the list a PITA to parse, in that you have to know the number of arguments to each function in order to parse the list you provided. Consider the python version: (alist.sort(), astring.split(), [x for x in alist if criteria (x)]) I mean, that last part is extremely weird, I mean, in your original question you use ; to separate each question: how does Python parse that? Really Mike, give it up: you gave a few problems, I answered a few, everyone could have seen that I separated each solution with a comma, (almost each keyword is a dead giveaway since they match the word in your original question). And you are suddenly saying that the way I decided to write my answer says something about Perl? How much rope do you need? Moreover, in your reply you clearly showed that you mixed up map and grep. Those are quite fundemental building blocks in perl, it's like mixing up an array with a hash. Oh, I understood it. Sure, is that why you talked about a tuple? But, lets drop it. No, I talked about a tuple to point out that doing it right made something a machine could parse properly, with no thought at all. So you have been assimilated by the borg then? And do you think one can't write a parser that is able to correctly parse my reply? I give you a hint: if a comma is followed by a keyword (bareword), it's a new statement. etc is a no-op statement. Or should my answer be pure Perl? Is your group of problems pure python? Perl? Trying to argue that I'm wrong because I'm wrong about Perl's behavior being bad would be a lot more effective if you pointed out where the descriptions of bad behavior were incorrect. If you can't distinguish map from grep, have problems with split (and maybe even white space), and have parsing problems (e.g. see a Perl list where there is none), it's going to be a bit hard, don't you think? real time guaranteed memory allocation/deallocation (which might be fixed by now in Java) That's an implementation feature, not a language feature. *sigh* That's an implementation feature, not a language feature. I might also note that you're wrong about alloc/free, in that you don't get real time guaranteed memory allocation/deallocation with it, either. That depends on the platform, of course. [ memory allocation and freeing bugs ] I'd say you've never done anything but trivial For someone who claims to maintain perl code but mixes up grep and map, and seems to have a hard time at understanding Perl in general, this is quite a bold statement, to say the least. Righ - you once again avoid the real issue. The real issue seems to be your *lack* of Perl skills. I have no idea if this has changed recently. The last thing I read about it is that there are 4 kinds of garbage collection one can select in Sun's implementation. If you had enough experience with jvm's, you'd know that Sun's wasn't the only one out ther. If your English reading skills where sufficient enough, you would have been able to understand from my use of the word implementation that I am aware of
Re: about Frame.__init__(self)
Hello , I am no expert on tkinter but this seems like an inheritance question. When you define a class that inherits from something ( Frame ) and you define an __init__ in your class you have to explicitly call the __init__ of your base class. class xxx(base): This class doesn't have an __init__ defined. base.__init__ is called instead def method_a(self): pass class xxx(base): This class defines an __init__ and has to explicitly call the base.__init__ def __init__(self): Python calls me if I am defined base.__init__(self) You will see this in more than GUI code, it is part of Python's OO design. I first saw this in some threading code , thru me for a loop too ;) search strategy: Python OO Python inheritance etc... hth, M.E.Farmer yang wrote: I just a newbie of python Now I found that almost every program use Tkinter have this line class xxx(xxx): x def __init__(self): x Frame.__init__(self) . ... the line Frame.__init__(self) puzzle me. why use it like this? can some one explain it? regards, yang -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of php implode
Maxim Kasimov wrote: i'm tying to run example, and then get a traceback. am i something missed? mysql create table tmp_tmp (id int not null auto_increment primary key, sd varchar(255) not null default '', si int not null default 1); import MySQLdb db = MySQLdb.connect(localhost, login, password, dbname) c = db.cursor() query_param = { ... 'sd' : 'somedata', ... 'si' : 2, ... } table = 'tmp_tmp' keys = query_param.keys() values = query_param.values() sql = INSERT INTO %s (%s) values (%s) % (table, , .join(keys), , .join([?] * len(keys))) c.execute(sql, values) Traceback (most recent call last): File stdin, line 1, in ? File /usr/local/lib/python2.2/site-packages/MySQLdb/cursors.py, line 95, in execute return self._execute(query, args) File /usr/local/lib/python2.2/site-packages/MySQLdb/cursors.py, line 108, in _execute self.errorhandler(self, ProgrammingError, m.args[0]) File /usr/local/lib/python2.2/site-packages/MySQLdb/connections.py, line 33, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.ProgrammingError: not all arguments converted Try another paramstyle (see http://python.org/peps/pep-0249.html), e. g. ... ,.join([%s] * len(keys)) ... instead of ... ,.join([?] * len(keys)) ... Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of php implode
done. thanks Try another paramstyle (see http://python.org/peps/pep-0249.html), e. g. ,.join([%s] * len(keys)) ... instead of ,.join([?] * len(keys)) ... Peter -- Best regards, Maksim Kasimov mailto: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: (PHP or Python) Developing something like www.tribe.net
Thanks fro ur advice. I was also thinking to look into quixote. but wanted a second opinion. thanks again. -- http://mail.python.org/mailman/listinfo/python-list
about Frame.__init__(self)
I just a newbie of python Now I found that almost every program use Tkinter have this line class xxx(xxx): x def __init__(self): x Frame.__init__(self) . ... the line Frame.__init__(self) puzzle me. why use it like this? can some one explain it? regards, yang -- http://mail.python.org/mailman/listinfo/python-list
Re: Semi-newbie, rolling my own __deepcopy__
Michael Spencer wrote: It appears that if you want to deepcopy an object that may contain arrays, you're going to have to 'roll your own' deep copier. Something like this would do it: [method deleted] Whew! Michael, that was way more than I bargained for. New issues for me: the ** notation, and the __repr__ method. I'll have a look at this -- but meanwhile, I converted my arrays over to lists. My program is now working. Although it's a bit slower than it would be with arrays, I'll live with the performance hit for now, because I can do the deepcopy operation without further fuss. BTW: are you sure you really need to copy those arrays? Yes, I do. The arrays (now lists) contain the weights for a customized neural net class that I wrote. The process of evolving the neural nets is to mutate copies of them. I want to keep the original nets until I'm sure I want to discard them, so copying is required. -- Rainforest laid low. Wake up and smell the ozone, Says man with chainsaw. John J. Ladasky Jr., Ph.D. -- http://mail.python.org/mailman/listinfo/python-list
Re: (PHP or Python) Developing something like www.tribe.net
I would also look at CherryPy, the new 2.0 version seems pretty interesting (I have not tried it, but I have seen a short presentation at the ACCU conference, and it looks really trivial to use). -- http://mail.python.org/mailman/listinfo/python-list
How do I access variable declared in one script in another python script
Hi All, Please could anyone tell me how to do this : I have one expect script, where i store some value in a variable. I am calling this script from my python script, and need to use this variable in the python script. How do i access this variable from my python script ? Thanks, ramya -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto debug c++ (SWIG) extension under Windows
Miki Tebeka schrieb: Hello Alexander, I can't figure out howto debug my c++ extension. If i compile it as release version, I've of course no chance to set a breakpoint. This is not true. You *can* set breakpoints in release mode, make sure to add debug information to your release build so you'll be able to see the sources. There are several cases (such as inlined functions) that you *can't* set breakpoint to. Don't work because of my MSVCR71D.dll problem. It seems, that if I include DEBUG informations in my project, there is a reference to that (debug) DLL. If I compile as debug I get the Error-window: ... missing MSVCR71D.dll ... Just copy it (and msvcp71d.dll) from your c:\windows\system32 (or wherever your windows is installed) to the Debug library (or to the Python install library). I don't have the dll MSVCR71D.dll on my system path. What I'm a bit confused about is, that I can't even start python_d (installed by ActiveState DEBUG extension to ActivePython). It requires also the DLL. Does anybody know, where to get that DLL ? Regards Alexander -- http://mail.python.org/mailman/listinfo/python-list
names of methods, exported functions
Hello: Is there a way to see at the python prompt the names of all the public methods of a class or the names exported by a module? I know that GUI-based IDEs have a nifty way of displaying these in the form of a drop-down list, but I'm looking for some function or method that will simply return a list of strings. Thanks, Mayer -- http://mail.python.org/mailman/listinfo/python-list
Secure FTP
I need to download files over a secure channel. I have been looking into Paramiko which seems to have the functonality I need. The problem is I need a FTP server which supports key based encryption to install on my windows server. Has anyone succeeded in doing this? If so - what FTP server did you use? Dan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting the sender widget's name in function (Tkinter)
On 26 Apr 2005 13:37:29 -0700, infidel [EMAIL PROTECTED] wrote: from Tkinter import Tk, Button def say_hello(event): print 'hello!' print event.widget['text'] root = Tk() button1 = Button(root, text='Button 1') button1.bind('Button-1', say_hello) button1.pack() button2 = Button(root, text='Button 2') button2.bind('Button-1', say_hello) button2.pack() root.mainloop() Unfortunately, making a binding to Button-1 on Button widgets does not have the same behavior as setting their 'command' option. The binding will fire when the button is *pressed*; the command will be called when the button is *released*. So, binding to ButtonRelease-1 instead of Button-1 make things a little better, but still does not have the same effect, since ButtonPress and ButtonRelease events are balanced: the widget getting the ButtonRelease event is always the same as the one getting the ButtonPress event. So if the mouse button is pressed inside the Button, then the mouse pointer goes out of it, and then the mouse button is released, the Button will still get the ButtonRelease event and fire the binding. This is not the normal behavior for a button and this is not the behavior you get via the 'command' option (just try it...). So having a different function for each button or using tiissa's solution is definitely better. HTH -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\\'*9--56l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text width
On Tue, 26 Apr 2005 17:01:46 -0700, James Stroud [EMAIL PROTECTED] wrote: Hello All, I would like for a tkinter text widget to be aware of how big the frame that contains it is, then I would like for it to reset its width to the appropriate number of characters when this frame changes size. Errr... This is supposed to be the regular behaviour. How do you create your Text widget? Do you specify a width and height? If you do not, the default width and height are 80 and 24 respectively, and the widget won't resize to less than that. If you want a Text widget to be the smallest as possible in its container, you can do something like: - from Tkinter import * root = Tk() t = Text(root, width=1, height=1) t.pack(fill=BOTH, expand=1) root.geometry('500x200') root.mainloop() - The trick is to create the Text as small as possible (width=1, height=1), make it fill its whole container (pack(fill=BOTH, expand=1)), then set the dimensions for the container window (geometry('500x200')). You'll get a Text that will shrink and expand as much as you like. Is it what you were after? HTH -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\\'*9--56l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
Re: regex over files
Jeremy Bowers wrote: On Tue, 26 Apr 2005 20:54:53 +, Robin Becker wrote: Skip Montanaro wrote: ... If I mmap() a file, it's not slurped into main memory immediately, though as you pointed out, it's charged to my process's virtual memory. As I access bits of the file's contents, it will page in only what's necessary. If I mmap() a huge file, then print out a few bytes from the middle, only the page containing the interesting bytes is actually copied into physical memory. my simple rather stupid experiment indicates that windows mmap at least will reserve 25Mb of paged file for a linear scan through a 25Mb file. I probably only need 4096b to scan. That's a lot less than even the page table requirement. This isn't rocket science just an old style observation. Are you trying to claim Skip is wrong, or what? There's little value in saying that by mapping a file of 25MB into VM pages, you've increased your allocated paged file space by 25MB. That's effectively tautological. If you are trying to claim Skip is wrong, you *do not understand* what you are talking about. Talk less, listen and study more. (This is my best guess, as like I said, observing that allocating things increases the number of things that are allocated isn't worth posting so my thought is you think you are proving something. If you really are just posting something tautological, my apologies and disregard this paragraph but, well, it's certainly not out of line at this point.) Well I obviously don't understand so perhaps you can explain these results I implemented a simple scanning algorithm in two ways. First buffered scan tscan0.py; second mmapped scan tscan1.py. For small file sizes the times are comparable. C:\code\reportlab\demos\gadflypaper\tmp\tscan0.py bingo.pdf len=27916653 w=103 time=22.13 C:\code\reportlab\demos\gadflypaper\tmp\tscan1.py bingo.pdf len=27916653 w=103 time=22.20 for large file sizes when paging becomes of interest buffered scan wins even though it has to do a lot more python statements. If this were coded in C the results would be plainer still. As I said this isn't about right or wrong it's an observation. If I inspect the performance monitor tscan0 is at 100%, but tscan1 is at 80-90% and all of memory gets used up so paging is important. This may be an effect of the poor design of xp if so perhaps it won't hold for other os's. C:\code\reportlab\demos\gadflypaper\tmp\tscan0.py dingo.dat len=139583265 w=103 time=110.91 C:\code\reportlab\demos\gadflypaper\tmp\tscan1.py dingo.dat len=139583265 w=103 time=140.53 C:\code\reportlab\demos\gadflypapercat \tmp\tscan0.py import sys, time fn = sys.argv[1] f=open(fn,'rb') n=0 w=0 t0 = time.time() while 1: buf = f.read(4096) lb = len(buf) if not lb: break n += lb for i in xrange(lb): w ^= ord(buf[i]) t1 = time.time() print len=%d w=%d time=%.2f % (n, w, (t1-t0)) C:\code\reportlab\demos\gadflypapercat \tmp\tscan1.py import sys, time, mmap, os fn = sys.argv[1] fh=os.open(fn,os.O_BINARY|os.O_RDONLY) s=mmap.mmap(fh,0,access=mmap.ACCESS_READ) n=len(s) w=0 t0 = time.time() for i in xrange(n): w ^= ord(s[i]) t1 = time.time() print len=%d w=%d time=%.2f % (n, w, (t1-t0)) -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: PDF Printing support from Python
Diez B. Roggisch [EMAIL PROTECTED] (DBR) wrote: You're use of the word driver is one with which I'm not familiar. But I don't really do windows so it's probably a Widnowism. DBR It could be that he means that creating PDFs on windows is done using DBR a fake printer that will produce the pdf when being printed to - and DBR that fake printer is implemented as a driver. But that is about creating a PDF file, whereas the OP was speaking about printing an existing PDF file, For that you need a PDF interpreter, not a PDF printer driver. -- Piet van Oostrum [EMAIL PROTECTED] URL: http://www.cs.uu.nl/~piet [PGP] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: names of methods, exported functions
Mayer wrote: Is there a way to see at the python prompt the names of all the public methods of a class or the names exported by a module? I know that GUI-based IDEs have a nifty way of displaying these in the form of a drop-down list, but I'm looking for some function or method that will simply return a list of strings. Modules generally do not export names[1]. You import a module and perhaps specific names within the module. The module can specify which names are public by the use of the underscore naming convention and the magic __all__ name, which can contain a list of those names which will be imported by default through from module import *. That said, dir() is the function you are looking for. If you want to restrict to only methods on the class, and not just all attributes, you'll have to check the type of each attribute. -- Michael Hoffman [1] OK, I have written modules that set a variable in __main__ using sys.modules but other than that... -- http://mail.python.org/mailman/listinfo/python-list
Re: names of methods, exported functions
Mayer == Mayer [EMAIL PROTECTED] writes: Mayer Hello: Mayer Is there a way to see at the python prompt the names of all Mayer the public methods of a class or the names exported by a Mayer module? I know that If you use ipython, you can press tab after the period, e.g. [~]|128 import re [~]|129 re.TAB re.DOTALL re.MULTILINE re.__all__re.error re.search re.I re.S re.__doc__re.escape re.split re.IGNORECASE re.U re.__file__ re.findallre.sub re.L re.UNICODEre.__name__ re.finditer re.subn re.LOCALE re.VERBOSEre.compilere.match re.template re.M re.X re.engine re.purge re.__class__ [~]|129 re. ISTR the completion can be added to plain old python prompt as well, through rlcompleter. -- Ville Vainio http://tinyurl.com/2prnb -- http://mail.python.org/mailman/listinfo/python-list
Re: Coding Standards (and Best Practices)
On Tue, 26 Apr 2005 11:02:33 -0700, Trent Mick wrote: [Isaac Rodriguez wrote] Hi, I am fairily new to Python, but I am really liking what I am seeing. My team is going to re-design some automation projects, and we were going to use Python as our programming language. One of the things we would like to do, since we are all new to the language, is to define a set of guidelines and best practices as our coding standards. Does anyone know where I can get some information about what the community is doing? Are there any well defined guidelines established? http://www.python.org/peps/pep-0008.html and you may also be interested by a tool such as pylint[1] which help to enforce coding standards on your code base. Most of the styles suggested in pep 8 are checked by pylint, using its default configuration. [1] http://www.logilab.org/projects/pylint/ -- Sylvain Thénault LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org -- http://mail.python.org/mailman/listinfo/python-list
Doubt regarding python Compilation
Dear all, I have doubt regarding python Compilation. I want to know whether Python is compiler language or interpreted language. If Python is interpreter language why compilation is there. with regards Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
how to connect my sql with Python
Dear All, I am doing Python-cgi Project in my company. To connect My sql database(Mysql 4.1.11.) into Python(2.3.3) cgi. I have installed MySQL-python-1.2.0. After installation of MySQL-Python-1.2.0 I try import MySQLdb module. It raised the following error import MySQLdb Traceback (most recent call last): File stdin, line 1, in ? File /System/Links/Libraries/python2.4/site-packages/MySQLdb/__init__.py, line 27, in ? import _mysql ImportError: libmysqlclient.so.14: cannot open shared object file: No such file or directory so kindly give me guidance to connect Mysql and Python regards Praba Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
U¿ytkownik monkey [EMAIL PROTECTED] napisa³ w wiadomo¶ci news:[EMAIL PROTECTED] If using Jython to complie, is the end-user need JRE instead of Python installed, or need both of them? Only JRE. Just like Java. I don't know the exact details, but try using the compiled Python scripts (bytecode). I believe they are semi-optimized and platform independent. They are the .pyc and .pyo files generated when the script is run. Is that means a .py convert to .pyc or .pyo, without the need of make file as using py2exe? .pyc files are generated every time a module (any .py file can be a module) is imported. So if you have a program, say, example.py, you just start the python interpreter and write: import example And then example.pyc will appear beside example.py. This new file does not require example.py (you can even delete it), and works on any computer with Python installed (on Windows you can just double-click it) If you start the Python interpreter using: python -OO (if you are using Windows, you shoud start the interpreter from the command line, probably something like: c: cd \ python24\python -OO) and then import your example.py, you will get a file example.pyo, which is also stripped of any documentation strings (a bit harder to decode). regards, Filip Dreger -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt regarding python Compilation
praba kar [EMAIL PROTECTED] wrote: I have doubt regarding python Compilation. you sure have a lot of doubts. I want to know whether Python is compiler language or interpreted language. If Python is interpreter language why compilation is there. the CPython implementation of Python runs on a virtual machine (similar to Java), and the compilation process converts your code to instructions for that machine (so-called bytecodes). Python never interprets your code; it's always compiled to bytecode before being executed (this also applies to the interactive promt, which compiles each statement before running it). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Python licence again
On Tue, 26 Apr 2005 23:26:41 +1000, you wrote: [snip] Yup, pesky furriners, can't spell 'Merican prop'ly like God intended; they shouldn't be allowed on the net, sheriff should run 'em right out o' the county ... Sheriff is not available, for further info pls ask for R. Marley. I don't understand the connection with Bob Marley; pls enlighten me. He shot the sheriff. and heading Would that be like heading a soccer ball? Or heeding the sucker call (like I just did?) What makes you think you were heeding a sucker call? Perhaps it's just bad wordplay from me. I assumed you knew that 'heading' was a misspelt 'heeding' but you playingly used literally heading in your reply. For those who didn't get understand that, though, I offered the correct heeding and then rhyming with soccer ball, I presented myself as the sucker who offered the correct spelling when _it was not needed_. So I didn't think I was heeding a sucker call at any moment, I just wrote that as a pun. There were no indirect accusations about your post, if that is what you meant. the google suggestions that probably looked like didn't you mean : Python License You might find, were you to try it, that it makes no such suggestions. Google isn't what it used to be when I was 6 yrs old. That would make you, what, say 10 years old now? When I was 6 yrs old, Google was inexistant. It isn't anymore, so my assertion is correct (even though it's useless :) I'm 33 btw. -- Christos Georgiou, Customer Support Engineer Silicon Solutions, Medicon Ltd. Melitonos 5, Gerakas 153 44 Greece Tel +30 21 06606195 Fax +30 21 06612666 Mob +30 693 6606195 Dave always exaggerated. --HAL -- http://mail.python.org/mailman/listinfo/python-list
Re: bytecode non-backcompatibility
Martin v. Löwis wrote: Maurice LING wrote: technicalities are wrong but situation remains unchanged. For C modules, it is very likely that new versions of Python will continue to break the ABI, by changing the layout of structures. The most straight-forward way to deal with it as a sysadmin or user is to install multiple versions of Python on a single machine. If Fink considers python2.4 as a replacement for python2.3, then this is a flaw in Fink. In Debian, there is a python package, which currently depends on python2.3. Sometime in the future, it will depend on python2.4. Users which update will then get python2.4, however, python2.3 will remain installed and usable, with all the extension modules that were installed for it. Regards, Martin Fink does not consider python2.4 to be a replacement for python2.3. In fact, you can install python2.2, 2.3 and 2.4 in the same machine with Fink. It will maintain 3 sets of libraries as /sw/lib/python2.2, /sw/lib/python2.3 and /sw/lib/python2.4. The chore is that when say Fink installs python2.4, all the libraries in /sw/lib/python2.3/site-packages have to be re-installed into /sw/lib/python2.4/site-packages, one by one. There is no simple way of doing that... which makes any system admin needing to re-install 50 3rd party libraries into /sw/lib/python2.4/site-packages a big task, as well as satisfying the necessary dependencies. So if C extension API (or whatever that is really called) is stable, the system admin can just copy all of /sw/lib/python2.3/site-packages into /sw/lib/python2.4/site-packages and it should work. From what you've said, it seems that this isn't possible. So my alternative solution is that PyPI have a mechanism to maintain what had been installed in the site-package directory and to download the libraries and install into the new site-package directory... What do you think? Cheers maurice -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
monkey wrote: It is generally not very easy or straight-forward. For now, you can use pyfreeze to snap the application. If your application does not use any C modules, you can try to use Jython instead. Cheers Maurice If using Jython to complie, is the end-user need JRE instead of Python installed, or need both of them? The end-user needs the JRE, not Python. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: how to connect my sql with Python
praba kar [EMAIL PROTECTED] wrote: I am doing Python-cgi Project in my company. To connect My sql database(Mysql 4.1.11.) into Python(2.3.3) cgi. I have installed MySQL-python-1.2.0. After installation of MySQL-Python-1.2.0 I try import MySQLdb module. It raised the following error import MySQLdb Traceback (most recent call last): File stdin, line 1, in ? File /System/Links/Libraries/python2.4/site-packages/MySQLdb/__init__.py, line 27, in ? import _mysql ImportError: libmysqlclient.so.14: cannot open shared object file: No such file or directory so kindly give me guidance to connect Mysql and Python have you installed the required libmysqlclient library? if you have, have you installed in a location where the runtime linker can find it? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Howto debug c++ (SWIG) extension under Windows
Hello Alexander, I can't figure out howto debug my c++ extension. If i compile it as release version, I've of course no chance to set a breakpoint. This is not true. You *can* set breakpoints in release mode, make sure to add debug information to your release build so you'll be able to see the sources. There are several cases (such as inlined functions) that you *can't* set breakpoint to. Don't work because of my MSVCR71D.dll problem. It seems, that if I include DEBUG informations in my project, there is a reference to that (debug) DLL. But I'm talking about *release* build. If I compile as debug I get the Error-window: ... missing MSVCR71D.dll ... Just copy it (and msvcp71d.dll) from your c:\windows\system32 (or wherever your windows is installed) to the Debug library (or to the Python install library). I don't have the dll MSVCR71D.dll on my system path. What I'm a bit confused about is, that I can't even start python_d (installed by ActiveState DEBUG extension to ActivePython). It requires also the DLL. Does anybody know, where to get that DLL ? Try download MSVCR71D.dll in google. Another option if to compile you extension in debug mode but to link it to the regular Python. Just undef _DEBUG when compiling the SWIG output file. Bye. -- Miki Tebeka [EMAIL PROTECTED] http://tebeka.bizhat.com The only difference between children and adults is the price of the toys pgp8oJsLTEHQf.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
And what did you use for deploying either PyGTK and wxPython? In other words, what were your workspace and logic of the development? Thanks Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
Aaand: which do you prefer? Daniel -- http://mail.python.org/mailman/listinfo/python-list
suggestions on how to do this
The problem I have is as follows: I have a recursive function b(k) b(k) = -(A/k**2)*(b(k-2) - b(k-5)) k0, b(k)=0 k=0, b(k)=1 k=1, b(k)=0 eg. b(2) = -A/4 b(3) = 0 b(4) = A**2/64 note that as k increases b(k) can itself be a sum of terms in powers of A rather than a single power of A in the examples above. Summing all terms and equating to zero gives: F= sum b(k) = 0 for all k = 0, infinity When this is expanded I get a polynomial F(A). I want to determine the coefficients of the polynomial so that I can find the roots of the function F up to a specified order of A. I have yet to code this but I was hoping for some ideas on how to do this reasonably. I figure I can compute each b(k) and store the numeric value(s) and associated powers of A. Then collect coefficients for like powers of A. Finally I have a set of polynomial coefficients in A which I can pass to scipy.base.roots() Any suggestions on how I might do this efficiently? I have no doubt I can get this done with brute force, but I would prefer to explore more elegant means which I look to the masters for. tia -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Perl PDF files
Hopefully, Adobe will choose to support SVG as a response to Microsoft's Metro, and take us all off the hook with respect to cracking open their proprietary format. -- http://mail.python.org/mailman/listinfo/python-list
How can i solve this problem with py2exe ?
Hi, I´m with problem to create a executable program in python. I´m using py2exe but i don´t know if it´s right. When i run in prompt"python setup.py py2exe", appear in the end this: ### The following modules appear to be missing[ '_imaging_gif','libVTKCommonPython', 'libVTKContribPython', 'libVTKGraphicsPython', 'libVTKImagingPython', 'libVTKPatentedPython', libvtkCommonPython', 'libvtkFilteringPython', 'libvtkGraphicsPython', 'libvtkHybridPython', 'libvtkIOPython', 'libvtkImagingPython','libvtkParallelPython', 'libvtkPatentedPython', 'libvtkRenderingPython', 'numarray.array', 'numarray.dot', 'numarray.fromfile', 'numarray.size', 'numarray.zeros', 'vtk.vtkActor2D', 'vtk.vtkDCMParser', 'vtk.vtkImageClip', 'vtk.vtkImageFlip', 'vtk.vtkImageImport', 'vtk.vtkImageMagnify', 'vtk.vtkImageMapper', 'vtk.vtkImagePermute', 'vtk.vtkImageReader', 'vtk.vtkImageResample', 'vtk.vtkImageReslice','vtk.vtkImageShiftScale', 'vtk.vtkImageThreshold', 'vtk.vtkImageViewer', 'vtk.vtkImageWriter', 'vtk.vtkRenderWindow', 'vtk.vtkRenderer', 'vtk.vtkTextMapper', 'vtk.vtkTextProperty', 'vtk.vtkTransform'] ### How can i solve this problem? My setup.py: from distutils.core import setupimport py2exefrom glob import glob setup( # The first three parameters are not required, if at least a # 'version' is given, then a versioninfo resource is built from # them and added to the executables. version = "2.0", description = "programa InVesalius", name = "InVesalius", # targets to build console = ["C:\\promed2.0\\python\\MyMainModule.py"], data_files=[("icons", glob("C:\\promed2.0\\icons\\*.*")), ("docs",glob("C:\\promed2.0\\docs\\*.*")), ("config", ["C:\\promed2.0\\setup.cfg"]) ],packages = ['vtk-windows', 'vtk-windows.vtk', 'vtk-windows.vtk.gtk', 'vtk-windows.vtk.qt', 'vtk-windows.vtk.tk', 'vtk-windows.vtk.util', 'vtk-windows.vtk.wx', 'vtk-windows.vtk.test'], ) My PYTHONPATH = C:\Python23;C:\promed2.0\vtk-windows;C:\promed2.0\python My dir: ## promed2.0/ setup.cfg setup.pyicons/ docs/ python/ MyMainModule.py vtk-window/ vtkpython.py vtkpythontk.py vtk.pth vtkCommon.dll vtkCommonPython.dll vtkCommonTCL.dll ... vtk/ ### OS: win 2K Python ver: 2.3.5py2exe ver: 0.5.4 Thanks Glauco No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 25/4/2005 -- http://mail.python.org/mailman/listinfo/python-list
Re: kdialog and unicode
On 26 Apr 2005 19:16:25 -0700, [EMAIL PROTECTED] wrote: John Machin wrote: On 26 Apr 2005 13:39:26 -0700, [EMAIL PROTECTED] (dumbkiwi) wrote: Peter Otten [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Dumbkiwi wrote: Just encode the data in the target encoding before passing it to os.popen(): Anyway, from your post, I've done some more digging, and found the command: sys.setappdefaultencoding() which I've used, and it's fixed the problem (I think). Dumb Kiwi, eh? Maybe not so dumb -- where'd you find sys.setappdefaultencoding()? I'm just a dumb Aussie [1]; I looked in the 2.4.1 docs and also did import sys; dir(sys) and I can't spot it. Hmmm. See post above, seems to be something generated by eric3. So this may not be the fix I'm looking for. In any case, how could the magical sys.setappdefaultencoding() fix your problem? From your description, your problem appeared to be that you didn't know what encoding to use. I knew what encoding to use, Would you mind telling us (a) what that encoding is (b) how you came to that knowledge (c) why you just didn't do test = os.popen('kdialog --inputbox %s' %(data.encode('that_encoding'))) instead of test = os.popen('kdialog --inputbox %s' %(data.encode('utf-8'))) the problem was that the text was being passed to kdialog as ascii. It wasn't being passed to kdialog; there was an attempt which failed. The .encode('utf-8') at least allows kdialog to run, but the text still looks like crap. Using sys.setappdefaultencoding() seemed to help. The text looked a bit better - although not entirely perfect - but I think that's because the font I was using didn't have the correct characters (they came up as square boxes). And the font you *were* using is what? And the font you are now using is what? What facilities do you have to use different fonts? What is the essential difference between send(u_data.encode('polish')) and sys.setappdefaultencoding('polish') ... send(u_data) Not sure - I'm new to character encoding, and most of this seems like black magic to me. The essential difference is that setting a default encoding is a daft idea. [1]: Now that's *TWO* contenders for TautologyOTW :-) Before I retract that back to one contender, I'll give it one more shot: 1. Your data: you say it is Polish text, and is utf-8. This implies that it is in Unicode, encoded as utf-8. What evidence do you have? Have you been able to display it anywhere so that it looks good? If it's not confidential, can you show us a dump of the first say 100 bytes of text, in an unambiguous form, like this: print repr(open('polish.text', 'rb').read(100)) 2. Your script: You say I then manipulate the data to break it down into text snippets - uh-huh ... *what* manipulations? Care to tell us? Care to show us the code? 3. kdialog: I know nothing of KDE and its toolkit. I would expect either (a) it should take utf-8 and be able to display *any* of the first 64K (nominal) Unicode characters, given a Unicode font or (b) you can encode your data in a legacy charset, *AND* tell it what that charset is, and have a corresponding font or (c) you have both options. Which is correct, and what are the details of how you can tell kdialog what to do -- configuration? command-line arguments? HTHYTHYS, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I don't know the exact details, but try using the compiled Python scripts (bytecode). I believe they are semi-optimized and platform independent. They are the .pyc and .pyo files generated when the script is run. Okay, I found this documentation http://fux0r.phathookups.com/programming-tutorials/Python/tut/node43.html. It hides the source but you still need Python installed on the system running the bytecode. But those files can be decompyled. -- -- Lucas Raab lvraab@earthlink.net dotpyFE@gmail.com AIM:Phoenix11890 MSN:dotpyfe@gmail.com IRC:lvraab ICQ:324767918 Yahoo: Phoenix11890 -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
Maurice LING [EMAIL PROTECTED] wrote: news:[EMAIL PROTECTED] If your application does not use any C modules, you can try to use Jython instead. Program in python but use jythonc to convert it into Java source files and package it into Java JAR files, then you will only need to release the JAR files without needing to release your codes. using Jython will not helps to hide your sources - jar-files are also easy to decompile and to receive the source code (it will even looks like original). To avoid releasing your java-code (as far as it possible), the jar-files are also necessary for processing by obfuscators -- Best regards, Maksim Kasimov mailto: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
mysql.h: No such file or directory when building MySQL-python
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: -- [ ]# export PATH=$PATH:/usr/local/mysql/bin/ [ ]# export mysqlclient=mysqlclient_r [ ]# python setup.py clean [ ]# python setup.py build running build running build_py running build_ext building '_mysql' extension creating build/temp.linux-i686-2.3 gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.3 -c _mysql.c -o build/temp.linux-i686-2.3/_mysql.o -I'/usr/include/mysql' _mysql.c:41:19: mysql.h: No such file or directory I don't understand why I get this error message, since I usually build MySQL+C programs by using: gcc -o myprogram -I'/usr/local/mysql/include/mysql' -L'/usr/local/mysql/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm myprogram.c My server configuration: --- [ ]# /usr/local/mysql/bin/mysql_config --cflags[-I'/usr/local/mysql/include/mysql'] --libs [-L'/usr/local/mysql/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm] --socket[/tmp/mysql.sock] --port [3306] --version [3.23.58] [ ]# find . -name mysql.h ./usr/src/php-4.3.10/ext/mysql/libmysql/mysql.h ./usr/src/mysql-3.23.58/include/mysql.h ./usr/src/mysql-4.1.9/include/mysql.h ./usr/include/mysql/mysql.h ./usr/local/mysql/include/mysql/mysql.h -- [ ]# locate libmysqlclient /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.so /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.a /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.so.10 /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.so.10.0.0 /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.lai /usr/src/mysql-3.23.58/libmysql/.libs/libmysqlclient.la /usr/src/mysql-3.23.58/libmysql/libmysqlclient.la /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.so /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.a /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.so.14 /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.lai /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.so.14.0.0 /usr/src/mysql-4.1.9/libmysql/.libs/libmysqlclient.la /usr/src/mysql-4.1.9/libmysql/libmysqlclient.la /usr/local/mysql/lib/mysql/libmysqlclient.la /usr/local/mysql/lib/mysql/libmysqlclient.so.10.0.0 /usr/local/mysql/lib/mysql/libmysqlclient.so /usr/local/mysql/lib/mysql/libmysqlclient.a /usr/local/mysql/lib/mysql/libmysqlclient.so.10 -- Any suggestion? Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list
Re: delete will assure file is deleted?
On Tue, 26 Apr 2005 21:33:52 -0500, rumours say that Mike Meyer [EMAIL PROTECTED] might have written: This is just a little bit tricky. os.remove (on FreeBSD 5-STABLE, anyway) throws an OSError exception if it doesn't have permission to remove the file, *or* if the file doesn't exist. You have to examine the exception for it's value, which is the result of a strerror call. I believe that the result of strerror is platform dependent. Although I don't have experience with FreeBSD, so far checking the exception's errno args does the job. Example: import errno try: ... except OSError, exc: if exc.errno == errno.ENOENT: # file inexistant ... elif exc.errno == errno.EPERM: # no permissions ... else: raise -- TZOTZIOY, I speak England very best. Be strict when sending and tolerant when receiving. (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting into Python, comming from Perl.
Tim Roberts wrote: That is truly wonderous. Are you famliar with the phrase jumping the shark? This chart might prove that, with Perl 6, Perl has now jumped the shark. For those of us who maybe don't spend enough time watching TV: http://www.wordspy.com/words/jumptheshark.asp -Peter -- http://mail.python.org/mailman/listinfo/python-list
Which IDE is recommended?
Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent of php implode
On Tue, Apr 26, 2005 at 09:59:29PM -0500, Mike Meyer wrote: Jeff Epler [EMAIL PROTECTED] writes: items = query_param.items() keys = [item[0] for item in items] values = [item[1] for item in items] Is there some reason not to do: keys = query_params.keys() values = query_params.values() That would seem to be a lot more obvious as to what was going on. I was afraid that .keys() and .values() might not match up (so that the i'th key maps to the i'th value in query_param). Now that I've glanced at the documentation, I see that this *is* guaranteed[1], and I should have written the code you proposed. Jeff [1] http://docs.python.org/lib/typesmapping.html note 3 pgpxQa6k4Ldvu.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Internet Explorer, COM+, Javascript and Python
I need to make IE execute javascript in a web page with COM+ and Python. Similarly to the way they do it in this article. . . http://www.codeproject.com/com/jscalls.asp -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
And then example.pyc will appear beside example.py. This new file does not require example.py (you can even delete it), and works on any computer with Python installed Filip, you can read through my mind (-: You just told me what I want to know exactly, even I can't ask the question correctly. Thx.. python24\python -OO) and then import your example.py, you will get a file example.pyo, which is also stripped of any documentation strings (a bit harder to decode). Is .pyo still not secure for serious purpose? The -OO function refer to which area of python that I can read a doc in details? The end-user needs the JRE, not Python. Kent Actually I still not dare to touch Jython, because I am still digging python now. But the JRE may not attract end-user, because it is still associate with slow and eating much system resource, although Java is sure a respectfully programming language. What do you think? -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
But those files can be decompyled. Hi, so which way to go? -- http://mail.python.org/mailman/listinfo/python-list
Re: names of methods, exported functions
On Wed, 27 Apr 2005 10:45:05 +0100, Michael Hoffman [EMAIL PROTECTED] wrote: Mayer wrote: Is there a way to see at the python prompt the names of all the public methods of a class or the names exported by a module? I know that GUI-based IDEs have a nifty way of displaying these in the form of a drop-down list, but I'm looking for some function or method that will simply return a list of strings. Modules generally do not export names[1]. You import a module and perhaps specific names within the module. The module can specify which names are public by the use of the underscore naming convention and the magic __all__ name, which can contain a list of those names which will be imported by default through from module import *. That said, dir() is the function you are looking for. If you want to restrict to only methods on the class, and not just all attributes, you'll have to check the type of each attribute. A few more hints for the OP: Don't forget that dir(thing) gets you all the inherited methods of thing as well. To limit it to the attribute names of thing, use vars(thing).keys(). If thing is a class, that will show the methods. If thing is an instance, it will show instance attribute names, so if you want the immediate class methods, use vars(type(thing)).keys(). If you want gobs of info use help(thing). E.g., if you have your own class Foo like class Foo(list): ... def mrev(self): return Foo(reversed(self)) ... def msor(self): return sorted(self) ... foo = Foo('zvbac') foo ['z', 'v', 'b', 'a', 'c'] foo.mrev() ['c', 'a', 'b', 'v', 'z'] foo.msor() ['a', 'b', 'c', 'v', 'z'] The short form: vars(Foo).keys() ['__module__', 'mrev', 'msor', '__dict__', '__weakref__', '__doc__'] Using dir(): dir(Foo) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__dict__ ', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', ' __hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod ule__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__ ', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__weakref__', 'append', 'count', 'extend', 'index', 'insert', 'mrev', 'msor', 'pop', 'remove', 'reverse', 'sort'] Using help: (BTW, it would be nice to have some keyword arguments for help to filter down information to exclude what may not be interesting) help(Foo) Help on class Foo in module __main__: class Foo(__builtin__.list) | Method resolution order: | Foo | __builtin__.list | __builtin__.object | | Methods defined here: | | mrev(self) | | msor(self) | | -- | Data and other attributes defined here: | | __dict__ = dictproxy object | dictionary for instance variables (if defined) | | __weakref__ = attribute '__weakref__' of 'Foo' objects | list of weak references to the object (if defined) | | -- | Methods inherited from __builtin__.list: | | __add__(...) | x.__add__(y) == x+y | | __contains__(...) | x.__contains__(y) == y in x | | __delitem__(...) | x.__delitem__(y) == del x[y] | | __delslice__(...) | x.__delslice__(i, j) == del x[i:j] | | Use of negative indices is not supported. | | __eq__(...) | x.__eq__(y) == x==y | | __ge__(...) | x.__ge__(y) == x=y | | __getattribute__(...) | x.__getattribute__('name') == x.name | | __getitem__(...) | x.__getitem__(y) == x[y] | | __getslice__(...) | x.__getslice__(i, j) == x[i:j] | | Use of negative indices is not supported. | | __gt__(...) | x.__gt__(y) == xy | | __hash__(...) | x.__hash__() == hash(x) | | __iadd__(...) | x.__iadd__(y) == x+=y | | __imul__(...) | x.__imul__(y) == x*=y | | __init__(...) | x.__init__(...) initializes x; see x.__class__.__doc__ for signature | | __iter__(...) | x.__iter__() == iter(x) | | __le__(...) | x.__le__(y) == x=y | | __len__(...) | x.__len__() == len(x) | | __lt__(...) | x.__lt__(y) == xy | | __mul__(...) | x.__mul__(n) == x*n | | __ne__(...) | x.__ne__(y) == x!=y | | __repr__(...) | x.__repr__() == repr(x) | | __reversed__(...) | L.__reversed__() -- return a reverse iterator over the list | | __rmul__(...) | x.__rmul__(n) == n*x | | __setitem__(...) | x.__setitem__(i, y) == x[i]=y | | __setslice__(...) | x.__setslice__(i, j, y) == x[i:j]=y | | Use of negative indices is not supported. | | append(...) | L.append(object) -- append object to end | |
Re: Which IDE is recommended?
monkey wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
What about eric? Good, it seem a very capable ide. But it require qt and for linux only? (can't find the system requirement) I have been using PyDev for some time, but i think it is not always very handsome (e.g. writing a 5-line script in vim needs less time than eclipse startup ;-) otoh, for 5line scripts i am using vim anyway... Yes, eclipse really eat my ram out -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
On 4/27/05, monkey [EMAIL PROTECTED] wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. Believe it or not, this has been discussed before :) Some relevant links, in no particular order: http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/e58230e15f7bb072/ec34f252a00c4b31?q=boa+wing+komodornum=1#ec34f252a00c4b31 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/4ac901800452fe52/32f9a7f307d16bbd?q=boa+wing+komodornum=3#32f9a7f307d16bbd http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b4301bf4de581351/84fea0f68251b810?q=idernum=14#84fea0f68251b810 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/6018db6e62e44895/46ef2516271a51d3?tvc=1q=vim+emacs+komodo#46ef2516271a51d3 http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/a917d15f5a16500c/d989575525959c32?q=vim+emacs+komodornum=4#d989575525959c32 http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e3a65f2908bb8ba4/12ea5915f8f09546?q=vim+emacs+komodornum=5#12ea5915f8f09546 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/8cf3565673bc4a7e/a4a84c1e7271ca1a?tvc=1q=vim+emacs+komodo#a4a84c1e7271ca1a http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/5de87dcdd817ba26/b2ff72c8e864818b?q=vim+emacs+wingrnum=1#b2ff72c8e864818b http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/766c24a82674da7/47d9c8157639d81e?q=vim+wing+komodornum=2#47d9c8157639d81e http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/b21e43c45f183dc7/3a118074c68f1f35?q=vim+wing+komodornum=3#3a118074c68f1f35 http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/2225676eb7e1b4e/cdee764dfa2b5391?q=best+IDernum=1#cdee764dfa2b5391 Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: names of methods, exported functions
Bengt Richter wrote: Using help: (BTW, it would be nice to have some keyword arguments for help to filter down information to exclude what may not be interesting) No kidding. What do you think the output should look like in that case? I think we don't need the mro, or any of the magic methods inherited from the builtin. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
Sorry about the empty post. I'm a fan of PSPad. It's free, light weight, and works with everything. http://www.pspad.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: schedule a monthly ftp event
Peter Hansen wrote: Jeremy Bowers wrote: ... On UNIX, use some cron varient, Windows has some sort of Scheduler built in but I've never done anything with it but turn it off Modern Windowsen also have the AT command line program which is sometimes a much more appropriate way to get at that capability than the Scheduler GUI approach. Haven't had occasion to use either yet, myself... Personally I use the scheduler GUI and the schtasks.exe command-line program which is an interface to the same capability. At.exe gives you an interface to an older API. But there is a Python interface to the older API. Here's an example: http://www.microsoft.com/technet/scriptcenter/scripts/python/os/tasks/ostkpy01.mspx -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
On Wed, 27 Apr 2005 21:16:29 +0800, monkey [EMAIL PROTECTED] wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). Hello, I think, it is. But SciTE is also nice (you can start Python Programs with F5, IIRC, and you see the output of your program). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. But I personally recommend DrPython. (Not only, I'm a member of the project). It is very customizable (Keyboard Shortcuts, customizable right-mouse popup menu, Syntax Check, you can define your own scripts or macros and you can extend it with plugins, as there are several available). (Find/Replace in Files, Sessions, Code Completition, Document List, Position Marker, Autocomplete, Incremental Search, Abbreviations You can open several Python prompts in the editor and start your currently typed program and view the output. It is written in wxPython, open source and under development. I use it for all my Python typing and development. -- Franz Steinhäusler http://drpython.sourceforge.net/ http://mitglied.lycos.de/drpython/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
On 2005-04-27, monkey [EMAIL PROTECTED] wrote: Yes, I want more options. Since the python doc mentioned py2exe only, and it is difficult to understand how it work.(may be you guys know C and make file, but I am still foolish here...) py2exe has nothing to do with C or make files. You create a setup.py file containing a couple lines of python. You run that python program, and you end up with an .exe file and some associated .dll files. I typically use inno-setup to create an installer.exe that creates a desktop icon and start-menu entry, but that's optional. Is that means a .py convert to .pyc or .pyo, without the need of make file as using py2exe? Huh? You don't need a make file for py2exe. -- Grant Edwards grante Yow! I'd like TRAINED at SEALS and a CONVERTIBLE on visi.commy doorstep by NOON!! -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
On 2005-04-27, dcrespo [EMAIL PROTECTED] wrote: And what did you use for deploying either PyGTK and wxPython? In other words, what were your workspace and logic of the development? To whom is this question addressed? I suggest you quote properly when replying in order to give your question the context required to answer it. -- Grant Edwards grante Yow! Am I elected yet? at visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
On 2005-04-27, dcrespo [EMAIL PROTECTED] wrote: Aaand: which do you prefer? Neither particularly. I'm using wxPython because GTK for windows wasn't ready three years ago when I initially had to write my first Windows application. If I evaluated both of them again today, I might choose GTK, and I might not. -- Grant Edwards grante Yow! INSIDE, I have the at same personality disorder visi.comas LUCY RICARDO!! -- http://mail.python.org/mailman/listinfo/python-list
Re: parse tree has symbols not in the grammar?
Terry, Thanks for the reply. Did you not find them in grammar.txt, which you referenced, or Grammar/Grammar is the source, which you did not. I didn't find them in grammar.txt. I didn't find Grammar/Grammar because I was looking in an installed Python rather than the source (my mistake; I've found it now). I assumed that the two would the same. Guido has said that the grammar in the ref manual, meant for human consumption, is equivalent to but not quite the same as the grammar used to generate the parser, which has to meet LL1 constraints. Ok, thanks for the info. While I found a comment re: the ref manual being for human consumption[1], I didn't take this to mean that its grammar was actually not the same as the implementation grammar, only that it was set forth in English (hence, my assumption above). Would there be any value, I wonder, in posting Grammar/Grammar with the rest of the docs, e.g., at doc/ref/grammar-parser.txt? Thanks again for the sanity check! chad -- [1] http://python.org/doc/ref/introduction.html -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
On 26 Apr 2005 18:15:51 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there some reason why you want to run the .pyc file, rather than the .py file? If you start the script with a. It's more efficient, since the code doesn't need to be compiled before it's run. b. What if you want to ship closed-source? Mike -- Michael P. Soulier [EMAIL PROTECTED] http://www.digitaltorque.ca http://opag.ca python -c 'import this' -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
If you see carefully, that question was for you too, because the reply is at the same level as the one that says Aaand: which do you prefer? :) Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
The ActiveGrid IDE is a sample app with wxPython. It has a lot of good features including a source code debugger that allows you to debug wx apps and set breakpoints from the code editor. I am also biased though--I work on that IDE and use it for all my coding. Its pretty far along on Windows and getting better on Linux. We just got it working on a Mac yesterday so that version won't be out for a bit. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
On 25 Apr 2005 08:56:23 -0700, dcrespo [EMAIL PROTECTED] wrote: Hi all... I'm learning both, but at a slow step, so I want to know all the comments about this subject in this group. Personally, I like pyGTK more because the docs are better. There's nothing I hate more than trying to use an API that's poorly documented, and wxPython's is horrid. The API docs are for C++ with an occasional comment about Python, and the examples are all done with an obsolete API that has since been updated. I've found wxPython very frustrating for these reasons, whereas PyGTK's docs are up-to-date and well done, easy to work with. Maybe the wxPython people think their docs are good, but likely they've forgotten how well they already know the API. They need to take the time to update them. Mike -- Michael P. Soulier [EMAIL PROTECTED] http://www.digitaltorque.ca http://opag.ca python -c 'import this' -- http://mail.python.org/mailman/listinfo/python-list
How do I parse this ? regexp ?
Hello all, I have this line of numbers: 04242005 18:20:42-0.02, 271.1748608, [-4.119873046875, 3.4332275390625, 105.062255859375], [0.093780517578125, 0.041015625, -0.960662841796875], [0.01556396484375, 0.01220703125, 0.01068115234375] repeated several times in a text file and I would like each element to be part of a vector. how do I do this ? I am not very capable in using regexp as you can see. Thanks in advance, Jake. -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I parse this ? regexp ?
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Hello all, I have this line of numbers: 04242005 18:20:42-0.02, 271.1748608, [-4.119873046875, 3.4332275390625, 105.062255859375], [0.093780517578125, 0.041015625, -0.960662841796875], [0.01556396484375, 0.01220703125, 0.01068115234375] repeated several times in a text file and I would like each element to be part of a vector. how do I do this ? I am not very capable in using regexp as you can see. You don't need a regexp to do that. Use the split string method. It will split on spaces by default. If you want to keep the values inside [] together, remove the spaces before splitting or split on the [ char first and then split the first item using spaces as a separator. Be seeing you, -- Jorge Godoy [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
On Wednesday 27 April 2005 01:16 pm, monkey wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. Is Boa actively used? There doesn't seem to be much activity its mailing list. The tutorial fails for me using python 2.3.5, wxpython 2.5.3.2 and Boa 0.4.0 under debian sid. Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
Michael Soulier wrote: Is there some reason why you want to run the .pyc file, rather than the .py file? If you start the script with a. It's more efficient, since the code doesn't need to be compiled before it's run. b. What if you want to ship closed-source? #!/usr/bin/env python import app hardly qualifies as hard to compile or open source /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
On Wed, 27 Apr 2005 21:16:29 +0800, monkey [EMAIL PROTECTED] wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. If you intend to use Python for Matlab-like calculations with numerical arrays and plotting with Matplotlib, then ipython is the right choice-- it has a special 'pylab' mode that is Matplotlib-aware, allowing you to make plots interactively (as well as various other useful features). Matt Feinstein -- There is no virtue in believing something that can be proved to be true. -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
monkey wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. Here's been my experience: * Don't underestimate IDLE, it's surprisingly capable considering it's just a dinky little thing * PyDev isn't yet mature enough to make it practical for me * SPE has great features, but the pure-Python-ness makes it slow! Even just typing at a steady pace is slowed down due to all the name lookups. Plus, I still haven't found a way to reset the built-in Python shell, so if you run/import your module into it, you have to reload the entire app to reuse the shell. del module-name doesn't help because the classes will still be in the registry * WingIDE is the most advanced by far, but isn't free. Its built-in Python shell also suffers from not easily being able to test _the module you're writing_ without a bunch of path switching. I remember the interface feeling slow on Windows, but on Linux everything is snappy. The quickness of the autocompletion for even seperate module members amazes me * If you're running KDE, KDevelop is very capable. The autocompletion is very generic though, it'll happily complete any word you've typed before. The auto-indentation isn't nearly as spot-on as WingIDE's * I hate PythonWin or whatever it's called. Dunno what more to say -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list
Re: delete will assure file is deleted?
Christos TZOTZIOY Georgiou wrote: Although I don't have experience with FreeBSD, so far checking the exception's errno args does the job. if that doesn't work on FreeBSD, FreeBSD is not a proper Unix. import errno try: ... except OSError, exc: if exc.errno == errno.ENOENT: # file inexistant ... elif exc.errno == errno.EPERM: # no permissions ... make that elif exc.errno in (errno.EACCES, errno.EPERM): # no permissions /F -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
it's not quite true since the latest stable release (2.6.0.0) see the new wx doc (it's generated with epydoc so it's not for C++): http://www.wxpython.org/docs/api/ i used wxPython with XRCed a few times and i liked the way it works (worked under linux and win as well for me) nsz -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
#!/usr/bin/env python import app Yes, of course this is a possibility. But it implies having (or giving away) two files. I think having one file is always better than having two files. Because if you have two files, you need a third one: a README that tells you what to do with the two files and that one of the files must either be in $PYTHONPATH, or in the same directory as the other one and '.' must be in your $PYTHONPATH , and so on. Actually, some people will also need a fourth file: One that contains an explanation of terms like $PYTHONPATH and the like. Jörg -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
py2exe has nothing to do with C or make files. You create a setup.py file containing a couple lines of python. You run that python program, and you end up with an .exe file and some associated .dll files. I typically use inno-setup to create an installer.exe that creates a desktop icon and start-menu entry, but that's optional. Is py2exe used to make a .exe file to install .py, or make the self-contain .exe file of the program itself? -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
Szabolcs Nagy wrote: it's not quite true since the latest stable release (2.6.0.0) see the new wx doc (it's generated with epydoc so it's not for C++): http://www.wxpython.org/docs/api/ i used wxPython with XRCed a few times and i liked the way it works (worked under linux and win as well for me) +1. I've had a lot of success with XRCed, but no success with wxGlade. The UI in XRCed needs polish but it's easy enough to use. Also, wxGlade wants to spew generated Python code, while XRCed generates a nice resource file that wx can load easily. Shane -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
On Wed, 27 Apr 2005 10:37:11 -0400, Michael Soulier [EMAIL PROTECTED] wrote: On 26 Apr 2005 18:15:51 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there some reason why you want to run the .pyc file, rather than the .py file? If you start the script with a. It's more efficient, since the code doesn't need to be compiled before it's run. b. What if you want to ship closed-source? I don't think either of these reasons is particularly compelling. To avoid the costs of byte compilation (which are typically pretty minimal), structure your code to have a simple, short main .py file which imports most of its code from other modules. This gives you the automatic byte compilation caching behavior Python normally uses for imports for the bulk of your code. Shipping closed source takes a lot more than just shipping .pyc files. .pyc files are trivially (or near trivially) converted back into .py files. The only parts which cannot be restored are the comments, which are discarded at compilation time. Jp -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
I really like eclipse + pydev Regards, Philippe monkey wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
I just happened across the page linked to below, and remembered this thread, and, well... here you go: http://www.lyra.org/greg/python/ Executable .pyc files Ever wanted to drop a .pyc file right into your web server's cgi-bin directory? Frustrated because the OS doesn't know what to do with a .pyc? (missing the #! line) Look no further! :-) Below is a tiny Bash script to do this. cat your .pyc onto the end of this and drop it wherever you need direct execution of that .pyc -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I parse this ? regexp ?
Hello, I am not understanding your answer, but I probably asked the wrong question :-) I want to remove the commas, and square brackets [ and ] characters and rewrite this whole line (and all the ones following in a text file where only space would be a delimiter. How do I do this ? I have tried this: f = open(name3,'r') r = r\d+\.\d* for line in f: cols = line.split() data1 = re.findall(r,line) and then I don't know what to do with either cols nor data1 Jake. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
On 2005-04-27, dcrespo [EMAIL PROTECTED] wrote: If you see carefully, that question was for you too, because the reply is at the same level as the one that says Aaand: which do you prefer? :) You're assuming that everybody's newsreader displays things in the same manner yours does. You're wrong: they don't. -- Grant Edwards grante Yow! Maybe we could paint at GOLDIE HAWN a rich PRUSSIAN visi.comBLUE -- -- http://mail.python.org/mailman/listinfo/python-list
RE: How do I parse this ? regexp ?
From: [EMAIL PROTECTED] I want to remove the commas, and square brackets [ and ] characters and rewrite this whole line (and all the ones following in a text file where only space would be a delimiter. How do I do this ? If all you want to do to the data as you read in and write out a line, how about string.replace('[',' ')? x = 'as[df]as,df' x = x.replace(']',' ') x = x.replace('[',' ') x = x.replace(',',' ') ___ The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
On 2005-04-27, monkey [EMAIL PROTECTED] wrote: py2exe has nothing to do with C or make files. You create a setup.py file containing a couple lines of python. You run that python program, and you end up with an .exe file and some associated .dll files. I typically use inno-setup to create an installer.exe that creates a desktop icon and start-menu entry, but that's optional. Is py2exe used to make a .exe file to install .py, or make the self-contain .exe file of the program itself? The latter. It's not completely self contained, there is an ..exe and some dll files that need to be distributed together. It's explained very clearly by the py2exe web site: http://starship.python.net/crew/theller/py2exe/ Never used google before? Just go to www.google.com and type in py2exe. Click search. It's the first hit. -- Grant Edwards grante Yow! Is something VIOLENT at going to happen to a visi.comGARBAGE CAN? -- http://mail.python.org/mailman/listinfo/python-list
Re: Secure FTP
In article [EMAIL PROTECTED], Daniel Bowett [EMAIL PROTECTED] wrote: I need to download files over a secure channel. I have been looking into Paramiko which seems to have the functonality I need. The problem is I need a FTP server which supports key based encryption to install on my windows server. Has anyone succeeded in doing this? If so - what FTP server did you use? Well, not precisely this, since we're fortunate to be able to leave the Microsoft part out of the equation, but it may help to know that GSSAPI Kerberos5 is a standard FTP authentication that includes encryption, so if you can authenticate that way, you can get encrypted data transfer. Microsoft supports and uses Kerberos5 -- their domain controller is a Kerberos KDC -- but interoperability with other platforms is a problem, and so far as I know it's purely internal and never supported in Microsoft's own software for any of the client/server protocols that use it elsewhere. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
monkey wrote: Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse) also worth looking. Actually which one are you guys using? and why? I think it is also valuable for those who are new to python as me. Eric3 for big stuff. SciTE for small stuff. -- http://mail.python.org/mailman/listinfo/python-list
Re: suggestions on how to do this
chris [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a recursive function b(k) b(k) = -(A/k**2)*(b(k-2) - b(k-5)) This is specifically called a recurrence relation/ [snip] When this is expanded I get a polynomial F(A). I want to determine the coefficients of the polynomial so that I can find the roots of the function F up to a specified order of A. This is a math/numerical analysis problem. If you don't get an answer here, I'd look for a text of recurrence relations and polynomials, and look for a math/numerical analysis newsgroup. sci.mathematics? Note: your subject line is so vague that a specialist who can tell you more could but only selectively opens threads could easily miss this. It is only happenstance that I didn't. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: bytecode non-backcompatibility
Maurice LING [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So my alternative solution is that PyPI have a mechanism to maintain what had been installed in the site-package directory and to download the libraries and install into the new site-package directory... What do you think? I doubt anyone disputes that upgrades are more hassle than we would like. My main point was that freezing CPython's technology is not the solution. Any other upgrade helper that you can contribute will be welcome. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE is recommended?
* Don't underestimate IDLE, it's surprisingly capable considering it's just a dinky little thing Yes, I believe IDLE is the a unbeatible last resort for python (-: * SPE has great features, but the pure-Python-ness makes it slow! Is it related to wxpython you mean? or program with GUI in tk (the default installed with python) is faster? Would you mind to tell me more... -- http://mail.python.org/mailman/listinfo/python-list
Re: names of methods, exported functions
Michael Hoffman wrote: Bengt Richter wrote: Using help: (BTW, it would be nice to have some keyword arguments for help to filter down information to exclude what may not be interesting) No kidding. What do you think the output should look like in that case? I think we don't need the mro, or any of the magic methods inherited from the builtin. -- Michael Hoffman The help code is part of pydoc, IIRC, feel free to have a go at it ;) M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I parse this ? regexp ?
Thank you, it works, but I guess not all the way: for instance, I have this: 04242005 18:20:42-0.024329, 271.2469504, [-4.097900390625, 3.4332275390625, 105.062255859375], [0.0384521484375, 0.08416748046875, -1.026885986328125], [0.00640869140625, 0.00885009765625, 0.00701904296875] translates into '04242005 18:20:42-0.024329 271.2469504 -4.097900390625 3.4332275390625 105.0622558593750.0384521484375 0.08416748046875 -1.0268859863281250.00640869140625 0.00885009765625 0.00701904296875 \n' but I need to remove the first - between 18:20:42 and 0.024329 but not the others. Thank you in advance, Jake. -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
Joerg Schuster wrote: #!/usr/bin/env python import app Yes, of course this is a possibility. But it implies having (or giving away) two files. yeah, think of all the disk space you'll waste! Because if you have two files, you need a third one: a README that tells you what to do with the two files so you're saying that the set of people that can deal with no more than one file at a time but knows how to install and configure Python (which in itself comes with a few thousand files) is larger than zero? I think having one file is always better than having two files. so you don't ever use modules? you haven't distributed many Python programs, have you? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: compile shebang into pyc file
On 2005-04-27, Fredrik Lundh [EMAIL PROTECTED] wrote: so you're saying that the set of people that can deal with no more than one file at a time but knows how to install and configure Python (which in itself comes with a few thousand files) is larger than zero? There are a lot of Linux users who already have python installed but don't know it. Python was always a required package for a RedHat install. It's not required on some distros, but it's installed by default and you've got to go out of your way to de-selected it when you install. I've found that giving Linux users a single file executable Python script works wonderfully, but it's really only an option for fairly small applications -- and I don't care if they have source code. -- Grant Edwards grante Yow! Look!! Karl Malden! at visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I parse this ? regexp ?
[EMAIL PROTECTED] wrote: Thank you, it works, but I guess not all the way: for instance, I have this: 04242005 18:20:42-0.024329, 271.2469504, [-4.097900390625, 3.4332275390625, 105.062255859375], [0.0384521484375, 0.08416748046875, -1.026885986328125], [0.00640869140625, 0.00885009765625, 0.00701904296875] translates into '04242005 18:20:42-0.024329 271.2469504 -4.097900390625 3.4332275390625 105.0622558593750.0384521484375 0.08416748046875 -1.0268859863281250.00640869140625 0.00885009765625 0.00701904296875 \n' but I need to remove the first - between 18:20:42 and 0.024329 but not the others. Use the find() method on the string to locate the index of this first '-', then break the line into two parts before and after the '-'. You should spend some quality time with the string documentation to internalize the possibilities for yourself. There's only so much work we can do for you. Also, take a look at David Mertz's fine _Text Processing in Python_ available in dead-tree form or online. http://gnosis.cx/TPiP/ -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
how can I sort a bunch of lists over multiple fields?
I didn't think this would be as difficult as it now seems to me. I am reading in a csv file that documents a bunch of different info on about 200 books, such as title, author, publisher, isbn, date and several other bits of info too. I can do a simple sort over the first field (title as it turns out), and that is fine as far as it gets: import string bookData = open(r'D:\path\to\books.csv', 'r') sBookData = bookData.read() lBooks = string.split(sBookData, '\n') lBooks.sort() sorted = string.join(lBooks, '\n') output = open(r'D:\path\to\output.csv', 'w') output.close() I really want to be able to sort the list of books based on other criterium, and even multiple criteria (such as by author, and then by date.) I am using python 2.4 and have found this site: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305304 and so I tried doing things like lBooks.sort(cmp=cmp5) Traceback (most recent call last): File interactive input, line 1, in ? NameError: name 'cmp5' is not defined (I was hoping that cmp5 meant it would use the 5th item in the lists to sort across) lBooks.sort(key=lambda i:i[4]) Traceback (most recent call last): File interactive input, line 1, in ? File interactive input, line 1, in lambda IndexError: string index out of range (I was hoping for similar things) would you be so kind as to point me in the right direction? THanks! googleboy -- http://mail.python.org/mailman/listinfo/python-list