Roundup Issue Tracker release 0.8
I'm proud to release this 8th major feature release of Roundup. First up, big thanks go to alexander smishlajev who has done some really good work getting the i18n and new configuration components of this release going. Please note that Roundup now requires Python 2.3 or later. Please continue to use 0.7 if you require Python 2.1 compatibility. Version 0.8 introduces far too many features to list here so I've put together a What's New page: http://roundup.sourceforge.net/doc-0.8/whatsnew-0.8.html This 0.8.0 release fixes some bugs in the previous beta releases: - handle capitalisation of class names in text hyperlinking (sf bug 1101043) - quote full-text search text in URL generation - fixed problem migrating mysql databases - fix search_checkboxes macro (sf patch 1113828) - fix bug in date editing in Metakit - allow suppression of search_text in indexargs_form (sf bug 1101548) - hack to fix some anydbm export problems (sf bug 1081454) - ignore AutoReply messages (sf patch 1085051) - fix ZRoundup syntax error (sf bug 1122335) - fix roundup-server log and PID file paths to be absolute - fix initialisation of roundup-server in daemon mode so initialisation errors are visible - fix: 'Logout' link was enabled on issue index page only - have Permissions only test the check function if itemid is suppled - modify cgi templating system to check item-level permissions in listings - enable batching in message and file listings - more documentation of security mechanisms (incl. sf patches 1117932, 1117860) - better unit tests for security mechanisms - code cleanup (sf patch 1115329 and additional) - issue search page allows setting of no sorting / grouping (sf bug 1119475) - better edit conflict handling (sf bug 1118790) - consistent text searching behaviour (AND everywhere) (sf bug 1101036) - fix handling of invalid date input (sf bug 1102165) - retain Boolean selections in edit error handling (sf bug 1101492) - fix initialisation of logging module from config file (sf bug 1108577) - removed rlog module (py 2.3 is minimum version now) - fixed class help listing paging (sf bug 1106329) - nicer error looking up values of None (response to sf bug 1108697) - fallback for (list) popups if javascript disabled (sf patch 1101626) If you're upgrading from an older version of Roundup you *must* follow the Software Upgrade guidelines given in the maintenance documentation. Roundup requires python 2.3 or later for correct operation. To give Roundup a try, just download (see below), unpack and run:: python demo.py Source and documentation is available at the website: http://roundup.sourceforge.net/ Release Info (via download page): http://sourceforge.net/projects/roundup Mailing lists - the place to ask questions: http://sourceforge.net/mail/?group_id=31577 About Roundup = Roundup is a simple-to-use and -install issue-tracking system with command-line, web and e-mail interfaces. It is based on the winning design from Ka-Ping Yee in the Software Carpentry Track design competition. Note: Ping is not responsible for this project. The contact for this project is [EMAIL PROTECTED] Roundup manages a number of issues (with flexible properties such as description, priority, and so on) and provides the ability to: (a) submit new issues, (b) find and edit existing issues, and (c) discuss issues with other participants. The system will facilitate communication among the participants by managing discussions and notifying interested parties when issues are edited. One of the major design goals for Roundup that it be simple to get going. Roundup is therefore usable out of the box with any python 2.1+ installation. It doesn't even need to be installed to be operational, though a disutils-based install script is provided. It comes with two issue tracker templates (a classic bug/feature tracker and a minimal skeleton) and five database back-ends (anydbm, sqlite, metakit, mysql and postgresql). -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
[ANN] Data Plotting Library DISLIN 8.3
I am pleased to announce version 8.3 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for several C, Fortran 77 and Fortran 90 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported for the most operating systems. DISLIN distributions and manuals in PDF, PostScript and HTML format are available from the DISLIN home page http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin --- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Copying data between file-like objects
Thomas Lotze wrote: if you don't know how large f2 can be, use shutil.copyfileobj: help(shutil.copyfileobj) Help on function copyfileobj in module shutil: copyfileobj(fsrc, fdst, length=16384) copy data from file-like object fsrc to file-like object fdst This sounds like what I was looking for. Thanks for the pointer. However, the following doesn't seem like anything is being copied: from StringIO import StringIO from shutil import copyfileobj s = StringIO() s2 = StringIO() s.write('asdf') copyfileobj(s, s2) s2.getvalue() copyfileobj copies from the current location, and write leaves the file pointer at the end of the file. a s.seek(0) before the copy fixes that. to copy stringio objects, you can use f1 = StringIO(f2.getvalue()). But this should have the same problem as using read(): a string will be created on the way which contains all the content. getvalue() returns the contents of the f2 file as a string, and f1 will use that string as the buffer. there's no extra copying. Because I want to manipulate a copy of the data and be able to compare it to the original afterwards. why not just use a plain string (or a list of strings)? your focus on StringIO sounds like a leftover from some C library you've been using in an earlier life ;-) Another thing I'd like to do is copy parts of a StringIO object's content to another object. This doesn't seem possible with any shutil method. Any idea on that? use a plain string and slicing. (if you insist on using StringIO, use seek and read) What one can really wonder, I admit, is why the difference between holding data two or three times in memory matters that much, especially if the latter is only for a short time. But as I'm going to use the code that handles the long string as a core component to some application, I'd like to make it behave as well as possible. use plain strings, so you know what you're doing. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: check if object is number
Steven Bethard wrote: Actually no, floats don't meet this behaviour or more specifically floats don't guarantee this behaviour. It depends of course on your implementation of f, but it is possible with floats to keep incrementing and never reach a maximum. My code won't hit this corner case. I'm incrementing with integers. incrementing what with integers? f = 9007199254740992.0 f == f+1 True /F -- http://mail.python.org/mailman/listinfo/python-list
How new Check 21 legislation is affecting you...
Good Afternoon! Recenty intrdocuced legislation requires business and home users to print personal and business checks with security blank check stock and magnetic ink. Please find qualified suppliers at Google by clicking on the followingl link. http://www.google.com/search?sourceid=navclientie=UTF-8rls=GGLC,GGLC:1969-53,GGLC:enq=blank+check+paper%2C+magnetic+ink+for+inkjets Thank you very much. Cathleen Baer Marketing Relationship Representative Globalzon Consulting Group -- http://mail.python.org/mailman/listinfo/python-list
Re: perl -p -i -e trick in Python?
On Wed, 16 Feb 2005 01:44:40 -0500, rumours say that Jack Diederich [EMAIL PROTECTED] might have written: /tmp/ python Python 2.3.4 (#2, Jan 5 2005, 08:24:51) Type help, copyright, credits or license for more information. ^D Instant porting of any program to python. Smooth. -- 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: Copying data between file-like objects
Fredrik Lundh wrote: copyfileobj copies from the current location, and write leaves the file pointer at the end of the file. a s.seek(0) before the copy fixes that. Damn, this cannot be read from the documentation, and combined with the fact that there's no length parameter for a portion to copy either, I thought copying would mean copying all. getvalue() returns the contents of the f2 file as a string, and f1 will use that string as the buffer. there's no extra copying. Oh, good to know. Then StringIO(f2.getvalue()) or StringIO(f2.read()) would be the way to go. Because I want to manipulate a copy of the data and be able to compare it to the original afterwards. why not just use a plain string (or a list of strings)? your focus on StringIO sounds like a leftover from some C library you've been using in an earlier life ;-) Because the data can be a lot, and modifying long strings means a lot of slicing and copying partial strings around, if I understand right. Modifying a StringIO buffer is possible in-place. Plus, it's easier to teach an algorithm that works on a StringIO to use a file instead, so I may be able to avoid reading stuff into memory altogether in certain places without worrying about special cases. use a plain string and slicing. (if you insist on using StringIO, use seek and read) OK. -- Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Michael Hoffman schrieb: Ilias Lazaridis wrote: But don't act like the volunteers who develop Python owe you a version of Python that runs out of the box on MinGW. They don't, anymore than you owe *me* a version of Python that runs out of the box on MinGW. Please, leave him alone. When he posted here first his tone made me suspicious and I did some searching. Replies like yours are exactly what he wants. He is here to fight and to waste your time. But if you enjoy this ... go ahead ;) I don't so this will be my only post in this thread. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES
Ilias Lazaridis schrieb: I'm a newcomer to python: Sorry, I'm breaking my promise to post only once to this thread. But I've found the ultimate recipe to resolve all issues of this and other similar threads: Please read http://nobelprize.org/medicine/educational/pavlov/ and then do something useful :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
Hans Nowak built some old DOS binaries... although I believe on his website he points to a more 'modern' projects. Sorry - restricted internet or I would check for you. Try http://zephyrfalcon.org Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: perl -p -i -e trick in Python?
Hello Wonjae, I read the comment of http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277753. (Title : Find and replace string in all files in a directory) perl -p -i -e 's/change this/..to this/g' trick looks handy. Does Python have a similar trick? Or, is there a shorter Python recipe for the given problem? See the fileinput module. HTH. -- Miki Tebeka [EMAIL PROTECTED] http://tebeka.bizhat.com The only difference between children and adults is the price of the toys -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Fredrik Lundh wrote: in this case, def __del__(self): super(self.__class__, self).__del__() should do the trick. Only if nobody ever tries to subclass your class, and if they aren't going to subclass it why bother to use super in the first place. class Base(object): def __del__(self): print Base.__del__ class A(Base): def __del__(self): print A.__del__ super(self.__class__, self).__del__() class B(A): def __del__(self): print B.__del__ super(self.__class__, self).__del__() a = A() del a A.__del__ Base.__del__ b = B() del b B.__del__ A.__del__ A.__del__ A.__del__ A.__del__ A.__del__ ... and so on ... I don't see any easy way to ensure that the __del__ method gets passed up the chain safely. -- http://mail.python.org/mailman/listinfo/python-list
Re: problem: reducing comparison
©someone sent me the following code, which performs identically with the original reduce. (tested for pairings of comb(n) with large n) Superb. © ©def reduce2( pairings, pair ): ©result={} ©for i,j in pairings.itervalues(): ©if i in pair: i=pair[0] ©if j in pair: j=pair[0] ©if ij: (i,j) = (j,i) ©if i!=j: result[%d,%d%(i,j)] = (i,j) ©return result © © ©def reduce(pairings, pair): ©ps=pairings.copy(); j=pair; ©ps.pop(%d,%d%(j[0],j[1]),0) ©for k in pairings.itervalues(): © if (k[0]==j[0]): ©if (j[1] k[1]): ©ps.pop(%d,%d%(j[1],k[1]),0) ©else: ©ps.pop(%d,%d%(k[1],j[1]),0) ©if (k[1]==j[0]): ©if (k[0] j[1]): ©ps.pop(%d,%d%(k[0],j[1]),0) ©else: ©ps.pop(%d,%d%(j[1],k[0]),0) ©return ps © ©is reduce2 more efficient? It works entirely differently. I'll have to think about it... besides algorithmic... onto the minute academic diddling, i wonder if it is faster to delete entries in dict or add entries... Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html Xah Lee wrote: here are the answers: Perl code: sub reduce ($$) { my %hh= %{$_[0]}; # e.g. {'1,2'=[1,2],'5,6'=[5,6],...} my ($j1,$j2)=($_[1]-[0],$_[1]-[1]); # e.g. [3,4] delete $hh{$j1,$j2}; foreach my $k (keys %hh) { $k=~m/^(\d+),(\d+)$/; my ($k1,$k2)=($1,$2); if ($k1==$j1) { if ($j2 $k2) { delete $hh{$j2,$k2}; } else { delete $hh{$k2,$j2}; }; }; if ($k2==$j1) { if ($k1 $j2) { delete $hh{$k1,$j2}; } else { delete $hh{$j2,$k1}; }; }; } return \%hh; } ... In imperative languages such as Perl and Python and Java, in general it is not safe to delete elements when looping thru a list-like entity. (it screws up the iteration) One must make a copy first, and work with the copy. Note also that in Python there's already a function called reduce. (it is equivalent to Mathematica's Fold.) In Python, looks like user can over-ride default functions. This post is archived at http://xahlee.org/perl-python/pairing_reduce.html Possible errata or addenda will appear there. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list
Re: pyFMOD writing a callback function in Python
Hi, Check out pySonic, a new FMOD wrapper written with Pyrex. Much more Pythonic. I have only found Win32-Downloads. The same is true for pyFMOD. What options do I have to make it work on Linux? Ciao, MM -- Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013. http://www.marian-aldenhoevel.de Wir brauchen keine Opposition, wir sind bereits Demokraten. -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables.
sry, I mean the problem is... about lining it doesn't look like this... Allen woke up early in the morning. But, it was unusal by Allen. Allen's pillow was with Allen. Allen didn't want to wake up But, Allen tried my best and woke up. it was so amazing -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Duncan Booth wrote: Fredrik Lundh wrote: in this case, def __del__(self): super(self.__class__, self).__del__() should do the trick. Only if nobody ever tries to subclass your class, and if they aren't going to subclass it why bother to use super in the first place. class Base(object): def __del__(self): There should be a super(self.__class__, self)._del__() here if I'm not totaly wong, which could be the case here ;) print Base.__del__ -- -- Ola Natvig [EMAIL PROTECTED] infoSense AS / development -- http://mail.python.org/mailman/listinfo/python-list
MYSQL - how to install ?
I use XP windows and Python 2.3. How can I install MYSQL on my computer? I could not find any installer for MYSQL and Python 2.3 Thanks for help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Ola Natvig wrote: def __del__(self): There should be a super(self.__class__, self)._del__() here if I'm not totaly wong, which could be the case here ;) print Base.__del__ There was one, but for some reason you trimmed it out of your quote: The original code before you trimmed it was: class B(A): def __del__(self): print B.__del__ super(self.__class__, self).__del__() -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables.
administrata wrote: sry, I mean the problem is... about lining it doesn't look like this... Allen woke up early in the morning. But, it was unusal by Allen. Allen's pillow was with Allen. Allen didn't want to wake up But, Allen tried my best and woke up. it was so amazing In the future, please follow the advice given on this page: http://www.catb.org/~esr/faqs/smart-questions.html Also, consider joining the tutor mailing list. http://mail.python.org/mailman/listinfo/tutor For this problem, see the textwrap module in the standard library. http://docs.python.org/lib/module-textwrap.html -- 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
Re: [ANN] IPython 0.6.11 is out.
Warning - if you are upgrading and have an old pysh.py dangling around in $HOME/.ipython, be sure to delete it. The old version is incompatible with the new ipython. -- Ville Vainio http://tinyurl.com/2prnb -- http://mail.python.org/mailman/listinfo/python-list
Re: MYSQL - how to install ?
Download MySQL for windows at: http://www.mysql.com Then: http://www.google.co.uk/search?hl=enq=python+mysqlbtnG=Google+Searchmeta= Lad wrote: I use XP windows and Python 2.3. How can I install MYSQL on my computer? I could not find any installer for MYSQL and Python 2.3 Thanks for help Lad. -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
john san wrote: How to install python under DOS and is there any Wxpython-like can be installed under dos? Thanks. Are you actually still running a pure DOS machine? Or are you running the dos prompt through Windows? -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] problem: reducing comparison
Xah Lee wrote: attached below is the Perl documentation that i wrote for a function called reduce, which is really the heart of a larger software. Don't shadow built-ins. Especially for a function name. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list
Re: MYSQL - how to install ?
For MySQL on windows go here: http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.10-win32.zip/from/pick#mirrors For Python 2.3.5 binary installer for win32: http://www.python.org/ftp/python/2.3.5/Python-2.3.5.exe -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
Any reason you're asking about wxPython for DOS? Just curious. -- http://mail.python.org/mailman/listinfo/python-list
Re: some qustions on python
Can you be a bit more specific about what you're wanting? A design process will be very similar across languages no matter which language it is. If you'd like a small evaluation of Python you're best served by reading the official summary: http://www.python.org/doc/Summary.html Else you'll always be directed to Eric Raymond's How To Ask Smart Questions FAQ ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Duncan Booth wrote: There was one, but for some reason you trimmed it out of your quote: The original code before you trimmed it was: Look carefully, he was commenting on the contents of class Base (which does omit the line he suggests), not class B. Whether he's correct or not, I'm not wizardly enough to comment on. -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler
Easy, easy... Use py2exe: http://starship.python.net/crew/theller/py2exe/ -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Ola Natvig wrote: Duncan Booth wrote: class Base(object): def __del__(self): There should be a super(self.__class__, self)._del__() here if I'm not totaly wong, which could be the case here ;) print Base.__del__ Thanks to Brian Beck for pointing out I hadn't read your question correctly. There must not be a super call from the class Base. This is a common problem when using super: if the method you are propagating isn't defined by 'object' (and most aren't), then you must provide some way to terminate the chain of calls. One way to do this is to ensure that you have some base class which does not attempt to pass the call upwards. Then all you have to do is ensure that everything that has the method is a subclass of Base and this will ensure that the Base method will be the last method called in the super chain. If I had included a super call: class Base(object): def __del__(self): print Base.__del__ super(self.__class__, self).__del__() x = Base() del x Base.__del__ Exception exceptions.AttributeError: 'super' object has no attribute '__del__' in bound method Base.__del__ of __main__.Base object at 0x00B43D90 ignored -- http://mail.python.org/mailman/listinfo/python-list
Architecture of Python restored! [was Re: Architecture of Python was removed ?]
Jim Jackson's UIUC email address is/was [EMAIL PROTECTED] Jim, if you're out there, is it okay to reconstruct your old C427 assignment somewhere else? The original pages at http://wiki.cs.uiuc.edu/cs427/PYTHON appear to be restored completely, including the nice visualizations! thanks, Gerrit -- Gaudi systems architecting: http://www.extra.research.philips.com/natlab/sysarch/ -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Data Plotting Library DISLIN 8.3
I am pleased to announce version 8.3 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for several C, Fortran 77 and Fortran 90 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported for the most operating systems. DISLIN distributions and manuals in PDF, PostScript and HTML format are available from the DISLIN home page http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin --- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Am Tue, 15 Feb 2005 18:57:47 -0800 schrieb Paul Rubin: I've started a few threads before on object persistence in medium to high end server apps. This one is about low end apps, for example, a simple cgi on a personal web site that might get a dozen hits a day. The idea is you just want to keep a few pieces of data around that the cgi can update. [cut] Anyway, something like dbm or shelve coupled with flock-style file locking and a version of dbmopen that automatically retries after 1 second if the file is locked would do the job nicely, plus there could be a cleanup mechanism for detecting stale locks. Is there a standard approach to something like that, or should I just code it the obvious way? Hi, I would use the pickle module and access to the pickle files could be serialized (one after the other is allowed to read or write) with file locking. This means your cgi application can only serve one request after the other. HTH, Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Maybe ZODB helps. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
supress creation of .pyc files
Hi, Is there a way to import a file without creating a .pyc file? Of course you can delete the pyc in my script after the import statement, but maybe there is a switch that I have not found yet. The imported file is a config file, not a script. Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Diez B. Roggisch [EMAIL PROTECTED] writes: Maybe ZODB helps. I think it's way too heavyweight for what I'm envisioning, but I haven't used it yet. I'm less concerned about object persistence (just saving strings is good enough) than finding the simplest possible approach to dealing with concurrent update attempts. -- http://mail.python.org/mailman/listinfo/python-list
Re: supress creation of .pyc files
On Wed, 16 Feb 2005 14:53:22 +0100, Thomas Guettler wrote: The imported file is a config file, not a script. You could use execfile() to read the file, and not import. Jeremy -- http://mail.python.org/mailman/listinfo/python-list
adding new functionality to a function non-intrusively!
Hello all, Recently I've started to refactor my code ... I would like to add extra functionality to a function !non-intrusively! (not rewriting the old code is really important) How can I achieve this? Thus I start with an old function named fA. I would like to add extra functionality to fA. Essentially this gives a new function fA which can call the old function fA thanks a lot for reading so far Peter ps. following idea does not work! # fA = old fA, already defined def tempFunc(*args): # do something with fA return fA = tempFunc # gives infinite loop, recursive mails # this example is explained in more detail in other mail called: renaming 'references' to functions gives recursive problems' -- http://mail.python.org/mailman/listinfo/python-list
Re: Stable GUI
Check out EasyGui. It's easy to use/modify Tinker: http://www.ferg.org/easygui/ From the web page: Experienced Pythonistas need support for quick and dirty GUI features. New Python programmers need GUI capabilities that don't require any knowledge of Tkinter, frames, widgets, callbacks or lambda. This is what EasyGUI provides. Using EasyGUI, all GUI interactions are invoked by simple function calls. EasyGUI is different from other GUIs in that EasyGUI is NOT event-driven. It allows you to program in a traditional linear fashion, and to put up dialogs for simple input and output when you need to. If you have not yet learned the event-driven paradigm for GUI programming, EasyGUI will allow you to be productive with very basic tasks immediately. Later, if you wish to make the transition to an event-driven GUI paradigm, you can do so with a more powerful GUI package such as anygui, PythonCard, Tkinter, wxPython, etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Diez B. Roggisch [EMAIL PROTECTED] writes: I think it's way too heavyweight for what I'm envisioning, but I haven't used it yet. I'm less concerned about object persistence (just saving strings is good enough) than finding the simplest possible approach to dealing with concurrent update attempts. And that's exactly where zodb comes into play. It has full ACID support. Opening a zodb is a matter of three lines of code - not to be compared to rdbms'ses. The issue with using an rdbms is not with the small amount of code needed to connect to it and query it, but in the overhead of installing the huge piece of software (the rdbms) itself, and keeping the rdbms server running all the time so the infrequently used app can connect to it. ZODB is also a big piece of software to install. Is it at least 100% Python with no C modules required? Does it need a separate server process? If it needs either C modules or a separate server, it really can't be called a low-end strategy. -- http://mail.python.org/mailman/listinfo/python-list
Getting milliseconds in Python
I am trying to record how long an operation takes, but can't seem to find a function that will allow me to record the timestamp in milliseconds, maybe I am looking in the wrong place? -- http://mail.python.org/mailman/listinfo/python-list
RE: Getting milliseconds in Python
Title: RE: Getting milliseconds in Python [mjs7231] #- I am trying to record how long an operation takes, but can't seem to #- find a function that will allow me to record the timestamp in #- milliseconds, maybe I am looking in the wrong place? Use time.time(). import time def f(): t = time.time() [x**2 for x in range(5)] t = time.time() - t print %.2f msec % (t*1000) f() 16.00 msec . Facundo Bitácora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://pyar.decode.com.ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley. Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje. Muchas Gracias. -- http://mail.python.org/mailman/listinfo/python-list
renaming 'references' to functions can give recursive problems
Hello all, Recently I've started to refactor my code ...(I'm using python 2.3.4) I tried to add extra functionality to old functions non-intrusively. When I used a construct, which involves renaming functions etc... I came across some recursive problems. (a basic construct can be found under the section BASIC CODE) These problems do not occur when renaming objects. (see section EXTRA CODE) My question now is: I do not know the underlying idea of functions. Is this the way they should behave? Or should they work the same way as objects do? (My preferences goes to this last option) BASIC CODE: --- def fA(input): # starting point: function named fA return input def newFA(input): # new function with added functionality #does something extra with a! return fA(input) fA = newFA # this should allow to add functionality without # breaking older code which uses the name fA! fA() # execute fA() problem: you get... File recursivemethods.py, line 7, in newFA return fA(input) RuntimeError: maximum recursion depth exceeded when using objects this problems does not occur... EXTRA CODE: PYTHON-CODE # REMARKS referenceA = SomeObject() # referenceA - SomeObject() # references to the memory space of # some object referenceB = referenceA # referenceB - SomeObject() # is also a reference to ... referenceA = referenceB # referenceA references to SomeObject() # now for functions! fA = function # fA references to memory space # of a function def newFA(input): # newFA references to a function return fA(input) # which holds a reference to fA. # Notice the important difference with objects! # newFA holds a reference to the reference fA # When using object you reference to # the memory space of fA!!! fA = newFA fA() # recursive problems!!! -- -- http://mail.python.org/mailman/listinfo/python-list
Re: adding new functionality to a function non-intrusively!
Whenever I want to add functionality to a function while still allowing it to word as it was before my edit would be to include a few optional variables passed to the string. something to this effect would look like: -- BEFORE: -- def myfunction(a, b): return (a + b) -- AFTER: -- def myfunction(a, b, op=add): if (op == add): return (a + b) else: return (a - b) -- -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
The issue with using an rdbms is not with the small amount of code needed to connect to it and query it, but in the overhead of Its not only connecting - its creating (automaticall if necessary) and connecting which is actually only opening. installing the huge piece of software (the rdbms) itself, and keeping the rdbms server running all the time so the infrequently used app can connect to it. ZODB is also a big piece of software to install. Is it at least 100% Python with no C modules required? Does it need a separate server process? If it needs either C modules or a separate server, it really can't be called a low-end strategy. It has to be installed. And it has C-modules - but I don't see that as a problem. Of course this is my personal opinion - but it's certainly easier installed than to cough up your own transaction isolated persistence layer. I started using it over pickle when my multi-threaded app caused pickle to crash. ZODB does not have a server-process, and no external setup beyond the installation of the module itself. Even if you consider installing it as too heavy for your current needs, you should skim over the tutorial to get a grasp of how it works. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Sounds like you want pickle or cpickle. On Tue, 15 Feb 2005 19:00:31 -0800 (PST), Paul Rubin http://phr.cx@nospam.invalid wrote: I've started a few threads before on object persistence in medium to high end server apps. This one is about low end apps, for example, a simple cgi on a personal web site that might get a dozen hits a day. The idea is you just want to keep a few pieces of data around that the cgi can update. Immediately, typical strategies like using a MySQL database become too big a pain. Any kind of compiled and installed 3rd party module (e.g. Metakit) is also too big a pain. But there still has to be some kind of concurrency strategy, even if it's something like crude file locking, or else two people running the cgi simultaneously can wipe out the data store. But you don't want crashing the app to leave a lock around if you can help it. Anyway, something like dbm or shelve coupled with flock-style file locking and a version of dbmopen that automatically retries after 1 second if the file is locked would do the job nicely, plus there could be a cleanup mechanism for detecting stale locks. Is there a standard approach to something like that, or should I just code it the obvious way? Thanks. -- http://mail.python.org/mailman/listinfo/python-list -- Thomas G. Willis http://paperbackmusic.net -- http://mail.python.org/mailman/listinfo/python-list
KWF delivery failure notification
KWF was unable to deliver message. Remote server's reply: 550 Message rejected: virus found. (Worm.SomeFool.P) Message headers follow: From: python-list@python.org To: [EMAIL PROTECTED] Subject: Re: Message Date: Tue, 15 Feb 2005 17:04:55 +0500 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary==_NextPart_000_0016=_NextPart_000_0016 X-Priority: 3 X-MSMail-Priority: Normal -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Diez B. Roggisch [EMAIL PROTECTED] writes: It has to be installed. And it has C-modules - but I don't see that as a problem. Of course this is my personal opinion - but it's certainly easier installed than to cough up your own transaction isolated persistence layer. I started using it over pickle when my multi-threaded app caused pickle to crash. I don't feel that I need ACID since, as mentioned, I'm willing to lock the entire database for the duration of each transaction. I just want a simple way to handle locking, retries, and making sure the locks are cleaned up. ZODB does not have a server-process, and no external setup beyond the installation of the module itself. That helps, thanks. Even if you consider installing it as too heavy for your current needs, you should skim over the tutorial to get a grasp of how it works. Yes, I've been wanting to look at it sometime. -- http://mail.python.org/mailman/listinfo/python-list
Re: adding new functionality to a function non-intrusively!
Decorators are your friends. You can wrap a function and give it additional functionality. For instance just yesterday I needed to keep track of how many times a function is called. This can be done with this decorator: .def with_counter(f): .def wrappedf(*args, **kw): .wrappedf.counter += 1 .return f(*args, **kw) .wrappedf.counter = 0 .wrappedf.func_name = f.func_name .return wrappedf [EMAIL PROTECTED] # requires Python 2.4 .def g(): .print called .print g.counter .g() .print g.counter This is intented just as an appetizer. Look at the cookbook for more examples. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Tom Willis [EMAIL PROTECTED] writes: Sounds like you want pickle or cpickle. No, the issue is how to handle multiple clients trying to update the pickle simultaneously. -- http://mail.python.org/mailman/listinfo/python-list
Re: adding new functionality to a function non-intrusively!
Hello I indeed also rely on your idea. My problem however is: is has to be non-intrusively in both ways. In your example, it would indeed not break the old code which relies on myfunction but my problems is: I also do not want to change the code of the 'before' myfunction. so my problem in fact is: BEFORE: def myfunction(a,b): return (a+b) AFTER: def myfunction(a,b, op=add): if (op == add): # some function which calls the old code for myfunction kind regards -- http://mail.python.org/mailman/listinfo/python-list
Test for structure
Hi there, how can I check if a variable is a structure (i.e. a list)? For my special problem the variable is either a character string OR a list of character strings line ['word1', 'word2',...] So how can I test if a variable 'a' is either a single character string or a list? I tried: if a is list: but that does not work. I also looked in the tutorial and used google to find an answer, but I did not. Has anyone an idea about that? Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
I'd like to second this one...ZODB is *extremely* easy to use. I use it in projects with anything from a couple dozen simple objects all the way up to a moderately complex system with several hundred thousand stored custom objects. (I would use it for very complex systems as well, but I'm not working on any right now...) There are a few quirks to using ZODB, and the documentation sometimes feel lite, but mostly that's b/c ZODB is so easy to use. Chris On Wed, 16 Feb 2005 15:11:46 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Paul Rubin wrote: Diez B. Roggisch [EMAIL PROTECTED] writes: Maybe ZODB helps. I think it's way too heavyweight for what I'm envisioning, but I haven't used it yet. I'm less concerned about object persistence (just saving strings is good enough) than finding the simplest possible approach to dealing with concurrent update attempts. And that's exactly where zodb comes into play. It has full ACID support. Opening a zodb is a matter of three lines of code - not to be compared to rdbms'ses. And apart from some standard subclassing, you don't have to do anything to make your objects persistable. Just check the tutorial. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list -- It is our responsibilities, not ourselves, that we should take seriously. -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: Test for structure
On Wed, 16 Feb 2005 07:11:08 -0800 (PST), alex [EMAIL PROTECTED] wrote: how can I check if a variable is a structure (i.e. a list)? For my special problem the variable is either a character string OR a list of character strings line ['word1', 'word2',...] So how can I test if a variable 'a' is either a single character string or a list? I tried: if a is list: but that does not work. I also looked in the tutorial and used google to find an answer, but I did not. Has anyone an idea about that? http://www.brunningonline.net/simon/blog/archives/001349.html -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Test for structure
Perhaps you're looking for the type() built in function and the types modules? type('aaa') type 'str' type([]) type 'list' import types if type([]) is types.ListType: ... print 'is a list' ... is a list Chris On Wed, 16 Feb 2005 07:10:56 -0800 (PST), alex [EMAIL PROTECTED] wrote: Hi there, how can I check if a variable is a structure (i.e. a list)? For my special problem the variable is either a character string OR a list of character strings line ['word1', 'word2',...] So how can I test if a variable 'a' is either a single character string or a list? I tried: if a is list: but that does not work. I also looked in the tutorial and used google to find an answer, but I did not. Has anyone an idea about that? Alex -- http://mail.python.org/mailman/listinfo/python-list -- It is our responsibilities, not ourselves, that we should take seriously. -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: Test for structure
import types v = [] if type(v) is types.ListType: pass -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: adding new functionality to a function non-intrusively!
thx a lot for the information on decorators this will be very usefull... (sounds like a little step towards aspect orientated programming,:) ) Because I use libraries which rely on boost-python I can not jump into python 2.4 but I understand the main idea and can also use it in python 2.3 (it will only cost a little bit more extra coding) -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
see the topic: adding new functionality to a function non-intrusively! and decorators if you want to add functionality to a function! -- http://mail.python.org/mailman/listinfo/python-list
ZODB performance (was Re: low-end persistence strategies?)
Chris Cioffi wrote: I'd like to second this one...ZODB is *extremely* easy to use. I use it in projects with anything from a couple dozen simple objects all the way up to a moderately complex system with several hundred thousand stored custom objects. (I would use it for very complex systems as well, but I'm not working on any right now...) Chris (or anyone else), could you comment on ZODB's performance? I've Googled around a bit and haven't been able to find anything concrete, so I'm really curious to know how ZODB does with a few hundred thousand objects. Specifically, what level of complexity do your ZODB queries/searches have? Any idea on how purely ad hoc searches perform? Obviously it will be affected by the nature of the objects, but any insight into ZODB's performance on large data sets would be helpful. What's the general ratio of reads to writes in your application? I'm starting on a project in which we'll do completely dynamic (generated on the fly) queries into the database (mostly of the form of from the set of all objects, give me all that have property A AND have property B AND property B's value is between 10 and 100, ...). The objects themselves are fairly dynamic as well, so building it on top of an RDBMS will require many joins across property and value tables, so in the end there might not be any performance advantage in an RDBMS (and it would certainly be a lot work to use an object database - a huge portion of the work is in the object-relational layer). Anyway, thanks for any info you can give me, -Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
Op 2005-02-16, peter schreef [EMAIL PROTECTED]: Hello all, Recently I've started to refactor my code ...(I'm using python 2.3.4) I tried to add extra functionality to old functions non-intrusively. When I used a construct, which involves renaming functions etc... I came across some recursive problems. (a basic construct can be found under the section BASIC CODE) These problems do not occur when renaming objects. (see section EXTRA CODE) My question now is: I do not know the underlying idea of functions. Is this the way they should behave? Or should they work the same way as objects do? (My preferences goes to this last option) BASIC CODE: --- def fA(input): # starting point: function named fA return input def newFA(input): # new function with added functionality #does something extra with a! return fA(input) fA = newFA # this should allow to add functionality without # breaking older code which uses the name fA! fA() # execute fA() Try this: def fA(input): return input def newFA(input, f= fA): return f(input) fA = newFA -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Working With Forms
Hello- I have been asked to design a routine to query a database and write the results out in a way that will fit on a specified form. I think it would be better if I could work with the form and overlay the data in Python, then either write it out to a file or print it. I have worked with the reportlab pdf library and the Python Imaging Library but have never tried anything like this before. The form is complex (it's a Health Care Benefit Report Form) which I have in pdf and png format. Since this is an area where I have very little experience, does anyone have advise, examples, warnings, etc. for me? How do I go about writing out a form with dynamic information? Thanks! --greg - This message was sent using Conway Corporation WebMail -- www.conwaycorp.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Stable GUI
Lars wrote: Maybe you should describe your particular application and the reasons why you really need lightspeed widget rendering ? Stability goes without saying:) It's a GUI for some database input, output routines. It sopouse to wark 24h/day, and about 150 input-outputs/h. Fast: Because it's going to work on some old machines PI or PII, so I don't need any *lightspeed*, but I don't wan't to wait 5s to open a new Frame or something like that. Stable: I tought that thay are, but wxPython broke on some simple test programs that came with wxPython-demo. Tkinter newer broke, but neather the programs I wrote were somthing complicated. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
What about bsddb? On most Unix systems it should be already installed and on Windows it comes with the ActiveState distribution of Python, so it should fullfill your requirements. -- http://mail.python.org/mailman/listinfo/python-list
more os.walk() issues... probably user error
This function is intended to remove unwanted files and dirs from os.walk(). It will return correctly *IF* I leave the 'for fs in fs_objects' statement out (basically leave out the entire purpose of the function). It's odd, when the program goes into that statment... even when only a 'pass', and nothing else is present, nothing is returned. Why is that? I'm testing Python 2.4 on Linux x86 and WinXP. Results are the same on either platform. def build_clean_list(self, path): file_skip_list = ['search_results.txt'] dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] fs_objects = os.walk(path, topdown=True) ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##fs[1].remove(d) return fs_objects -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls. This is no good, I am looking for milliseconds, not seconds.. as stated above. -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
Michele Simionato [EMAIL PROTECTED] writes: What about bsddb? On most Unix systems it should be already installed and on Windows it comes with the ActiveState distribution of Python, so it should fullfill your requirements. As I understand it, bsddb doesn't expose the underlying Sleepycat API's for concurrent db updates, nor does it appear to make any attempt at locking, based on looking at the Python lib doc for it. There's an external module called pybsddb that includes this stuff. Maybe the stdlib maintainers ought to consider including it, if it's considered stable enough. -- http://mail.python.org/mailman/listinfo/python-list
Re: ZODB performance (was Re: low-end persistence strategies?)
Chris (or anyone else), could you comment on ZODB's performance? I've Googled around a bit and haven't been able to find anything concrete, so I'm really curious to know how ZODB does with a few hundred thousand objects. Specifically, what level of complexity do your ZODB queries/searches have? Any idea on how purely ad hoc searches perform? Obviously it will be affected by the nature of the objects, but any insight into ZODB's performance on large data sets would be helpful. What's the general ratio of reads to writes in your application? This is a somewhat weak point of zodb. Zodb simply lets you store arbitrary object graphs. There is no indices created to access these, and no query language either. You can of course create indices yourself - and store them as simply as all other objects. But you've got to hand-tailor these to the objects you use, and create your querying code yourself - no 4gl like sql available. Of course writing queries as simple predicates evaluated against your whole object graph is straightforward - but unoptimized. The retrieval of objects themselves is very fast - I didn't compare to a rdbms, but as there is no networking involved it should be faster. And of course no joins are needed. So in the end, if you have always the same kind of queries that you only parametrize and create appropriate indices and hand-written execution plans things are nice. But I want to stress another point that can cause trouble when using zodb and that I didn't mention in replies to Paul so far, as he explicitly didn't want to use an rdbms: For rdbms'ses, a well-defined textual representation of the entities stored in the db is available. So while you have to put some effort on creating on OR-mapping (if you want to deal with objects) that will most likely evolve over time, migrating the underlying data usually is pretty straightforward, and even toolsupport is available. Basically, you're only dealing with CSV-Data that can be easily manipulated and stored back. ZODB on the other side is way easier to code for - but the hard times begin if you have a rolled out application that has a bunch of objects inside zodb that have to be migrated to newer versions and possibly changed object graph layouts. This made me create elaborate yaml/xml serializations to allow for im- and exports and use with xslt and currently I'm investigating a switch to postgres. This point is important, and future developments of mine will take that into consideration more than they did so far. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
mjs7231 == mjs7231 [EMAIL PROTECTED] writes: mjs7231 This is no good, I am looking for milliseconds, not mjs7231 seconds.. as stated above. Well seconds/1000.0 = millseconds -- or are you worries about floating point error? 7 from datetime import datetime 8 dt = datetime.now() 9 dt.microsecond Out[9]: 20222 Converting to milliseconds is left as an exercise for the reader... See also the timeit module... JDH -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
People sometimes run to complicated systems, when right before you there is a solution. In this case, it is with the filesystem itself. It turns out mkdir is an atomic event (at least on filesystems I've encountered). And, from that simple thing, you can build something reasonable as long as you do not need high performance. and space isn't an issue. You need a 2 layer lock (make 2 directories) and you need to keep 2 data files around plus a 3rd temporary file. The reader reads from the newest of the 2 data files. The writer makes the locks, deletes the oldest data file and renames it's temporary file to be the new data file. You could have the locks expire after 10 minutes, to take care of failure to clean up. Ultimately, the writer is responsible for keeping the locks alive. The writer knows it is his lock because it has his timestamp. If the writer dies, no big deal, since it only affected a temporary file and the locks will expire. Rename the temporary file takes advantage of the fact that a rename is essentially immediate. Since, whatever does the reading, only reads from the newest of the 2 files (if both are available). Once, the rename of the temporary file done by the writer is complete, any future reads will now hit the newest data. And, deleting the oldest file doesn't matter since the reader never looks at it. If you want more specifics let me know. john -- http://mail.python.org/mailman/listinfo/python-list
Re: more os.walk() issues... probably user error
rbt wrote: This function is intended to remove unwanted files and dirs from os.walk(). It will return correctly *IF* I leave the 'for fs in fs_objects' statement out (basically leave out the entire purpose of the function). It's odd, when the program goes into that statment... even when only a 'pass', and nothing else is present, nothing is returned. Why is that? I'm testing Python 2.4 on Linux x86 and WinXP. Results are the same on either platform. def build_clean_list(self, path): file_skip_list = ['search_results.txt'] dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] fs_objects = os.walk(path, topdown=True) ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##fs[1].remove(d) return fs_objects Just to clarify, it's wrong of me to say that 'nothing is returned'... in either case, this is what is returned: Here's what was returned and its type: generator object at 0x407dbe4c type 'generator' But, I can't iterate over the returned object when I descend into the for statement I mentioned above. -- http://mail.python.org/mailman/listinfo/python-list
Re: supress creation of .pyc files
In article [EMAIL PROTECTED], Thomas Guettler [EMAIL PROTECTED] wrote: Hi, Is there a way to import a file without creating a .pyc file? Of course you can delete the pyc in my script after the import statement, but maybe there is a switch that I have not found yet. The imported file is a config file, not a script. Thomas If you're on unix, you can put the .py files you want to import in a new directory, then change the permissions on this directory so that you do not have write permission for it. rg -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Fredrik Lundh wrote: Warning: Due to the precarious circumstances under which __del__() methods are invoked, exceptions that occur during their execution are ignored, and a warning is printed to sys.stderr instead. Also, when __del__() is invoked in response to a module being deleted (e.g., when execution of the program is done), other globals referenced by the __del__() method may already have been deleted. For this reason, __del__() methods should do the absolute minimum needed to maintain external invariants. Jeff Epler wrote: *Bugsandcaveats:Thedestructionofmodulesandobjectsin modulesis *doneinrandomorder;thismaycausedestructors (__del__()methods)to *failwhentheydependonotherobjects (evenfunctions)ormodules. 2 Questions... 1) Why does this never happen in C++? Or does it, its just never happened to me? 2) I can understand random destruction of instantiated objects, but I find it weird that class definitions (sorry, bad terminology) are destroyed at the same time. So __del__ can't safely instantiate any classes if its being called as a result of interpreter shutdown? Boo... Oh well, thanks for the help...now I know. -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
pure DOS, old pc, used for teaching . want show some windows under DOS (under Python). Daniel Bowett [EMAIL PROTECTED] news:[EMAIL PROTECTED] john san wrote: How to install python under DOS and is there any Wxpython-like can be installed under dos? Thanks. Are you actually still running a pure DOS machine? Or are you running the dos prompt through Windows? -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
Just want to show windows under dos without MsWindows. Also find some difficulty to simply install WxPython under directory(DOS) and then run, which is very good thing if it is just like Java. I want a simple solution for Python to install to DOS and then can have Windows running.( to be used under mod-xbox which support only limited python via using xboxmediacenter. (xbox using stripped NT OS). Harlin [EMAIL PROTECTED] news:[EMAIL PROTECTED] Any reason you're asking about wxPython for DOS? Just curious. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
mjs7231 wrote: Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls. This is no good, I am looking for milliseconds, not seconds.. as stated above. If your system _can_ provide better accuracy than seconds, it is returned as fraction of a second. That is the whole point the result of time being a float and not an int. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: more os.walk() issues... probably user error
That's an easy one: fs_objects is not modified by your ode, so you get it back as created by os.walk -- http://mail.python.org/mailman/listinfo/python-list
Re: more os.walk() issues... probably user error
rbt [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] rbt wrote: This function is intended to remove unwanted files and dirs from os.walk(). It will return correctly *IF* I leave the 'for fs in fs_objects' statement out (basically leave out the entire purpose of the function). It's odd, when the program goes into that statment... even when only a 'pass', and nothing else is present, nothing is returned. Why is that? I'm testing Python 2.4 on Linux x86 and WinXP. Results are the same on either platform. def build_clean_list(self, path): file_skip_list = ['search_results.txt'] dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] fs_objects = os.walk(path, topdown=True) ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##fs[1].remove(d) return fs_objects Just to clarify, it's wrong of me to say that 'nothing is returned'... in either case, this is what is returned: Here's what was returned and its type: generator object at 0x407dbe4c type 'generator' But, I can't iterate over the returned object when I descend into the for statement I mentioned above. What do you mean by not being able to iterate over the returned object? What kind of error are you getting? Have you tried to debug the code? BTW, os.walk indeed returns a generator. You should familiarize yourself with generators and iterators if you haven't done so yet. -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
The documentation hides this fact (I missed that) but actually python 2.3+ ships with the pybsddb module which has all the functionality you allude too. Check at the test directory for bsddb. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
Hello, nice solution: but it puzzles me :) can anyone tell me why ---correct solution def fA(input): return input def newFA(input, f= fA): return f(input) fA = newFA is correct and: -infinite loop- def fA(input): return input def newFA(input): return fA(input) fA = newFA gives an infinite recursive loop? kind regards Peter Antoon Pardon wrote: Op 2005-02-16, peter schreef [EMAIL PROTECTED]: Hello all, Recently I've started to refactor my code ...(I'm using python 2.3.4) I tried to add extra functionality to old functions non-intrusively. When I used a construct, which involves renaming functions etc... I came across some recursive problems. (a basic construct can be found under the section BASIC CODE) These problems do not occur when renaming objects. (see section EXTRA CODE) My question now is: I do not know the underlying idea of functions. Is this the way they should behave? Or should they work the same way as objects do? (My preferences goes to this last option) BASIC CODE: --- def fA(input): # starting point: function named fA return input def newFA(input): # new function with added functionality #does something extra with a! return fA(input) fA = newFA # this should allow to add functionality without # breaking older code which uses the name fA! fA() # execute fA() Try this: def fA(input): return input def newFA(input, f= fA): return f(input) fA = newFA -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: more os.walk() issues... probably user error
rbt [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] def build_clean_list(self, path): file_skip_list = ['search_results.txt'] dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] fs_objects = os.walk(path, topdown=True) ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##fs[1].remove(d) return fs_objects Rather as an aside, the idiom for using os.walk is for dirpath, dirnames, dirfiles in os.walk(path): for f in dirnames: if f in file_skip_list: print f filenames.remove(f) if d in dir_skip_list: print d dirnames.remove(f) More crucially for your code, returning the generator object after having iterated all the way through it will not do you any good. The generator has an internal state that puts it at the end of the iteration so you cannot use it to iterate again. -- http://mail.python.org/mailman/listinfo/python-list
Re: more os.walk() issues... probably user error
rbt wrote: rbt wrote: This function is intended to remove unwanted files and dirs from os.walk(). It will return correctly *IF* I leave the 'for fs in fs_objects' statement out (basically leave out the entire purpose of the function). It's odd, when the program goes into that statment... even when only a 'pass', and nothing else is present, nothing is returned. Why is that? I'm testing Python 2.4 on Linux x86 and WinXP. Results are the same on either platform. def build_clean_list(self, path): file_skip_list = ['search_results.txt'] dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] fs_objects = os.walk(path, topdown=True) fs_objects is a generator, not a list. This loop is exhausting fs_objects, so when you return fs_objects is at the end of iteration, there is nothing left. ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##fs[1].remove(d) Add this here: yield fs and take out the return. This turns build_clean_list() into a generator function and you will be able to iterate the result. Kent return fs_objects Just to clarify, it's wrong of me to say that 'nothing is returned'... in either case, this is what is returned: Here's what was returned and its type: generator object at 0x407dbe4c type 'generator' But, I can't iterate over the returned object when I descend into the for statement I mentioned above. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
This is no good, I am looking for milliseconds, not seconds.. as stated above. The docs are not very clear. I had the same issue when I was trying to do the same thing, but the time and datetime modules return milliseconds on my linux machines. -- http://mail.python.org/mailman/listinfo/python-list
Python to be used for Mod Language in Battlefield 1942 Sequel
I love the orignal so much, now to hear that mod's will be created in Python, well it brings tears of joy. Python Used as Modding Language for Battlefield 2 Programming First Person Shooters (Games) Posted by Zonk on Friday February 11, @11:27AM from the snakes-and-guns dept. Dutch Dopey writes In an interview with Lars Gustavsson of DICE, it was mentioned that Battlefield 2's modding tools are going to be delivered with the game, and that the tools are the same ones used to develop the game. The modding language in use is Python, and will support all aspects of the language http://developers.slashdot.org/developers/05/02/11/1439230.shtml?tid=156tid=204 -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
peter wrote: Hello, nice solution: but it puzzles me :) can anyone tell me why ---correct solution def fA(input): return input def newFA(input, f= fA): return f(input) fA = newFA is correct and: def fA(input): ... print inside fA ... return input ... def newFA(input,f=fA): ... print inside newFA ... return f(input) ... fA = newFA fA(2) inside newFA inside fA 2 while: -infinite loop- def fA(input): return input def newFA(input): return fA(input) fA = newFA gives an infinite recursive loop? def fA(input): ... print inside fA ... return input ... def newFA(input): ... print inside newFA ... return fA(input) ... fA = newFA fA(2) inside newFA inside newFA inside newFA inside newFA What is happening is that when you call fA (inside newFA) in the second case, you are calling newFA because fA is pointing to newFA (hope that made sense ;-)). So it was recursive. While in the former case you called f, which pointed to fA, but not to newFA. Probably the following will make it clearer: def fA(input): ... print inside fA ... return input ... def newFA(input,f=fA): ... print inside newFA ... print f is pointing to: ,f ... return f(input) ... fA = newFA fA(2) inside newFA f is pointing to: function fA at 0x43123374 inside fA 2 fA function newFA at 0x43194064 newFA function newFA at 0x43194064 Thus f and fA do not point to the same function object when you execute the statement fa(2). This f is called once and terminates. thanks, Satchit -- http://mail.python.org/mailman/listinfo/python-list
Re: check if object is number
Fredrik Lundh wrote: Steven Bethard wrote: Actually no, floats don't meet this behaviour or more specifically floats don't guarantee this behaviour. It depends of course on your implementation of f, but it is possible with floats to keep incrementing and never reach a maximum. My code won't hit this corner case. I'm incrementing with integers. incrementing what with integers? f = 9007199254740992.0 f == f+1 True I mean that the number that's being incremented is an integer: py f = 9007199254740992.0 py i = 9007199254740991 py i = f True py i += 1 py i = f True py i += 1 py i = f False Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
mjs7231 [EMAIL PROTECTED] wrote: Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls. This is no good, I am looking for milliseconds, not seconds.. as stated above. are you sure you know what a millisecond is? can you spot the milliseconds here: import time time.time() 1108575508.234 time.time() 1108575515.062 or here: time.clock() 1.6349019714375455 time.clock() 2.2402415685960024 time.clock() 2.7715522631434739 /F -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Christopher J. Bottaro wrote: 2 Questions... 1) Why does this never happen in C++? Or does it, its just never happened to me? C++ uses an entirely different allocation model. if you think in C++ when you write Python, you will write bad Python. 2) I can understand random destruction of instantiated objects, but I find it weird that class definitions (sorry, bad terminology) are destroyed at the same time. So __del__ can't safely instantiate any classes if its being called as a result of interpreter shutdown? Boo... please read the essay. and fixing your terminology may help you understand how things work (hint: class creates a class object and binds it to a name, like any other assignment. class objects are no different from other objects) (btw, if you don't know exactly why you need to use __del__, chances are that you don't need to use it. __del__ is a finalizer, not a destructor.). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
peter wrote: Hello, nice solution: but it puzzles me :) can anyone tell me why ---correct solution def fA(input): return input def newFA(input, f= fA): return f(input) fA = newFA is correct and: -infinite loop- def fA(input): return input def newFA(input): return fA(input) In newFA, fA is not bound until you call newFA. By which time you've re-bound fA to newFA, causing the recursion. In the 'correct' solution above, f is bound to the original fA function at the time the def fA statement is executed, which is what you want. fA = newFA gives an infinite recursive loop? kind regards Peter Regards Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: super not working in __del__ ?
Christopher J. Bottaro wrote: 2 Questions... 1) Why does this never happen in C++? Or does it, its just never happened to me? 2) I can understand random destruction of instantiated objects, but I find it weird that class definitions (sorry, bad terminology) are destroyed at the same time. So __del__ can't safely instantiate any classes if its being called as a result of interpreter shutdown? Boo... Keep in mind that in Python, everything is a (dynamically created) object, including class objects. My recall of C/C++ memory organization is pretty weak, but IIRC it gives completely different behavior to code, stack objects, and heap objects. Code never needs to be cleaned up. In Python, everything (including functions and classes) is effectively a heap object, and thus functions and classes can (and indeed must) be cleaned up. Refcounting means that they won't ever (normally) be cleaned up while they're still in use, but during program shutdown refcounting necessarily ceases to apply. The closest that would happen in C++, I believe, would manifest itself as memory leaks and/or access of already-freed memory. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
mjs7231 wrote: This is no good, I am looking for milliseconds, not seconds.. as stated above. That IS what you want. seconds * 100 = milliseconds -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading functions from a file during run-time
#--- file bar.py def negate(n): return -n def square(n): return n*n #--- end bar.py foo=bar fs=__import__(foo) import types f=[a for a in dir(fs) if a[0:2]!='__' and type(getattr(fs,a))==types.FunctionType] f ['negate', 'square'] n=5 exec(print fs.+f[0]+(n)) -5 exec(print fs.+f[1]+(n)) 25 Isn't the problem solved? -- http://mail.python.org/mailman/listinfo/python-list
Re: [Errno 18] Invalid cross-device link using os.rename
Thanks, Jeff. I appreciate the input. I just stuck with os.system('mv %s %s'). Seems to work fine. On Mon, 14 Feb 2005 18:31:18 -0600, Jeff Epler [EMAIL PROTECTED] wrote: mv is a surprisingly complex program, while os.rename is a wrapper around rename(2) which is probably documented on your system to return EXDEV under these circumstanes. os.xxx is generally a fairly thin wrapper around what your OS provides, and inherits all the gotchas. For some activities, os.shutil provides something that is between os.xxx and os.system(xxx) in complexity and capability. Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
peter [EMAIL PROTECTED] wrote PYTHON-CODE # REMARKS referenceA = SomeObject() # referenceA - SomeObject() # references to the memory space of # some object referenceB = referenceA # referenceB - SomeObject() # is also a reference to ... referenceA = referenceB # referenceA references to SomeObject() # now for functions! fA = function # fA references to memory space # of a function nope. it refers to a function object. function objects are no different from ordinary objects. def newFA(input): # newFA references to a function not yet. return fA(input) # which holds a reference to fA. nope. the function does not hold a reference to fA. fA is a global, and will be resolved at runtime. # Notice the important difference with objects! # newFA holds a reference to the reference fA no, it doesn't hold a reference to the reference. it contains the name fA, and will look for that when you call it. # When using object you reference to # the memory space of fA!!! you're confused. resetting your brain and reading the documentation again might help: http://docs.python.org/ref/objects.html http://docs.python.org/ref/naming.html /F -- http://mail.python.org/mailman/listinfo/python-list
RE: Getting milliseconds in Python
Title: RE: Getting milliseconds in Python [Brian Beck] #- seconds * 100 = milliseconds Wht? It really is seconds = 1000 * milliseconds . Facundo Bitácora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://pyar.decode.com.ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley. Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje. Muchas Gracias. -- http://mail.python.org/mailman/listinfo/python-list
RE: renaming 'references' to functions can give recursive problem s
Title: RE: renaming 'references' to functions can give recursive problems [Fredrik Lundh] #- you're confused. resetting your brain and reading the documentation #- again might help: #- #- http://docs.python.org/ref/objects.html #- http://docs.python.org/ref/naming.html This article will also help him a lot: http://starship.python.net/crew/mwh/hacks/objectthink.html . Facundo Bitácora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://pyar.decode.com.ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley. Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje. Muchas Gracias. -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading functions from a file during run-time
or don't use exec(): f=[getattr(fs,a) for a in dir(fs) if a[0:2]!='__' and type(getattr(fs,a))==types.FunctionType] f [function negate at 0x100a00, function square at 0x144038] f[0](n) -5 f[1](n) 25 -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
Brian Beck wrote: That IS what you want. seconds * 100 = milliseconds are you sure you know what a millisecond is? (duck) -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
john san wrote: Just want to show windows under dos without MsWindows. Also find some difficulty to simply install WxPython under directory(DOS) and then run, which is very good thing if it is just like Java. I don't think you'll have any luck finding wxPython for DOS. A bit of a looksee around the wxWidgets website (wxPython is a wrapper for wxWidgets) mentions being available for Win3.1 and up, as well as various levels of *nix installs (wxGTK, wxMotif, wxX11), but no mention of DOS. I suppose that a very ambitious person could perhaps get the wxUniversal port to run on DOS, but I presume that this would be far from trivial. On the other hand, you probably could find and/or create some sort of basic text-only windowing library. It won't be wxPython, nor anything even close to that level of sophistication, but that's what happens when you insist on using an OS that's been obsolete for a decade or more. ;) Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list
Re: renaming 'references' to functions can give recursive problems
brain reset and understood thx a lot for all your answers Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Multidimensional arrays - howto?
[EMAIL PROTECTED] wrote: Hello all, I am trying to convert some C code into python. Since i am new to python, i would like to know how to deal with multidimensional arrays? Thanks, -Joe Here's a snippet of what i am trying to convert: # define table0 15 # define table1 20 unsigned int Table[table0][table1] if(Table[table0][table1] != 0) { Table[table0][table1]-- } You might consider numarray. This is a package which is downloadable from Source Forge and intended for numeric and other arrays. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting milliseconds in Python
Brian Beck wrote: That IS what you want. seconds * 100 = milliseconds May I assume that this IS what you want ? ()___ ()//__/)_() ||(___)//#/_/#/_/#/_/#()/|| |||#| |#|_|#|_|#|_|| || |||_|#|_|#|_|#|_|#||/|| |||#|_|#|_|#|_|#|_|| :) (credits to jgs, found on http://www.ascii-art.de/ascii/ab/bed.txt) -- Amand Tihon -- http://mail.python.org/mailman/listinfo/python-list