Re: list index()
On Aug 31, 11:05 am, Jon Ribbens [EMAIL PROTECTED] wrote: On 2007-08-31, Erik Max Francis [EMAIL PROTECTED] wrote: I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll and role similarly. My accent is probably from the East Midlands of the UK, but is not pronounced. _Troll_ and _frolic_ aren't pronounced with the same o sound in any accent I've ever heard of. Welcome to England! Which you pronounce _boat_ and _bot_ the same way, too? No. HTH HAND. For some, troll rhymes with roll, for others, with doll. Does it matter? As for the pronunciation of Python, let's ask Guido! :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote: Like in math where you put letters that represent numbers for place holders to try to find the answer type complex numbers? You shouldnt worry about it in python, its pretty large to handle all your calc. -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
So what exactly is a complex number? It is a math construct, and has almost nothing to do with Python, other than the fact that Python has a data type for them. So, here is a list of better ways to get information about complex numbers than asking python-list: 1. Google it: http://www.google.com/search?q=Complex+Numbers 2. Wikipedia: See the first result of the above 3. Ask a math teacher 4. Just stay in school and do your math homework. You will learn about it eventually. -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
On Aug 31, 5:28 pm, Chris Mellon [EMAIL PROTECTED] wrote: On 8/31/07, Steve Holden [EMAIL PROTECTED] wrote: sturlamolden wrote: On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, then? When is it OK to use them? There are fractions that can be exactly represented by floats that cannot be exactly represented by decimals. Would you care to give an example? There are fractions that can be exactly represented by decimals that cannot be exactly represented by floats. Which one is better? Which do we prefer? What a float cannot do is to represent a decimal fractional number (e.g. 1.1) exactly. If we need that, we cannot use floats. A notable example is monetary computations, it covers 99% of the use for decimal numbers in computers. For this reason, we should never use floats to add 10 cents to a dollar. The use of decimals for monetary calculations is mandatory. That last sentence is patent nonsense, and completely untrue. Many satisfactory financial applications have been written using only floating-point arithmetic. Indeed I believe the accountant's Swiss army knife, the Excel spreadsheet, uses floating-point numbers exclusively. This is true, although Excel munges it's FP to provide expected results. It depends on what you consider a financial application though. Excel, while in extremely broad use, is not used to implement any of the systems which actually define money, like the back end financial systems at banks and credit unions. In my experience, by far the most common method of calculating financial numbers is actually using integer amounts, and then applying well-defined rounding rules which I can't be bothered to look up the name for. For what it's worth, the work that I do with money (which is middleware doing data transport, not calculations or billing) uses either string representations or fixed point. What you say about floating-point have speed advantages is true, but you go too far in claiming that decimal arithmetic is mandatory for monetary calculations. That's about as sensible as saying that base 12 and base 20 arithmetic units were required to calculate in pounds, shillings and pence. I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4 shillings, not 1.333... pounds. FYI, 1 pound 4 shillings was 1.20 pounds; 1.333... pounds was 1 pound 6 shillings 8 pence. I think... -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
Mark Dickinson wrote: That's because the call to abs() usually collapses two values to one (e.g. -2 and 2 both end up being 2), but there's only one integer n for which abs(n) == 0. Ah. Need to sleep more. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4 shillings, not 1.333... pounds. When I worked on the British Railways National Payroll system, about 35 years ago, we, in common with many large users, wrote our system to deal with integer amounts of pennies, and converted to pounds, shillings and pence in the output part of the system. -- David Wild using RISC OS on broadband www.davidhwild.me.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Is English your native language? I'm having a hard time decoding your question. dont be an ass About the complex numbers I get what they are in python now. Thanks Paul Boddie -Lamonte. On 8/31/07, Paul Boddie [EMAIL PROTECTED] wrote: On 31 Aug, 18:12, Chris Mellon [EMAIL PROTECTED] wrote: On 8/31/07, Carsten Haese [EMAIL PROTECTED] wrote: On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote: Like in math where you put letters that represent numbers for place holders to try to find the answer type complex numbers? Is English your native language? I'm having a hard time decoding your question. I'm pretty sure he was describing middle school algebra. Yes, I imagine that the letters that represent numbers is intended to refer to this: http://en.wikipedia.org/wiki/Elementary_algebra Whereas complex numbers are, of course, described here: http://en.wikipedia.org/wiki/Complex_number I hope the above resources are informative for the original inquirer. Paul -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
low level ethernet device access in linux
Hi, I have a windows application, written in delphi, that communicates to our devices using raw ethernet frames. I am trying to port this application to linux using python. However, when I try to open a socket, I get this error: File /home/tbrown/projects/discovery/trunk/comm.py, line 9, in __init__ self.s = socket(AF_PACKET, SOCK_RAW, proto) File /usr/local/lib/python2.5/socket.py, line 156, in __init__ _sock = _realsocket(family, type, proto) socket.error: (1, 'Operation not permitted') I understand that I am getting this error because I am running the application as a user and not as root. I would like to be able to run this app. as a user. Is there a way to create a socket without running the app. as root or sudo? When I run the app. as root I get this error: discovery.py: cannot connect to X server Thanks, Tom -- http://mail.python.org/mailman/listinfo/python-list
Python 3000 released as 3.0a1
[Bcc: [EMAIL PROTECTED] The first Python 3000 release is out -- Python 3.0a1. Be the first one on your block to download it! http://python.org/download/releases/3.0/ Excerpts: Python 3000 (a.k.a. Py3k, and released as Python 3.0) is a new version of the language that is incompatible with the 2.x line of releases. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. This is an ongoing project; the cleanup isn't expected to be complete until 2008. In particular there are plans to reorganize the standard library namespace. The release plan is to have a series of alpha releases in 2007, beta releases in 2008, and a final release in August 2008. The alpha releases are primarily aimed at developers who want a sneak peek at the new langauge, especially those folks who plan to port their code to Python 3000. The hope is that by the time of the final release, many 3rd party packages will already be available in a 3.0-compatible form. More links: * Online docs: http://docs.python.org/dev/3.0/ * What's new: http://docs.python.org/dev/3.0/whatsnew/3.0.html * Source tar ball: http://python.org/ftp/python/3.0/Python-3.0a1.tgz * Windows MSI installer: http://python.org/ftp/python/3.0/python-3.0a1.msi * PEP 3000: http://python.org/dev/peps/pep-3000/ * Issue tracker: http://bugs.python.org/ * Py3k dev list: http://mail.python.org/mailman/listinfo/python-3000/ * Conversion tool for Python 2.x code: http://svn.python.org/view/sandbox/trunk/2to3/ -- --Guido van Rossum (home page: http://www.python.org/~guido/) -- http://mail.python.org/mailman/listinfo/python-list
Wing IDE 3.0 beta2 released
Hi, I'm happy to announce the release of Wing IDE 3.0 beta 2. It is available from http://wingware.com/wingide/beta Changes since the previous beta release include: * Stackless Python 2.4 and 2.5 are now supported * Python 2.5 for 64-bit Windows is now supported * Fixed Zope WingDBG so it will connect back to IDE * Improved auto-completion coverage for imports and end cases * Up to 10% speed-up when running in debugger * Fixed many other bugs, particularly source browser, OS commands, testing tool, and source assistant (*) In addition, we have introduced Wing IDE 101, a free scaled back version of Wing IDE designed for teaching introductory programming courses. The CHANGELOG.txt file in the installation provides additional details. The major new features introduced in Wing 3.0 are: * Multi-threaded debugger * Debug value tooltips in editor, debug probe, and interactive shell * Autocompletion in debug probe and interactive shell * Automatically updating project directories * Testing tool, currently supporting unittest derived tests (*) * OS Commands tool for executing and interacting with external commands (*) * Rewritten indentation analysis and conversion (*) * Introduction of Wing IDE 101, a free edition for beginning programmers * Available as a .deb package for Debian and Ubuntu * Support for Stackless Python * Support for 64 bit Python on Windows and Linux (*)'d items are available in Wing IDE Professional only. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Compatibility Notes --- The file pattern in the Testing tab of Project Properties will need to be re-entered if the project was saved with one of the 3.0 alpha releases. Reporting Bugs -- Please report bugs using the Submit Bug Report item in the Help menu or by emailing support at wingware dot com. This is beta quality software that installs side-by-side with Wing 2.x or 1.x. We advise you to make frequent backups of your work when using any pre-release version of Wing IDE. Upgrading - To upgrade a 2.x license or purchase a new 3.x license: Upgradehttps://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. If you are not ready to upgrade, feel free to keep using a series of trial licenses. There will be no limit on the number of trials until 3.0 final is out. Thanks! The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Question involving a Python app...
On Aug 31, 8:43 am, sberry [EMAIL PROTECTED] wrote: On Aug 31, 8:25 am, [EMAIL PROTECTED] wrote: On Aug 31, 9:52 am, sberry [EMAIL PROTECTED] wrote: I am a Flash developer (also a Python dev) and I use an editor called SEPY Actionscript Editor. The latest release version does not support Flash CS3, so I downloaded the source from subversion, edited it, and recompiled to get a version that worked with CS3. Right now, in order to run the program I have to do a command line python main.pyw. The question now is this: Others in my company would like to use the version I have compiled without installing Python, wxPython, 4suite, antlr, and a whole bunch of other Python libs. So, how do I create an executable (on Windows) to install the program so it will run without the aforementioned framework being installed? I know this isn't really an entirely Pythonic question, but this group has always been very helpful in the past. Thanks I find GUI2exe to be very easy to use. It's just py2exe with a GUI frontend. Seehttp://xoomer.alice.it/infinity77/main/GUI2Exe.htmlfor more information. Mike Thanks for the help... and for giving it so quickly - I can always count on this group. Problems though... I was successful at creating the dist dir with my executable file, but when I try to run it I get an error.log file with the following: type 'exceptions.IOError' [Errno 9] Bad file descriptor [53]: main.pyw [29]: SEPY.pyo [16]: core\__init__.pyo [5]: core\documents\__init__.pyo [11]: core\documents\compare.pyo [15]: core\documents\editor.pyo [13]: core\io\__init__.pyo [6]: core\io\xml\__init__.pyo [11]: core\io\xml\autoformat.pyo [29]: Ft\Xml\Domlette.pyo [355]: Ft\Xml\InputSource.pyo [584]: Ft\Xml\Catalog.pyo [62]: warnings.pyo [126]: warnings.pyo [122]: Ft\__init__.pyo Can anyone help explain what I am missing here? THANKS! Ok, I figured some of this out. I added the module antlr, and the package Ft and recompiled. Now I have the error.log down to this: type 'exceptions.ImportError' No module named shell [53]: main.pyw [37]: SEPY.pyo [11]: core\io\PythonShortCut.pyo Any ideas on how to get rid of these last couple of errors? -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
On 31 Aug, 18:12, Chris Mellon [EMAIL PROTECTED] wrote: On 8/31/07, Carsten Haese [EMAIL PROTECTED] wrote: On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote: Like in math where you put letters that represent numbers for place holders to try to find the answer type complex numbers? Is English your native language? I'm having a hard time decoding your question. I'm pretty sure he was describing middle school algebra. Yes, I imagine that the letters that represent numbers is intended to refer to this: http://en.wikipedia.org/wiki/Elementary_algebra Whereas complex numbers are, of course, described here: http://en.wikipedia.org/wiki/Complex_number I hope the above resources are informative for the original inquirer. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Google spreadsheets
On Aug 31, 5:40 pm, Michele Simionato [EMAIL PROTECTED] wrote: I would like to upload a tab-separated file to a Google spreadsheet from Python. Does anybody have a recipe handy? TIA, Michele Simionato Probably its irrelevant to python. Use should see Google Spreadsheet API and use it in your python application. http://code.google.com/apis/spreadsheets/ -- http://mail.python.org/mailman/listinfo/python-list
Re: reload(sys)
Sönmez Kartal wrote: On 31 A ustos, 04:24, Steven Bethard [EMAIL PROTECTED] wrote: Sönmez Kartal wrote: I've had an encoding issue and solved it by sys.setdefaultencoding('utf-8')... My first try wasn't successful since setdefaultencoding is not named when I imported sys module. After, I import sys module, I needed to write reload(sys) also. I wonder why we need to call reload(sys) to get setdefaultencoding named? sys.setdefaultencoding is purposely deleted from the sys module after it's loaded because you really shouldn't be using it. The reload() call restores the deleted attribute. If you'd like a less brittle solution to your encoding issue, explain what the issue was, and people here can probably help you find a better solution. STeVe I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as f.write(str(xml)). At execution of that line, it gives error with description, configure your default encoding... Could you post the actual traceback you're getting? STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: low level ethernet device access in linux
On 2007-08-31, Tom Brown [EMAIL PROTECTED] wrote: I understand that I am getting this error because I am running the application as a user and not as root. I would like to be able to run this app. as a user. Is there a way to create a socket without running the app. as root or sudo? Yes. According to the raw(7) man page: ERRORS EPERM The user doesn't have permission to open raw sockets. Only pro- cesses with a effective user ID of 0 or the CAP_NET_RAW attribute may do that. Anticipating your next question: $ man capabilities -- Grant Edwards grante Yow! Well, I'm INVISIBLE at AGAIN ... I might as well visi.compay a visit to the LADIES ROOM ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to exit a while loop on keystroke?
Hello, I am new to python, and have written a simple program to read a port via telnet. I would like it to run until any key is pressed. Of course I wouldn't mind requiring a specific keystroke in the future, but I would think this is simpler for now. I have used kbhit() and getch() many times in C, but I can't find anything similar in Python. I am using Linux also, so the msvcrt code isn't an option. I have tried sys.stdin.read(), but that hangs UNTIL a key is pressed. You might want to look at http://docs.python.org/lib/module-curses.html Another solution is to ask the user to hit CTRL-C from time import sleep try: while 1: print BEEP sleep(1) except KeyboardInterrupt: print BYE BYE HTH, -- Miki [EMAIL PROTECTED] http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for Delaunay triangulation module...
On 2007-08-31, Grant Edwards [EMAIL PROTECTED] wrote: So for lack of a delaunay module, I'm stuck trying to port my application to Win32. I've found that VTK contains a Delaunay triangulation module, and Entought Python includes VTK, so that's next on my list of things to try as soon as VTK finishes building on my Linux box (where I do all of my actual development). -- Grant Edwards grante Yow! hubub, hubub, HUBUB, at hubub, hubub, hubub, HUBUB, visi.comhubub, hubub, hubub. -- http://mail.python.org/mailman/listinfo/python-list
troll vs. trawl [was: Re: list index()]
On Fri, Aug 31, 2007 at 10:27:34AM +0100, Richie Hindle wrote: [Carsten] .. If we start labeling people, this thread will earn you a label that rhymes with roll. [Hendrik] weird this - maybe a native English speaker can comment - when I pronounce what fishermen do - it rhymes with roll, but when I am talking about the thing that lives under bridges and munches goats, the O sound is shorter, and more towards the back of my mouth. But - the word for someone who posts to the internet with the intention of stirring up trouble derives from the word for what fishermen do, not from the word for something that lives under a bridge. It derives from trolling for suckers or trolling for newbies. Many thesauri list the 'troll' as a synonym of 'trawl'. Given their etymologies... 1. 'trawl' is 'probably from L. tragula dragnet.' -- URL: http://www.etymonline.com/index.php?term=trawl 2. blockquote troll (v.) 1377, to go about, stroll, later (c.1425) roll from side to side, trundle, from O.Fr. troller, a hunting term, wander, to go in quest of game without purpose, from a Gmc. source (cf. O.H.G. trollen to walk with short steps), from P.Gmc. *truzlanan. Sense of sing in a full, rolling voice (first attested 1575) and that of fish with a moving line (1606) are both extended technical applications of the general sense of roll, trundle, the latter perhaps confused with trail or trawl. Fig. sense of to draw on as with a moving bait, entice, allure is from 1565. Meaning to cruise in search of sexual encounters is recorded from 1967, originally in homosexual slang. /blockquote -- URL: http://www.etymonline.com/index.php?term=troll ... it was probably inevitable that 'troll' and 'trawl' become synonymous. David -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Carsten Haese wrote: On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote: Like in math where you put letters that represent numbers for place holders to try to find the answer type complex numbers? Is English your native language? I'm having a hard time decoding your question. Here is a simple explanation (and it is not complete by a long shot). A number by itself is called a scalar. For example, when I say, I have 23 apples, the 23 is a scalar that just represents an amount in this case. One of the most common uses for Complex Numbers is in what are called vectors. In a vector, you have both an amount and a *direction*. For example, I can say, I threw 23 apples in the air at a 45 degree angle. Complex Numbers let us encode both the magnitude (23) and the direction (45 degrees) as a number. There are actually two ways to represent Complex Numbers. One is called the rectangular form, the other the polar form, but both do the same thing - they encode a vector. Complex Numbers show up all over the place in engineering and science problems. Languages like Python that have Complex Numbers as a first class data type allow you do to *arithmetic* on them (add, subtract, etc.). This makes Python very useful when solving problems for engineering, science, navigation, and so forth. HTH, -- Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list
[python 3.0] reload() gone?
I read in the Python 3.0 documentation that reload() was removed, without further explanations. http://docs.python.org/dev/3.0/whatsnew/3.0.html?highlight=reload So what are we supposed to do to reload modules? Thanks Bernard -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to exit a while loop on keystroke?
Thanks, The curses library doesn't look to helpful to me. However using CTRL- C is fine and is working nicely. BTW, it should be time.sleep(1) in the example above, instead of just sleep(1) (Just in case any other newbies like me read this) Thanks again -- http://mail.python.org/mailman/listinfo/python-list
Re: Joining Big Files
On Aug 27, 12:43 am, mcl [EMAIL PROTECTED] wrote: All, Thank you very much. As my background is much smaller memory machines than today's giants - 64k being abigmachine and 640k being gigantic. I get very worried about crashing machines when copying or editingbigfiles, especially in a multi-user environment. Mr Knuth - that brings back memories. I rememeber implementing some of his sort routines on a mainframe with 24 tape units and an 8k drum and almost eliminating one shift per day of computer operator time. Thanks again Richard I can imagine ... though I don't go back that far. Cool ... Vasudev -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
Paddy wrote: On Aug 31, 8:47 am, Erik Max Francis [EMAIL PROTECTED] wrote: Hendrik van Rooyen wrote: weird this - maybe a native English speaker can comment - when I pronounce what fishermen do - it rhymes with roll, but when I am talking about the thing that lives under bridges and munches goats, the O sound is shorter, and more towards the back of my mouth. Native English accents vary as well, but _roll_ rhymes with _troll_, not _trawl_. _Trawl_ would rhyme with _fall_, and _fall_ definitely doesn't rhyme with _roll_. -- Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/ San Jose, CA, USA 37 20 N 121 53 W AIM, Y!M erikmaxfrancis I do not like work even when someone else does it. -- Mark Twain I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll and role similarly. My accent is probably from the East Midlands of the UK, but is not pronounced. If your accent isn't pronounced how do we know what it sounds like? regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: platform system may be Windows or Microsoft since Vista
On Aug 31, 9:47 am, [EMAIL PROTECTED] wrote: Let's suppose you get Python for Vista Windows today fromhttp://www.python.org/download/. Should you then conclude that the tests: if platform.system() in ('Windows', 'Microsoft'): if not (platform.system() in ('Windows', 'Microsoft')): Good analysis. Log a bug @ bugs.python.org -Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
Alex Martelli wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... Why wouldn't the one obvious way be: def inAnotB(A, B): inA = set(os.listdir(A)) inBs = set(os.listdir(B)) return inA.difference(inBs) If you want a set as the result, that's one possibility (although possibly a bit wasteful as you're building one more set than necessary); I read the original request as implying a sorted list result is wanted, just like os.listdir returns (possibly sorted in case-independent order depending on the underlying filesystem). There's no real added value in destroying inA's ordering by making it a set, when the list comprehension just naturally keeps its ordering. As I had reason to point out in another thread only recently, os.listdir() makes no promises about the filename ordering. Nevertheless I agree with you that the list comprehension method is the obvious way to solve the problem, and the set optimization is just that. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Michele Simionato wrote: I am curious. Why do you think I attacked you? The conversion went as follows: I don't think you attacked me. I was referring to another person, who apparently came to your defense and *did* attack me. For the record, I apologize for saying that you don't seem to know what DbC is. I shouldn't have made it personal. I should have just made the points I made and let them stand on their own. Having said that, I think that some of the statements you made were clearly excessive. Unit testing is a thousand times better than DbC? How could that possibly be? As I tried to explain, DbC can be *used* for unit testing and *also* for integrated system testing. I would not call that an attack. If you want to see an attack, wait for Alex replying to you observations about the low quality of code at Google! ;) I don't know much about Google code, but I know that the line breaking logic (or lack thereof) on Google Groups is a constant annoyance to me. But maybe I just haven't figured out how to use it yet. -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
Chris Mellon wrote: On 8/31/07, Steve Holden [EMAIL PROTECTED] wrote: sturlamolden wrote: On 31 Aug, 02:12, Wildemar Wildenburger [EMAIL PROTECTED] wrote: I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, then? When is it OK to use them? There are fractions that can be exactly represented by floats that cannot be exactly represented by decimals. Would you care to give an example? There are fractions that can be exactly represented by decimals that cannot be exactly represented by floats. Which one is better? Which do we prefer? What a float cannot do is to represent a decimal fractional number (e.g. 1.1) exactly. If we need that, we cannot use floats. A notable example is monetary computations, it covers 99% of the use for decimal numbers in computers. For this reason, we should never use floats to add 10 cents to a dollar. The use of decimals for monetary calculations is mandatory. That last sentence is patent nonsense, and completely untrue. Many satisfactory financial applications have been written using only floating-point arithmetic. Indeed I believe the accountant's Swiss army knife, the Excel spreadsheet, uses floating-point numbers exclusively. This is true, although Excel munges it's FP to provide expected results. It depends on what you consider a financial application though. Excel, while in extremely broad use, is not used to implement any of the systems which actually define money, like the back end financial systems at banks and credit unions. In my experience, by far the most common method of calculating financial numbers is actually using integer amounts, and then applying well-defined rounding rules which I can't be bothered to look up the name for. For what it's worth, the work that I do with money (which is middleware doing data transport, not calculations or billing) uses either string representations or fixed point. What you say about floating-point have speed advantages is true, but you go too far in claiming that decimal arithmetic is mandatory for monetary calculations. That's about as sensible as saying that base 12 and base 20 arithmetic units were required to calculate in pounds, shillings and pence. I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4 shillings, not 1.333... pounds. There is much in what you say (which, I am happy to note, doesn't really contradict much of what I wrote). While I agree that Excel isn't a fundamental component of back-end financial systems you might be surprised at just how many people rely on its currency cells for financial applications, albeit of a more lightweight kind. You let yourself down just a little right at the end by not knowing the intricacies of the old sterling currency - since there were twenty shillings to the pound and twelve pennies to a shilling that would have been £1.2. However, you are correct in assuming that nobody tried to represent £1 3s. 4d. as 23.333... shillings. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
On Fri, 2007-08-31 at 11:13 -0600, Lamonte Harris wrote: Is English your native language? I'm having a hard time decoding your question. dont be an ass I'm sorry you took it this way. I was only trying to help. It won't happen again. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
Jeffrey Barish wrote: Robert Kern wrote: Ivan Voras wrote: Jeffrey Barish wrote: If you take the difference between two uniformly distributed random variables, the probability density function forms an isosceles triangle centered at 0. Take the absolute value of that variable and the pdf is a straight line with maximum value at 0 tapering to 0 at max. Thus, z = abs(randint(0, max) - randint(0, max)) ought to do the trick. It's elegant :) I've noticed something interesting in my test: the value 0 appears less often than other values (which behave as they should). The distribution of the difference (before the abs()) looks like this (max=4): # ### # ### ---0+++ 321 123 Taking the absolute value doubles up the non-zero masses, but there's no negative 0 to add to the 0s stack. # # ### ### 0123 The method does not work because of that. The math says that it works, so we must not be implementing it correctly. The math says nothing of the kind about the method that was stated. I suspect that our mistake is quantizing the random variable first and then taking the difference and absolute value. What result do you get when you quantize once? That is, obtain two random values (floats) with uniform pdf. Take the difference. Abs. Round to int. This way, everything in the band from (-0.5, +0.5) goes to 0, and that's the highest part of the triangle. That's a very different it. The difference is not just implementation. If you change round to truncate, that method should work, though. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Steve Holden wrote: Frankly I am getting a little tired of they way you are unable to even recognize that your readers may well have a sensible appreciation of the difficulties about which you write. As has been pointed out already, many readers here are extremely experienced programmers. You said in an earlier post that's not an insult, but that isn't really up to you to decide. If it gives offense then it probably is, whether it was intended to do so or not. You don't seem to appreciate the insulting nature of your tone, and calling people bozos is not likely to endear you to most c.l.py readers since it comes off as arrogant. You quoted what I wrote in reply to a personal attack against me, but you conveniently neglected to quote the original insult that I was replying to. OK, I'll concede that I shouldn't have replied to a personal insult with another insult, but why am I the only one at fault here rather than the guy who started it? Frankly, Mr. Holden, I'm getting a bit tired of the clannish behavior here, where outsiders like me are held to a higher standard than your insider friends. I don't know who you are, nor do I care what you and your little group think about me. As for DbC or what I call self-testing code, I have come to the (tentative) realization that it is easy to implement in current Python -- without resorting to the decorators hack. OK, maybe this should have been obvious to me from the start, but here goes: All you really need to test the pre-conditions of a function is a call at the top of the function to another function that checks the inputs. To test the post-conditions, you just need a call at the bottom of the function, just before the return, that checks the return values. Those functions can also check the invariants. Then you define a global variable to switch all the self-test functions on or off at once. An advantage of this approach is that all the self tests can be put at the bottom of the file (or perhaps in another file) to reduce clutter in the primary code. I'd still prefer PEP 316, but this seems like a reasonable alternative. One suggestion I have for PEP 316 is to provide a way to place the self-test checks in a separate file to reduce clutter. -- http://mail.python.org/mailman/listinfo/python-list
Re: fcntl problems
In article [EMAIL PROTECTED], mhearne808[insert-at-sign-here]gmail[insert-dot-here]com [EMAIL PROTECTED] wrote: Looking at my flock(3) man page, I'm guessing that 35 is the error code for EWOULDBLOCK. Which system header file am I supposed to look in to figure that magic number out? On a MacOS system, you can find them in /usr/include/sys/errno.h On a Linux system, try /usr/include/asm-generic/errno.h However, if you're writing in Python, you will probably have an easier time using the errno module, e.g., ] import errno ] errno.errorcode[35] 'EDEADLOCK' Note that some codes have multiple names (e.g., EAGAIN and EWOULDBLOCK) so that this lookup may not return exactly the name you're expecting. Cheers, -M -- Michael J. Fromberger | Lecturer, Dept. of Computer Science http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA -- http://mail.python.org/mailman/listinfo/python-list
code check for modifying sequence while iterating over it?
After just getting bitten by this error, I wonder if any pylint, pychecker variant can detect this error? -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Alex Martelli wrote: Russ specifically mentioned *mission-critical applications* as being outside of Python's possibilities; yet search IS mission critical to Google. Yes, reliability is obtained via a systems approach, Alex, I think you are missing the point. Yes, I'm sure that web searches are critical to Google's mission and commercial success. But the point is that a few subtle bugs cannot destroy Google. If your search engines and associated systems have bugs, you fix them (or simply tolerate them) and continue on. And if a user does not get the results he wants, he isn't likely to die over it -- or even care much. Online financial transactions are another matter altogether, of course. User won't die, but they will get very irate if they lose money. But I don't think that's what you are talking about here. -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Russ wrote: Steve Holden wrote: Frankly I am getting a little tired of they way you are unable to even recognize that your readers may well have a sensible appreciation of the difficulties about which you write. As has been pointed out already, many readers here are extremely experienced programmers. You said in an earlier post that's not an insult, but that isn't really up to you to decide. If it gives offense then it probably is, whether it was intended to do so or not. You don't seem to appreciate the insulting nature of your tone, and calling people bozos is not likely to endear you to most c.l.py readers since it comes off as arrogant. You quoted what I wrote in reply to a personal attack against me, but you conveniently neglected to quote the original insult that I was replying to. OK, I'll concede that I shouldn't have replied to a personal insult with another insult, but why am I the only one at fault here rather than the guy who started it? You aren't, and if I wasn't being even-handed I apologize. Frankly, Mr. Holden, I'm getting a bit tired of the clannish behavior here, where outsiders like me are held to a higher standard than your insider friends. I don't know who you are, nor do I care what you and your little group think about me. Well that's a healthy attitude, but I am concerned that the Python community should be as welcoming as possible, so I don't like the fact that you feel you are being treated differently from anyone else. As for DbC or what I call self-testing code, I have come to the (tentative) realization that it is easy to implement in current Python -- without resorting to the decorators hack. OK, maybe this should have been obvious to me from the start, but here goes: All you really need to test the pre-conditions of a function is a call at the top of the function to another function that checks the inputs. To test the post-conditions, you just need a call at the bottom of the function, just before the return, that checks the return values. Those functions can also check the invariants. Then you define a global variable to switch all the self-test functions on or off at once. It does constrain functions to return only from the bottom of their code, though, which not all Python functions currently do. Though there's nothing to stop you putting the calls before every return. An advantage of this approach is that all the self tests can be put at the bottom of the file (or perhaps in another file) to reduce clutter in the primary code. I'd still prefer PEP 316, but this seems like a reasonable alternative. One suggestion I have for PEP 316 is to provide a way to place the self-test checks in a separate file to reduce clutter. That would be a sensible suggestion. It would also be possible to guard the lengthier tests with if debug to allow them to be omitted (presumably along with their imports with a little further effort in code organization) in (optimized) production mode where timings were critical. This could allow the benefits of DbC and unit testing at the same time. Putting the verification code into external functions does assume that global variables aren't used in the pre- and post-conditions, but I presume that's a part of the regime anyway. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
On Aug 31, 5:39 pm, David H Wild [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4 shillings, not 1.333... pounds. When I worked on the British Railways National Payroll system, about 35 years ago, we, in common with many large users, wrote our system to deal with integer amounts of pennies, and converted to pounds, shillings and pence in the output part of the system. So you never handled halfpennies? -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
MRAB wrote: On Aug 31, 5:39 pm, David H Wild [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4 shillings, not 1.333... pounds. When I worked on the British Railways National Payroll system, about 35 years ago, we, in common with many large users, wrote our system to deal with integer amounts of pennies, and converted to pounds, shillings and pence in the output part of the system. So you never handled halfpennies? Nobody was paid to the ha'penny. You could spend them in the shops, but payroll systems didn't use them. I am happy to say that I didn't become involved in financial programming until after decimalization (February 1971, IIRC - I was in Sweden at the time). regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Horace Lives!
Mégalo! -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: JavaScript
Hi! I know how to, but only with IE on windows. -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: Registering a python function in C
Thanks for the responses. To be more specific, this code is part of a Maya plugin. The funcion MFnPlugin::registerUI takes a pointer to a PyObject which is the function that will set up the UI for that plugin. The code Matimus posted seems to me exactly like what I need to do, except that maya gives me an error when I call PyImport_ImportModule... I don't even have a chance to check the return value, Maya simply gives up. I have checked that python is initialized by the time I call this function, and the python path is correct, I can load the module from the maya python interpreter. What bugs me is that PyImport_ImportModule doesn't even return, it should return 0 if something bad happened, right? Here's my code: if(Py_IsInitialized()) cout python is already initialized endl; if(!Py_IsInitialized()){ cout had do initialize python endl; Py_Initialize(); } PyObject* mod= PyImport_ImportModule(vzPyTest); if(mod == 0){ cout didn't load endl; } PyObject* func1 = PyObject_GetAttrString(mod, vzPyTest.test1); PyObject* func2 = PyObject_GetAttrString(mod, vzPyTest.test2); plugin.registerUI(func1, func2); Thanks for the help!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Carsten Haese wrote: On Fri, 2007-08-31 at 11:13 -0600, Lamonte Harris wrote: Is English your native language? I'm having a hard time decoding your question. dont be an ass I'm sorry you took it this way. I was only trying to help. It won't happen again. For what it's worth, I too had difficulty parsing Like in math where you put letters that represent numbers for place holders to try to find the answer type complex numbers?, so I suppose I must be an ass too. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Neil Cerutti wrote: Who watches the watchmen? The contracts are composed by the programmers writing the code. Is it likely that the same person who wrote a buggy function will know the right contract? The idea here is that errors in the self-testing code are unlikely to be correlated with errors in the primary code. Hence, you get a sort of multiplying effect on reliability. For example, if the chance of error in the primary code and the self-test code are each 0.01, the chance of an undetected error is approximately 0.01^2 or 0.0001. -- http://mail.python.org/mailman/listinfo/python-list
Horace Lives!
http://horace-vitreouschina.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
In article [EMAIL PROTECTED], MRAB [EMAIL PROTECTED] wrote: When I worked on the British Railways National Payroll system, about 35 years ago, we, in common with many large users, wrote our system to deal with integer amounts of pennies, and converted to pounds, shillings and pence in the output part of the system. So you never handled halfpennies? Halfpennies had disappeared from the BR accounting system before the first use of computers for accounting work. -- David Wild using RISC OS on broadband www.davidhwild.me.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
On Fri, 31 Aug 2007 02:37:15 -0700, Erik Max Francis [EMAIL PROTECTED] wrote: _Troll_ and _frolic_ aren't pronounced with the same o sound in any accent I've ever heard of. You've never heard an English accent then. Which you pronounce _boat_ and _bot_ the same way, too? No - but I would pronounce lever and fever the same way, if that helps. DaveM -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: pronounciation [was: list index()]
On Aug 31, 11:19 am, Tim Golden [EMAIL PROTECTED] wrote: Tim Golden wrote: Erik Max Francis wrote: Paddy wrote: I say the 'oll' in troll like the 'ol' in frolic, and pronounce roll and role similarly. My accent is probably from the East Midlands of the UK, but is not pronounced. _Troll_ and _frolic_ aren't pronounced with the same o sound in any accent I've ever heard of. Which you pronounce _boat_ and _bot_ the same way, too? [Amusingly contemplating a trolling war about the pronunciation of troll] Well they sound the same in my more-or-less South London accent. I can't write those funny phonetic symbols (and I hate to imagine the Unicode encoding hoops I'd have to jump through to make them readable anyway) but both os sound short to me. Like bot rather than boat using your example. Since we're talking... I'm still a little startled when I listen to some of the excellent webcasts that are being produced these days (showmedo.com and friends) and hear American voices pronounce Python... well, the way they do, with the stress and something of a drawl on the second syllable. I'm sure it's just as amusing the other way round: we pronounce it with the stress on the first syllable and the characteristic short vowel sound in the second. (Something like: Pie'thun). TJG The only true way of pronouncing Python (the computing language), is the way it is done at the beginning of Monty Pythons Flying Circus of course :-) Your right, the American way does make me pause. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Steve Holden wrote: Well that's a healthy attitude, but I am concerned that the Python community should be as welcoming as possible, so I don't like the fact that you feel you are being treated differently from anyone else. I certainly appreciate that. And I will try my best to refrain from the little personal zingers (and the big ones too). All you really need to test the pre-conditions of a function is a call at the top of the function to another function that checks the inputs. To test the post-conditions, you just need a call at the bottom of the function, just before the return, that checks the return values. Those functions can also check the invariants. Then you define a global variable to switch all the self-test functions on or off at once. It does constrain functions to return only from the bottom of their code, though, which not all Python functions currently do. Though there's nothing to stop you putting the calls before every return. Oops! I didn't think of that. The idea of putting one before every return certainly doesn't appeal to me. So much for that idea. -- http://mail.python.org/mailman/listinfo/python-list
Re: Registering a python function in C
On Aug 31, 3:33 pm, fernando [EMAIL PROTECTED] wrote: Thanks for the responses. To be more specific, this code is part of a Maya plugin. The funcion MFnPlugin::registerUI takes a pointer to a PyObject which is the function that will set up the UI for that plugin. The code Matimus posted seems to me exactly like what I need to do, except that maya gives me an error when I call PyImport_ImportModule... I don't even have a chance to check the return value, Maya simply gives up. I have checked that python is initialized by the time I call this function, and the python path is correct, I can load the module from the maya python interpreter. What bugs me is that PyImport_ImportModule doesn't even return, it should return 0 if something bad happened, right? Here's my code: if(Py_IsInitialized()) cout python is already initialized endl; if(!Py_IsInitialized()){ cout had do initialize python endl; Py_Initialize();} PyObject* mod= PyImport_ImportModule(vzPyTest); if(mod == 0){ cout didn't load endl;} PyObject* func1 = PyObject_GetAttrString(mod, vzPyTest.test1); PyObject* func2 = PyObject_GetAttrString(mod, vzPyTest.test2); plugin.registerUI(func1, func2); Thanks for the help!!! One thing I've learned is that the C interface can be tricky the first time. Is Maya a different python build than what is contained at python.org? If so, I suggest you get your C program to work with the latest python build from python.org. Then see if you can get it to work with the Maya version. -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
I'm sorry that I took the time to respond. -- Jeffrey Barish -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to exit a while loop on keystroke?
On Aug 31, 7:11 pm, gsxg [EMAIL PROTECTED] wrote: Thanks, The curses library doesn't look to helpful to me. And yet it is. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to exit a while loop on keystroke?
On Aug 31, 11:11 am, gsxg [EMAIL PROTECTED] wrote: Thanks, The curses library doesn't look to helpful to me. However using CTRL- C is fine and is working nicely. BTW, it should be time.sleep(1) in the example above, instead of just sleep(1) (Just in case any other newbies like me read this) Thanks again Depends on how you import 'time' import time time.sleep(1) from time import sleep sleep(1) ~Sean -- http://mail.python.org/mailman/listinfo/python-list
Re: reload() gone?
On Aug 31, 7:10 pm, Bernard Lebel [EMAIL PROTECTED] wrote: I read in the Python 3.0 documentation that reload() was removed, without further explanations. http://docs.python.org/dev/3.0/whatsnew/3.0.html?highlight=reload So what are we supposed to do to reload modules? PEP 3100 says: use exec() instead. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: [python 3.0] reload() gone?
Bernard Lebel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] |I read in the Python 3.0 documentation that reload() was removed, | without further explanations. | | http://docs.python.org/dev/3.0/whatsnew/3.0.html?highlight=reload The .a1 release docs are a bit skimpy in places. Reload() often does not do what people want or expect. | So what are we supposed to do to reload modules? He once said he was working on a replacement that he was first testing on himself. I guess it did not make .a1. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: reload() gone?
On 8/31/07, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Aug 31, 7:10 pm, Bernard Lebel [EMAIL PROTECTED] wrote: I read in the Python 3.0 documentation that reload() was removed, without further explanations. http://docs.python.org/dev/3.0/whatsnew/3.0.html?highlight=reload So what are we supposed to do to reload modules? PEP 3100 says: use exec() instead. However, it provides no information on how to do this. exec(import foo) doesn't do it. exec(open(foo.__file__)) doesn't work either, but that might just be teething problems (open returns a TextIOWrapper object which exec doesn't identify as a file). exec(open(foo.__file__).read(), foo.__dict__) was the best I could come up with. That's frigging horrible, and it won't work unless you've got access to the actual python source file of the module. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to exit a while loop on keystroke?
On Aug 31, 3:55 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Aug 31, 7:11 pm, gsxg [EMAIL PROTECTED] wrote: Thanks, The curses library doesn't look to helpful to me. And yet it is. -- Arnaud Maybe the OP is on Windows. The docs seem to indicate that the curses module isn't for Windows (see excerpt below): quote While curses is most widely used in the Unix environment, versions are available for DOS, OS/2, and possibly other systems as well. This extension module is designed to match the API of ncurses, an open- source curses library hosted on Linux and the BSD variants of Unix. unquote See also: http://docs.python.org/lib/module-curses.html Oddly enough, I have it in my Windows distro, so it's rather confusing. I've never used it, so I don't know if it plays nice on Windows or not. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Biased random?
Jeffrey Barish wrote: I'm sorry that I took the time to respond. I'm sorry. I didn't intend my post to be as harsh as it was. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
On Sep 1, 4:51 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Fri, 31 Aug 2007 12:06:49 -0400, Steve Holden [EMAIL PROTECTED] declaimed the following in comp.lang.python: That last sentence is patent nonsense, and completely untrue. Many satisfactory financial applications have been written using only floating-point arithmetic. Indeed I believe the accountant's Swiss army knife, the Excel spreadsheet, uses floating-point numbers exclusively. Excel supports M$'s Currency data type That sentence is also completely untrue. Excel supports only IEEE 754 64-bit floating point, and that is how bean-counts, temperature readings, dates, and money amounts are stored in an XLS file. What is confusing you may be the helpful way that COM etc examine the number format that's been used on a cell. Example: actual value is 1.234567. (a float). The number format used in Excel causes it to be displayed as $1.23. However what COM etc produce when they extract the data is a currency or money instance containing $1.2345 which is NEITHER what you see NOR what you've actually got. That's a somewhat Procrustean attitude to support. -- which I believe is a 64-bit INTEGER scaled for four decimal places. It's general format is a variant type accepting integer, float, text, date/time (but can't differentiate currency form float on input) Excel has no concept of a variant type. General is a number format, not a data type. Excel has storage types corresponding to Python's float, unicode (16 bit), bool and None, as well as an error type. -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
On Sep 1, 4:58 am, MRAB [EMAIL PROTECTED] wrote: On Aug 31, 5:39 pm, David H Wild [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Chris Mellon [EMAIL PROTECTED] wrote: I believe that to the degree that real accounting was done in those currencies it did in fact use non-decimal bases. Just as people don't use decimal time values (except us crazy computer folk), you're write 1 pound 4 shillings, not 1.333... pounds. When I worked on the British Railways National Payroll system, about 35 years ago, we, in common with many large users, wrote our system to deal with integer amounts of pennies, and converted to pounds, shillings and pence in the output part of the system. So you never handled halfpennies? Or farthings? -- http://mail.python.org/mailman/listinfo/python-list
Re: Question involving a Python app...
Simon Brunning wrote: On 8/31/07, sberry [EMAIL PROTECTED] wrote: So, how do I create an executable (on Windows) to install the program so it will run without the aforementioned framework being installed? Check out py2exe. Uhm, just an idea ... Can't we (that is, someone else) set up a reply-bot that spots FAQs and post the appropriate FGAs? /W -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Tim Daneliuk wrote: A number by itself is called a scalar. For example, when I say, I have 23 apples, the 23 is a scalar that just represents an amount in this case. One of the most common uses for Complex Numbers is in what are called vectors. In a vector, you have both an amount and a *direction*. For example, I can say, I threw 23 apples in the air at a 45 degree angle. Complex Numbers let us encode both the magnitude (23) and the direction (45 degrees) as a number. 1. Thats the most creative use for complex numbers I've ever seen. Or put differently: That's not what you would normally use complex numbers for. 2. Just to confuse the issue: While complex numbers can be represented as 2-dimensional vectors, they are usually considered scalars as well (since they form a field just as real numbers do). There are actually two ways to represent Complex Numbers. One is called the rectangular form, the other the polar form, but both do the same thing - they encode a vector. Again, that is just one way to interpret them. Complex numbers are not vectors (at least no moe than real numbers are). /W -- http://mail.python.org/mailman/listinfo/python-list
Python Unicode to String conversion
Hi everyone, I'm having quite some troubles trying to convert Unicode to String (for use in psycopg, which apparently doesn't know how to cope with unicode strings). The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 (sorry, locale is french, it means byte sequence invalid for encoding utf8, the value is probably an e with one of the french accents) I've found lots of stuff about this googling the error, but I don't seem to be able to find a works always-function just to convert a unicode variable back to string... If someone could find me a solution, that'd really be a lifesaver. I've been losing hours and hours over this one :s thijs -- http://mail.python.org/mailman/listinfo/python-list
parsing response from SOAPpy request
I'm using SOAPpy to access weather data from the NOAA National Digital Forecast Database XML Web Service [1] and I've been having trouble figuring out how to parse the data. The response comes back as XML document but when I check it with type(result) it shows the the response is a string. Does anyone have any suggestions on getting relevant data? Thanks, -Sean [1] http://www.weather.gov/forecasts/xml/ -- http://mail.python.org/mailman/listinfo/python-list
Re: fcntl problems
In message [EMAIL PROTECTED], Miles wrote: except IOError, e: if e.args[0] == 35: Why not except IOError, (ErrNo, Msg) : if ErrNo == errno.EAGAIN : -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a simple way to exit a while loop on keystroke?
In message [EMAIL PROTECTED], gsxg wrote: I am new to python, and have written a simple program to read a port via telnet. I would like it to run until any key is pressed. Did you mean telnet or did you mean local terminal? For a local terminal, the following demo script should give you a starting point: #!/usr/bin/python import sys import select import termios import tty timeout = 0.0 # nonzero to wait that long for keypress save_attrs = termios.tcgetattr(sys.stdin.fileno()) # save terminal settings for restoration--note that this script # doesn't currently trap CTRL/C, so settings will not be properly # restored if that is hit tty.setcbreak(sys.stdin.fileno()) # or can use setraw to block CTRL/C while True : (input_ready, _, _) = select.select((sys.stdin,), (), (), timeout) if sys.stdin in input_ready : break #end if sys.stdout.write(Running...\n) #end while termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, save_attrs) sys.stdout.write(Finished.\n) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Unicode to String conversion
[EMAIL PROTECTED] wrote: Hi everyone, I'm having quite some troubles trying to convert Unicode to String (for use in psycopg, which apparently doesn't know how to cope with unicode strings). The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 (sorry, locale is french, it means byte sequence invalid for encoding utf8, the value is probably an e with one of the french accents) I've found lots of stuff about this googling the error, but I don't seem to be able to find a works always-function just to convert a unicode variable back to string... If someone could find me a solution, that'd really be a lifesaver. I've been losing hours and hours over this one :s thijs Question is, what should it be converted to when there is no corresponding ascii character to map the offending character to? Do you want to throw it away? Your expectation works always is very ill-defined. Write a small function to process the strings yourself and set up a substitution dictionary to do the conversion yourself. -Larry -- http://mail.python.org/mailman/listinfo/python-list
How can I wait for all the threads I spawn for 5 minutes
Hi, In my python program, I would to like to spwan 5 threads, for the them for 5 minutes maximum and the continue. Here is my script: threads = [] for j in range(5): t = MyThread() threads.append(t) for t in threads: t.join(60*5) print thread join\n # wait for 5 minutes for all the threads to complete , and # then continue But this code ends up waiting 5 minutes for **each** thread. that is not what I want. I just want to wait for 5 minutes for all threads. how can I do that? And after 5 minutes, i want to kill off all the threads I spawn earlier, how can I do that in python. Thank you for any help. -- http://mail.python.org/mailman/listinfo/python-list
Re: parsing response from SOAPpy request
seancron wrote: I'm using SOAPpy to access weather data from the NOAA National Digital Forecast Database XML Web Service [1] and I've been having trouble figuring out how to parse the data. The response comes back as XML document but when I check it with type(result) it shows the the response is a string. Does anyone have any suggestions on getting relevant data? Thanks, -Sean [1] http://www.weather.gov/forecasts/xml/ XML data is just a string of characters. Use elementree xml parser (built into Python 2.5 available for download for prior versions) to parse it for what you want to extract. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Parameter Passing - String Variable Truncated ?
Hi, I'm passing what I think is a string parameter to another Python program (spawn.py) - see the code snip below. But only the counter part gets printed to a log file via spawn.py. Yet the echo print to the output window shows the whole string with the fc part. Better explained below I hope, there's the calling .py and the spawn script .py: ...snip... while fc: counter = counter + 1 fc_cntr = str(counter) + ' : ' + fc print fc_cntr + '\n' # Print to Pythonwin interactive window - eg. 1 : New York - all is printed OK arglist = [] arglist.append(pythonPath) arglist.append(spawn_script) arglist.append(fc_cntr) # This gets sent to the spawn_script but only 1 gets printed os.spawnv(os.P_WAIT, pythonPath, arglist) fc = fcs.next() ... -- ## the spawn_script import win32com.client, sys, os, time, re in_featclass = sys.argv[1] handle = open('C:\\log_file.txt', 'a') handle.write(in_featclass + \n) # ONLY the counter part gets printed to the log file!Why? -- Thanks, for help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Unicode to String conversion
On 8/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi everyone, I'm having quite some troubles trying to convert Unicode to String (for use in psycopg, which apparently doesn't know how to cope with unicode strings). The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 (sorry, locale is french, it means byte sequence invalid for encoding utf8, the value is probably an e with one of the french accents) I've found lots of stuff about this googling the error, but I don't seem to be able to find a works always-function just to convert a unicode variable back to string... encode(). You didn't post the code that was failing, I can encode that value into UTF-8 (and unless I'm very much mistaken, you should be able to encode any unicode string to UTF-8). -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Neil Cerutti wrote: On 2007-08-31, Ricardo Aráoz [EMAIL PROTECTED] wrote: Russ wrote: Yes, thanks for reminding me about that. With SPARK Ada, it is possible for some real (non-trivial) applications to formally (i.e., mathematically) *prove* correctness by static analysis. I doubt that is possible without static declarative type- checking. SPARK Ada is for applications that really *must* be correct or people could die. I've always wondered... Are the compilers (or interpreters), which take these programs to machine code, also formally proven correct? And the OS in which those programs operate, are they also formally proven correct? And the hardware, microprocessor, electric supply, etc. are they also 'proven correct'? Who watches the watchmen? The contracts are composed by the programmers writing the code. Is it likely that the same person who wrote a buggy function will know the right contract? Actually my point was that if a program is to be trusted in a critical situation (critical as in catastrophe if it goes wrong) then the OS, the compiler/interpreter etc should abide by the same rules. That is obviously not possible, so there's not much case in making the time investment necessary for correctness proof of a little program (or usually a little function inside a program) when the possibilities for failure are all around it and even in the code that will run that function. And we should resort to other more sensible answers to the safety problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Unicode to String conversion
On Sep 1, 8:55 am, [EMAIL PROTECTED] wrote: Hi everyone, I'm having quite some troubles trying to convert Unicode to String (for use in psycopg, which apparently doesn't know how to cope with unicode strings). The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 (sorry, locale is french, it means byte sequence invalid for encoding utf8, I'm a pig-ignorant Anglo; it's news to me that Python error messages varied by locale; I thought they always came out in ASCII as G(od| uido) intended :-) Does that message emanate from Python or psycopg? In either case, it is saying that it is expecting a UTF8-encoded string, but the string given to it is not a valid UTF8-encoded string. the value is probably an e with one of the french accents) PROBABLY?? (1) Please try to understand that computers are quite deterministic. (2) If you want help, stop guessing and use something like print repr(the_value) and tell us what it *actually* is. Also show us the *relevant* parts of your code, so that we can see how your are trying to convert your data, and how you are trying to pass it to psycopg. Also show us the full traceback that you get. I've found lots of stuff about this googling the error, but I don't seem to be able to find a works always-function just to convert a unicode variable back to string... If someone could find me a solution, that'd really be a lifesaver. I've been losing hours and hours over this one :s 1. Find out what your input data actually is (e.g. unicode) 2. Find out what form psycopg requires (e.g. utf8-encoded str). 3. unicode to utf8 is quite simple: useq = uS\xe9quence # that's Sequence with an acute accent on the first e useq8 = useq.encode('utf8') print repr(useq) u'S\xe9quence' print repr(useq8) 'S\xc3\xa9quence' useq8.decode('utf8') u'S\xe9quence' # round trip works as expected Here is what ASCII-Python says about malformed UTF8: \xe0\x20\x63.decode('utf8') Traceback (most recent call last): File stdin, line 1, in module File C:\python25\lib\encodings\utf_8.py, line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2: invalid data Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Wildemar Wildenburger [EMAIL PROTECTED] wrote: Again, that is just one way to interpret them. Complex numbers are not vectors (at least no moe than real numbers are). OK, let me take a shot at this. Math folks like to group numbers into sets. One of the most common sets is the set of integers. I'm not sure what the formal definition of an integer is, but I expect you know what they are: 0, 1, 2, 3, 4, etc, plus the negative versions of these: -1, -2, -3, etc. The set of integers have a few interesting properties. For example, any integer plus any other integer gives you another integer. Math geeks would say that as, The set of integers is closed under addition. Likewise for subtraction; any integer subtracted from any other integer gives you another integers. Thus, the set of integers is closed under subtraction as well. And multiplication. But, division is a bit funky. Some integers divided by some integers give you integers (i.e. 6 / 2 = 3), but some done (i.e. 5 / 2 = 2.5). So, now we need another kind of number, which we call reals (please, no nit picking about rationals). Reals are cool. Not only are the closed under addition, subtraction, and multiplication, but division too. Any real number divided by any other real number gives another real number. But, it's not closed over *every* possible operation. For example, square root. If you take the square root of 4.23, you get some real number. But, if you try to take the square root of a negative number, you can't do it. There is no real number which, when you square it, gives you (to use the cannonical example), -1. That's where imaginary numbers come in. The math geeks invented a wonderful magic number called i (or sometimes j), which gives you -1 when you square it. So, the next step is to take an imaginary number and add it to a real number. Now you've got a complex number. There's all kinds of wonderful things you can do with complex numbers, but this posting is long enough already :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Unicode to String conversion
On Sep 1, 9:56 am, Chris Mellon [EMAIL PROTECTED] wrote: On 8/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi everyone, I'm having quite some troubles trying to convert Unicode to String (for use in psycopg, which apparently doesn't know how to cope with unicode strings). The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 (sorry, locale is french, it means byte sequence invalid for encoding utf8, the value is probably an e with one of the french accents) I've found lots of stuff about this googling the error, but I don't seem to be able to find a works always-function just to convert a unicode variable back to string... encode(). You didn't post the code that was failing, I can encode that value into UTF-8 What is that value? (1) unichr(0xe02063)? You must have a wide unicode build of Python ... (2) u\xe0\x20\x63? Of course you can encode it; so what? (and unless I'm very much mistaken, you should be able to encode any unicode string to UTF-8). That is true, by definition. However you are barking this truism up the wrong tree. The unknown complainant's whinge is that it is expecting a sequence of octets (an 8-bit string) that is valid UTF8, but the actuality is something else. It is *NOT* trying to say that a unicode input can't be converted to UTF8. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Unicode to String conversion
On Fri, 2007-08-31 at 15:55 -0700, [EMAIL PROTECTED] wrote: Hi everyone, I'm having quite some troubles trying to convert Unicode to String (for use in psycopg, which apparently doesn't know how to cope with unicode strings). The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 I'm guessing that you are passing a latin-1 encoded string and pretend (or psycopg assumes) incorrectly that it's UTF-8 encoded. In latin-1 encoding, 0xe0 is a small letter a with a grave accent, 0x20 is a space, and 0x63 is a small letter c. While this is a perfectly valid latin-1 encoded character string, it doesn't represent a valid UTF-8 encoded character string. It seems that you need to pass a UTF-8 encoded string to the database. To give you specific advice on how to do that, we'd have to see your code. For now, I'll give you the generic advice of taking a look at http://www.amk.ca/python/howto/unicode . HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
How to find out if the interpreter is a debug build?
How can i find out if a selected python interpreter (i only know the path name under which i should start it) is a debug build? I tried sys.api_version, sys.platform, sys.version, sys.version_info and there is no difference between python.exe and python_d.exe. I'm pretty sure the information is stored somewhere but i can't find it. Please help. -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Russ wrote: Alex, I think you are missing the point. Yes, I'm sure that web searches are critical to Google's mission and commercial success. But the point is that a few subtle bugs cannot destroy Google. If your search engines and associated systems have bugs, you fix them (or simply tolerate them) and continue on. And if a user does not get the results he wants, he isn't likely to die over it -- or even care much. But if this pattern of not getting wanted results is common, then the user will migrate to alternative search engines and this will *kill* the business. Wrong results won't impact ONE search, but many will impact the company business and will be part of the recipe to take it out of business. Online financial transactions are another matter altogether, of course. User won't die, but they will get very irate if they lose money. But I don't think that's what you are talking about here. Lets make someone loose his job and have all his money commitments compromised because of this money lost and we might be talking about people taking their lives. Again, this isn't 100% sure to happen, but it *can* happen. As it happens with a peacemaker: the user won't die if his heart skips one beat, but start skipping a series of them and you're incurring in serious problems. Just because the result isn't immediate it doesn't mean it isn't critical. -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Ricardo Aráoz wrote: Actually my point was that if a program is to be trusted in a critical situation (critical as in catastrophe if it goes wrong) then the OS, the compiler/interpreter etc should abide by the same rules. That is obviously not possible, so there's not much case in making the time investment necessary for correctness proof of a little program (or usually a little function inside a program) when the possibilities for failure are all around it and even in the code that will run that function. And we should resort to other more sensible answers to the safety problem. I don't quite see it that way. I would agree that if your OS and compiler are unreliable, then it doesn't make much sense to bend over backwards worrying about the reliability of your application. But for real safety-critical applications, you have no excuse for not using a highly reliable OS and compiler. For really critical stuff, I think the real-time OSs are usually stripped down to the bare basics. And if you are using something like SPARK Ada, the language itself is stripped of many of the fancier features in Ada itself. (There's also something called the Ada Ravenscar profile, which I believe is geared for safety-critical use but is not quite as restrictive as SPARK.) Keep in mind that the OS and compiler are typically also used for many other applications, so they tend to get tested fairly thoroughly. And remember also that you won't have extraneous applications running -- like a web browser or a video game, so the OS will probably not be heavily stressed. The most likely source of failure is likely to be your application, so bending over backwards to get it right makes sense. Then again, if you are running C on Windows, you might as well just give up on reliability from the start. You don't have a prayer. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I wait for all the threads I spawn for 5 minutes
herman wrote: Hi, In my python program, I would to like to spwan 5 threads, for the them for 5 minutes maximum and the continue. Here is my script: threads = [] for j in range(5): t = MyThread() threads.append(t) for t in threads: t.join(60*5) print thread join\n # wait for 5 minutes for all the threads to complete , and # then continue But this code ends up waiting 5 minutes for **each** thread. that is not what I want. I just want to wait for 5 minutes for all threads. how can I do that? And after 5 minutes, i want to kill off all the threads I spawn earlier, how can I do that in python. Thank you for any help. Well, to answer your second question, there is no reliable way to kill a thread without having the thread periodically examine some aspect of its environment that the main thread can change to indicate the requirement that the sub-thread terminate. The easiest way to check the number of outstanding threads is to use threading.activeCount(), which tells you how many outstanding threads remain. Here's some code I used in a test program recently: # As long as we have more than just the 'main' thread running, # print out a status message while threading.activeCount() 1 : print -- after, iterCount, sleeps, \ str(threading.activeCount()), threads running in total iterCount += 1 time.sleep(1) print Only main thread remains Clearly you will need to set some termination flag (a global variable would do) after time is up, and as long as your threads examine this flag you'll be good to go. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Parameter Passing - String Variable Truncated ?
On Sep 1, 9:54 am, goldtech [EMAIL PROTECTED] wrote: Hi, I'm passing what I think is a string parameter to another Python program (spawn.py) - see the code snip below. But only the counter part gets printed to a log file via spawn.py. Yet the echo print to the output window shows the whole string with the fc part. Better explained below I hope, there's the calling .py and the spawn script .py: ...snip... while fc: counter = counter + 1 fc_cntr = str(counter) + ' : ' + fc print fc_cntr + '\n' # Print to Pythonwin interactive window - eg. 1 : New York - all is printed OK arglist = [] arglist.append(pythonPath) arglist.append(spawn_script) arglist.append(fc_cntr) # This gets sent to the spawn_script but only 1 gets printed os.spawnv(os.P_WAIT, pythonPath, arglist) fc = fcs.next() ... -- ## the spawn_script import win32com.client, sys, os, time, re in_featclass = sys.argv[1] handle = open('C:\\log_file.txt', 'a') handle.write(in_featclass + \n) # ONLY the counter part gets printed to the log file!Why? -- Try handle.write(repr(sys.argv[1:]) + \n) and come back with your conclusions ... unless of course someone has spoonfed you in the meantime. Another clue: write yourself a little arg-dumper script and try running it in a Command Prompt window. 8--- import sys for x, arg in enumerate(sys.argv): print x, repr(arg) 8--- HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Parameter Passing - String Variable Truncated ?
goldtech wrote: Hi, I'm passing what I think is a string parameter to another Python program (spawn.py) - see the code snip below. But only the counter part gets printed to a log file via spawn.py. Yet the echo print to the output window shows the whole string with the fc part. Better explained below I hope, there's the calling .py and the spawn script .py: ...snip... while fc: counter = counter + 1 fc_cntr = str(counter) + ' : ' + fc print fc_cntr + '\n' # Print to Pythonwin interactive window - eg. 1 : New York - all is printed OK arglist = [] arglist.append(pythonPath) arglist.append(spawn_script) arglist.append(fc_cntr) # This gets sent to the spawn_script but only 1 gets printed os.spawnv(os.P_WAIT, pythonPath, arglist) fc = fcs.next() ... -- ## the spawn_script import win32com.client, sys, os, time, re in_featclass = sys.argv[1] Try in_featclass = sys.argv[1:] to collect all the arguments. At the moment I suspect some shell argument processing is intervening, splitting your N : something into multiple arguments. handle = open('C:\\log_file.txt', 'a') handle.write(in_featclass + \n) # ONLY the counter part gets printed to the log file!Why? -- Thanks, for help. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for Delaunay triangulation module...
In message [EMAIL PROTECTED], Grant Edwards wrote: So for lack of a delaunay module, I'm stuck trying to port my application to Win32. Why not run it under Cygwin? :) -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Jorge Godoy wrote: Russ wrote: Alex, I think you are missing the point. Yes, I'm sure that web searches are critical to Google's mission and commercial success. But the point is that a few subtle bugs cannot destroy Google. If your search engines and associated systems have bugs, you fix them (or simply tolerate them) and continue on. And if a user does not get the results he wants, he isn't likely to die over it -- or even care much. But if this pattern of not getting wanted results is common, then the user will migrate to alternative search engines and this will *kill* the business. Wrong results won't impact ONE search, but many will impact the company business and will be part of the recipe to take it out of business. Online financial transactions are another matter altogether, of course. User won't die, but they will get very irate if they lose money. But I don't think that's what you are talking about here. Lets make someone loose his job and have all his money commitments compromised because of this money lost and we might be talking about people taking their lives. Again, this isn't 100% sure to happen, but it *can* happen. As it happens with a peacemaker: the user won't die if his heart skips one beat, but start skipping a series of them and you're incurring in serious problems. Just because the result isn't immediate it doesn't mean it isn't critical. We probably need to distinguish between mission-critical, where a program has to work reliably for an organization to meet its goals, and safety-critical where people die or get hurt if the program misbehaves. The latter are the ones where you need to employ all possible techniques to avoid all possible failure modes. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Parameter Passing - String Variable Truncated ?
Steve Holden wrote: [...] in_featclass = sys.argv[1] Try in_featclass = sys.argv[1:] Sorry, that should have been in_featclass = .join(sys.argv[1:])+\n regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
In message [EMAIL PROTECTED], Carsten Haese wrote: On Thu, 2007-08-30 at 11:21 -0700, [EMAIL PROTECTED] wrote: I wish they were not getting rid of dict.has_key() in Python 3, which I prefer to IN. That wish will only come true if you maintain your own fork of Python 3. has_key() will go away, period. It has been made obsolete by in, which is faster and more concise. And is also a backdoor way of introducing non-virtual methods into Python, is it not. -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
In message [EMAIL PROTECTED], sturlamolden wrote: There are fractions that can be exactly represented by floats that cannot be exactly represented by decimals. There are no such. -- http://mail.python.org/mailman/listinfo/python-list
HowTo Use Cython on a Windows XP Box?
August 31, 2007 I just downloaded the current Cython release and have no problem running the cpython.py translator on the demo code. But when I try compiling, I get an error complaining that my version of Python (which is the current 2.5.1 downloaded from python.org) was compiled with Visual C++ 2003. I only have Visual C++ 2005 on my machine and am unable to find a download of 2003 on the Microsoft site (no big surprise). I have never built Python from source. Is it necessary or can someone suggest an alternative? TIA david lees -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
On Sat, 2007-09-01 at 13:50 +1200, Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Carsten Haese wrote: has_key() will go away, period. It has been made obsolete by in, which is faster and more concise. And is also a backdoor way of introducing non-virtual methods into Python, is it not. If by that you mean that in tests can't be overridden, that's not true: class LyingDict(dict): ... def __contains__(self, key): return False ... d = LyingDict() d[1] = 42 1 in d False If you mean something else, please clarify. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: strings (dollar.cents) into floats
In message [EMAIL PROTECTED], Wildemar Wildenburger wrote: But what use is there for floats, then? When is it OK to use them? Floating-point numbers are useful when you have to deal with very large and very small amounts at the same time. In using them, you must understand something about how rounding errors work, e.g. 1) Addition of a lot of very precise quantities together will produce a less-precise quantity: x = 0.1 x 0.10001 for i in range(0, 100) : x += 0.1 ... x 10.1133289 (Note the original quantity was precise to over 16 figures, the accumulated total to less than 7.) 2) Subtraction of two nearly-equal quantities will also reduce precision: 1.0 / 1000 0.001 1.0 / 1001 0.000999000999000999 1.0 / 1000 - 1.0 / 1001 9.9900099900102068e-07 (Again, note the drop from about 15 figures of precision down to about 12.) In terms of currency amounts, if you're only doing additions and subtractions, then usual practice would be to work in integer cents/pence, and format as dollars/euros/pounds/whatever and cents/pence only for display and user input. That way you avoid the above rounding problems. But if you're doing multiplications and divisions (e.g. currency conversions, taxation, interest computations, futures, derivatives etc), then it doesn't really matter. You're going to get rounding errors anyway, and floating point will probably let you manage them better than integers will. -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Wildemar Wildenburger wrote: Tim Daneliuk wrote: A number by itself is called a scalar. For example, when I say, I have 23 apples, the 23 is a scalar that just represents an amount in this case. One of the most common uses for Complex Numbers is in what are called vectors. In a vector, you have both an amount and a *direction*. For example, I can say, I threw 23 apples in the air at a 45 degree angle. Complex Numbers let us encode both the magnitude (23) and the direction (45 degrees) as a number. 1. Thats the most creative use for complex numbers I've ever seen. Or put differently: That's not what you would normally use complex numbers for. 2. Just to confuse the issue: While complex numbers can be represented as 2-dimensional vectors, they are usually considered scalars as well (since they form a field just as real numbers do). There are actually two ways to represent Complex Numbers. One is called the rectangular form, the other the polar form, but both do the same thing - they encode a vector. Again, that is just one way to interpret them. Complex numbers are not vectors (at least no moe than real numbers are). /W Yeah, I know it's a simplification - perhaps even a vast simplification - but one eats the elephant a bite at a time. FWIW, the aforementioned was my first entre' into complex arithmetic, long before I waded through complex analysis and all the more esoteric stuff later in school. I wonder why you think it is creative, though. Most every engineer I've ever know (myself included) was first exposed to complex numbers in much this way. Then again, I was never smart enough to be a pure mathematician ;) -- Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Wildemar Wildenburger wrote: Tim Daneliuk wrote: A number by itself is called a scalar. For example, when I say, I have 23 apples, the 23 is a scalar that just represents an amount in this case. One of the most common uses for Complex Numbers is in what are called vectors. In a vector, you have both an amount and a *direction*. For example, I can say, I threw 23 apples in the air at a 45 degree angle. Complex Numbers let us encode both the magnitude (23) and the direction (45 degrees) as a number. 1. Thats the most creative use for complex numbers I've ever seen. Or put differently: That's not what you would normally use complex numbers for. Oh, one other thing I neglected to mention. My use of vector here is certainly incorrect in the mathematician's sense. But I first ran into complex arithmetic when learning to fly an airplane. The airplane in flight has a speed (magnitude) and a bearing (direction). The winds aloft also have speed and bearing. These are called the aircraft vector and the wind vector respectively. They must be added to compute the actual (effective) speed/direction the aircraft is flying. In the Olden Days (tm), we did this graphically on a plastic flight computer and a grease pencil. With the advent of calculators like the HP 45 that could do polar - rectangular conversion, this sort of problem became a snap to do. It is from this experience that I used the (non-mathematical) sense of the word vector ... Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list
Non-Blocking IO
I'm trying to use popen2 to call a program and then write and read data from the program using a Python script. Unfortunately, my calls to read block (I need non-blocking IO), and all the workarounds I've seen online don't work. Here is my most promising solution and how it breaks: Source of solution: http://mail.python.org/pipermail/python-dev/2005-March/052263.html def setblocking(fd,flag): set/clear blocking mode # get the file's current flag settings fl = fcntl.fcntl(fd, fcntl.F_GETFL) if flag: # clear non-blocking mode from flags fl = fl ~os.O_NONBLOCK else: # set non-blocking mode from flags fl = fl | os.O_NONBLOCK # update the file's flags fcntl.fcntl(fd, fcntl.F_SETFL, fl) def try3(): fin,fout= os.popen2(echo.py) setblocking(fout.fileno(),False) os.write(fin.fileno(),'blah') fin.flush() print os.read(fout.fileno(),256) Calling try3() yields the error: File ./test.py, line 54, in try3 print os.read(fout.fileno(),256) OSError: [Errno 35] Resource temporarily unavailable If anyone could help me accomplish this I'd be extremely grateful. Thanks! MP -- http://mail.python.org/mailman/listinfo/python-list
Re: Python weather application
On Aug 30, 5:41 pm, Zentrader [EMAIL PROTECTED] wrote: On Aug 30, 12:45 pm, seancron [EMAIL PROTECTED] wrote: Does anybody have any suggestions for getting started on desigining a desktop weather application in Python? I've been looking for access to weather data and while I have found several including the weather.com service I've decided to use the Yahoo! Rss Weather feed since it doesn't have a license like the weather.com service does. However one problem I have with it is that it only accepts zip codes or locations ids. So if a user was to enter the name of the city instead of those two there would be an error. I could make it so they could only enter in the location code or zip code but I would really prefer to have it be automatically corrected. Does anyone have ideas on how to go about this or have an other suggestions? Thanks, Sean Use a dictionary to convert from the city chosen to the zip/location code to use at Yahoo. You can purchase/subscribe a zip code database and then use that as a reverse look-up for your user entering a city. try the postal service website for the database info. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parameter Passing - String Variable Truncated ?
snip... -- Try handle.write(repr(sys.argv[1:]) + \n) and come back with your conclusions ... unless of course someone has spoonfed you in the meantime. Another clue: write yourself a little arg-dumper script and try running it in a Command Prompt window. 8--- import sys for x, arg in enumerate(sys.argv): print x, repr(arg) 8--- HTH, John It's a list. ... ['5', ':', 'Alaska.shp'] ['6', ':', 'Arizona.shp'] ['7', ':', 'Arkansas.shp'] ['8', ':', 'California.shp'] ['9', ':', 'Colorado.shp'] ['10', ':', 'Connecticut.shp'] ['11', ':', 'Delaware.shp'] ['12', ':', 'District', 'of', 'Columbia.shp'] ['13', ':', 'Florida.shp'] ['14', ':', 'West', 'Virginia.shp'] ['15', ':', 'Wisconsin.shp'] ['16', ':', 'Wyoming.shp'] Thanks, Lee G. -- http://mail.python.org/mailman/listinfo/python-list
Re: Important Research Project
E.D.G. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Important Research Project (Related to computer programming) Posted by E.D.G. on August 30, 2007 [EMAIL PROTECTED] This effort was not successful. And I am returning to trying to slowly make progress with the computer program I have been developing. I was hoping that there might be some people who had Perl chart and .exe generation programs running on their own computer who could say, Here is how to merge them with Perl; here is how to use them; this is what they will do, etc. Or, I was hoping that someone would respond and say that although they are using Fortran or Basic etc. instead of Perl, they would be interested in getting a copy of Perl running, determine how to get those routines running, and then pass along the information. That would have saved some time. I work on these projects all the time. And it has been my experience that the world of science does not have the type of organized structure at this time to enable people to easily obtain that type of assistance. I have established an organization which will hopefully help with that problem. It might be going public at a Web site some time in the next year. There were some questions regarding the computer program I discussed. This is what it does: It provides researchers with the a certain amount of ability to determine if different events are somehow linked with one another. For example, it can be used to compare two or more earthquakes, earthquakes and electromagnetic pulses, tornados and electromagnetic pulses, and even earthquakes and tornados etc. It makes it possible for people to study events taking place deep in the Earth by evaluating electromagnetic pulse data associated with those events. Under the right conditions it can be used to forecast earthquakes. That is the reason it was developed in the first place. You can see the type of data it generates at the following Web page: http://www.freewebz.com/eq-forecasting/Data.html The plan is that when it has chart and standalone .exe program file generation capabilities, program copies will be circulated within the earthquake forecasting community in the People's Republic of China. It was discussed in detail there at a scientific conference in December of 2003. At that time it was too complex for widespread use. After the chart feature becomes operational etc. I am also planning to contact U.S. government officials to see if one or more lectures can be organized regarding the basic technology and theories, and the program's capabilities. These are personal opinions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Non-Blocking IO
In message [EMAIL PROTECTED], mp wrote: Calling try3() yields the error: File ./test.py, line 54, in try3 print os.read(fout.fileno(),256) OSError: [Errno 35] Resource temporarily unavailable That's what's supposed to happen. That's telling you there are no bytes currently available to be read. -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
In message [EMAIL PROTECTED], Wildemar Wildenburger wrote: Tim Daneliuk wrote: One of the most common uses for Complex Numbers is in what are called vectors. In a vector, you have both an amount and a *direction*. For example, I can say, I threw 23 apples in the air at a 45 degree angle. Complex Numbers let us encode both the magnitude (23) and the direction (45 degrees) as a number. 1. Thats the most creative use for complex numbers I've ever seen. Or put differently: That's not what you would normally use complex numbers for. But that's how they're used in AC circuit theory, as a common example. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find out if the interpreter is a debug build?
In message [EMAIL PROTECTED], llothar wrote: How can i find out if a selected python interpreter (i only know the path name under which i should start it) is a debug build? What's the difference in their behaviour? -- http://mail.python.org/mailman/listinfo/python-list
Re: Automation and scheduling of FrontPage publishing using Python
In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: We have numerous web sites which are currently being manually published via Front Page. Doing one or two sites on an ad-hoc basis was not too bad but we are now over 20 or thirty at set times during a business day. Let me open the bidding by suggesting that you stop using FrontPage. -- http://mail.python.org/mailman/listinfo/python-list
Re: HowTo Use Cython on a Windows XP Box?
On Aug 31, 9:06 pm, David Lees [EMAIL PROTECTED] wrote: August 31, 2007 I just downloaded the current Cython release and have no problem running the cpython.py translator on the demo code. But when I try compiling, I get an error complaining that my version of Python (which is the current 2.5.1 downloaded from python.org) was compiled with Visual C++ 2003. I only have Visual C++ 2005 on my machine and am unable to find a download of 2003 on the Microsoft site (no big surprise). I have never built Python from source. Is it necessary or can someone suggest an alternative? TIA david lees Unless you are customizing Python (and you can accomplish a *lot* without doing so), it is not necessary to build Python from source. Download one of the pre-built Windows binaries and install it, or get the Win Python distribution from ActiveState and install that. Then start writing your own Python demo scripts. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Unicode to String conversion
In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: The error I keep having is something like this: ERREUR: Séquence d'octets invalide pour le codage «UTF8» : 0xe02063 It would be useful to see some actual code snippet, traceback listing etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
In article [EMAIL PROTECTED], Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: In message [EMAIL PROTECTED], Wildemar Wildenburger wrote: Tim Daneliuk wrote: One of the most common uses for Complex Numbers is in what are called vectors. In a vector, you have both an amount and a *direction*. For example, I can say, I threw 23 apples in the air at a 45 degree angle. Complex Numbers let us encode both the magnitude (23) and the direction (45 degrees) as a number. 1. Thats the most creative use for complex numbers I've ever seen. Or put differently: That's not what you would normally use complex numbers for. But that's how they're used in AC circuit theory, as a common example. Well, not really. They're often talked about as vectors, when people are being sloppy, but they really aren't. In the physical world, let's say I take out a compass, mark off a bearing of 045 (north-east), and walk in that direction at a speed of 5 MPH. That's a vector. The north and east components of the vector are both measuring fundamentally identical quantities, along perpendicular axes. I could pick any arbitrary direction to call 0 (magnetic north, true north, grid north, or for those into air navigation, the 000 VOR radial) and all that happens is I have to rotate my map. But, if I talk about complex impedance in an AC circuit, I'm measuring two fundamentally different things; resistance and reactance. One of these consumes power, the other doesn't. There is a real, physical, difference between these two things. When I talk about having a pole in the left-hand plane, it's critical that I'm talking about negative values for the real component. I can't just pick a different set of axis for my complex plane and expect things to still make sense. -- http://mail.python.org/mailman/listinfo/python-list