Re: [Tutor] SSL Error

2018-08-03 Thread Terry Carroll
ll. Also, before your "import requests" line, include these: import sys print(sys.version) After the "import requests" line, include this: print(requests.__version__) -- Terry Carroll carr...@tjc.com ___ Tutor maillist - T

Re: [Tutor] Wish to upgrade Python 3.6.5 to Python 3.6.6 for Linux Mint 19

2018-07-15 Thread Terry Carroll
don't fix it" theory. That being said, if you do want to update to the latest version available for Mint, this command should do it for you: sudo apt-get install --only-upgrade python3 If Mint doesn't have a vetted 3.6.6 yet, I would leave it alone. -- Terry Carroll carr.

Re: [Tutor] Regex not working as desired

2018-02-27 Thread Terry Carroll
On Mon, 26 Feb 2018, Terry Carroll wrote: Instead of looking fo re xcaprions.. Wow. That should read "Instead of looking for exceptions..." Something really got away from me there. -- Terry Carroll carr...@tjc.com ___ Tutor maillist

Re: [Tutor] Regex not working as desired

2018-02-27 Thread Terry Carroll
uot;, "4","44", "444", ""] for thing in test_data: m = p.match(thing) if m is None: print("not all digits:", thing) else: print("all digits:", thing) -- Terry Carroll carr...@tjc.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] Java equivalent of Python-Tutor?

2018-02-07 Thread Terry Carroll
hope the blatantly obsequious sucking up at the beginning of my note makes up for it.) -- Terry Carroll carr...@tjc.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-26 Thread Terry Carroll
On Wed, 25 May 2016, Alex Hall wrote: You're not missing anything; I wasn't clear. I wasn't sure if raise or sys.exit(1) were the preferred ways, or if there was some other way I didn't know about. If you're aborting because of the exception after unsuccessfully trying to handle it, you can

Re: [Tutor] Getting started in testing

2016-05-24 Thread Terry Carroll
Thanks to Alan, Danny, Albert-Jan and Ben for their suggestions. I've now gotten my feet wet in unittest and have gone from not quite knowing where to start to making substantial progress, with a small suite of tests up and running. ___ Tutor

[Tutor] Getting started in testing

2016-05-19 Thread Terry Carroll
Is anyone aware of any good tutorials on testing one's Python code? These days, I'm a hobby programmer, writing little things just for my own use, and don't really sweat testing much. But I do have one niche open-source project where I need to be a bit more regimented, and specifically need

Re: [Tutor] sqlite

2016-05-18 Thread Terry Carroll
On Tue, 3 May 2016, Crusier wrote: I am just wondering if there is any good reference which I can learn how to program SQLITE using Python I can not find any book is correlated to Sqlite using Python. "The Definitive Guide to SQLite" is about SQLite, but includes a chapter on both PySQLite

[Tutor] Plotting with python

2015-10-30 Thread Terry Carroll
If you were going to get started doing some simple plotting with Python 2.7 (in my case, I'm simply plotting temperature against time-of-day) what would you use? - matplotlib [1] - gnuplot [2] - something else entirely? Assume no substantial familiarity with the underlying plotting

Re: [Tutor] Your confirmation is required to leave the Tutor mailing list

2014-02-10 Thread Terry Carroll
On Mon, 10 Feb 2014, tutor-confirm+c3fa710640d780363ebaec9fd955eefa81f1b...@python.org wrote: Mailing list removal confirmation notice for mailing list Tutor We have received a request for the removal of your email address, carr...@tjc.com from the tutor@python.org mailing list. To confirm

[Tutor] How can a CGI program get the URL that called it?

2014-01-10 Thread Terry Carroll
How can my Python 2.7 CGI program find the URL that caused the program to be called? I have a program that creates a JPG or PNG file on the fly, and needs to construct a URL to it. I know the path relative to my program is, for example, ../temp/tmpiicack.png (the filename generated by

Re: [Tutor] How can a CGI program get the URL that called it?

2014-01-10 Thread Terry Carroll
Ah, I discovered what my problem was... On Fri, 10 Jan 2014, Alan Gauld wrote: its calling your file. You should know where your file is? My problem was that, I know where the file is in the host's file system, and relative to my CGI program. I do not have a URL to that file. If you want

Re: [Tutor] How can a CGI program get the URL that called it?

2014-01-10 Thread Terry Carroll
On Sat, 11 Jan 2014, Steven D'Aprano wrote: However, if you pass a path using \ to posixpath, it treats them as non-separators: That's apparenbtly what's happening. I didn't investigate much, once I found out that using posixpath didn't address the issue I was having; using replace() was

Re: [Tutor] Which computer operating system is best for Python developers?

2012-03-02 Thread Terry Carroll
(Re Python on Windows 7) On Thu, 23 Feb 2012, Tim Golden wrote: On 23/02/2012 09:00, Alan Gauld wrote: If you do a reinstall, download the ActiveState version rather than the Python.org version. I also recommend the ActiveState distro. I am going to third Alan's and Tim's recommendations

Re: [Tutor] The Perennial 3.2 vs 2.7

2011-11-19 Thread Terry Carroll
On Thu, 17 Nov 2011, Wayne Werner wrote: On Thu, Nov 17, 2011 at 8:45 PM, Mark Lybrand mlybr...@gmail.com wrote: so, use my 2.7 and not my 3.2 for my study? Or use my 3.2 for study and then do what I have to in 2.7 after including those lines? Honestly it probably doesn't

Re: [Tutor] Stacks and Stack underflow/Stack overflow

2011-11-19 Thread Terry Carroll
On Sat, 19 Nov 2011, Joe Batt wrote: Hi All  Could some kind soul please explain why you get a stack underflow and a stack overflow. I am getting the following error in Python 3 Traceback (most recent call last):   File /Users/joebatt/Desktop/python/pickling puzzle 5.py, line 39, in module    

Re: [Tutor] regexp

2011-11-06 Thread Terry Carroll
On Sat, 5 Nov 2011, Dinara Vakhitova wrote: I need to find the words in a corpus, which letters are in the alphabetical order (almost, my etc.) I started with matching two consecutive letters in a word, which are in the alphabetical order, and tried to use this expression: ([a-z])[\1-z], but it

Re: [Tutor] Assigning variables with names set by other variables

2011-11-04 Thread Terry Carroll
On Fri, 4 Nov 2011, Max S. wrote: Is it possible to create a variable with a string held by another variable in Python?  For example, It's possible, but in almost all cases where this comes up, the better approach is to use a dictionary.___ Tutor

Re: [Tutor] Mailing list archive oddity?

2011-09-29 Thread Terry Carroll
On Thu, 29 Sep 2011, Hugo Arts wrote: * someone from the future is in need of python help and is sending messages back in time. I'm betting this is Guido and his time machine again. ___ Tutor maillist - Tutor@python.org To unsubscribe or change

[Tutor] xrange() with start or stop sys.maxint?

2011-05-18 Thread Terry Carroll
Is there any way to use xrange with a start or stop value that exceeds sys.maxint? import sys print sys.maxint 2147483647 start = sys.maxint-1 for i in xrange(start, start+1): ... pass ... start = sys.maxint for i in xrange(start, start+1): ... pass ... Traceback (most recent call

Re: [Tutor] Overriding a method in a class

2011-05-15 Thread Terry Carroll
On Sat, 14 May 2011, Alan Gauld wrote: Is there any reason you can'tt override in the uisual way by inheritance? Doh! Of course I should. I've written plenty of classes before, but never one intended to be inherited, and now that you point it out, it's obvious that that's what I should be

[Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
I have a pretty basic point of confusion that I'm hoping I can have explained to me. I have a class in which I want to override a method, and have my method defined externally to the class definition invoked instead. But when I do so, my external method is invoked with a different argument

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
On Fri, 13 May 2011, Terry Carroll wrote: What I *expect* is to see ['abcdefg'] printed. What I get is: Sorry, mixed multiple examples; What I had expected was ['wxyz']. Still the same question though. BTW, I forgot to mention: Python 2.7.1, under Windows. (Still not used

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
method, and does not insert the self reference into the argument list. end uninformed speculation Now I'll wait for one of the experts to edify me. On Fri, 13 May 2011, Terry Carroll wrote: I have a pretty basic point of confusion that I'm hoping I can have explained to me. I have a class

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
On Fri, 13 May 2011, Terry Carroll wrote: For my specific case, I'm going to go with a Plan B of using callbacks; and provide default unbound callbacks present in the module, but not defined in the class itself. Here's a callback-with-default approach, which works: ### Thing.py

Re: [Tutor] module to parse XMLish text?

2011-01-14 Thread Terry Carroll
On Fri, 14 Jan 2011, Stefan Behnel wrote: Terry Carroll, 14.01.2011 03:55: Does anyone know of a module that can parse out text with XML-like tags as in the example below? I emphasize the -like in XML-like. I don't think I can parse this as XML (can I?). Sample text between the dashed lines

Re: [Tutor] Writing to the terminal?

2010-12-12 Thread Terry Carroll
On Fri, 10 Dec 2010, Modulok wrote: Assume I'm working in a command shell on a terminal. Something like tcsh on xterm, for example. I have a program which does *something*. Let's say it counts down from 10. How do I print a value, and then erase that value, replacing it with another value? Say

Re: [Tutor] Writing to the terminal?

2010-12-12 Thread Terry Carroll
On Mon, 13 Dec 2010, Steven D'Aprano wrote: Which operating system and terminal did you use? In my experience, using print is not satisfactory... You're right; it worked under Windows, but not under Linux. Given the other details of the question, my suggestion is not an adequate solution.

Re: [Tutor] Which non SQL Database ?

2010-12-08 Thread Terry Carroll
On Sat, 4 Dec 2010, Jorge Biquez wrote: What would do you suggest to take a look? If possible available under the 3 plattforms. I would second the use of SQLite. It's built into Python now, on all platforms. But you specified non SQL, so one other thing I'd suggest is to just create the

Re: [Tutor] Question on tkinter event binding

2010-12-03 Thread Terry Carroll
On Fri, 3 Dec 2010, Albert-Jan Roskam wrote: I'm trying to make a small improvement on a data entry program and it is literally giving me a headache. Followed shortly thereafter with: On Fri, 3 Dec 2010, Albert-Jan Roskam wrote: Aaahhh, got it! Peace! ... I'll paste the working code below.

Re: [Tutor] Pyserial and invalid handle

2010-12-02 Thread Terry Carroll
On Wed, 1 Dec 2010, Walter Prins wrote: But whatever the case may be, suffice it to say I've reproduced your issue on my Win7 64bit box, and then resolved it by installing the PyWin32 modules. I'd like to put in a plug for Activestate Python here. Activestate has a free distribution of

Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?

2010-11-28 Thread Terry Carroll
On Thu, 25 Nov 2010, Alan Gauld wrote: Yves Dextraze yd...@videotron.ca wrote Sent from my iPod There is no mention on Amazon of any new editions and they usually announce several months in advance... A pity a new Tkinter book using Tix and ttk instead of PMW would be a really useful

Re: [Tutor] %T as a strftime format identifier

2010-11-27 Thread Terry Carroll
On Sat, 27 Nov 2010, Steven D'Aprano wrote: [st...@sylar ~]$ python2.5 Python 2.5 (r25:51908, Nov 6 2007, 16:54:01) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Type help, copyright, credits or license for more information. import time time.strftime(%T) '19:03:16' Interesting. On my

[Tutor] %T as a strftime format identifier

2010-11-26 Thread Terry Carroll
Was %T ever a valid format specifier for time.strftime in Python? I just installed a Python streaming MP3 server called Edna (http://edna.sourceforge.net/). It was an easy install except that I got a ValueError on one line, essentially for: time.strftime(%a, %d %b %Y %T GMT) After a few

[Tutor] wxPython, Tkinter (was: program hangs in while loop using wx.yield

2010-11-16 Thread Terry Carroll
On Tue, 16 Nov 2010, Patty wrote: Hi Terry - I am an alumni of UCSC (University of California, Santa Cruz) and live really close so I can request books throughout the UC system just like you describe and there is no limit - or maybe an extremely high limit - to the number of books I can check

Re: [Tutor] program hangs in while loop using wx.yield

2010-11-15 Thread Terry Carroll
On Sun, 14 Nov 2010, Alex Hall wrote: Is there a basic tutorial for this sort of thing? Chapter 3 (Working in an event-driven environment) of the book wxPython in Action is a pretty good tutorial on event-driven GUI programming in wxPython. The book in general is pretty good; I no longer

[Tutor] Stupid bug

2010-11-10 Thread Terry Carroll
This isn't a question, I'm just offering it as a cautionary tale and an opportunity to laugh at my own stupidity. I have a small function to calculate the MD5 checksum for a file. It's nothing fancy: ### import hashlib def md5(filename, bufsize=65536):

Re: [Tutor] Data Directory under site-packages

2010-11-10 Thread Terry Carroll
On Wed, 10 Nov 2010, Greg Lindstrom wrote: I'm writing my first module that I intend to put under our company's site-packages directory for everyone to use in their programs. The problem I'm having is that I want to place files in a data directory under the module directory (under

Re: [Tutor] Too different 2.6 vs 2.7?

2010-11-08 Thread Terry Carroll
On Mon, 8 Nov 2010, Jorge Biquez wrote: Are there really BIG differences between version 2.6 and 2.7? I'm in a similar boat. I use Ubuntu 10.04 aw well as Windows XP, Vista and 7. I keep to similar levels just to avoid confusion and at present run Python 2.6 on all systems. If I had an

Re: [Tutor] Interactive visualization in python

2010-11-07 Thread Terry Carroll
On Sun, 7 Nov 2010, Alan Gauld wrote: Most GUI toolkits have a tree widget like the Wiondows Explorer tree view. The Tkintrer version is included in the Tix module which extends the basic Tkinter widgets. I'm pretty sure wxPython will have one too. I haven't used it, but wxPython's tree

Re: [Tutor] Reading the CDROM in Linux

2010-11-06 Thread Terry Carroll
On Fri, 5 Nov 2010, Terry Carroll wrote: Aha, this looks like it will work; I was starting to think along these lines; I was thinking of reading the output of df, but this is cleaner. Just to close this out, here's what's working for me. It will need to be prettied up, and the /media

Re: [Tutor] Reading the CDROM in Linux

2010-11-05 Thread Terry Carroll
On Sat, 6 Nov 2010, Steven D'Aprano wrote: Anyway, more modern Linux systems automatically mount CDs and DVDs. By convention, /mnt/... is used for manually mounts, and /media/... for automatic mounts of media. I am seeing my volume in /media ; however, I won't know the volume name when my

Re: [Tutor] Reading the CDROM in Linux

2010-11-05 Thread Terry Carroll
On Sat, 6 Nov 2010, Steven D'Aprano wrote: Terry Carroll wrote: I have a program that traverses the directory of a CDROM using os.walk. I do most of my work on Windows, but some on (Ubuntu) Linux, and I'd like this to work in both environments. On Windows, I do something along the lines

[Tutor] Optparse question: if only certain values are acceptable

2009-05-08 Thread Terry Carroll
I'm tryng to use optparse for the first time. The toy summary is that I want to have the following command format: prognam -f FORMAT Where FORMAT, if specified, must be one of X, Y, or Z. In otherwords, if the user enters: progname -f X It runs, producing its output in format X. Similar

Re: [Tutor] Optparse question: if only certain values are acceptable

2009-05-08 Thread Terry Carroll
On Sat, 9 May 2009, Sander Sweers wrote: Is the below what you are looking for? It's exactly what I was looking for. Thanks very much. Now I'm going to have to re-read the docs and see why I couldn't pick that up from them. ___ Tutor maillist -

Re: [Tutor] Parsing suggestion? (CUE file)

2009-02-03 Thread Terry Carroll
On Tue, 3 Feb 2009, Kent Johnson wrote: Ah, I see. I imagined something more ambitious, that treated the lines as fields. I find that the more ambitious my projects become, the less likely I am to complete them! With two toddlers, on a good day, I get 30 to 60 minutes of discretionary

[Tutor] Parsing suggestion? (CUE file)

2009-02-03 Thread Terry Carroll
I am parsing certai ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Parsing suggestion? (CUE file)

2009-02-03 Thread Terry Carroll
On Tue, 3 Feb 2009, Terry Carroll wrote: I am parsing certai Sorry about that. I was composing this message last night when my Internet connection went down. When I logged on this morning, I had a partial message. I meant to cancel but unfortunately, in pine, the SEND key (CTRL-X

Re: [Tutor] Parsing suggestion? (CUE file)

2009-02-03 Thread Terry Carroll
On Tue, 3 Feb 2009, Kent Johnson wrote: On Tue, Feb 3, 2009 at 2:55 PM, Terry Carroll carr...@tjc.com wrote: The silver cloud to my temporary Internet outage was that I was able to solve my problem, in the process discovering that the csv module can parse a CUE file[1] quite nicely

Re: [Tutor] MP3Info class usage

2008-12-19 Thread Terry Carroll
On Thu, 18 Dec 2008, Gareth at Serif wrote: I've not installed it, I've just imported it in my main program. How do you install eyeD3, there's no installation package? I read the readme, which talks about executing 'configure', but that just reports back that it is not recognized as an

Re: [Tutor] MP3Info class usage

2008-12-19 Thread Terry Carroll
On Fri, 19 Dec 2008, Terry Carroll wrote: configure is s shell script. You'll need a version os shell that runs on windows. make, too, I'll bet. I run Cygwin on windows, which is a pretty good thing to have apart from this. It's free and avaliable from http://www.cygwin.com

Re: [Tutor] ftplib.storbinary and using a progress bar

2008-09-06 Thread Terry Carroll
On Sat, 6 Sep 2008, johnf wrote: I'm currently using ftplib.storbinary() to upload a file to a FTP server. However, I would like to inform the user of the progress being made during the file transfer (it could be a very long transfer). But ftplib.storbinary() has no callback like

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread Terry Carroll
On Sat, 6 Sep 2008, John Fouhy wrote: 2008/9/5 Terry Carroll [EMAIL PROTECTED]: So here's my routine to address the problem. It consists of making a multiplication table of coefficients that includes the factor such as 5, 25, 125, etc., and their values (1, 6, 31, etc). Then, starting

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-05 Thread Terry Carroll
On Fri, 5 Sep 2008, Terry Carroll wrote: On Sat, 6 Sep 2008, John Fouhy wrote: You can count the number of fives in the prime decomposition of a number by just dividing by 5 repeatedly until you don't get a whole number. But that requires having the number first, doesn't it? In other

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Terry Carroll
On Thu, 4 Sep 2008, Robert Berman wrote: It can easily be seen that 6! = 720 and has exactly one trailing zero. What is the lowest integer, x, such that x! has 7^20 trailing zeros? It does not, on the surface, appear to be a frontal lobe breaker. Design an algorithm to build factorials;

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Terry Carroll
On Thu, 4 Sep 2008, Robert Berman wrote: Time to do some reading about regex. And here I thought I was slick working with lists and strings. You shouldn't need a regexp for this. An easy way to count the trailing zeros is: - convert the number to a string; - make a copy, stripping off the

Re: [Tutor] Decimals 'not equal to themselves' (e.g. 0.2 equals 0.200000001)

2008-08-05 Thread Terry Carroll
On Sun, 3 Aug 2008, CNiall wrote: 0.2 0.20001 0.33 0.33002 As you can see, the last two decimals are very slightly inaccurate. However, it appears that when n in 1/n is a power of two, the decimal does not get 'thrown off'. How might I make Python recognise

Re: [Tutor] adding a watermark to a sequence of images

2008-07-21 Thread Terry Carroll
On Sun, 20 Jul 2008, Christopher Spears wrote: Has anyone used Python to watermark of sequence of images? There's a recipe for watermarking using PIL here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879 I have a half-baked program that goes through a directory of images and

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Terry Carroll
On Mon, 21 Jul 2008, Daniel Sarmiento wrote: What about the following function? if x == 0: return False return True I don't like it, myself. You have multiple points of exit, and, yes, you can see that the fallthough is only executed if the condition is not met, but it makes you do

Re: [Tutor] adding a watermark to a sequence of images

2008-07-21 Thread Terry Carroll
On Mon, 21 Jul 2008, Christopher Spears wrote: By all means, share your script! Even if I don't use it, I can learn something from it! Well, maybe. If nothing else, perhaps you'll learn some new bad habits. The timestamp on this file shows that I dropped this project in June 2005, and you

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008, Monika Jisswel wrote: Well, you can check whether your system has reached its limits or not, but what for ? So I can debug the problem. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008, Monika Jisswel wrote: I see no problem, if you open very BIG files then your memory will get filled up your system will halt, I'm going to disagree with you on this one. First, in general, it is not the case that opening a very large file will cause memory to be filled

[Tutor] Any way of monitoring a python program's memory utilization?

2008-07-16 Thread Terry Carroll
Is there any way of having my program see how much memory it's using? I'm iterating through a vey large tarfile (uncompressed, it would be about 2.4G, with about 2.5 million files in it) and I can see from some external monitors that its virtual storage usage just grows and grows, until my whole

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-16 Thread Terry Carroll
On Wed, 16 Jul 2008, Terry Carroll wrote: The obvious thing to do is to also filter by PID, which is the second element; Of course that opens a new question: how to find one's own PID from within Python. More googling awaits. And, while searching for that, I found out hwo to find

[Tutor] Anyone using tarfile?

2008-07-15 Thread Terry Carroll
I'm trying to use tarfile with no luck. Anyone on this list used it successfully? Here's a sample program pared down to illustrate the error. I'm arbitrarily trying to extract the 4th TARred file in the tarball (a file that I know from other debugging efforts is data/c410951c, and that I can

Re: [Tutor] Anyone using tarfile?

2008-07-15 Thread Terry Carroll
On Tue, 15 Jul 2008, Kent Johnson wrote: What version of Python are you using? I have 2.5.2 and the line numbers in my tarfile.py are quite different than yours. The changelog for Python 2.5.2 shows many fixes to tarfile so an upgrade may be in order. And that was it! I pulled the most

[Tutor] Traversing a two-dimensional array(was: (no subject)

2008-06-18 Thread Terry Carroll
On Wed, 18 Jun 2008, amit sethi wrote: Hi , Could you please tell me , how i can traverse a two dimensional array , i am sorry , it must be pretty simple but I am new to python am not able to understand. What many languages would call a two-dimensional array would be represented in Python as

Re: [Tutor] do I need f.close()

2008-06-12 Thread Terry Carroll
On Wed, 11 Jun 2008, dave selby wrote: The whole topic came up because I just finished reading 'learning python' 3rd edition OReilly as a refresher where there are multiple instances of suggesting that you do the exact opposite eg ... [line.rstrip() for line in open('myfile')] ... p361 for

Re: [Tutor] How to get a script to open a text file with Python?

2008-06-10 Thread Terry Carroll
On Tue, 10 Jun 2008, Alan Gauld wrote: If TextPad is your default txt editor just use os.system(foo.txt) or os.startfile(foo.txt); sounds like the equivalent, but for some reason, I prefer it. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Little problem with math module

2008-05-21 Thread Terry Carroll
Tiago Katcipis [EMAIL PROTECTED] wrote def newton_divergente(x): return math.pow(x, 1.0/3.0) but when x = -20 it returns this error return math.pow(x, 1.0/3.0) ValueError: math domain error but why is that? is it impossible to calculate -20 ^ (1/3) ? Can I chime in late

Re: [Tutor] Little problem with math module

2008-05-21 Thread Terry Carroll
On Wed, 21 May 2008, Terry Carroll wrote: The following (barely-tested) routine should calculate all the Nth roots of a given x, even when x is negative and N is even: I realize I'm probably talking to myself here, but for the benefit of the archives, I found a more elegant approach after

Re: [Tutor] web programming tutorials?

2008-04-18 Thread Terry Carroll
On Fri, 18 Apr 2008, Che M wrote: Thank you, everyone, for all the responses! I will wade through them and try to get some understanding and then will no doubt come back with some questions in some days. Much appreciated. -Che Che, I've done several superficial web programs over the years,

Re: [Tutor] Diff for Python

2008-04-05 Thread Terry Carroll
On Fri, 4 Apr 2008, Wayne Watson wrote: Is there a Linux diff-like command for Python code? I'd like to see the difference between two py files. You could just use diff. Python itself also has difflib: http://python.org/doc/2.5/lib/module-difflib.html

Re: [Tutor] Video file metadata? (MP4/WMV)

2008-03-05 Thread Terry Carroll
On Tue, 4 Mar 2008, Allen Fowler wrote: I can't seem to find a simple description of the MP4 sepc... it might be because there is not one. :) Does this help? http://www.digitalpreservation.gov/formats/fdd/fdd000155.shtml I think, though, that using Python to drive an already-written utility

Re: [Tutor] Python oddity

2008-02-27 Thread Terry Carroll
On Wed, 27 Feb 2008, Keith Suda-Cederquist wrote: Hi, I'm using iPython and I've run into an occasional problem that I don't understand. Here is what I'm seeing: aa=range(0,10) bb=aa print aa [0,1,2,3,4,5,6,7,8,9] print bb [0,1,2,3,4,5,6,7,8,9] # okay, everything allright at this

Re: [Tutor] library to create venn diagrams?

2008-02-25 Thread Terry Carroll
On Tue, 26 Feb 2008, John Fouhy wrote: On 25/02/2008, Danny Navarro [EMAIL PROTECTED] wrote: Hi all, Does anyone know a Python library to generate Venn diagrams with more than 3 datasets? The area of the datasets and the intersections should be proportional to the quantity of data.

Re: [Tutor] Change dictionary value depending on a conditional statement.

2008-02-13 Thread Terry Carroll
I don't think I saw anyone point this out yet, but, using list as a variable name is a bad idea, because it hides the list method. x = list(abcdefg) x ['a', 'b', 'c', 'd', 'e', 'f', 'g'] This works. You now have a variable named x that is a list. list = list(hijklmnop) list ['h', 'i', 'j',

[Tutor] What web framework?

2008-01-28 Thread Terry Carroll
I'm writing a pretty small database program. It tracks CDROMs with archives of, say, MP3 files; although I'm writing it with an eye to to generalize to, for example, support a collection of image files, or actual audio CDs, as well; or just about any types of files that might lend themselves to

Re: [Tutor] Projects

2008-01-23 Thread Terry Carroll
On Wed, 23 Jan 2008, Jason Massey wrote: An example routine to translate a number into [its] english equivalent was given (again, this is Java): static String convertDigitToEnglish(int d) { switch ( d ) { case 1: return one; case 2: return two;

Re: [Tutor] data structure question

2008-01-18 Thread Terry Carroll
On Fri, 18 Jan 2008, Alexander wrote: I'm trying to write a small todo list/task manager... Hi, Alexander. Not to derail your actual question, but have you looked at Task Coach? It's a small todo list/task manager, written in Python using wxPython. It does much, perhaps all, of what you're

Re: [Tutor] 2 problems in a small script

2007-10-12 Thread Terry Carroll
On Fri, 12 Oct 2007, Kent Johnson wrote: Dick Moores wrote: I'm just not comfortable with list comprehensions yet, Hmm, too bad. I use list comps and generator expressions constantly. It took me a while to get list comprehensions. It's one of those things that suddenly snaps into place

Re: [Tutor] os.rename anomaly in Python 2.3 on Windows XP

2007-10-10 Thread Terry Carroll
On Tue, 9 Oct 2007, Tony Cappellini wrote: Unfortunately,os.listdir() returns the same string as glob.glob, for the problem file I mentioned. Tony -- Try specifying the argument to os.listdir as a unicode string. I've found that cures many ailments like this. e.g., instead of something

Re: [Tutor] random number generator

2007-10-04 Thread Terry Carroll
On Thu, 4 Oct 2007, Jim Hutchinson wrote: Any idea what I'm doing wrong? while (guess != number): This is your problem. Like all^h^h^h most numbers in computing, floating point numbers are stored in binary. They only approximate the decimal values they print out as. Two numbers can print

Re: [Tutor] random number generator

2007-10-04 Thread Terry Carroll
On Thu, 4 Oct 2007, Jerry VanBrimmer wrote: I'm no Python wizard, I'm still learning myself. But I think you need another if statement to check if guess is equal to number. if guess == number: print Congratulations! No, he's got the equivalent function in his while statement: while

Re: [Tutor] Need help speeding up algorithm.

2007-10-02 Thread Terry Carroll
Ian, thanks for cleaning this up and submitting it. I was curious what its performance would be. On Wed, 26 Sep 2007, Ian Witham wrote: while count 0: fivecount += count count /= 5 This is a great improvement, and I'm embarrased that I didn't think of it myself!

Re: [Tutor] detecing palindromic strings

2007-09-28 Thread Terry Carroll
On Fri, 28 Sep 2007, Christopher Spears wrote: I'm trying to write a script that detects if a string is palindromic (same backward as it is forward). This is what I have so far: my_str = raw_input(Enter a string: ) string_list = [] Here you are creating a list and assiging the name

Re: [Tutor] largest and smallest numbers

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, John Fouhy wrote: You've got upper and lower bounds - maybe you could do a binary search to find the max exactly? It should only take the same number of steps again... I thought of that; and then I thought I'd rather go home and have dinner.

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: As I was using a list comprehension I wasn't sure how to make the calculations stop when the result of integer division == 0. I don't see how to do that, either. Someone on this list (sorry, I forget who) once suggested that the list comprehension

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Wed, 26 Sep 2007, Ian Witham wrote: My solution still took over 5 seconds on the Sphere Judge machine. How much data are they throwing at you? For the sample data they provide on the website, your first slow solution finished on my machine almost instantaneously.

Re: [Tutor] quick question

2007-09-24 Thread Terry Carroll
On Mon, 24 Sep 2007, max baseman wrote: for example how hard would it be to write a program that take's a input of a in out table and finds the rule ex: in out 10 23 5 13 1 5 0 3 the rule is in*2+3 This is called linear

Re: [Tutor] largest and smallest numbers

2007-09-24 Thread Terry Carroll
On Mon, 24 Sep 2007, Christopher Spears wrote: How can I find the largest float and complex numbers? That's an interesting question.. I just tried this: x = 2.0 while True: x = x*2 print x if repr(x) == 1.#INF: break to just keep doubling X until Python began representing it as

Re: [Tutor] Need help speeding up algorithm.

2007-09-24 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: I am attempting to do this https://www.spoj.pl/problems/FCTRL/ project for the Sphere Online Judge. (Summary of the problem: for a given integer N, determine the number of trailing zeroes in N! For example, for N=10, N! = 3628800, so the number of

Re: [Tutor] Finding even and odd numbers

2007-09-19 Thread Terry Carroll
On Wed, 19 Sep 2007, Boykie Mackay wrote: if not n1: return false The above should return false for all even numbers,numbers being represented by n.I have tried to wrap my head around the 'not n1' but I'm failing to understand what's going on.Could someone please explain the

Re: [Tutor] referencing vars()

2007-09-16 Thread Terry Carroll
On Sat, 15 Sep 2007, John wrote: I'm trying to do the above, but of course get an error because vardict is only referencing vars(), thus changes size... also, I tried vardict=[vars()], but this fails as well?? How about import copy vardict=copy.copy(vars()) That way, you've made a copy

Re: [Tutor] evaluating AND

2007-09-14 Thread Terry Carroll
On Fri, 14 Sep 2007, Rikard Bosnjakovic wrote: For me, if x would be enough. If you think it's a bad thing when x is of the wrong data, then you really should check that it contains *correct* data as well. That's an okay approach, but, but it's also non-Pythoninc; more of the

Re: [Tutor] Just bought Python in a Nutshell

2007-09-14 Thread Terry Carroll
On Thu, 13 Sep 2007, Lamonte Harris wrote: http://www.powells.com/biblio/63-9780596001889-7 Used, has anyone read this book. Any additional information that you like,dislike about this book? I love it, and use it more than any other Python book. Much as I hate to be the bearer of bad news

Re: [Tutor] remove blank list items

2007-09-14 Thread Terry Carroll
On Fri, 14 Sep 2007, Michael Langford wrote: What you want is a set, not a list. Lucky for you, a python dict uses a set for its keys, so cheat and use that. Is that true? d={1:a, 2:b} k=d.keys() type(k) type 'list' ___ Tutor maillist -

Re: [Tutor] evaluating AND

2007-09-13 Thread Terry Carroll
On Thu, 13 Sep 2007, Orest Kozyar wrote: Given a variable x that can either be None or a tuple of two floats [i.e. (0.32, 4.2)], which syntax is considered most appropriate under Python coding standards? if x and x[0] 0: pass =OR= if x: if x[0] 0:

Re: [Tutor] evaluating AND

2007-09-13 Thread Terry Carroll
On Thu, 13 Sep 2007, Adam Bark wrote: The problem is what if it's an empty list or tuple? It would pass but have not value whereas if x would work fine. Exactly. The poster stated that x is supposed to be either None or a tuple of two floats. Just to put a bit of meat on the example, let's

  1   2   3   4   >