Re: [Tutor] The '45' bug in round()
On Mon, Mar 19, 2007 at 03:04:03AM -0700, Dick Moores wrote: > Yesterday I was shocked, SHOCKED, to discover that round() is > occasionally rounding incorrectly. For example, "Garbage In, Garbage Out" :-) Floating point numbers in Python (and other computer languages) are only an approximation: >>> print round(0.145, 2) 0.14 >>> 0.145 0.14499 >>> print round(0.145001, 2) 0.15 http://docs.python.org/tut/node16.html has some more information about this. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [tutor] ipconfig
On Thu, Aug 10, 2006 at 04:47:43PM +0300, [EMAIL PROTECTED] wrote: > is there in python an independent from the system way to obtain the IP >>> import socket >>> hostname = socket.gethostname() >>> ip = socket.gethostbyname(hostname) >>> print ip 192.168.1.10 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] IDE for Python
On Tue, Jul 25, 2006 at 08:34:39PM +0530, Basavaraj SP. wrote: > I am new to Python. > > I want to know which IDE I should use for programming. > > If so from where can I get it? ActivePython is a good start: http://www.activestate.com/Products/ActivePython/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I am not really convinced using Python...
On Tue, Jul 25, 2006 at 05:14:35PM +0200, Rob Sinclar wrote: > Yep Python is an interpreted language. In other words every python app needs > the python interpreter to be able to run. I'm not sure, but I don't think there's anything particular about the language that says it should be interpreted. As far as I know, programs built with IronPython don't require Python to be installed - only the .NET (2.0?) Framework. http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython You can also build .exe files for Windows using py2exe. http://www.py2exe.org/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using python to create and save a Ms Word file
On Thu, Jul 20, 2006 at 01:25:26PM -0400, Andrew Robert wrote: > I have a text file being broadcast on a web site and I would like to download > it > and save it as an MS Word file. ... > I found the following code on the web that comes close to what i need. > > It: > > - - reads a file passed to it > - - opens word file > - - dumps the read contents to the file > - - places a time stamp at the end signaling when the conversion occured > > What is is missing is how to automate saving/closing the file when the > conversion is complete. > > Would someone be able to help fill in the blanks on this? I've never played with Win32 COM before, but your message inspired me to learn. :-) A quick Google later, and it seems you need to add the following methods to the CWordAutomate class: def Save(self, sFilename): self.m_obDoc.SaveAs(sFilename) def Quit(self): self.m_obWord.Quit() Then in your code: > sLastMsg = time.strftime( "document generated on %c", time.localtime() ) > obWord.WriteLine( sLastMsg, "Times New Roman", 14, 0 ) Add these: obWord.Save("blah.doc") obWord.Quit() On my system, "blah.doc" was saved as C:\Documents and Settings\ozzmosis\My Documents\blah.doc So you'll need to specify an absolute pathname if you want it to be saved somewhere else. I picked this up from: http://mail.python.org/pipermail/python-win32/2002-June/000396.html I guess we both need to subscribe to the python-win32 mailing list... ;-) Regards Andrew ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ASCII
On Wed, Mar 29, 2006 at 01:51:30PM +0530, Kaushal Shriyan wrote: > > How do i use this ASCII values in my day to day activities, I am going > > through learning python, > > Its a very general question not related to python at all, I have a > minimum knowledge in ASCII just wanted to know how it is used and how > it helps out http://en.wikipedia.org/wiki/Ascii may help. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to monitor streaming data from the internet via modem?
On Thu, Mar 09, 2006 at 12:57:53PM +, Ben Vinger wrote: > On 3/8/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > Ethereal is one well known and powerful one, but there are others > > which may be simpler to use. > > Yes, with Ethereal comes a command-line version called tethereal, which I've > used within Python on both Windows and Linux. It worked nicely for trafic > analysis, but if you're interested only in the clear text passing through > the line, I'd think of using netcat. tcpflow may also be worth a look. http://www.circlemud.org/~jelson/software/tcpflow/ Regards Andrew ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python interpreter/Xemacs and the py-execute-buffer
On Wed, Mar 08, 2006 at 11:46:37PM -0800, Francesco Queirolo wrote: > I have been using Xemacs 21.4 Patch 13 on Windows XP with Python 2.4.2 > (final). Whenever I try to run a script inside the xemacs window using: > C-c C-c I get the following: Opening output file: Invalid argument, > C:\Documents and Settings\jkat\Local Settings\Temp;C:\Devel\emacsk2AS2x > and of course my code doesn't pop the output up to the xemacs screen. > The last part of the error message "k2AS2x" is different every time. I > have already re-installed xemacs and am rather baffled after creating > folders called Devel and temp as well. I wonder if it's because there are spaces in the filename. Just a guess. Regards Andrew ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to write a string into a specific line in a file
On Tue, Mar 07, 2006 at 11:18:27AM -, Alan Gauld wrote: > > I was wondering if it is possible to write a string to a specific line > > in a file without reading in the whole file in as the below. > > Some languages, such as COBOL and some BASICs etc support > random access files, unfortunately Python doesn't (Although I'll be > amazed if somebody hasn't cooked up (or is cooking up) a module > that does it) You then go on to mention file.seek(). I thought that seek() provided "random access", ie. to seek to anywhere at random in a file. Can you clarify what you mean by "random access files"? Regards Andrew ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] saving .csv file as an xl worksheet
On Mon, Mar 06, 2006 at 02:46:36PM +0530, arun wrote: > Can i save a file with a desired extension?? > for ex: I have a .csv file (test.csv) and i want to save this file as > test.xls from a python script. Just changing the file extension from .csv to .xls won't change the file format. OpenOffice 2.0 supports both .csv and .xls file formats and includes some sort of Python integration. It may be possible to use that. Regards Andrew ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Iron Python
On Sat, Mar 04, 2006 at 12:21:56AM -0800, ryan luna wrote: > Hello, i have a question about Iron Python, what exactly does it do? > i know its something about .net but i still dont understand exactly > what it does, To use it do you still write your scripts in the Python > IDLE, or what 0-o, It's Microsoft's version of Python (written in C#) that runs on top of the .NET Framework, so it can generate .exe files for .NET, among other things. A short demo: D:\devel\IronPython>IronPythonConsole.exe IronPython 1.0.2237 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> print "Hello world." Hello world. >>> ^Z D:\devel\IronPython>type hello.py print "Hello world." D:\devel\IronPython>IronPythonConsole.exe hello.py Hello world. D:\devel\IronPython>IronPythonConsole.exe -O -X:SaveAssemblies hello.py Hello world. D:\devel\IronPython>dir hello.exe Directory of D:\devel\IronPython 2006-03-04 20:16 3,072 hello.exe D:\devel\IronPython>hello.exe Hello world. Regards Anderw ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor