[ANN] Leipzig Python User Group Meeting, August 12, 2008, 08:00 pm
=== Leipzig Python User Group === We will meet on Tuesday, August 12 at 8:00 pm at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). We'll have a talk about Matplotlib, a library for generating two-dimensional graphs (see http://matplotlib.sourceforge.net/ ). Food and soft drinks are provided. Please send a short confirmation mail to [EMAIL PROTECTED] , so we can prepare appropriately. Everybody who uses Python, plans to do so or is interested in learning more about the language is welcome. While the meeting language will be mainly German, we will provide English translation if needed. Current information about the meetings are at http://www.python-academy.com/user-group . Stefan == Leipzig Python User Group === Wir treffen uns am Dienstag, 12.08.2008 um 20:00 Uhr im Schulungszentrum der Python Academy in Leipzig ( http://www.python-academy.de/Schulungszentrum/anfahrt.html ). Diesmal gibt es einen Vortrag über die Matplotlib-Bibliothek zur Erstellung zweidimensionaler Diagramme (siehe http://matplotlib.sourceforge.net/ ). Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter [EMAIL PROTECTED] wäre nett, damit wir genug Essen besorgen können. Willkommen ist jeder, der Interesse an Python hat, die Sprache bereits nutzt oder nutzen möchte. Aktuelle Informationen zu den Treffen sind unter http://www.python-academy.de/User-Group zu finden. Viele Grüße Stefan -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: eric 4.2.0 released
Hi, I am proud to announce the immediate availability of eric 4.2.0. It is available via http://www.die-offenbachs.de/eric/index.html. The highlight of changes are as follows. APIs: - added API file for Ruby - added Ruby API file for eric4 Ruby files - enhanced the API file generation tool and dialog Configuration: - reorganized the configuration dialog - changed settings from native format to ini format Editor: - added functionality to mark all occurrances of a searched text - enhanced unicode support (added utf-16 and utf-32) - added an action to insert a new line below the current one (Shift+Return) - added capability to save the folding state of a file in the session file - added capability to save the open multi project and the open project in the global session file General VCS support: - added an LED to signal the project's VCS status to the project viewer Graphics: - added capability to save UML like graphics as SVG - added capability to display SVG files Help Viewer: - added a QWebKit based help viewer (available if Qt 4.4 is installed) Plugins: - added HTTPS support to plugin repository dialog (for Qt 4.3 and newer) Project: - added multiproject support - added storage key PROJECTTYPESPECIFICDATA for project type specific data (may be used by project type plugins) - moved all supporting project management files (e.g. tasks file) to a management subdirectory Shell: - made Shell history more comfortable by -- selecting from history via a dialog -- list the history in a dialog with capabilities to --- delete entries --- copy entries to the current editor --- execute entries in the shell Templates: - extended the templates system to support a few predefined variables (thanks to Dan Bullok) Toolbars: - added a toolbar manager and a toolbar configuration dialog - cleaned up the default toolbars Translations: - added Spanish translations from Jaime Seuma - added Turkish translations from Serdar Koçdaş Various: - enhancements to the class browsers - added print preview capability (available if Qt 4.4 is installed) - added new default icon set based on the Oxygen icons Viewmanager: - added a viewmanager plugin using the new QMdiArea - added double click action to the tabview viewmanager. Double clicking the space right of the last tab opens a new editor. What is eric? - eric is a Python and Ruby IDE that comes with batteries included. Please see the eric web site for details. Regards, Detlev -- Detlev Offenbach [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Quality of Standard Modules
js wrote: I read an interview with Guido at http://www.techworld.com.au/article/255835/a-z_programming_languages_python and that's very interesting. In that article, he said there are also a lot of modules that aren't particularly well thought-out, or serve only a very small specialized audience, or don't work well with other modules. I'm curious what modules he's refering and other Pythonistas feel it's not pythonic. Consider the next paragraph: We're cleaning up the worst excesses in Python 3.0, but for many reasons it's much harder to remove modules than to add new ones -- there's always *someone* who will miss it. I probably should have set the bar for standard library modules higher than I did (especially in the early days, when I accepted pretty much anything anyone was willing to contribute). Now check out what was removed ;-) http://www.python.org/dev/peps/pep-3108/ will help. -- http://mail.python.org/mailman/listinfo/python-list
Re: internet searching program
On Fri, 08 Aug 2008 19:59:02 -0700, KillSwitch wrote: Is it possible to make a program to search a site on the internet, then get certain information from the web pages that match and display them? Like, you would put in keywords to be searched for on youtube.com, then it would search youtube.com, get the names of the videos, the links, and the embed information? Or something like that. Search the Internet? Hmmm... I'm not sure, but I think Google does something quite like that, but I don't know if they do it with a computer program or an army of trained monkeys. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: relative imports improve program organization... suggestions?
On Aug 8, 12:37 pm, DG [EMAIL PROTECTED] wrote: Alright, I have searched and searched and read many conversations on the topic of relative and absolute imports and am still not getting the whole thing through my skull. Highlights of what I've read:http://mail.python.org/pipermail/python-list/2007-January/422973.htmlhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/...http://www.python.org/dev/peps/pep-0328/http://docs.python.org/whatsnew/pep-328.html So my problem and argument: I want to create a package organized as the following: pckg/ __init__.py main.py moduleA/ __init__.py A_base.py A1/ __init__.py A_inherit1.py other_A1_files... A2/ __init__.py A_inherit2.py other_A2_files... moduleB/ ... Explanation: The main program is located in main.py and it implements the different modules (A, B). Within the modules the basic organization is; the base class for all different types of A is directly within the moduleA directory. All of the different inherited classes of A are within their own subdirectory with a mess of their own files. This is done so that a new subclass of A can be added/removed by just adding/ removing the subdirectory and each of these subclasses may have their own maintainer, but they should all inherit from A_base.py If I am developing the A1 directory, I want to be able to test A_inherit1.py by using 'if __name__ == __main__' within the A_inherit1.py file and by typing 'python A_inherit1.py' on the command line. I prefer this simply to keep all unit tests within the same directory and same file as the inherited class. My Problem: A_inherit1.py has the line: 'from ..A_base import A_Base_Class' so that I can later declare the inherited class as such: 'A1_Inherited_Class(A_Base_Class):' *BUT* I get the 'attempted relative import in non-package' error even when I try the 'from __future__ import absolute_import' command. I would prefer to be able to test the file without adding anything to the PYTHONPATH, like I said by using the name == main trick. So could someone explain to me what the rationale behind not allowing parent directory relative imports is? And possibly what I can do to get around it? (I really don't like messing with the sys.path for something like this) Thanks, Danny G Didn't read the whole thing, but would imp.load_source( name, relative_path ) help you at all? -- http://mail.python.org/mailman/listinfo/python-list
Re: interpreter vs. compiled
On Aug 5, 2:09 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Regarding exploring processor instructions. Lets say you compile a C program targeting x86 architecture, with optimizations turned on for speed, and let the compiler automatic select MMX and SSE instructions for numeric code. I have now a program that executes very fast, and does what I want very well. Now when I execute it on a x86 processor with the new SSE 4 instructions, it will not matter, because it cannot take advantage of them. With a JIT is different. Assuming that the JIT is also aware of the SSE 4 instructions, it might take advantage of this new set, if for a given instruction sequence it is better to do so. For the usage of the profile guided optimizations, here go a few examples. The JIT might find out that on a given section, the vector indexes are always correct, so no need for bounds verification is needed. Or if the language is a OOP one, it might come to the conclusion that the same virtual method is always called, so there is no need for a VMT lookup before calling the method, thus it replaces the already generated code by a direct call. Or that a small method is called enough times, so it would be better to inline it instead. Here are a few papers about profile guided optimizations: http://rogue.colorado.edu/EPIC6/EPIC6-ember.pdfhttp://www.cs.princeton.edu/picasso/mats/HotspotOverview.pdf Of course most of these optimizations are only visible in applications that you use for longer that 5m. -- Paulo There are two things I can emphasize after reading the papers and your post. One is the benefit of distributing an incompletely compiled module, which is that it makes machine-targeted specializations possible right then and there, and does not require recompiling from the source on the original author's/distributor's budget. Even if there's no YOURSUITE.EXE built, the code is still in a state where you can make one, by only needing JIT.LIB on your machine. The second is the massive use of lightweight profiling in choosing optimizations in JIT. One of the advantages is inlining common function sequences, that you would either have to detect yourself, or inline everything, to achieve. What are some others? -- http://mail.python.org/mailman/listinfo/python-list
Re: mktime overflow in March 2008?
Robert Latest [EMAIL PROTECTED] wrote: Here's what happens on my Windows machine (Win XP / Cygwin) at work. I've googled a bit about this problem but only found references to instances where people referred to dates before the Epoch. Of course at home on my Linux box everything works. I know that everything has its limits somewhere, but I've never heard of March 2008 being a problem. Tomorrow I'm going to write a test loop that shows me the exact last second that mktime is going to be able to handle. Sort of like the way Calvin's father explains the weight limit specification of bridges. That's what it's going to sound like when I ask my question. ... t = time.strptime(Mar 30, 2008 2:43:32 am, %b %d, %Y %I:%M:%S %p) time.mktime(t) Traceback (most recent call last): File stdin, line 1, in module OverflowError: mktime argument out of range What time zone are you in? March 30, 2008, was a Sunday. If that happened to be the date your country transitioned to summer time, then the hour between 2 AM and 3 AM would not exist. Does it work if you use 3:43 AM? -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Class definition attribute order
On Aug 5, 5:05 am, Michele Simionato Yep. Seehttp://stacktrace.it/articoli/2008/01/metaclassi-python-3000 (I am working on an English translation these days, but for the moment you can use Google Translator). M. Simionato FWIW, I have just finished translating the first part of the article and I have posted it on my blog on Artima: http://www.artima.com/weblogs/viewpost.jsp?thread=236234 -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with global variables
Anthony Kuhlman [EMAIL PROTECTED] wrote: Pythoners, I'm having trouble understanding the behavior of global variables in a code I'm writing. I have a file, test.py, with the following contents foo = [] def goo(): global foo foo = [] foo.append(2) def moo(): print foo In an ipython session, I see the following: In [1]: from test import * In [2]: foo Out[2]: [] In [3]: goo() In [4]: foo Out[4]: [] In [5]: moo() [2] I don't understand this behavior. I assumed that foo as defined in test.py is a global object, but that doesn't seem to be the case. Obviously, there's some sort of namespace thing going on here that I don't get. The ipython session seems to be dealing with one copy of foo while goo() and moo() are using an entirely different copy. If I take out the line 'foo = []' in goo(), everything behaves exactly as I expect, that is, in ipython, when I type goo() followed by foo I get [2]. Can anyone shed some light on this behavior? The bit of information you need to solve this problem is that python variables are not like variables in other languages, they don't contain values, they refer to them. This means that there can be many names for the same value. You've made two variables called foo, one in the interative interpreter (by your from test import * statement) and one in the test module, and by the time you get to [4] they have different values. The foo in the interpreter still refers to the original list, but the foo in the test module has been overwritten with a new list by the assignment 'foo = []'. This didn't affect the foo in the interactive interpreter. Compare and contrast with this import test test.foo [] test.goo() test.foo [2] test.moo() [2] This works as you expect because you are always using the foo from the test namespace. My advice is to avoid global variables completely. Consider wrapping all your global variables into a class and exporting a single instance of this class to keep your globals in. Eg --- test2.py --- class Test(object): def __init__(self): self.foo = [] def goo(self): self.foo.append(2) def moo(self): print self.foo test = Test() from test2 import test test.foo [] test.goo() test.foo [2] test.moo() [2] -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Entry widgets 'font' property (API ?) changed in Python 2.5.2 ?
Hi Eric, Thanks for your response. Tkinter is a very thin wrapper over an embedded tcl/tk interpreter. So I guess the API change is caused by a tcl/tk version change, not by a Python one. You can check the version of the tcl/tk interpreter you're using from Python via: root = Tkinter.Tk() root.tk.eval('puts $tcl_patchLevel') root.tk.eval('puts $tk_patchLevel') The Windows box reports 8.4.12 whereas the OpenSuze 11 box reports 8.5.2 I suppose the Suze 10.2 box had a lesser version and hence the API change. 2. How can I achieve what I want alternatively ? I'd use this way: import tkFont entryFontDescr = Entry()[font] entry_font = tkFont.Font(font=entryFontDescr) print entry_font.actual() This works very well, thank you :) Regards, -- Atul -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is ::= used as assignment operator in doc statements?
[EMAIL PROTECTED] writes: Why is statments expressed with ::= as the assigning operator? like: http://docs.python.org/ref/grammar.txt That page is part of the language reference. It shows, not Python code, but a description of part of the Python grammar. See §1.2 URL:http://www.python.org/doc/ref/notation.html. -- \ “A man must consider what a rich realm he abdicates when he | `\ becomes a conformist.” —Ralph Waldo Emerson | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
ANN: P4D 1.2
P4D = E4X style embedded DSL for Python but without E and X. The main feature of P4D 1.2 are *Bytelets*. While the primary purpose of P4D 1.1 was the support textual data which can be considered as isomorphic to XML the new release is focussed on binary data. Bytelets are P4D objects that are assembled from hexcode which is reified as a Hex object. Bytelets can also be serialized as Hex objects which makes them apt for low level communication. Bytelets can be used to parse hexcode into other Bytelets of the same structure and Bytelets can be cloned like object prototypes which makes it easy to produce sequences of variations of one Bytelet ( usually you do not derive from a Bytelet but modify a prototype ). For more information see: http://pypi.python.org/pypi/P4D http://www.fiber-space.de http://www.fiber-space.de/EasyExtend/doc/p4d/bytelets.html -- http://mail.python.org/mailman/listinfo/python-list
ANN: eric 4.2.0 released
Hi, I am proud to announce the immediate availability of eric 4.2.0. It is available via http://www.die-offenbachs.de/eric/index.html. The highlight of changes are as follows. APIs: - added API file for Ruby - added Ruby API file for eric4 Ruby files - enhanced the API file generation tool and dialog Configuration: - reorganized the configuration dialog - changed settings from native format to ini format Editor: - added functionality to mark all occurrances of a searched text - enhanced unicode support (added utf-16 and utf-32) - added an action to insert a new line below the current one (Shift+Return) - added capability to save the folding state of a file in the session file - added capability to save the open multi project and the open project in the global session file General VCS support: - added an LED to signal the project's VCS status to the project viewer Graphics: - added capability to save UML like graphics as SVG - added capability to display SVG files Help Viewer: - added a QWebKit based help viewer (available if Qt 4.4 is installed) Plugins: - added HTTPS support to plugin repository dialog (for Qt 4.3 and newer) Project: - added multiproject support - added storage key PROJECTTYPESPECIFICDATA for project type specific data (may be used by project type plugins) - moved all supporting project management files (e.g. tasks file) to a management subdirectory Shell: - made Shell history more comfortable by -- selecting from history via a dialog -- list the history in a dialog with capabilities to --- delete entries --- copy entries to the current editor --- execute entries in the shell Templates: - extended the templates system to support a few predefined variables (thanks to Dan Bullok) Toolbars: - added a toolbar manager and a toolbar configuration dialog - cleaned up the default toolbars Translations: - added Spanish translations from Jaime Seuma - added Turkish translations from Serdar Koçdaş Various: - enhancements to the class browsers - added print preview capability (available if Qt 4.4 is installed) - added new default icon set based on the Oxygen icons Viewmanager: - added a viewmanager plugin using the new QMdiArea - added double click action to the tabview viewmanager. Double clicking the space right of the last tab opens a new editor. What is eric? - eric is a Python and Ruby IDE that comes with batteries included. Please see the eric web site for details. Regards, Detlev -- Detlev Offenbach [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED]
FLJ. -- http://mail.python.org/mailman/listinfo/python-list
Free Mobile Softwares
Http://www.mobilestreet.net Mobilestreet Download Free Mobile Stuff From Mobile Street. Largest Collection of Mobile Stuff On Internet , Themes , Games , Islamic Section , Ringtones, Funny Movies and Naat Much More Avaliable, Nokia , Sony Ericsson, Motorola, Smart Phones, Pocket Pc and Much More. http://www.mobilestreet.net -- http://mail.python.org/mailman/listinfo/python-list
invite friends: contact list importing from hotmail, yahoo, gmail etc.
Hi All, I googled a lot trying to find out any FOSS python software for the above, but could not find one. Any pointers would be of vital help. thanks, Sanjay -- http://mail.python.org/mailman/listinfo/python-list
cresitrepair
hi guys you can download the softwares and can get the latest tips and tricks about computers in this blog so just visit hte site and enjoy. If you don't gat what you want try the ads given there and son't forger to search in google search box what you want. the site is www.creditrepairs-rs.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
How to round a floating point to nearest 10?
I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 9 kol, 01:27, Carl Banks [EMAIL PROTECTED] wrote: On Aug 8, 1:11 pm, [EMAIL PROTECTED] wrote: Thanks for quick reply.Maybe I'm crazy but I did what you said and I stll get the same error :( :( :( :(.I have boost version 1.34.1 and I'm running it on Windows XP SP2. While you're at it, please post your setup.py Carl Banks Hi, Here is my setup.py script: setup(name=MyApp, ext_modules=[ Extension(hello, [hellomodule.cpp], libraries = [boost_python], include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\ \boost'], ) ]) Regards, Veki -- http://mail.python.org/mailman/listinfo/python-list
Second mortgage loans
The arrears rate stood at 1.33 percent of all mortgages by the end of the first half, up from 1.10 percent at the end of 2007 and 1.02 percent at the end of the first half of last year, the CML said. The CML is maintaining its forecast of 45,000 total possessions and 170,000 mortgages in arrears of more than three months by the end of the year. There are a total of around 11.74 million mortgages in the UK, the CML said. [EMAIL PROTECTED] Copyright Thomson Financial News Limited 2008. All rights reserved. The copying, republication or redistribution of Thomson Financial News Content, including by framing or similar means, is expressly prohibited without the prior written consent of Thomson Financial News. Neither the Subscriber nor Thomson Financial News warrants the completeness or accuracy of the Service or the suitability of the Service as a trading aid and neither accepts any liability for losses howsoever incurred. The content on this site, including news, quotes, data and other information, is provided by Thomson Financial News and its third party content providers for your personal information only, and neither Thomson Financial News nor its third party content providers shall be liable for any errors, inaccuracies or delays in content, or for any actions taken in reliance thereon. http://www.my-quickloans.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Fastest way to store ints and floats on disk
Laszlo Nagy [EMAIL PROTECTED] writes: The facts table cannot be kept in memory because it is too big. I need to store it on disk, be able to read incrementally, and make statistics. In most cases, the statistic will be simple sum of the measures, and counting the number of facts affected. To be effective, reading the facts from disk should not involve complex conversions. For this reason, storing in CSV or XML or any textual format would be bad. I'm thinking about a binary format, but how can I interface that with Python? I already looked at: - xdrlib, which throws me DeprecationWarning when I store some integers - struct which uses format string for each read operation, I'm concerned about its speed What else can I use? pytables (http://www.pytables.org/) looks like the right kind of thing. -M- -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
On Aug 9, 9:31 pm, Will Rocisky [EMAIL PROTECTED] wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? import decimal [decimal.Decimal(int(round(x, -1))) for x in (76.1, 74.9)] [Decimal(80), Decimal(70)] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
Will Rocisky wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? help(round) Help on built-in function round in module __builtin__: round(...) round(number[, ndigits]) - floating point number Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative. for f in 74.9, 75.0, 75.1: ... print %r -- %r % (f, round(f, -1)) ... 74.906 -- 70.0 75.0 -- 80.0 75.094 -- 80.0 Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On 9 kol, 13:34, [EMAIL PROTECTED] wrote: On 9 kol, 01:27, Carl Banks [EMAIL PROTECTED] wrote: On Aug 8, 1:11 pm, [EMAIL PROTECTED] wrote: Thanks for quick reply.Maybe I'm crazy but I did what you said and I stll get the same error :( :( :( :(.I have boost version 1.34.1 and I'm running it on Windows XP SP2. While you're at it, please post your setup.py Carl Banks Hi, Here is my setup.py script: setup(name=MyApp, ext_modules=[ Extension(hello, [hellomodule.cpp], libraries = [boost_python], include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\ \boost'], ) ]) Regards, Veki Hello, ...and here is the error: C:\Panda3D-1.5.2\python\Lib\site-packagespython setup.py build running build running build_ext building 'hello' extension D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c / nologo /Ox /MD /W3 /GX /DNDEBUG -ID:\Program Files\boost\boost_1_34_1\boost - IC:\Panda3D -1.5.2\python\include -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.cpp / Fobuild\t emp.win32-2.5\Release\hellomodule.obj hellomodule.cpp hellomodule.cpp(9) : fatal error C1083: Cannot open include file: 'boost/python/ module.hpp': No such file or directory error: command 'D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe' failed with exit status 2 C:\Panda3D-1.5.2\python\Lib\site-packagespause Press any key to continue . . . -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
On Aug 9, 5:46 pm, Peter Otten [EMAIL PROTECTED] wrote: Will Rocisky wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? help(round) Help on built-in function round in module __builtin__: round(...) round(number[, ndigits]) - floating point number Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative. for f in 74.9, 75.0, 75.1: ... print %r -- %r % (f, round(f, -1)) ... 74.906 -- 70.0 75.0 -- 80.0 75.094 -- 80.0 Peter thank -- http://mail.python.org/mailman/listinfo/python-list
Re: mktime overflow in March 2008?
Tim Roberts wrote: What time zone are you in? March 30, 2008, was a Sunday. If that happened to be the date your country transitioned to summer time, then the hour between 2 AM and 3 AM would not exist. Does it work if you use 3:43 AM? Actually you're right; I'm in Middle Europe, and DST was started on March 30, 2am. I need to check this. robert -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
On Sat, 9 Aug 2008 04:31:38 -0700 (PDT), Will Rocisky [EMAIL PROTECTED] wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? for n in (74.9, 76.1): print int((n+5)/10)*10 70 80 Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is ::= used as assignment operator in doc statements?
Ben Finney wrote: [EMAIL PROTECTED] writes: Why is statments expressed with ::= as the assigning operator? like: http://docs.python.org/ref/grammar.txt That page is part of the language reference. It shows, not Python code, but a description of part of the Python grammar. See §1.2 URL:http://www.python.org/doc/ref/notation.html. Of historic interest is Extended Bachus-Naur Normal Form (EBNF): http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form Colin W. -- http://mail.python.org/mailman/listinfo/python-list
list question... unique values in all possible unique spots
I'm wondering how to do this the most elegant way: I found this quiz in some magazine. I've already solved it on paper, but want to write a python program to solve it. It comes down to being able to represent range(1,27) through a number of formulas. How do I write a loop that will loop through this list, so that: 1. every number only occurs once, and 2. I get every possibility of order within the list? I guess it'd be somewhat similar to Sudoku, where you have the numbers from 1-9 in any possible order. Here it's 1-26. -- http://mail.python.org/mailman/listinfo/python-list
Ascii to binary conversion
Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) -- http://mail.python.org/mailman/listinfo/python-list
Re: list question... unique values in all possible unique spots
On Aug 9, 9:05 am, ToshiBoy [EMAIL PROTECTED] wrote: I'm wondering how to do this the most elegant way: I found this quiz in some magazine. I've already solved it on paper, but want to write a python program to solve it. It comes down to being able to represent range(1,27) through a number of formulas. How do I write a loop that will loop through this list, so that: 1. every number only occurs once, and 2. I get every possibility of order within the list? I guess it'd be somewhat similar to Sudoku, where you have the numbers from 1-9 in any possible order. Here it's 1-26. Search for a permutation generator function. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
On Aug 9, 11:18 pm, azrael [EMAIL PROTECTED] wrote: Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) Here's one way: def a2b(a): ...ai = ord(a) ...return ''.join('01'[(ai x) 1] for x in xrange(7, -1, -1)) ... a2b('1') '00110001' a2b('2') '00110010' a2b(chr(0)) '' a2b(chr(255)) '' BUT ... why are you doing this so much that the speed matters??? -- http://mail.python.org/mailman/listinfo/python-list
wxPython IDE question
Hi, I know this has been asked many times, but I can't seem to find a real good IDE for wxPython. I look at an application such as testuff.com and I am sure it was written using wxPython, however the GUI is so clean and robust that I can't imagine them not using an IDE with those characteristics. Isn't there one single IDE out there that would provide me all the tools to create such a nice GUI? Something like the Visual studio of wxpython? I currently use Zend studio for my php dev, and i dont usually need a gui builder because we are talking web, but i feel the need in python for one. Can somebody recommend me a list of such an IDE? Even if its not free. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin [EMAIL PROTECTED] wrote: On Aug 9, 11:18 pm, azrael [EMAIL PROTECTED] wrote: Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) Here's one way: def a2b(a): ... ai = ord(a) ... return ''.join('01'[(ai x) 1] for x in xrange(7, -1, -1)) ... a2b('1') '00110001' a2b('2') '00110010' a2b(chr(0)) '' a2b(chr(255)) '' BUT ... why are you doing this so much that the speed matters??? -- http://mail.python.org/mailman/listinfo/python-list
Re: Large production environments using ZODB/ZOE?
Phillip B Oldham wrote: I've been reading a lot recently on ZODB/ZOE, but I've not seen any reference to its use in large-scale production envrironments. Are there any real-world examples of ZODB/ZOE in use for a large system? By large, I'm thinking in terms of both horizontally-scaled systems and in terms of data storage size. I have been told (by one of the developers) that Viacom uses it for their video streaming website which is quite large. There is also a list of organizations on Zope's webside that is pretty impressive. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Extract string from log file
203.114.10.66 - - [01/Aug/2008:05:41:21 +0300] GET /stat.gif? stat=vc=F-Securev=1.1%20Build%2014231s=av%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton %20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows %20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f %3B26027%3B26447%3B26003%3B22452%3B%7Dr=0.9496 HTTP/1.1 200 43 http://dfstage1.f-secure.com/fshc/1.1/release/devbw/1.1.14231/ card.html Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) does anyone know how can i extract certain string from this log file using regular expression in python or using XML. can teach me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
azrael wrote: looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin [EMAIL PROTECTED] wrote: On Aug 9, 11:18 pm, azrael [EMAIL PROTECTED] wrote: Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) Here's one way: def a2b(a): ...ai = ord(a) ...return ''.join('01'[(ai x) 1] for x in xrange(7, -1, -1)) ... a2b('1') '00110001' a2b('2') '00110010' a2b(chr(0)) '' a2b(chr(255)) '' BUT ... why are you doing this so much that the speed matters??? Opposite of ord() is chr(). These functions have been available in every language I've used for the last 30 years. I would suggest that you might want to spend a little time reading a good Python book and to work through the tutorial. It will be worth your investment of time. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
On Aug 9, 8:18�am, azrael [EMAIL PROTECTED] wrote: Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) In Pthon 2.6 3.0 there actually IS a bin() function. IDLE 2.6b1 bin(ord('1')) '0b110001' But it has that worthless '0b' decorator, but that's easily dealt with. bin(ord('1'))[2:] '110001' And you won't get leading 0s unless you ask for them. bin(ord('1'))[2:].zfill(8) '00110001' If you have previous Python versions (and even if you have 2.6), you might consider getting the gmpy module. It will convert to any base from 2 to 36 and in addition, provides a nice set of binary manipulation functions such as popcount (number of 1-bits), scan1 (finds posistion of first 1-bit), Hamming Distance (number of differing bits between two numbers), etc. import gmpy gmpy.digits(ord('1'))# base 10 by default '49' gmpy.digits(ord('1'),2) # same in base 2 (note - no decorator) '110001' gmpy.digits(ord('1'),2).zfill(8) # add leading 0s '00110001' gmpy.popcount(ord('1')) # of 1-bits 3 gmpy.scan1(ord('1')) # the first 1 is at bit 0 0 gmpy.scan1(ord('1'),1) # the next 1 is at bit 4 4 gmpy.hamdist(ord('1'),ord('6')) # differ at 3 bit positions 3 And you probably won't find anything faster than gmpy. -- http://mail.python.org/mailman/listinfo/python-list
Re: list question... unique values in all possible unique spots
On Aug 9, 8:05�am, ToshiBoy [EMAIL PROTECTED] wrote: I'm wondering how to do this the most elegant way: I found this quiz in some magazine. I've already solved it on paper, but want to write a python program to solve it. It comes down to being able to represent range(1,27) through a number of formulas. How do I write a loop that will loop through this list, so that: 1. every number only occurs once, and 2. I get every possibility of order within the list? I guess it'd be somewhat similar to Sudoku, where you have the numbers from 1-9 in any possible order. Here it's 1-26. Python 2.6 has a permutation function: IDLE 2.6b1 import itertools for i in itertools.permutations(range(4)): print i (0, 1, 2, 3) (0, 1, 3, 2) (0, 2, 1, 3) (0, 2, 3, 1) (0, 3, 1, 2) (0, 3, 2, 1) (1, 0, 2, 3) (1, 0, 3, 2) (1, 2, 0, 3) (1, 2, 3, 0) (1, 3, 0, 2) (1, 3, 2, 0) (2, 0, 1, 3) (2, 0, 3, 1) (2, 1, 0, 3) (2, 1, 3, 0) (2, 3, 0, 1) (2, 3, 1, 0) (3, 0, 1, 2) (3, 0, 2, 1) (3, 1, 0, 2) (3, 1, 2, 0) (3, 2, 0, 1) (3, 2, 1, 0) Bur bear in mind that permutations of size n are n!. So the permutaions of range(1,27) is 26! which is print gmpy.fac(26) 40329146112660563558400 That's 403 octillion. Are you sure you want to do this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract string from log file
[EMAIL PROTECTED] wrote: 203.114.10.66 - - [01/Aug/2008:05:41:21 +0300] GET /stat.gif? stat=vc=F-Securev=1.1%20Build%2014231s=av%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton %20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows %20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f %3B26027%3B26447%3B26003%3B22452%3B%7Dr=0.9496 HTTP/1.1 200 43 http://dfstage1.f-secure.com/fshc/1.1/release/devbw/1.1.14231/ card.html Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) does anyone know how can i extract certain string from this log file using regular expression in python or using XML. can teach me. Joseph, You will get much more help on this list if you show us what you have actually tried so far to solve the problem on your own. Then post what is not working (with full tracebacks if there are any) and you will find that people will try to assist you. If you require help reading lines from a file or learning regular expressions, you really need to use Google to look for tutorials first. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
On Aug 9, 6:31�am, Will Rocisky [EMAIL PROTECTED] wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? print '%.0e' % 74.9 7e+01 print '%.0e' % 76.1 8e+01 -- http://mail.python.org/mailman/listinfo/python-list
RE: Extract string from log file
from each line separate out url and request parts. split the request into key-value pairs, use urllib to unquote key-value pairs..as show below... import urllib line = GET /stat.gif?stat=vc=F-Securev=1.1%20Build%2014231s=av%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton%20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows%20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f%3B26027%3B26447%3B26003%3B22452%3B%7Dr=0.9496 HTTP/1.1 words = line.split() for word in words: if word.find('?') = 0: req = word[word.find('?') + 1:] kwds = req.split('') for kv in kwds: print urllib.unquote(kv) stat=v c=F-Secure v=1.1 Build 14231 s=av{Norton 360 (Symantec Corporation)+69;}sw{Norton 360 (Symantec Corporation)+69;}fw{Norton 360 (Symantec Corporation)+5;}v{Microsoft Windows XP+insecure;Microsoft Windows XP Professional+f;26027;26447;26003;22452;} r=0.9496 good luck Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Saturday, August 09, 2008 10:48 AM To: python-list@python.org Subject: Extract string from log file 203.114.10.66 - - [01/Aug/2008:05:41:21 +0300] GET /stat.gif? stat=vc=F-Securev=1.1%20Build%2014231s=av%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton %20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows %20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f %3B26027%3B26447%3B26003%3B22452%3B%7Dr=0.9496 HTTP/1.1 200 43 http://dfstage1.f-secure.com/fshc/1.1/release/devbw/1.1.14231/ card.html Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) does anyone know how can i extract certain string from this log file using regular expression in python or using XML. can teach me. -- http://mail.python.org/mailman/listinfo/python-list 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: internet searching program
No, I mean to search the internet really fast and display only REALLY SPECIFIC information about certain web pages. Like, stuff Google wouldn't have. For instance, in the youtube example, it would name the names of the videos, the url's of them, and the EMBED information without you having to view the site. And BTW, I am extremely new to Python. I am going to buy a few books soon, and I can really start my learning then. And I'll look up some tut's on the 'net in the meantime. -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
You see, I don't like reading some tutorials. I pick myself a problem and look for ways to slove it. I am using Python for about 2 years, but mostly for image processing. As you say, ord is oposite to chr. I learn by example. thnx guys, this looks great On 9 kol, 16:47, Larry Bates [EMAIL PROTECTED] wrote: azrael wrote: looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin [EMAIL PROTECTED] wrote: On Aug 9, 11:18 pm, azrael [EMAIL PROTECTED] wrote: Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) Here's one way: def a2b(a): ... ai = ord(a) ... return ''.join('01'[(ai x) 1] for x in xrange(7, -1, -1)) ... a2b('1') '00110001' a2b('2') '00110010' a2b(chr(0)) '' a2b(chr(255)) '' BUT ... why are you doing this so much that the speed matters??? Opposite of ord() is chr(). These functions have been available in every language I've used for the last 30 years. I would suggest that you might want to spend a little time reading a good Python book and to work through the tutorial. It will be worth your investment of time. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Constructing MIME message without loading message stream
I would like to MIME encode a message from a large file without first loading the file into memory. Assume the file has been pre-encoded on disk (actually I am using encode_7or8bit, so the encoding should be null). Is there a way to construct the flattened MIME message such that data is streamed from the file as needed instead of being resident in memory? Do I have to subclass the MIMEBase class myself? Kris -- http://mail.python.org/mailman/listinfo/python-list
Video information
Is there a py module, which would get me information of a movie file: - resolution - fps -- http://mail.python.org/mailman/listinfo/python-list
Re: internet searching program
I think you are talking about screen scraping. Your program can get the html for the page, and search for an appropriate pattern. Look at the source for a YouTube view page and you will see a string var embedUrl = 'http:// You can write code to search for that in the html text. But embedUrl is not a standard javascript item; it is part of the YouTube design. You will be relying on that, and if YouTube changes how they provide such a string, you will be out of luck; at best you will have to rewrite part of your code. In other words, screen scraping relies on the site not doing a major reworking and on you doing a little reverse engineering of the page source. So how to get the html into your program? In python the answer to that is urllib. http://docs.python.org/lib/module-urllib.html mt -- http://mail.python.org/mailman/listinfo/python-list
Missing exceptions in PEP 3107
I'm just reading PEP 3107 (function annotations) and wonder why exceptions are not mentioned there. I think it would be helpful if one could specify which exceptions can be raised by a function, similarly to how it is possible in C++ using the throw clause. The syntax would be something like this: def foo(a: expr, b: expr = 5) raises expr - expr: The expr in that raises clause should be a list of Exceptions. Having the list of possible exceptions as annotation alone would be already helpful. Of course it could be also discussed whether Python should check that the function really raises only these exceptions (as in C++), or we could even have checked exceptions (as in Java, but this seems to be a controversial issue). Has this already been discussed, or is it in a different PEP? -- Christoph -- http://mail.python.org/mailman/listinfo/python-list
Re: internet searching program
On Aug 9, 12:59 pm, KillSwitch [EMAIL PROTECTED] wrote: Is it possible to make a program to search a site on the internet, then get certain information from the web pages that match and display them? Like, you would put in keywords to be searched for on youtube.com, then it would search youtube.com, get the names of the videos, the links, and the embed information? Or something like that. You might find the mechanize module handy: http://wwwsearch.sourceforge.net/mechanize/ And possibly BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract string from log file
On Aug 9, 11:22 pm, [EMAIL PROTECTED] wrote: from each line separate out url and request parts. split the request into key-value pairs, use urllib to unquote key-value pairs..as show below... import urllib line = GET /stat.gif?stat=vc=F-Securev=1.1%20Build%2014231s=av%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton%20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton%20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows%20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f%3B26027%3B26447%3B26003%3B22452%3B%7Dr=0.9496 HTTP/1.1 words = line.split() for word in words: if word.find('?') = 0: req = word[word.find('?') + 1:] kwds = req.split('') for kv in kwds: print urllib.unquote(kv) stat=v c=F-Secure v=1.1 Build 14231 s=av{Norton 360 (Symantec Corporation)+69;}sw{Norton 360 (Symantec Corporation)+69;}fw{Norton 360 (Symantec Corporation)+5;}v{Microsoft Windows XP+insecure;Microsoft Windows XP Professional+f;26027;26447;26003;22452;} r=0.9496 good luck Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Saturday, August 09, 2008 10:48 AM To: [EMAIL PROTECTED] Subject: Extract string from log file 203.114.10.66 - - [01/Aug/2008:05:41:21 +0300] GET /stat.gif? stat=vc=F-Securev=1.1%20Build%2014231s=av%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dsw%7BNorton %20360%20%28Symantec%20Corporation%29+69%3B%7Dfw%7BNorton %20360%20%28Symantec%20Corporation%29+5%3B%7Dv%7BMicrosoft%20Windows %20XP+insecure%3BMicrosoft%20Windows%20XP%20Professional+f %3B26027%3B26447%3B26003%3B22452%3B%7Dr=0.9496 HTTP/1.1 200 43 http://dfstage1.f-secure.com/fshc/1.1/release/devbw/1.1.14231/ card.html Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) does anyone know how can i extract certain string from this log file using regular expression in python or using XML. can teach me. --http://mail.python.org/mailman/listinfo/python-list 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. do you mind to explain further. based on the source code that you gave me. what will it output. i wonder. Sorry i am new to string extraction. i do understand your python coding. the only thing i don't understand is this part. for word in words: if word.find('?') = 0: req = word[word.find('?') + 1:] kwds = req.split('') for kv in kwds: print urllib.unquote(kv) what does this code do? anyway, is this code automatic. what i mean is can it extract the string everytime when a new log file is being output by the sever? -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython IDE question
This is generally a easy-find on 'google', or your favourite search-engine! :-) ... and of course the Python Wiki too... http://wxglade.sourceforge.net/ http://boa-constructor.sourceforge.net/ are the free ones most often cited, and I'm sure there are others. From a pure IDE (non Visual GUI compositing standpoint), I like PyScripter. It's snappy and very functional. cheers, BD On 8/9/08, Samuel Morhaim [EMAIL PROTECTED] wrote: Hi, I know this has been asked many times, but I can't seem to find a real good IDE for wxPython. I look at an application such as testuff.com and I am sure it was written using wxPython, however the GUI is so clean and robust that I can't imagine them not using an IDE with those characteristics. Isn't there one single IDE out there that would provide me all the tools to create such a nice GUI? Something like the Visual studio of wxpython? I currently use Zend studio for my php dev, and i dont usually need a gui builder because we are talking web, but i feel the need in python for one. Can somebody recommend me a list of such an IDE? Even if its not free. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: kill thread
2008/8/8 [EMAIL PROTECTED]: On 8 Ago, 10:03, Mathieu Prevot [EMAIL PROTECTED] wrote: 2008/8/8 Miki [EMAIL PROTECTED]: Hello, I have a threading.Thread class with a for i in range(1,50) loop within. When it runs and I do ^C, I have the error [1] as many as loops. I would like to catch this exception (and if possible do some cleanup like in C pthreads) so the program finishes cleanly. Where and how can I do this ? in __run__ ? __init__ ? a try/except stuff ? You can have a try/except KeyboardException around the thread code. HTH, -- Miki Of course, but I don't know where. I placed this inside loop, within called functions from the loop, I still have the problem. Mathieu Try this: loop_completed = True for i in range(1,50): try: # your code here except KeyboardException: loop_completed = False break # this breaks the loop # end loop if loop_completed: # code to be executed in case of normal completion else: # code to be executed in case of interruption # code to be executed in both cases Thanks for answers. My code sheme was the following: main() starts 2 thread trees (threads of threads of ...) and some of these have for loops. These loops needed to be as you recommended: for ... : try: # instructions except KeyboardInterrupt: # cleaning instructions break The problem with atexit.register is that is doesn't work in case of system signals catches (http://tinyurl.com/6kdaba) Thanks, Mathieu _ def main(): query1 = Thread1 batch1 = Thread2 while True: try: #some code for updating / synchronize / etc threads except KeyboardInterrupt: try: query1.terminate() batch1.terminate() except: pass finally: break _ I used also from http://sebulba.wikispaces.com/recipe+thread2 the following new Thread class: _ import threading, inspect, ctypes def _async_raise(tid, exctype): raises the exception, performs cleanup if needed if not inspect.isclass(exctype): raise TypeError(Only types can be raised (not instances)) res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) if res == 0: raise ValueError(invalid thread id) elif res != 1: # if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) raise SystemError(PyThreadState_SetAsyncExc failed) class Thread(threading.Thread): def _get_my_tid(self): determines this (self's) thread id if not self.isAlive(): raise threading.ThreadError(the thread is not active) # do we have it cached? if hasattr(self, _thread_id): return self._thread_id # no, look for it in the _active dict for tid, tobj in threading._active.items(): if tobj is self: self._thread_id = tid return tid raise AssertionError(could not determine the thread's id) def raise_exc(self, exctype): raises the given exception type in the context of this thread _async_raise(self._get_my_tid(), exctype) def terminate(self): raises SystemExit in the context of the given thread, which should cause the thread to exit silently (unless caught) self.raise_exc(SystemExit) _ -- http://mail.python.org/mailman/listinfo/python-list
Re: Fastest way to store ints and floats on disk
On Aug 7, 2:27 pm, M.-A. Lemburg [EMAIL PROTECTED] wrote: On 2008-08-07 20:41, Laszlo Nagy wrote: Hi, I'm working on a pivot table. I would like to write it in Python. I know, I should be doing that in C, but I would like to create a cross platform version which can deal with smaller databases (not more than a million facts). The data is first imported from a csv file: the user selects which columns contain dimension and measure data (and which columns to ignore). In the next step I would like to build up a database that is efficient enough to be used for making pivot tables. Here is my idea for the database: Original CSV file with column header and values: Color,Year,Make,Price,VMax Yellow,2000,Ferrari,10,254 Blue,2003,Volvo,5,210 Using the GUI, it is converted to this: dimensions = [ { 'name':'Color', 'colindex:0, 'values':[ 'Red', 'Blue', 'Green', 'Yellow' ], }, { 'name':'Year', colindex:1, 'values':[ 1995,1999,2000,2001,2002,2003,2007 ], }, { 'name':'Make', colindex:2, 'value':[ 'Ferrari', 'Volvo', 'Ford', 'Lamborgini' ], }, ] measures = [ { 'name', 'Price', 'colindex':3 }, { 'name', 'Vmax', 'colindex':4 }, ] facts = [ ( (3,2,0),(10.0,254.0) ), # ( dimension_value_indexes, measure_values ) ( (1,5,1),(5.0,210.0) ), # Some million rows or less ] The core of the idea is that, when using a relatively small number of possible values for each dimension, the facts table becomes significantly smaller and easier to process. (Processing the facts would be: iterate over facts, filter out some of them, create statistical values of the measures, grouped by dimensions.) The facts table cannot be kept in memory because it is too big. I need to store it on disk, be able to read incrementally, and make statistics. In most cases, the statistic will be simple sum of the measures, and counting the number of facts affected. To be effective, reading the facts from disk should not involve complex conversions. For this reason, storing in CSV or XML or any textual format would be bad. I'm thinking about a binary format, but how can I interface that with Python? I already looked at: - xdrlib, which throws me DeprecationWarning when I store some integers - struct which uses format string for each read operation, I'm concerned about its speed What else can I use? import marshal marshal.dump(1, open('test.db', 'wb')) marshal.load(open('test.db', 'rb')) 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. Depending on how hard-core you want to be, store the int, float, string, and long C structures directly to disk, at a given offset. Either use fixed-length strings, or implement (or find) a memory manager. Anyone have a good alloc-realloc-free library, C or Python? -- http://mail.python.org/mailman/listinfo/python-list
shelve save object
Hi there! I am using the shelve module in a script to save information in between runtime sessions of the program. (its a sort of data collector, so its important to hold on to anything computed ). In any case, I shelve into a file test.txt. I notice that when i try running the program on a different computer (by either emailing or transfering the file test.txt via USB key), the program is unable to load the shelve file. What can I do to fix this? It would be a great shame to see that after collecting all this information and shelving it that I cannot move to another computer or share the information through the save.txt file. Thanks in advance! Jon -- http://mail.python.org/mailman/listinfo/python-list
Re: Video information
On 2008-08-09, dusans [EMAIL PROTECTED] wrote: Is there a py module, which would get me information of a movie file: - resolution - fps I don't know of one. I use the transcode utilities for this and parse their output. -Bill -- Sattre PressIn the Quarter http://sattre-press.com/ by Robert W. Chambers [EMAIL PROTECTED] http://sattre-press.com/itq.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
On Aug 10, 12:37 am, azrael [EMAIL PROTECTED] wrote: [top-posting corrected] On 9 kol, 15:39, John Machin [EMAIL PROTECTED] wrote: On Aug 9, 11:18 pm, azrael [EMAIL PROTECTED] wrote: Hy folks, I googled, and searched, and can not bealive that I have not found a built in way to convert the easy and elegant python way a function to easily convert simple ascii data to binary and back. I've written some my own but they were pretty slow using binascii linbrary with hexifly and unhexifly functions conbined with a lookuptable of binary and hex values. Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) why are you doing this so much that the speed matters??? the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) WHY do you plan to change about 10 M ascii chars into about 90 M bytes? Who or what is going to consume the output? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing exceptions in PEP 3107
On Aug 9, 9:08 am, Christoph Zwerschke [EMAIL PROTECTED] wrote: I'm just reading PEP 3107 (function annotations) and wonder why exceptions are not mentioned there. I think it would be helpful if one could specify which exceptions can be raised by a function, similarly to how it is possible in C++ using the throw clause. The syntax would be something like this: def foo(a: expr, b: expr = 5) raises expr - expr: The expr in that raises clause should be a list of Exceptions. Having the list of possible exceptions as annotation alone would be already helpful. Of course it could be also discussed whether Python should check that the function really raises only these exceptions (as in C++), or we could even have checked exceptions (as in Java, but this seems to be a controversial issue). Has this already been discussed, or is it in a different PEP? -- Christoph Keep in mind that annotations are just a way of associating some information with the parameters or a function. There is a special parameter called `return` to help associate information with the return value. Whether that information is used to describe the types of the function parameters, how they are used, or something completely different is up to the application that uses them. When you say: The expr in that raises clause should be a list of Exceptions. You are clearly confusing the annotation feature with a possible application of the annotation feature. Annotation could be used for many different applications besides type safety. Annotation simply creates a dictionary. The name `return` was chosen for the return value because it _is_ a keyword and therefore could not conflict with the name of any of the parameters. Using raises would mean that we would have to introduce the name raises as a new keyword. It would be better just to use they existing keyword raise. With all of that being said, a package or application that uses annotation could simply use the data-structure associated with return to also contain exception information. That might not seem intuitive, but keep in mind that the value associated with return in the associations dictionary is going to be a special case anyway. def foo(a: a info, b: b info) - return info, exception info: return hello world Matt -- http://mail.python.org/mailman/listinfo/python-list
Re: .cpp to .pyd
On Aug 9, 7:46 am, [EMAIL PROTECTED] wrote: On 9 kol, 13:34, [EMAIL PROTECTED] wrote: On 9 kol, 01:27, Carl Banks [EMAIL PROTECTED] wrote: On Aug 8, 1:11 pm, [EMAIL PROTECTED] wrote: Thanks for quick reply.Maybe I'm crazy but I did what you said and I stll get the same error :( :( :( :(.I have boost version 1.34.1 and I'm running it on Windows XP SP2. While you're at it, please post your setup.py Carl Banks Hi, Here is my setup.py script: setup(name=MyApp, ext_modules=[ Extension(hello, [hellomodule.cpp], libraries = [boost_python], include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1\ \boost'], ) ]) Regards, Veki Hello, ...and here is the error: C:\Panda3D-1.5.2\python\Lib\site-packagespython setup.py build running build running build_ext building 'hello' extension D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c / nologo /Ox /MD /W3 /GX /DNDEBUG -ID:\Program Files\boost\boost_1_34_1\boost - Good, it's included the directory you specified. IC:\Panda3D -1.5.2\python\include -IC:\Panda3D-1.5.2\python\PC /Tphellomodule.cpp / Fobuild\t emp.win32-2.5\Release\hellomodule.obj hellomodule.cpp hellomodule.cpp(9) : fatal error C1083: Cannot open include file: 'boost/python/ module.hpp': No such file or directory But the file is not located there. error: command 'D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe' failed with exit status 2 C:\Panda3D-1.5.2\python\Lib\site-packagespause Press any key to continue . . . Ok, you have your include directory: D:\Program Files\boost\boost_1_34_1\boost And the file it's trying to access: boost\python\module.hpp The compiler tries to join the two when searching for the file to include, like so: D:\Program Files\boost\boost_1_34_1\boost\boost\python\module.hpp Does this file exist on your system? Probably not. What you probably did was to include the top boost directory in your setup.py when you should have left it out like this: include_dirs = ['D:\\Program Files\\boost\\boost_1_34_1'] If that doesn't work, find the file module.hpp, take the complete pathname, remove the boost\python\module.hpp part, and use that as the include_dir. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
swig and DWMAPI.dll
Hello, When I try and compile a C++ project into a _mystuff.pyd file using swig with wxDev-C++ it works. I can import, run and everything else in python. When I try to compile with g++ command line or code::blocks, compiles just fine but when I try to import it I get this error: File input, line 1, in module File D:\python\spinmobules\speedy.py, line 7, in module import _speedy ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. Running dependency walker tells me that DWMAPI.dll is missing. This is a file that apparently is only on windows vista. Has anyone run into this problem? Is there an easy solution? Thanks, Jack -- http://mail.python.org/mailman/listinfo/python-list
new e-Book on multicore programming
http://www.cilk.com/multicore-e-book New e-Book: How to Survive the Multicore Revolution (or at Least Survive the Hype) the ebook covers: - Background on the emergence of mainstream multicore processors - The key challenges facing software developers - An introduction to multithreading concepts - Twenty questions to ask when going multicore - Overview of programming approaches, including OpenMP, Intel's TBB, MPI, Cilk++, WinAPI/Pthreads -- http://mail.python.org/mailman/listinfo/python-list
Re: Fastest way to store ints and floats on disk
On Aug 10, 4:58 am, castironpi [EMAIL PROTECTED] wrote: On Aug 7, 2:27 pm, M.-A. Lemburg [EMAIL PROTECTED] wrote: On 2008-08-07 20:41, Laszlo Nagy wrote: Hi, I'm working on a pivot table. I would like to write it in Python. I know, I should be doing that in C, but I would like to create a cross platform version which can deal with smaller databases (not more than a million facts). The data is first imported from a csv file: the user selects which columns contain dimension and measure data (and which columns to ignore). In the next step I would like to build up a database that is efficient enough to be used for making pivot tables. Here is my idea for the database: Original CSV file with column header and values: Color,Year,Make,Price,VMax Yellow,2000,Ferrari,10,254 Blue,2003,Volvo,5,210 Using the GUI, it is converted to this: dimensions = [ { 'name':'Color', 'colindex:0, 'values':[ 'Red', 'Blue', 'Green', 'Yellow' ], }, { 'name':'Year', colindex:1, 'values':[ 1995,1999,2000,2001,2002,2003,2007 ], }, { 'name':'Make', colindex:2, 'value':[ 'Ferrari', 'Volvo', 'Ford', 'Lamborgini' ], }, ] measures = [ { 'name', 'Price', 'colindex':3 }, { 'name', 'Vmax', 'colindex':4 }, ] facts = [ ( (3,2,0),(10.0,254.0) ), # ( dimension_value_indexes, measure_values ) ( (1,5,1),(5.0,210.0) ), # Some million rows or less ] The core of the idea is that, when using a relatively small number of possible values for each dimension, the facts table becomes significantly smaller and easier to process. (Processing the facts would be: iterate over facts, filter out some of them, create statistical values of the measures, grouped by dimensions.) The facts table cannot be kept in memory because it is too big. I need to store it on disk, be able to read incrementally, and make statistics. In most cases, the statistic will be simple sum of the measures, and counting the number of facts affected. To be effective, reading the facts from disk should not involve complex conversions. For this reason, storing in CSV or XML or any textual format would be bad. I'm thinking about a binary format, but how can I interface that with Python? I already looked at: - xdrlib, which throws me DeprecationWarning when I store some integers - struct which uses format string for each read operation, I'm concerned about its speed What else can I use? import marshal marshal.dump(1, open('test.db', 'wb')) marshal.load(open('test.db', 'rb')) 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. Depending on how hard-core you want to be, store the int, float, string, and long C structures directly to disk, at a given offset. Either use fixed-length strings, or implement (or find) a memory manager. Anyone have a good alloc-realloc-free library, C or Python? A long time ago, when I last needed to bother about such things (to override the memory allocator in the DJGPP RTL), Doug Lea's malloc did the trick. A memory allocator written in Python? That's a novel concept. -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii to binary conversion
azrael wrote: Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii(1) is converted to bin(00110001) Other alternatives in 2.6 (I believe) and 3.0: 0b00111010101 469 b='111010101' eval('0b'+b) 469 '{0:b}'.format(469) '111010101' -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
On Aug 10, 1:19 am, Mensanator [EMAIL PROTECTED] wrote: On Aug 9, 6:31 am, Will Rocisky [EMAIL PROTECTED] wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? print '%.0e' % 74.9 7e+01 print '%.0e' % 76.1 8e+01 But: print '%.0e' % 176.1 2e+002 Giving the Subject (How to round a floating point to nearest 10?), there's a strong presumption that the OP would want the answer to be 180, not 200. -- http://mail.python.org/mailman/listinfo/python-list
RE: shelve save object
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on similar os but different machines might not work either - goes back to what's available on that machine. inter operability of shelve files with similar os-es works! yes I had used it. For inter-operability of saved information across os-es, roll up your own bit of code to write it out into pickle files. Yes pickle files are inter-operable. Consider a database for persistent storage and retrieval from many os-es good luck. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of hypermonkey2 Sent: Saturday, August 09, 2008 3:33 PM To: python-list@python.org Subject: shelve save object Hi there! I am using the shelve module in a script to save information in between runtime sessions of the program. (its a sort of data collector, so its important to hold on to anything computed ). In any case, I shelve into a file test.txt. I notice that when i try running the program on a different computer (by either emailing or transfering the file test.txt via USB key), the program is unable to load the shelve file. What can I do to fix this? It would be a great shame to see that after collecting all this information and shelving it that I cannot move to another computer or share the information through the save.txt file. Thanks in advance! Jon -- http://mail.python.org/mailman/listinfo/python-list 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: How to round a floating point to nearest 10?
round(76.1, -2) 100.0 round(76.1, -1) 80.0 round(76.1) 76.0 builtin function round, will work for you.. Help on built-in function round in module __builtin__: round(...) round(number[, ndigits]) - floating point number Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative. good luck.. Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Machin Sent: Saturday, August 09, 2008 5:54 PM To: python-list@python.org Subject: Re: How to round a floating point to nearest 10? On Aug 10, 1:19 am, Mensanator [EMAIL PROTECTED] wrote: On Aug 9, 6:31 am, Will Rocisky [EMAIL PROTECTED] wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? print '%.0e' % 74.9 7e+01 print '%.0e' % 76.1 8e+01 But: print '%.0e' % 176.1 2e+002 Giving the Subject (How to round a floating point to nearest 10?), there's a strong presumption that the OP would want the answer to be 180, not 200. -- http://mail.python.org/mailman/listinfo/python-list 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: wxPython IDE question
On Sat, Aug 9, 2008 at 9:13 AM, Samuel Morhaim [EMAIL PROTECTED] wrote: Hi, I know this has been asked many times, but I can't seem to find a real good IDE for wxPython. I look at an application such as testuff.com and I am sure it was written using wxPython, however the GUI is so clean and robust that I can't imagine them not using an IDE with those characteristics. Isn't there one single IDE out there that would provide me all the tools to create such a nice GUI? Something like the Visual studio of wxpython? I currently use Zend studio for my php dev, and i dont usually need a gui builder because we are talking web, but i feel the need in python for one. Can somebody recommend me a list of such an IDE? Even if its not free. Thank you! You really should ask the guys at the wxPython list: http://wxpython.org/maillist.php But I think what you'll find is that most of them do it by hand. Dabo offers a little builder that you might find useful and I know a there's a fair amount of the regulars that like SPE or XRCed. Links are below: http://dabodev.com/ http://wiki.wxpython.org/XRCed http://pythonide.blogspot.com/ Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Class definition attribute order
On Aug 9, 7:55 am, Michele Simionato [EMAIL PROTECTED] wrote: On Aug 5, 5:05 am, Michele Simionato Yep. Seehttp://stacktrace.it/articoli/2008/01/metaclassi-python-3000 (I am working on an English translation these days, but for the moment you can use Google Translator). M. Simionato FWIW, I have just finished translating the first part of the article and I have posted it on my blog on Artima: http://www.artima.com/weblogs/viewpost.jsp?thread=236234 Great feature and great article! I haven't used ABCs yet, so my initial instinct would be to derive odict from dict (it would obviate the conversions in the metaclass). Are you using ABCs just to play with all the new toys at the same time? ;-) -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: Win32 trouble with threading, signals, and sleep()
Lowell Alleman wrote: I'm running into this issue on Windows with the follow exception at the time when the signal handler is called: Traceback (most recent call last): ... self.done.wait(30) File D:\Python24\lib\threading.py, line 348, in wait self.__cond.wait(timeout) File D:\Python24\lib\threading.py, line 222, in wait _sleep(delay) IOError: [Errno 4] Interrupted function call Well you've certainly picked a ticklish area to run into problems with ;). First, forget about the threading aspects for the moment. AFAICT the smallest program which reproduces your problem is: code import signal import time def handler (*args): pass signal.signal(signal.SIGBREAK, handler) time.sleep (10) /code Now run that and do a ctrl-break somewhere in that time.sleep. Sure enough... output Traceback (most recent call last): File C:\data\temp\sig3.py, line 8, in module time.sleep (10) IOError: [Errno 4] Interrupted function call /output Under the covers, the sleep function is implemented as a WaitForSingleObject call with a timeout. The object being waited on is an anonymous event which is set from a console ctrl handler when one of those interrupts happens (ctrl-c / ctrl-break / shutdown). This makes sure that the (otherwise blocking) sleep can be interrupted. Something like this: code import win32api import win32event hEvent = win32event.CreateEvent (None, 1, 0, None) def handler (*args): win32event.PulseEvent (hEvent) return True win32api.SetConsoleCtrlHandler (handler, 1) # # This line is basically the sleep happening # win32event.WaitForSingleObject (hEvent, 1) /code For reasons which I'm not aware of, the code recognises that the interrupt has fired and sets the WSAEINTR error code, which is the IOError 4 which you're seeing, and then exits. EINTR is usually issued when a blocking call is cancelled explicitly, so presumably this is considered a simulation of that. Not sure. What happens now is that control passes back out to the routine which called the sleep. But... an exception condition has been set inside the sleep call and is now raised, appearing to come from within the routine which called sleep. Clear? You could obviously continue to catch the exception. Alternatively, I think your best bet, as long as you can make it work with the threads, is to install your own console ctrl handler. Note that the docs for this specify that: When the signal is received, the system creates a new thread in the process to execute the function. So you'll need to be quite careful to make your code thread-safe. But it should work. I adapted your example slightly to replace all of the lines setting the signal handlers to one statement: win32api.SetConsoleCtrlHandler (handler, 1) and the handler function itself takes only one arg, the signal no, and returns False to indicate that control should pass to the next handler, which will probably be the default Python handler: def handler(arg): print Signal handler, arg global workers for w in workers: w.stop() return False Hope that all helps. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: How to round a floating point to nearest 10?
On Aug 9, 4:54 pm, John Machin [EMAIL PROTECTED] wrote: On Aug 10, 1:19 am, Mensanator [EMAIL PROTECTED] wrote: On Aug 9, 6:31 am, Will Rocisky [EMAIL PROTECTED] wrote: I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70. How can I achieve that? print '%.0e' % 74.9 7e+01 print '%.0e' % 76.1 8e+01 But: print '%.0e' % 176.1 2e+002 Which would be correct if your goal was to restrain to 1 significant digit. Giving the Subject (How to round a floating point to nearest 10?), there's a strong presumption that the OP would want the answer to be 180, not 200. Well, I can't read the OP's mind and the cases I HAVE encountered are concerned about the number of significant digits. When laboratories report 3 digits, all my manipulations (ppm conversion, dividing non-detect reporting limits by 2, comparison to TACO, etc. are required to also have exactly 3 digits of significance). print '%.2e' % 0.0123456 1.23e-006 print '%.2e' % 123456 1.23e+005 print '%.2e' % 0.123000456 1.23e-001 It all depends on what the OP actually wants. He's free to ignore my example. -- http://mail.python.org/mailman/listinfo/python-list
Re: shelve save object
On Aug 10, 5:32 am, hypermonkey2 [EMAIL PROTECTED] wrote: Hi there! I am using the shelve module in a script to save information in between runtime sessions of the program. (its a sort of data collector, so its important to hold on to anything computed ). In any case, I shelve into a file test.txt. I notice that when i try running the program on a different computer (by either emailing or transfering the file test.txt via USB key), the program is unable to load the shelve file. What can I do to fix this? It would be a great shame to see that after collecting all this information and shelving it that I cannot move to another computer or share the information through the save.txt file. For a start, you could consider telling us what unable to load the shelve file means ... please copy any error message, exception information and traceback and paste it into your response. Showing the code that deals with the shelf file would also be useful; we don't want to guess what your shelve.open args are. ... on a different computer: How many different computers? How many times? To check the possibility that the file was mangled in transit between computers, have you compared the filesize and md5 checksum before and after transport? When asking questions like this, it's a very good idea to state what computer platform, what version of what OS, and what version of Python. In your case, you need to report this info for both the creating computer and the unable-to-load computers(s). Try this on both the creating computer and the unable-to-load computers(s), at the Python interactive prompt: import whichdb whichdb.whichdb('test.txt') and report the results. Also consider changing the name from test.txt to something meaningful -- a file with a .txt extension is just begging silly software and silly humans to treat it as a text file and mangle it. HTH, John -- http://mail.python.org/mailman/listinfo/python-list
some kind of trace facility ?
hello, I want to investigate on a regular base the flow of my Python (most of them using wxPython) programs. So I want to have some log facilty, that logs things like - every time a function / method is called - the time spent in that function / method (or even better start / finish time) - in case the function / method has some predefined variables, the values of these variables - the caller As an extra condition, I'm only interested in my own program modules (located in a specific subdirectory). Is there a module available that can perform such a task ? Any hints to get started ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
scapy
I have macpython 2.5 installed, but I cant seem to get scapy installed. I have downloaded scapy.py, and put it in site-packages, for both my /Library/Python/2.5/site-packages and the one located in / System. Scapy fails to import. Is there another site-packages? Or a better way to install it? I am running OS X 10.5, on an intel mac. Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: internet searching program
Michael Tobis wrote: I think you are talking about screen scraping. Your program can get the html for the page, and search for an appropriate pattern. However, it wouldn't be really fast, because you still have to fetch all the pages that might contain data you're looking for. Google searches are fast because they've already fetched all the web pages in the world and indexed them. You might get somewhere using a program that does a site-specific google search to find potentially relevant pages, then goes and looks at those pages for further information. Another possibility might be to crawl the site and build your own index based on the information you're interested in. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
The wrong approach to things
Ok, so this isn't necessarily a programming issue, but anyways. I've managed to write that random wallpaper changer i've been wanting to make, but i've run into a little problem. According to the MS Knowledge Base, SystemParametersInfo() can't take a .jpg file as an argument when changing the wallpaper (it doesn't work, i've tried it), only .bmps so i'm stuck converting one of my many wallpapers from .jpg to .bmp, passing that to SystemParametersInfo(), and deleting the previous .bmp so that i don't have any duplicates. The problem with this is that other members of my family use this computer too, and they sometimes set the desktop wallpaper to some other, usually funny picture they've got stored on the HD, and when I run this little script it'll delete whatever the current wallpaper is, regardless of whether its one of mine or not. Any suggestions on how to work around this problem? #random wallpaper changer! import win32gui #use this to change the wallpaper. import os import os.path import random import Image SPI_SETDESKWALLPAPER = 20 #It took me WAY too long to find them. SPI_GETDESKWALLPAPER = 115 #I should keep these handy. def RandomlySelectWallpaper(filePaths): CurrentWallpaper = win32gui.SystemParametersInfo(SPI_GETDESKWALLPAPER) while True: index = random.randint(0,len(filePaths)-1) RandomlySelectedWallpaper = filePaths[index] if RandomlySelectedWallpaper CurrentWallpaper: break print RandomlySelectedWallpaper return RandomlySelectedWallpaper #it should be a string... def ChangeDesktopWallpaper(RandomlySelectedWallpaper): #so the RIGHT way to do this would be to use #win32gui.SystemParametersInfo() to change the wallpaper. #1) we convert the image to .bmp. #Delete the old wallpaper, actual delete occurs after new wallpaper has been set. pathToCurrentWall = win32gui.SystemParametersInfo(SPI_GETDESKWALLPAPER) root,extension = os.path.splitext(RandomlySelectedWallpaper) newFileName = root + '.bmp' print Wallpaper to delete: , pathToCurrentWall try: #every so often something goes wrong at this stage in the script #and I can't figure out what. Something raises an IOError. Image.open(RandomlySelectedWallpaper).save(newFileName) print File saved! except IOError: print Error while converting, please check filepath and permissions. print Program will restart in an attempt to generate a correct wallpaper. Main() win32gui.SystemParametersInfo(SPI_SETDESKWALLPAPER,newFileName, 1+2) print Removing: , pathToCurrentWall os.remove(pathToCurrentWall) def Main(): #woot. listOfWallpaperPaths = GenerateListOfWallpapers() RandomlySelectedWall = RandomlySelectWallpaper(listOfWallpaperPaths) ChangeDesktopWallpaper(RandomlySelectedWall) Main() -- http://mail.python.org/mailman/listinfo/python-list
Re: Class definition attribute order
On Aug 10, 12:14 am, thebjorn FWIW, I have just finished translating the first part of the article and I have posted it on my blog on Artima: http://www.artima.com/weblogs/viewpost.jsp?thread=236234 Great feature and great article! I haven't used ABCs yet, so my initial instinct would be to derive odict from dict (it would obviate the conversions in the metaclass). Are you using ABCs just to play with all the new toys at the same time? ;-) If you look at the original Italian version I did derive from dict originally; however since the ordered dict implementation I show does not support __delitem__ (on purpose, to make it simple enough to fit in a short paper) I thought it was more correct to derive from Mapping, not from dict. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
ANN: Chandler 1.0
The Chandler Project is pleased to announce the release of Chandler Desktop 1.0! The Chandler Project is an open source, standards-based information manager designed for personal use and small group collaboration. For more information on the Chandler Desktop 1.0, including the major changes we've made since the previous full release, 0.7, see the following blog post: http://blog.chandlerproject.org/2008/08/08/chandler-10/ Chandler Desktop 1.0 is available for download for Windows, Mac, and Linux at: http://chandlerproject.org/download Additional information is available from the Chandler Project homepage. Thanks for your interest in Chandler Desktop! -- Heikki Toivonen - http://www.heikkitoivonen.net -- http://mail.python.org/mailman/listinfo/python-list
Re: The wrong approach to things
On Aug 9, 9:20�pm, teh_sAbEr [EMAIL PROTECTED] wrote: Ok, so this isn't necessarily a programming issue, but anyways. I've managed to write that random wallpaper changer i've been wanting to make, but i've run into a little problem. According to the MS Knowledge Base, SystemParametersInfo() can't take a .jpg file as an argument when changing the wallpaper (it doesn't work, i've tried it), only .bmps so i'm stuck converting one of my many wallpapers from .jpg to .bmp, passing that to SystemParametersInfo(), and deleting the previous .bmp so that i don't have any duplicates. The problem with this is that other members of my family use this computer too, and they sometimes set the desktop wallpaper to some other, usually funny picture they've got stored on the HD, and when I run this little script it'll delete whatever the current wallpaper is, regardless of whether its one of mine or not. Any suggestions on how to work around this problem? Why not rename the file instead of deleting it? #random wallpaper changer! import win32gui #use this to change the wallpaper. import os import os.path import random import Image SPI_SETDESKWALLPAPER = 20 �#It took me WAY too long to find them. SPI_GETDESKWALLPAPER = 115 #I should keep these handy. def RandomlySelectWallpaper(filePaths): � � CurrentWallpaper = win32gui.SystemParametersInfo(SPI_GETDESKWALLPAPER) � � while True: � � � � index = random.randint(0,len(filePaths)-1) � � � � RandomlySelectedWallpaper = filePaths[index] � � � � if RandomlySelectedWallpaper CurrentWallpaper: � � � � � � break � � print RandomlySelectedWallpaper � � return RandomlySelectedWallpaper #it should be a string... def ChangeDesktopWallpaper(RandomlySelectedWallpaper): � � #so the RIGHT way to do this would be to use � � #win32gui.SystemParametersInfo() to change the wallpaper. � � #1) we convert the image to .bmp. � � #Delete the old wallpaper, actual delete occurs after new wallpaper has been set. � � pathToCurrentWall = win32gui.SystemParametersInfo(SPI_GETDESKWALLPAPER) � � root,extension = os.path.splitext(RandomlySelectedWallpaper) � � newFileName = root + '.bmp' � � print Wallpaper to delete: , pathToCurrentWall � � try: � � � � #every so often something goes wrong at this stage in the script � � � � #and I can't figure out what. Something raises an IOError. � � � � Image.open(RandomlySelectedWallpaper).save(newFileName) � � � � print File saved! � � except IOError: � � � � print Error while converting, please check filepath and permissions. � � � � print Program will restart in an attempt to generate a correct wallpaper. � � � � Main() � � win32gui.SystemParametersInfo(SPI_SETDESKWALLPAPER,newFileName, 1+2) � � print Removing: , pathToCurrentWall � � os.remove(pathToCurrentWall) def Main(): � � #woot. � � listOfWallpaperPaths = GenerateListOfWallpapers() � � RandomlySelectedWall = RandomlySelectWallpaper(listOfWallpaperPaths) � � ChangeDesktopWallpaper(RandomlySelectedWall) Main() -- http://mail.python.org/mailman/listinfo/python-list
Re: swig and DWMAPI.dll
Or, an equally excellent answer would be you still use swig? That's so outdated. Try Awesome McAwesomestein's Awesome C++ to Python Autowrap -- http://mail.python.org/mailman/listinfo/python-list
Re: Fastest way to store ints and floats on disk
On Aug 9, 4:43 pm, John Machin [EMAIL PROTECTED] wrote: On Aug 10, 4:58 am, castironpi [EMAIL PROTECTED] wrote: On Aug 7, 2:27 pm, M.-A. Lemburg [EMAIL PROTECTED] wrote: On 2008-08-07 20:41, Laszlo Nagy wrote: Hi, I'm working on a pivot table. I would like to write it in Python. I know, I should be doing that in C, but I would like to create a cross platform version which can deal with smaller databases (not more than a million facts). The data is first imported from a csv file: the user selects which columns contain dimension and measure data (and which columns to ignore). In the next step I would like to build up a database that is efficient enough to be used for making pivot tables. Here is my idea for the database: Original CSV file with column header and values: Color,Year,Make,Price,VMax Yellow,2000,Ferrari,10,254 Blue,2003,Volvo,5,210 Using the GUI, it is converted to this: dimensions = [ { 'name':'Color', 'colindex:0, 'values':[ 'Red', 'Blue', 'Green', 'Yellow' ], }, { 'name':'Year', colindex:1, 'values':[ 1995,1999,2000,2001,2002,2003,2007 ], }, { 'name':'Make', colindex:2, 'value':[ 'Ferrari', 'Volvo', 'Ford', 'Lamborgini' ], }, ] measures = [ { 'name', 'Price', 'colindex':3 }, { 'name', 'Vmax', 'colindex':4 }, ] facts = [ ( (3,2,0),(10.0,254.0) ), # ( dimension_value_indexes, measure_values ) ( (1,5,1),(5.0,210.0) ), # Some million rows or less ] The core of the idea is that, when using a relatively small number of possible values for each dimension, the facts table becomes significantly smaller and easier to process. (Processing the facts would be: iterate over facts, filter out some of them, create statistical values of the measures, grouped by dimensions.) The facts table cannot be kept in memory because it is too big. I need to store it on disk, be able to read incrementally, and make statistics. In most cases, the statistic will be simple sum of the measures, and counting the number of facts affected. To be effective, reading the facts from disk should not involve complex conversions. For this reason, storing in CSV or XML or any textual format would be bad. I'm thinking about a binary format, but how can I interface that with Python? I already looked at: - xdrlib, which throws me DeprecationWarning when I store some integers - struct which uses format string for each read operation, I'm concerned about its speed What else can I use? import marshal marshal.dump(1, open('test.db', 'wb')) marshal.load(open('test.db', 'rb')) 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. Depending on how hard-core you want to be, store the int, float, string, and long C structures directly to disk, at a given offset. Either use fixed-length strings, or implement (or find) a memory manager. Anyone have a good alloc-realloc-free library, C or Python? A long time ago, when I last needed to bother about such things (to override the memory allocator in the DJGPP RTL), Doug Lea's malloc did the trick. A memory allocator written in Python? That's a novel concept. For strings and longs, you need variable-length records. Wrap Lea's malloc in Python calls, and design a Python class where Year, Price, and VMax are stored as ints at given offsets from the start of the file, and Color and Make are stored as strings at given offsets. Don't bother to cache, just seek and read. Part 1 of the file, or File 1, looks like: Car 1 color_offset year_offset make_offset price_offset vmax_offset Car 2 color_offset year_offset make_offset price_offset vmax_offset Store them directly as bytes, not string reps. of numbers. 1024 1050 1054 1084 1088 1092 1112 1116 1130 1134 Part 2 looks like 1024 Yell 1028 ow 1050 2000 1054 Ferr 1058 ari 1084 10 1088 254 1092 Blue 1112 2003 1116 Volv and so on. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to find out if an object is a class?
Steven D'Aprano wrote: On Fri, 08 Aug 2008 16:38:14 +0200, Stefan Behnel wrote: Miles wrote: On Fri, Aug 8, 2008 at 2:31 AM, Stefan Behnel wrote: I recently had the reverse case that a (stupidly implemented) extension module required a callback function and I wanted to pass a function wrapped in a wrapper object. That failed, because it specifically checked for the argument being a function, not just a callable object. I had to pull quite a number of tricks to reimplement the wrapper class as a function (thank god, it's Python!). You really only needed one trick: def functionize(callable): return lambda *args, **kwargs: callable(*args, **kwargs) Congratulations, you found the trivial case. What other cases are there? It takes any callable, and returns a function that calls the callable. What else do you need? [...] What am I missing? The words stupidly implemented above? :) I have to set the callback in more than one place and (believe it or not) the library behaves (slightly) different when you pass different callbacks. The right way to use the above approach would be to wrap the callback right before passing it into the library - which I can't do, as that would give me a different function object each time. Also, most of the time I actually pass a function, except in one case where I need a wrapper for an existing function. So the solution I chose was to change the original wrapper class itself instead of re-wrapping it, so that I get the expected object right away. As usual, it's all about the details. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: some kind of trace facility ?
n Sat, Aug 9, 2008 at 4:14 PM, Stef Mientki [EMAIL PROTECTED] wrote: hello, I want to investigate on a regular base the flow of my Python (most of them using wxPython) programs. So I want to have some log facilty, that logs things like - every time a function / method is called - the time spent in that function / method (or even better start / finish time) - in case the function / method has some predefined variables, the values of these variables - the caller As an extra condition, I'm only interested in my own program modules (located in a specific subdirectory). Is there a module available that can perform such a task ? Any hints to get started ? thanks, Stef Mientki As is often the case, I have never used this technique, but have read about it: You may want to investigate a logging decorator. Python's Decorator module has a decorator factory that should allow you to log at least the calls. I'm not sure it would help you much with the time the method took, but I could very well be wrong about that. -- Stand Fast, tjg. [Timothy Grant] -- http://mail.python.org/mailman/listinfo/python-list
[issue3531] file read preallocs 'size' bytes which can cause memory problems
Antoine Pitrou [EMAIL PROTECTED] added the comment: I can't reproduce, your code snippet works fine. What Python version is it? -- nosy: +pitrou ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3531 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3531] file read preallocs 'size' bytes which can cause memory problems
Andrew Dalke [EMAIL PROTECTED] added the comment: I tested it with Python 2.5 on a Mac, Python 2.5 on FreeBSD, and Python 2.6b2+ (from SVN as of this morning) on a Mac. Perhaps the memory allocator on your machine is making a promise it can't keep? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3531 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3531] file read preallocs 'size' bytes which can cause memory problems
Antoine Pitrou [EMAIL PROTECTED] added the comment: Perhaps. I'm under Linux. However, at the end of the file_read() implementation in fileobject.c, you can find the following lines: if (bytesread != buffersize) _PyString_Resize(v, bytesread); Which means that the string *is* resized at the end. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3531 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3270] test_multiprocessing: test_listener_client flakiness
Hirokazu Yamamoto [EMAIL PROTECTED] added the comment: I confirmed this patch works on my win2000. And I believe it works on Trent's machine, too. http://mail.python.org/pipermail/python-dev/2008-June/080525.html ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3270 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3526] Customized malloc implementation on SunOS and AIX
Antoine Pitrou [EMAIL PROTECTED] added the comment: Le vendredi 08 août 2008 à 22:46 +, Martin v. Löwis a écrit : Instead, Python's own memory allocate (obmalloc) should be changed to directly use the virtual memory interfaces of the operating system (i.e. mmap), bypassing the malloc of the C library. How would that interact with fork()? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3531] file read preallocs 'size' bytes which can cause memory problems
Andrew Dalke [EMAIL PROTECTED] added the comment: You're right. I mistook the string implementation for the list one which does keep a preallocated section in case of growth. Strings of course don't grow so there's no need for that. I tracked the memory allocation all the way down to obmalloc.c:PyObject_Realloc . The call goes to realloc(p, nbytes) which is a C lib call. It appears that the memory space is not reallocated. That was enough to be able to find the python-dev thread Darwin's realloc(...) implementation never shrinks allocations from Jan. 2005, Bob Ippolito's post realloc.. doesn’t? (http://bob.pythonmac.org/archives/2005/01/01/realloc-doesnt/ ) and Issue1092502 . Mind you, I also get the problem on FreeBSD 2.6 so it isn't Darwin specific. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3531 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3531] file read preallocs 'size' bytes which can cause memory problems
Antoine Pitrou [EMAIL PROTECTED] added the comment: Le samedi 09 août 2008 à 11:26 +, Andrew Dalke a écrit : Mind you, I also get the problem on FreeBSD 2.6 so it isn't Darwin specific. Darwin and the BSD's supposedly share a lot of common stuff. But FreeBSD 2.6 is a bit old, isn't it? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3531 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3501] expm1 missing
Changes by Mark Dickinson [EMAIL PROTECTED]: -- assignee: - marketdickinson components: +Extension Modules -None priority: - normal versions: +Python 2.7, Python 3.1 -Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3501 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3532] bytes.tohex method
New submission from Matt Giuca [EMAIL PROTECTED]: I haven't been able to find a way to encode a bytes object in hexadecimal, where in Python 2.x I'd go str.encode('hex'). I recommend adding a bytes.tohex() method (in the same vein as the existing bytes.fromhex class method). I've attached a patch which adds this method to the bytes and bytearray classes (in the C code). Also included documentation and test cases. Style note: The bytesobject.c and bytearrayobject.c files are all over the place in terms of tabs/spaces. I used tabs in bytesobject and spaces in bytearrayobject, since those seemed to be the predominant styles in either file. Commit log: Added tohex method to bytes and bytearray objects. Also added documentation and test cases. -- components: Interpreter Core files: bytes.tohex.patch keywords: patch messages: 70932 nosy: mgiuca severity: normal status: open title: bytes.tohex method type: feature request versions: Python 3.0 Added file: http://bugs.python.org/file11091/bytes.tohex.patch ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3532 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3492] Zlib compress/decompress functions returning bytearray
Antoine Pitrou [EMAIL PROTECTED] added the comment: Any updates ? The py3k list is also very silent since the week-end...Thanks! Your two patches look good, I suppose either Alexandre or I will commit them soon. You shouldn't to worry when you don't get a reply immediately, people react simply when they have time to do so. And as for the mailing-list activity, we are in the beginning of August which I guess implies many people are on holidays. -- nosy: +pitrou ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3492 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3531] file read preallocs 'size' bytes which can cause memory problems
Andrew Dalke [EMAIL PROTECTED] added the comment: FreeBSD is why my hosting provider uses. Freebsd.org calls 2.6 legacy but the latest update was earlier this year. There is shared history with Macs. I don't know the details though. I just point out that the problem isn't only on Darwin. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3531 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3533] mac 10.4 buld of 3.0 --with-pydebug fails no __eprintf
New submission from Barry Alan Scott [EMAIL PROTECTED]: I wanted to use Py_DEBUG build to help debug a problem with ref counts in a C++ extension. I cannot find eprintf in the sources of python where does this symbol come from? How do I fix the build to define it? $ sw_vers ProductName:Mac OS X ProductVersion: 10.4.11 BuildVersion: 8S165 $ ./configure --enable-framework --enable-debug --with-pydebug $ make ... /usr/bin/install -c -d -m 755 Python.framework/Versions/3.0 if test ; then \ gcc -o Python.framework/Versions/3.0/Python -dynamiclib \ -isysroot \ -all_load libpython3.0.a -Wl,-single_module \ -install_name /Library/Frameworks/Python.framework/Versions/3.0/Python \ -compatibility_version 3.0 \ -current_version 3.0; \ else \ /usr/bin/libtool -o Python.framework/Versions/3.0/Python -dynamic libpython3.0.a \ -lSystem -lSystemStubs -arch_only ppc -install_name /Library/Frameworks/Python.framework/Versions/3.0/Python -compatibility_version 3.0 -current_version 3.0 ;\ fi ld: Undefined symbols: ___eprintf /usr/bin/libtool: internal link edit command failed make: *** [Python.framework/Versions/3.0/Python] Error 1 -- components: Build messages: 70935 nosy: barry-scott severity: normal status: open title: mac 10.4 buld of 3.0 --with-pydebug fails no __eprintf versions: Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3533 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3160] Building a Win32 binary installer crashes
Antoine Pitrou [EMAIL PROTECTED] added the comment: Hi Viktor, It's complicated for me to test under Windows right now, but your snippet looks buggy: script_data = open(self.pre_install_script, r).read() cfgdata = cfgdata + script_data + b\n\0 script_data is an unicode string because the file is opened in text mode, but you try to concatenate it with bytes objects which will fail. Please try to fix this and provide a proper patch :-) PS : I agree it is important to fix this. -- keywords: +patch nosy: +pitrou priority: - high ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3362] locale.getpreferredencoding() gives bus error on Mac OS X 10.4.11 PPC
Antoine Pitrou [EMAIL PROTECTED] added the comment: locale.getpreferredencoding() should certainly not crash but the question remains of what should be the outcome. I can see several possibilities: (1) return the empty string (2) return None (3) return ascii (!!) (4) raise an exception (which one?) (2) sounds the most logical to me, there is no preferred encoding in the environment so we just return None to indicate that the application has to choose its own default. -- nosy: +pitrou priority: - critical ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3362 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3362] locale.getpreferredencoding() gives bus error on Mac OS X 10.4.11 PPC
Changes by Antoine Pitrou [EMAIL PROTECTED]: -- versions: +Python 2.6, Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3362 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3253] shutil.move bahave unexpected in fat32
Antoine Pitrou [EMAIL PROTECTED] added the comment: This is already fixed in the trunk (which will become Python 2.6). -- nosy: +pitrou resolution: - fixed status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3253 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3205] bz2 iterator fails silently on MemoryError
Antoine Pitrou [EMAIL PROTECTED] added the comment: Fixed in r65609. Thanks for the report and for the patch! -- nosy: +pitrou resolution: - fixed status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3205 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3526] Customized malloc implementation on SunOS and AIX
Martin v. Löwis [EMAIL PROTECTED] added the comment: Instead, Python's own memory allocate (obmalloc) should be changed to directly use the virtual memory interfaces of the operating system (i.e. mmap), bypassing the malloc of the C library. How would that interact with fork()? Nicely, why do you ask? Any anonymous mapping will be copied (typically COW) to the child process, in fact, malloc itself uses anonymous mapping (at least on Linux). ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3362] locale.getpreferredencoding() gives bus error on Mac OS X 10.4.11 PPC
Martin v. Löwis [EMAIL PROTECTED] added the comment: No, getpreferredencoding should always produce an encoding name. If the application had an idea what to use, it wouldn't have to ask. So I favor (3), or, perhaps given that OSX uses UTF-8 in many places, (5) return UTF-8 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3362 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com