Re: [Tutor] 'in-place' methods

2006-02-18 Thread Terry Carroll
On Fri, 17 Feb 2006, Kent Johnson wrote: > Ruby has an interesting approach to this - the names of mutating methods > end with !. So it would be list.sort!() which gives a strong cue to what > is happening. What a great idea! Hmm.. maybe Python could do this, too; and use some other characters

Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread Terry Carroll
On Tue, 14 Feb 2006, Kent Johnson wrote: > Bottom line - it's a very hard problem which I don't think anyone has > solved to the satisfaction of all observers, though there are limited > solutions which some people find acceptable. I think it's telling that the restricted execution modules, rex

Re: [Tutor] sys.argv

2006-02-13 Thread Terry Carroll
On Mon, 13 Feb 2006, [ISO-8859-1] J?nos Juh?sz wrote: > Is it any way to translate the sort DOS filename to the long NTSF one with > python ? You'll have to expand on this to handle files other than current directory, but basically: >>> win32api.FindFiles("FILEWI~1.TXT")[0][8] 'FileWithALongFil

Re: [Tutor] nice()

2006-02-12 Thread Terry Carroll
On Sun, 12 Feb 2006, Smith wrote: > ... I think there is less baggage for the new user to think > about if the name is something like nice()--a function that makes the > floating point numbers "play nice." And I also think the name...sounds > nice.) For "number is close enough"? ___

Re: [Tutor] nutshell review

2006-02-10 Thread Terry Carroll
On Fri, 10 Feb 2006, Carroll, Barry wrote: > Another book I have just found that may turn out useful is "Python > Programming Patterns" by Thomas W. Christopher, published by Prentice > Hall PTR. I got that from the library about a year ago. I found it interesting, but not too helpful. One pr

Re: [Tutor] nutshell review

2006-02-10 Thread Terry Carroll
It's the Python Essential Reference book, Third Edition due out February 24. I'm not aware of a new Nutshell coming out. On Fri, 10 Feb 2006 [EMAIL PROTECTED] wrote: > See I couldn't tell if he was talking about the Nutshell book or the Python > Essential Reference book...thanks > Carl > >

Re: [Tutor] nutshell review

2006-02-09 Thread Terry Carroll
On Thu, 9 Feb 2006, Andre Roberge wrote: > I own about 10 Python books including Learning Python, Programming > Python and Python in a Nutshell. Of these three, Python in a Nutshell > is the one I find the most useful. The Python Cookbook (2nd ed) is my > other favourite. Your mileage may vary.

Re: [Tutor] nutshell review

2006-02-09 Thread Terry Carroll
On Fri, 10 Feb 2006, nephish wrote: > i know this comes up from time to time. i am considering buying 'python > in a nutshell'. All the reviews i have read for it are very good. But it > only covers up to python 2.2. i use 2.3 at work, and tinker with 2.4 at > home. As good a reference as it is, i

Re: [Tutor] Trying to enter text from a file to a Dictionary

2006-01-28 Thread Terry Carroll
On Sat, 28 Jan 2006, Kent Johnson wrote: > I find simple list comps far easier to read and write than the > equivalent for loop, and they fit the way I think about problems... I don't know if my experience is typical, but I found list comprehensions difficult to get. There's something, maybe ab

Re: [Tutor] designing a class

2006-01-26 Thread Terry Carroll
On Thu, 26 Jan 2006, Christopher Spears wrote: > Here is an exercise out of Learning Python: Which edition? If I recall, the second edition covers through a release of Python (2.2?) that permits direct subclassing of lists; while the earlier one came out prior to Python 2.2, and would expect you

Re: [Tutor] More Doubt with classes

2006-01-24 Thread Terry Carroll
On Tue, 24 Jan 2006, my long-lost cousin Barry wrote: > class Person: ... > def __del__(self): > '''I am dying.''' > print '%s says bye.' % self.name > Person.population -= 1 > > if Person.population == 0: > print 'I am the last one.' > e

Re: [Tutor] Totorial announcement

2006-01-23 Thread Terry Carroll
On Mon, 23 Jan 2006, Alan Gauld wrote: > But I don't have any other books published (yet) the stuff about > hypnotism and psychic stuff is another Alan Gauld based in > Chicago USA - I get a lot of email for him! :-) A friend of mine is the author of "Just Java," "Not Just Java," "Expert C Prog

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Terry Carroll
On Thu, 19 Jan 2006, Vincent Zee wrote: > Any pointers to other curses howto's? There's http://heather.cs.ucdavis.edu/~matloff/Python/PyCurses.pdf ; but it's mostly a couple of example programs, without a lot of explanation. ___ Tutor maillist - Tut

Re: [Tutor] copyright statement

2006-01-18 Thread Terry Carroll
On Thu, 19 Jan 2006, John Fouhy wrote: > Open mouth, insert foot, echo internationally... No, it wasn't a dumb question. I remember wondering about "quit" some time ago: if Python can see your "command" quit, why doesn't it just quit, instead of telling you how to quit with Ctrl-Z, Ctrl-D, or

Re: [Tutor] copyright statement

2006-01-18 Thread Terry Carroll
On Thu, 19 Jan 2006, John Fouhy wrote: > Anyone know anything about the 'copyright' statement? help(copyright) > is not ultra helpful, and I can't see anything in the docs (eg, > http://python.org/doc/2.4.2/ref/simple.html doesn't list it). Is it > ever intended to be used in normal code? No, no

Re: [Tutor] Open file error

2006-01-17 Thread Terry Carroll
On Tue, 17 Jan 2006, Paul Kraus wrote: > On Tuesday 17 January 2006 12:11 pm, andy senoaji wrote: > > I am starting to pull my hair here. There were some postings in the past, > > similar to my problem, but the response was not clear enough. Sorry if you > > thingk I am reposting this. > > > > I a

Re: [Tutor] Finding the Index of a member of a Tuple

2006-01-11 Thread Terry Carroll
On Wed, 11 Jan 2006, Steve Haley wrote: > I need to do something very simple but I'm having trouble finding the way to > do it - at least easily. I have created a tuple and now need to find the > position of individual members of that tuple. Specifically, the tuple is > something like: words = (

Re: [Tutor] Python on Windows: any way to access shortcut's info?

2006-01-09 Thread Terry Carroll
On Sun, 8 Jan 2006, Kent Johnson wrote: > You can set the command line arguments and working directory for a > shortcut by opening the properties window on the shortcut, at least in > Win2k. Thanks, Kent. My question is whether there's any way to get the name and directory of the shortcut fro

[Tutor] Python on Windows: any way to access shortcut's info?

2006-01-08 Thread Terry Carroll
I would like to know the name of the shortcut (link, I think, in Unix parlance) from which a python program is being invoked. I'd also like to be able to access the directory where the shortcut lives. Toy example: here's a directory structure: C:\ test\ argtest\ arga.py ar

Re: [Tutor] Nearly there

2006-01-06 Thread Terry Carroll
This is itching at me, too. On Fri, 6 Jan 2006, John Corry wrote: > Can anyone understand or tell me why this works but the following code does > not:- > > import win32api > filename = "testprint.txt" > fileobj=open (filename, "w") > fileobj.write ("This is a test") > fileobj.close() > win32api.

Re: [Tutor] iterate over daterange

2006-01-06 Thread Terry Carroll
On Fri, 6 Jan 2006, captnswing wrote: > Hello > I have a startdate and an enddate and I want to iterate over all days > in between the two > > there doesn't seem to be a range function for dates?!? Sounds like a good application for a generator: # def daterange(fr

[Tutor] Printing in Windows (was: Further help needed!

2006-01-04 Thread Terry Carroll
On Wed, 4 Jan 2006, John Corry wrote: > I am using the following code to send a text file to the printer:- > This code works on windows XP + Windows 2000. However it does not work on > windows 98SE. Here's another alternative, which might be even simpler, if it works for you, invoking the go

[Tutor] Printing in Windows (was: Further help needed!

2006-01-04 Thread Terry Carroll
I've edited the subject line to be a little more clear. On Wed, 4 Jan 2006, John Corry wrote: > I am using the following code to send a text file to the printer:- [ snip ] > This code works on windows XP + Windows 2000. However it does not work on > windows 98SE. Well, at least that narrows

Re: [Tutor] HD/DVD/CD

2006-01-04 Thread Terry Carroll
On Wed, 4 Jan 2006, Kent Johnson wrote: > To get the desired representation, you have to find a way to make Python > interpret the number as an unsigned integer. One way to do this is to > convert it to a long integer, then mask off the sign bits: > >>> i = long(-1972144115) & 0x Ah,

Re: [Tutor] HD/DVD/CD

2006-01-03 Thread Terry Carroll
On Wed, 4 Jan 2006, John Fouhy wrote: > On 04/01/06, Terry Carroll <[EMAIL PROTECTED]> wrote: > > I hope someone more artful than I can show a quick and easy way to convert > > either '758C87F3' or -1972144115 to the '8A73780D' that is your goal.

Re: [Tutor] HD/DVD/CD

2006-01-03 Thread Terry Carroll
On Tue, 3 Jan 2006, Ron Speerstra wrote: > my question: howtoo read the HD/CD/DVD serial-numbers with Python. I can take you part-way there, at least under Windows. Hopefully someone can finish the job. I'm assuming you want the same serial # that shows up when you do a DIR on the CD, e.g.:

Re: [Tutor] Printing

2005-12-27 Thread Terry Carroll
On Tue, 27 Dec 2005, John Corry wrote: > I am saving the code to c:\python24\jhc2.py > The code creates the file c:\python24\testprint.txt John, I would *very* strongly advise not to store your code in c:\python24 or any subdirectory in it. That is where Python itself lives, and it's very possib

Re: [Tutor] Printing

2005-12-27 Thread Terry Carroll
On Mon, 26 Dec 2005, John Corry wrote: > Thanks for the prompt reply. This is exactly what I am looking for. > However, I have tried the code on the page and I can't get it to work. ... > Traceback (most recent call last): > File "c:\python24\jhc.py", line12, in ? > 0 > pywintypes.error:

Re: [Tutor] Print random letters

2005-12-21 Thread Terry Carroll
On Wed, 21 Dec 2005, Kent Johnson wrote: > Take a look at random.choice() or possibly random.shuffle() or > random.sample(). And remember that a string is a kind of sequence. Good call; I should have read all the replies first. >>> random.choice(string.uppercase) is much clearer than my suggest

Re: [Tutor] Print random letters

2005-12-21 Thread Terry Carroll
On Wed, 21 Dec 2005, Johan Geldenhuys wrote: > I want to print out random letters from A - Z. I know how to do this > with numbers, but don't know with letters. >>> import string >>> import random >>> string.uppercase[random.randint(0,len(string.uppercase)-1)] 'K' >>> >>> string.uppercase[random

Re: [Tutor] List-question

2005-12-19 Thread Terry Carroll
On Mon, 19 Dec 2005, Ed Singleton wrote: > On 19/12/05, Ed Singleton <[EMAIL PROTECTED]> wrote: > > > > list2 = list.copy() > > > > Slices create a copy, so a shortcut is: > > > > list2 = list[:] > > Sorry, you need to: > > from copy import copy > > before you can use copy. It should also be,

Re: [Tutor] Using debuglevel with urllib2?

2005-11-08 Thread Terry Carroll
On Tue, 8 Nov 2005, Kent Johnson wrote: > You have to create your own HTTPHandler, set it to debug and install it > in urllib2. Like this: Thanks, Kent! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Using debuglevel with urllib2?

2005-11-08 Thread Terry Carroll
With urllib, you can set httplib.HTTPConnection.debuglevel to see the HTTP conversation. But it doesn't work with urllib2. Can someone explain how to use it in conjunction with urllib2? Longer story: debuuglevel is a nice debug tool that lets you see the client-server HTTP conversation: >>

Re: [Tutor] Can anyone help me?

2005-10-28 Thread Terry Carroll
On Fri, 28 Oct 2005, bob wrote: > At 09:42 PM 10/27/2005, Nathan Pinno wrote: > > >If I create a program that randomly draws 6 numbers, its like the lottery. > >According to an article I read in Reader's Digest, if you get a Quick Pick > >- which is six numbers at random - you increase your odd

Re: [Tutor] Boolean math question

2005-10-22 Thread Terry Carroll
On Sat, 22 Oct 2005, Joe Bennett wrote: > Anyone know of a good explanation of either how to perform boolean math > in Python? What I am trying to do is AND two numbers together: > > e = 51 AND 15 > > 00110011 > > > 0011 Use '&' rather than "AND": >>> e = 51 & 15 >>

Re: [Tutor] index and find

2005-10-22 Thread Terry Carroll
On Sat, 22 Oct 2005, Shi Mu wrote: > what is the difference between index and find in the module of string? > for both "find" and "index", I got the position of the letter. index raises a ValueError if the string isn't found: >>> s = "spam" >>> s.find('m') 3 >>> s.index('m') 3 >>> s.find('z') -1

Re: [Tutor] Can anyone teach me...?

2005-10-12 Thread Terry Carroll
On Wed, 12 Oct 2005, Alan Gauld wrote: > However I have to be honest and say that building GUIs in VB ... is a > lot easier than in Python IMHO. I have to say, I agree with that. I just started using VB a month ago (for a course I'm taking, all projects need to be in VB), and it's really a ple

Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Terry Carroll
On Tue, 20 Sep 2005, R. Alan Monroe wrote: > > >>> math.degrees(_) <--- in all my time on tutor > I have never noticed > this underscore trick > before That *is* cool. I've usually done something like: >>

Re: [Tutor] MySQLdb error - PLEASE SAVE ME!

2005-09-17 Thread Terry Carroll
On Sat, 17 Sep 2005, Ed Hotchkiss wrote: > I think that I am having some kind of error with my csv going into the > fields and being broken apart correctly. Ed, I'd suggest using the CSV module to parse out CSV files, rather than splitting it yourself. __

Re: [Tutor] re.findall(), but with overlaps?

2005-09-03 Thread Terry Carroll
On Sat, 3 Sep 2005, Kent Johnson wrote: > But I would say your chances of getting the name changed are slim to > none, the Python developers are extremely reluctant to make changes that > break existing code. Yeah, I know. I was mostly joking. Mostly. __

Re: [Tutor] re.findall(), but with overlaps?

2005-09-03 Thread Terry Carroll
On Sat, 3 Sep 2005, Kent Johnson wrote: > AFAIK that is the way to do it. I may put in an enhancement request to change the name of re.findall to re.findsome. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] re.findall(), but with overlaps?

2005-09-02 Thread Terry Carroll
A friend of mine got bitten by an expectations bug. he was using re.findall to look for all occurances of strings matching a pattern, and a substring he *knew* was in there did not pop out. the bug was that it overlapped another matching substring, and findall only returns non-overlapping str

Re: [Tutor] New Tutorial topic

2005-08-29 Thread Terry Carroll
On Sun, 28 Aug 2005, Alan G wrote: > I've just uploaded two new files to my tutorial the second is the > first of these and introduces databases, SQL and using the Python DBI > interface. Alan, thanks for this. I was just casting around for a tutorial on SQLite, and its use in Python. I've

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Terry Carroll
On Fri, 26 Aug 2005, Alberto Troiano wrote: > I need to generate a password..It has to be an 8 digit number and it has > to be random > > import random > random.randrange(,) > > The code works but sometimes it picks a number with 7 digits. Is there any > way that I can tell him

[Tutor] Splitting a unicode string into characters (was "(No Subject)")

2005-08-25 Thread Terry Carroll
Jorge, please include a subject line. On Thu, 25 Aug 2005, Jorge Louis de Castro wrote: > What is the best way to split a unicode string in its characters? > Specifically, having this unicode chinese string > > u'\u8C01\u4ECA\u5929\u7A7F\u4EC0\u4E48 I'm assuming you've actually got the close-q

Re: [Tutor] Sort a Set

2005-08-23 Thread Terry Carroll
On Tue, 23 Aug 2005, Kent Johnson wrote: > Actually the reverse parameter is new in 2.4 too, you have to do that in > a separate step also: Doh! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sort a Set

2005-08-23 Thread Terry Carroll
On Tue, 23 Aug 2005, Terry Carroll wrote to Jonas: > I don't know if you're in a position to rely on the sortedness of the > input data, but even if not, this works: > > >>> l=[24, 24, 15, 16, 16, 15, 24] > >>> l=sorted(list(set(l)), reverse=True)

Re: [Tutor] Sort a Set

2005-08-23 Thread Terry Carroll
On Tue, 23 Aug 2005, Jonas Melian wrote: > I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ] > Is possible get it without repeated numbers, without using set()? > > If I use set, then the list is unsorted and i cann't sorting it. Converting it to a set will eliminate dupes, and con

Re: [Tutor] reading excel and access files

2005-08-22 Thread Terry Carroll
On Mon, 22 Aug 2005, ZIYAD A. M. AL-BATLY wrote: > Someone posted this link on this list a while ago (sorry, I can't > remember who). I found it very useful under Win32: > > http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx What a great resource. Thanks for posting the U

Re: [Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Terry Carroll
On Mon, 8 Aug 2005, Tom Cloyd wrote: > So, thie > > webbrowser.open_new("file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.htm") > > does not work, but this > > webbrowser.open_new(r"file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.ht

Re: [Tutor] IP Address from Python module?

2005-08-05 Thread Terry Carroll
On Fri, 5 Aug 2005, Joseph Quigley wrote: > Is it possible to get my internet and/or network IP address from Python? import socket ipaddr = socket.gethostbyname(socket.gethostname()) Some users report this gives a meaningless '127.0.0.1' (i.e., localhost), though. But try it and see. It work

Re: [Tutor] What's the invalid syntax? Code supplied

2005-08-05 Thread Terry Carroll
On Fri, 5 Aug 2005, Nathan Pinno wrote: > What's the invalid syntax? Here is the code: Nathan, My method when encountering a syntax error like this is to look at the part of my code that's generating the syntax error, and see what structure or function it's using. Then find a program segment

Re: [Tutor] What's the invalid syntax? Code supplied

2005-08-04 Thread Terry Carroll
On Thu, 4 Aug 2005, Bob Gailer wrote: > At 06:51 PM 8/3/2005, Nathan Pinno wrote: > >That's part of my signature. It describes who I am. > > I would like to know who you are, but the signature does not convey enough > information. My guess is that you are on the crew of a MacDonald's > restaura

Re: [Tutor] cPickle.load()

2005-07-16 Thread Terry Carroll
On Sat, 16 Jul 2005, David Jimenez wrote: > [EOFError on pickle] First, something that may not be a problem, but let's get it out of the way, anyway: > pickle_file=open("pickles1.dat","w") >. . . > pickle_file=open("pickles1.dat","rb") I notice that your write open does not specify binary

Re: [Tutor] New entry in the Tutor list - Question: Python and dbf files

2005-07-08 Thread Terry Carroll
On Fri, 8 Jul 2005, Alessandro Brollo wrote: > 1. Does a Python dbf reader/writer module exist > somewhere? A google on "python dbf" led me to a few promising leads: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362715 http://www.fiby.at/dbfpy/ http://www.garshol.priv.no/download/so

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Terry Carroll
On Thu, 7 Jul 2005, Nathan Pinno wrote: > Why does invalid syntax popup? > def lookup_login_command(site,filename): > print "Lookup a login info card" > site = raw_input("Site: ") > if sitelist.has_key(site): > print "The ID is: ",sitelist[site][0] >

Re: [Tutor] Trying Ruby...

2005-06-14 Thread Terry Carroll
My original question: > I vaguely recall a post a few months ago, I don't know if it was in this > forum, where someone had a problem in Python, and it turns out it was > because a Ruby install messed with some setting, perhaps in the Windows > registry Anyway, I'd like to install Ruby, but wa

Re: [Tutor] Python Books

2005-06-12 Thread Terry Carroll
On Sun, 12 Jun 2005, Kristiano Ang wrote: > So, I'm prepared to invest in a Python book of some sort that will > help me master the language. Does anyone have any recommendations? Or > perhaps tutorials? I have limited programming experience (a little > dabbling in C++). For a how-to-learn Pytho

Re: [Tutor] Web browser

2005-06-11 Thread Terry Carroll
On Sat, 11 Jun 2005, Ismael Garrido wrote: > I've been looking around for a web browser either written in python, or > with python bindings. MozPython? http://www.thomas-schilz.de/MozPython/README.html > What I need to do is load a web-page, enter a password-protected site > and follow certai

Re: [Tutor] Newsreader list name?

2005-06-10 Thread Terry Carroll
> > I'm on OS X 10.4.1 and downloaded Hogwasher to try. Using my ISPs > > news server I found the two lists I mentioned, but I can't get > > anything nntp://news.gmane.org alone or in combination with a group Try news://news.gmane.org , if your reader requires specifying the protocol. __

Re: [Tutor] More image manipulation (fwd)

2005-06-07 Thread Terry Carroll
On Tue, 7 Jun 2005, D. Hartley wrote: > OK. I tried them out and I do see the diffence. (btw, testit1 gave me > the following error: > > Traceback (most recent call last): > File "", line 1, in ? > testit1() > File "", line 3, in testit1 > del fromlist[0] > IndexError: list assignmen

Re: [Tutor] More image manipulation

2005-06-07 Thread Terry Carroll
On Tue, 7 Jun 2005, Terry Carroll wrote: > On Tue, 7 Jun 2005, D. Hartley wrote: > > > def findlist(): > > newlist = [] > > for i in range(480): > > line = fromlist[:640] > > del fromlist[:640] > > x = line.index(195) >

Re: [Tutor] repr()

2005-06-07 Thread Terry Carroll
On Tue, 7 Jun 2005, Bernard Lebel wrote: > repr( myFunc ) > '' > > > > s = repr( myFunc() ) > print s > > 'None' In the first example, your repr invocation is: repr(myFunc) i.e., you're asking for the repr of the function myFunc. In the second example, your repr invocation is: repr(my

Re: [Tutor] More image manipulation

2005-06-07 Thread Terry Carroll
On Tue, 7 Jun 2005, D. Hartley wrote: > def findlist(): > newlist = [] > for i in range(480): > line = fromlist[:640] > del fromlist[:640] > x = line.index(195) > y = x + 5 > z = line[x:y] > del line[x:y] > for i in z: > n

[Tutor] Trying Ruby...

2005-06-06 Thread Terry Carroll
This message is not as off-topic as it at first appears. I'm a user of Activestate's ActivePython under Windows/XP. I want to give Ruby a spin, just for the heck of it. I vaguely recall a post a few months ago, I don't know if it was in this forum, where someone had a problem in Python, and it t

Re: [Tutor] Detecting my own IP address?

2005-06-05 Thread Terry Carroll
The Python Cookbook (1st ed) suggests this, in recipe 10.4 ("Finding Your Own Name and Address): >>> import socket >>> myname = socket.getfqdn(socket.gethostname()) >>> myaddr = socket.gethostbyname(myname) >>> myaddr '192.168.1.120' ___ Tutor maill

Re: [Tutor] quick PIL question

2005-06-02 Thread Terry Carroll
On Thu, 2 Jun 2005, Max Noel wrote: [explanation snipped] > Makes sense? Yes. Thanks very much. I think the problem is the the PIL documentation (reasonably) assumes that the reader already understands all the structures used in the imaging it supports; it just explains how PIL gives a

Re: [Tutor] quick PIL question

2005-06-02 Thread Terry Carroll
On Thu, 2 Jun 2005, D. Hartley wrote: > What does it mean if my image mode is "P"? In the documentation, it > says "typical values are '1', 'L', 'RGB', 'CMYK.'" (it's a gif, if > that's important) That's really weird. It does say that (in the description of im.mode, where you'd expect it). But

Re: [Tutor] List processing

2005-06-01 Thread Terry Carroll
On 1 Jun 2005 [EMAIL PROTECTED] wrote: > eYAL001C1 Spar81 3419451845192 1 > > So basically its a table, separated with tabs. What I need to do is make > a new file where all the entries in the table are those where the values > in columns 1 and 5 were present

[Tutor] Using Python to keep peace in the house (a little success story)

2005-05-29 Thread Terry Carroll
My wife and I have a disagreement over the use of our digital camera. She likes to have the date printed on the image. I hate that, I like the image to be pristine. Our camera has the option to put the date on the image, but we can't agree on whether to enable it. Well, Python to the rescue.

Re: [Tutor] Help: wget-- how does it work?

2005-05-28 Thread Terry Carroll
On Fri, 27 May 2005, Terry Carroll wrote: > I use this for an app I have that reads the 27-meg Unihan.txt file; but I > think I cheat and hardcode the 27-meg no. I just checked, and, yep, that's exactly what I do. ___ Tutor maillis

Re: [Tutor] reading comments

2005-05-28 Thread Terry Carroll
On Sat, 28 May 2005, Servando Garcia wrote: > How do I read the comments attached to a zipfile or for > any file .? Someone's on riddle 6! :-) z = zipfile.ZipFile(zipfilename, mode='r') zi = z.getinfo(zfilename) print zi.comment __

Re: [Tutor] increment operator

2005-05-28 Thread Terry Carroll
On Fri, 27 May 2005, Lee Cullens wrote: > I find the following invaluable - maybe you will also. > > http://rgruet.free.fr/PQR24/PQR2.4.html That's a great resource. Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listin

Re: [Tutor] Help: wget-- how does it work?

2005-05-27 Thread Terry Carroll
On Fri, 27 May 2005, Aaron Elbaz wrote: > First, I found the progress bar class from aspn > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/168639 > > This could be used to simulate wgets progress bar. What I'm trying to > figure out now is how one would stat a file as it was being downlo

[Tutor] Any Python interface to USPTO web site?

2005-05-27 Thread Terry Carroll
I have the need to run periodic searches on the US Patent and Trademark Office website, www.uspto.gov. Before I reinvent the wheel, I thought I'd check to see if anyone knew of such a beast. For instance, It's like to be able to pass an argument like one of these: an/"dis corporation" in/n

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Terry Carroll
On Thu, 19 May 2005, Max Noel wrote: > On May 19, 2005, at 23:05, Terry Carroll wrote: > > > Thanks to you both. I think I may need to step up my "development > > environment" beyond emacs and a command line. > > Actually, if you're having problem

[Tutor] Finding which list entry is being used, in a for loop (was: using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Terry Carroll
On Tue, 17 May 2005, Kent Johnson wrote: > I often find that the information in the traceback and exception are > enough to figure out the problem; if not, a few print statements can > help. You will get better at this with experience. Here's an example where traceback and print statements doesn

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-19 Thread Terry Carroll
On Wed, 18 May 2005 [EMAIL PROTECTED] wrote: > Another possibility is to look at this recipe: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65287 On Tue, 17 May 2005, Kent Johnson wrote: > I think this approach to debugging won't scale well and you are just > seeing the tip of the ic

Re: [Tutor] How to convert hex representation of char? (Challenge part 8)

2005-05-18 Thread Terry Carroll
On Wed, 18 May 2005, Pieter Lust wrote: > onepart and anotherpart contain many hex representations of nonprintable > characters, like '\x14'. But I can't manage to convert those to the > actual nonprintable characters. Any hints on how to do this? The string including the \x14 escape should be

Re: [Tutor] hettingertools?

2005-05-17 Thread Terry Carroll
On Tue, 17 May 2005, Terry Carroll wrote: > On Tue, 17 May 2005, D. Hartley wrote: > > > This was a hint from a python challenge, but I can't find anything > > about it online: Anyone know? > > Raymond Hettinger is a frequent contributor to Python. I don't k

Re: [Tutor] hettingertools?

2005-05-17 Thread Terry Carroll
On Tue, 17 May 2005, D. Hartley wrote: > This was a hint from a python challenge, but I can't find anything > about it online: Anyone know? Raymond Hettinger is a frequent contributor to Python. I don't know if that is part of it. ___ Tutor maillist

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-17 Thread Terry Carroll
On Wed, 18 May 2005 [EMAIL PROTECTED] wrote: > If main is a class, you could change to 'm = main()'; that would at > least give you access to the class attributes. Interesting approach; I'm refering to where main() is a method, the usual python idiom. __

[Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-17 Thread Terry Carroll
I've often found it convenient to run a Python program I'm developing with the -i flag. I find it convenient to use as a post-mortem as it hits bugs, or to explore data structures. I've recently started using the construct if __name__ == "__main__": main() And found I can't do the -i

Re: [Tutor] Linux variable to Python

2005-05-17 Thread Terry Carroll
On Fri, 13 May 2005, Alberto Troiano wrote: > To explain for those who doesn't know: > The first line creates a variable named "fec" with the value cam(a Linux > function returning year month day hour minute second).jpg > The second show the value of "fec" > The third moves hola.txt to the direct

Re: [Tutor] Objects in List

2005-05-16 Thread Terry Carroll
On Mon, 16 May 2005, Viljoen, Danie wrote: > My Code: > > class MyObject: > """A simple VO class""" > def setName(self, newName): > self.name=newName > > def getName(self): > return self.name > > def main(): > list=[] >

Re: [Tutor] How to verify all things are equal to one another

2005-05-16 Thread Terry Carroll
Thanks to all who responded on this. The commonly suggested: > if a == b == c == d == e == f == g: > do stuff Is just what I needed. It never occurred to me that Python supported a construct like that. I would have though this would have evaulated a la: if ((a == b) == c) == d) == e)

[Tutor] How to verify all things are equal to one another

2005-05-14 Thread Terry Carroll
Suppose I have several variables, e.g.: a, b, c, d, e, f, g. I would like to be able to see if they're all the same, I don't care what the value is, as long as they're equal. If they're all equal to 0, or to "spam", or to ["cleese", "idle", "gilliam"], as long as they're the same. Is there a mo

[Tutor] Perl to Python phrasebook

2005-05-13 Thread Terry Carroll
A "Perl-to-Python phrasebook," showing a number of common tasks in Perl, and how to do the equivalent in Python, is at . I'll bet a lot of readers know about it already, but I just stumbled on it and thought that some readers migh

Re: [Tutor] map() and lambda to change class instance attribute

2005-05-11 Thread Terry Carroll
It's not often I get a chance to correct Danny, but On Wed, 11 May 2005, Danny Yoo wrote: > map(lambda x: x^2, [1, 2, 3]) > > [x^2 for x in [1, 2, 3]] > then we're really saying something like this: > > [1, 2, 3] > | | | > | | | map()

Re: [Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread Terry Carroll
On Mon, 9 May 2005, Kent Johnson wrote: > >>> import webbrowser > >>> webbrowser.open("http://www.google.com/";) Beautiful; just what I needed. Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Any easy way to invoke the default browser on a specified URL?

2005-05-09 Thread Terry Carroll
Is there any way, from within Python, to cause the default browser (Firefox, in my case) to be invoked with a specific URL? I'd like to do something like (totally made-up name and syntax): OpenBrowser("http://www.google.com/";) and have a new browser window opened up pointing to Google. (Okay,

Re: [Tutor] need a example of translate or maketrans

2005-05-09 Thread Terry Carroll
On Mon, 9 May 2005, Servando Garcia wrote: > As you can guess I am working on the riddles. I have looked in vain > for a simple example and or a explanation of the string function > "translate" or even "maketrans" >Can someone please send me a working example,please. Here's a quic

Re: [Tutor] XML to Python

2005-05-06 Thread Terry Carroll
On Thu, 5 May 2005, Smith, Jeff wrote: > I'm able to use the built in XML parser to effect "normal" XML parsing > usage but frequently, I'm not doing anything to complicated and would > simply like to translate the XML file into a more "Pythonic" structure. > What's the best way to do this? Som

Re: [Tutor] Acessing files in Windows 2000

2005-03-08 Thread Terry Carroll
On Tue, 8 Mar 2005, Dave S wrote: > IOError: [Errno 2] No such file or directory: 'c:\\my documents\\memo.txt' My two thoughts. 1) is there actually a directory named "my documents" at the root? I don't know about Win2000, but for Win XP, the "my documents" directory is actually C:\Documen

Re: [Tutor] HELP: subclass of int

2005-03-08 Thread Terry Carroll
On Tue, 8 Mar 2005, Shidai Liu wrote: > I'll sum up a question as following: > > def int5(): > '''return 5''' > return 5 > > class my_int(int): > def __init__(self): > self.id = int5() > int.__init__(self, self.id) # FIXME: this line doesn't work > > the above code

Re: [Tutor] How to use threads ?

2005-03-02 Thread Terry Carroll
On Wed, 2 Mar 2005, Mark Kels wrote: > The only problem is that when I try to do it my thread doesnt closes. > When does a thread closes ? You got me. That's what I meant when I wrote "calls to t.isAlive() returned True long after the thread referred to had finished up and put out its final [shu

Re: [Tutor] How to use threads ?

2005-03-02 Thread Terry Carroll
On Tue, 1 Mar 2005, Mark Kels wrote: > Can anyone give me a very simple example on thread programming ? I don't think a simple example is possible, given that threads are inherently for slightly more complex processing than you ordinarily do. That being said, here's an example. This is a made-

Re: [Tutor] How can i use both float and int?

2005-02-22 Thread Terry Carroll
On Tue, 22 Feb 2005, . , wrote: > like... > > number1 = raw_input(float int("Number1: ") > > But, I think error will occur... You have some syntax issues here. What you want, I think, is to use raw_input to get input, and then convert that to float. try this: number1 = float(raw_input("Numb

Re: [Tutor] Active Python

2005-02-18 Thread Terry Carroll
On Fri, 18 Feb 2005, Bill Mill wrote: > How do you live without cygwin? I don't. I have it installed, too. But Agent Ransack is more convenient. If it wasn't free, I'd pay for it. It's primarily to search by filename, but the grep-like capability is a nice plus. _

Re: [Tutor] Active Python

2005-02-18 Thread Terry Carroll
On Thu, 17 Feb 2005, Jeff Shannon wrote: > On Thu, 17 Feb 2005 15:54:43 -0800 (PST), Terry Carroll <[EMAIL PROTECTED]> > wrote: > > > > I prefer the HTML, because I can then run searches against it from > > outside the help system. > > Interesting -

<    1   2   3   4   5   >