Re: [Tutor] Simple RPN calculator

2004-12-06 Thread Terry Carroll
On Mon, 6 Dec 2004, Chad Crabtree wrote: > Bob Gailer wrote: > > > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as > input > > and prints -0.0481481 8 lines of Python. That indeed is less > than > > 100. Took about 7 minutes to code and test. > > I'm quite interested in see

Re: [Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Terry Carroll
On Wed, 15 Dec 2004, Marc Gartler wrote: > Hi everybody, > > Prior to this chunk of code 'glass' has been chosen from a list of > colors via user input, and I now want to have that choice connect to > one of several possible classes: > > def glass_type(glasstype): > if glasstype == 'Red'

[Tutor] Reading the CDROM in Linux

2010-11-05 Thread Terry Carroll
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 of this: startpoint="D:/" for (root, dirs, files) in os.walk(start

[Tutor] Reading the CDROM in Linux

2010-11-05 Thread Terry Carroll
Alan Gauld wrote: I don't use Ubuntu so don;t know the standard anmswer there but it will depend on where the CD is mounterd. I usually mount cdroms on /dev/cdrom That's what I figured; I now realize I didn't say so in my email, but it's mounted at /dev/sr0, which is where I came up with tha

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 pr

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 th

Re: [Tutor] Reading the CDROM in Linux

2010-11-05 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 t

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 widge

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 u

[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 site-packag

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 longe

[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

[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. Sim

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] am I missing another simpler structure?

2004-12-17 Thread Terry Carroll
On Thu, 16 Dec 2004, Alan Gauld wrote: > In most debiggers ... So *that's* the trick to writing compact code! ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

[Tutor] Sample Tkinter data entry screen?

2004-12-24 Thread Terry Carroll
I haven't played with Tkinter in months, and always find it a frustrating experience (GUI stuff is non-intuitive to me). Taking the lazy way out, can anyone point me to a simple sample app that just puts up a data entry screen with a small (4 or 5) number of simple text-entry fields and lets me p

Re: [Tutor] Sample Tkinter data entry screen?

2004-12-25 Thread Terry Carroll
Thanks, Harm. On Sat, 25 Dec 2004, Harm Kirchhoff wrote: > What really helped me get going were the Tk inter chapters in > 'Programming Python' by Mark Lutz. I'll take a closer look at it. I don't find this book very helpful, because it assumes you've been following all the previous parts of t

Re: [Tutor] Sample Tkinter data entry screen?

2004-12-25 Thread Terry Carroll
On Sat, 25 Dec 2004, Alan Gauld wrote: > The case study in my tutor shows a text entry and set of radio buttons > and a Text field for outbut, along with some buttons. Is that enough? I'll have a look at it (printing a copy now); I expect it will be very helpful. Thanks, Alan.

[Tutor] Tkinter packing confusion

2004-12-27 Thread Terry Carroll
First, thanks for the responses on my questions on using Tkinter for data entry from last week. Alan's and Harm's responses were very helpful. I'm now playing with a tiny application that does nothing except allow the user to enter a variable for processing. It provides a default value, and th

Re: [Tutor] Tkinter packing confusion

2004-12-27 Thread Terry Carroll
On Mon, 27 Dec 2004, Terry Carroll wrote: > The program logic works, but I'm totally lost on the pakcer layout > manager. Never mind; I'm an idiot. > self.F=tk.Frame(top) > > fBaseURL=tk.Frame(self.F) > lBaseURL=tk.Label(self.F, tex

Re: [Tutor] file-like object

2005-01-14 Thread Terry Carroll
On Fri, 14 Jan 2005, Chad Crabtree wrote: > class _macroString(object): > def __init__(self,s): > self.macro=s > self.list=self.macro.split("\n") > for n,v in enumerate(self.list): > self.list[n]=v+'\n' Is this for loop a safe technique, where the list you

Re: [Tutor] file-like object

2005-01-14 Thread Terry Carroll
On Fri, 14 Jan 2005, Terry Carroll wrote: > Is this for loop a safe technique, where the list you're enumerating over > in the for statement is the same as the one being updated in the loop > body? Rather than cluttering the list by making three replies, I'd just like to th

[Tutor] Intro for interfacing with Microsoft Access?

2005-01-14 Thread Terry Carroll
Does anyone know of any online resource that explains how to interface to Microsoft Access via Python, where the intended audience is someone who knows Python, but not the Microsoft innards? I've found http://starship.python.net/crew/bwilk/access.html (which doesn't work for me, and presumably

Re: [Tutor] Intro for interfacing with Microsoft Access?

2005-01-14 Thread Terry Carroll
On Fri, 14 Jan 2005, Kent Johnson wrote: > A couple of minutes of googling for 'python odbc' finds the ODBC driver > that comes with win32all. It seems to have a fairly simple interface. > The download from this page has an example: > http://py.vaults.ca/apyllo2.py/D906422565 Thanks, Kent. I'm

[Tutor] Should this be a list comprehension or something?

2005-01-25 Thread Terry Carroll
The following Python code works correctly; but I can't help but wonder if my for loop is better implemented as something else: a list comprehension or something else more Pythonic. My goal here is not efficiency of the code, but efficiency in my Python thinking; so I'll be thinking, for example

Re: [Tutor] Should this be a list comprehension or something?

2005-01-28 Thread Terry Carroll
On Fri, 28 Jan 2005, Alan Gauld wrote: > > Oh wait, I know: let's all start writing code in MS Word .doc > format! > > Arial for functions, Times New Roman for classes. Who's with me? > ;-) > > So you've been looking at Eiffel then? > :-) I don't get this joke, but it sounds like the basis for i

Re: [Tutor] Should this be a list comprehension or something?

2005-01-28 Thread Terry Carroll
Sorry for not responding earlier to thank all the people who weighed in on my question. I'm glad to find that my first take on it was sufficiently pythonic. Alan, I'd never seen the criterion befor that list comprehensions should be used to generate other lists. That's helpful, and I'll keep

[Tutor] Naming conventions (was: Should this be a list comprehension or something?

2005-01-28 Thread Terry Carroll
On Wed, 26 Jan 2005, Sean Perry wrote: > And now, for the pedant in me. I would recommend against naming > functions with initial capital letters. In many languages, this implies > a new type (like your Water class). so CombineWater should be combineWater. I hate hate hate hate hate camelcase and

Re: [Tutor] Naming conventions

2005-01-28 Thread Terry Carroll
On Fri, 28 Jan 2005, Kent Johnson wrote: > Separating with underscores is quite common in the Python community, > actually it is the preferred spelling for library modules. So maybe you > should adopt that, just to reduce the confusion when your code does have > an encounter with the outside world

Re: [Tutor] Should this be a list comprehension or something?

2005-01-28 Thread Terry Carroll
On Fri, 28 Jan 2005, Alan Gauld wrote: > Its not so much a criterion that they *should* be used that way, > its just that its what they do. A list comprehension creates a list! > Thats why they are called *list* comprehensions. :-) See, I'd always figured that the reason it was called a list com

Re: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Terry Carroll
On Sun, 30 Jan 2005, Brandon wrote: > I'm trying to write a program they may involve needing to divide 1 by > another number. In the program below when I use 4 for the diameter of > the bore, and 1 for the diameter of the rod, and 60 for the PSI, the > force should be 706.8 . However the program k

Re: [Tutor] Presentation

2005-01-31 Thread Terry Carroll
On Tue, 1 Feb 2005, Paul Hartley wrote: > When I was a member of the Forth Interest Group in the USA we learned > that Forth was used on the buggy that went to mars, that it started life > controlling huge radio telescopes which only had 4k (yes 4k) of memory > for both language and application. >

Re: [Tutor] Presentation

2005-02-01 Thread Terry Carroll
On Wed, 2 Feb 2005, Paul Hartley wrote: > Not only is the language amazing but the community is fantastic!! The community is one of the things I particularly like about Python. I always hated asking a question in the Perl newsgroups; although you usually got an answer, you were almost certain to

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-02 Thread Terry Carroll
I got nothing on your Perl rant, but in response to the subject line... http://www.snopes.com/legal/arizona.htm ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

RE: [Tutor] executing SAS and passing parameters

2005-02-08 Thread Terry Carroll
Ah, SAS. I used that a lot in the early '80s for general programming. I felt a lot about SAS then as I do about Python now. Enough of that. Can you show your python code that invokes SAS; and can you also show what you type at a command line that makes SAS run the way you want? Given the c

Re: [Tutor] executing SAS and passing parameters

2005-02-09 Thread Terry Carroll
I'd echo what Alan said. It sounds more like you're having trouble finding out what the command line to SAS should look like, rather than invoking it with Python. (I'm going to quote some of your message out-of-order to better facilitate my approach to this. I will, I trust, not misrepresent

Re: ****SPAM(11.2)**** [Tutor] Larger program organization

2005-02-16 Thread Terry Carroll
On Fri, 11 Feb 2005, Bob Gailer wrote: > Whenever you find yourself writing an if statement ask whether this > would be better handled by subclasses. Whenever you find yourself about > to write a global statement, consider making the variables properties of > a class. Bob -- Brian already asked

Re: [Tutor] Active Python

2005-02-17 Thread Terry Carroll
On Wed, 16 Feb 2005, Robert Campbell wrote: > I am not a programmer, but have decided to learn Python. I am wondering > if anyone has used the Activestate ActivePython and what are the > advantages/disadvantages of using it rather than the standard Python > tools. If you're on Windows, I recomme

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 -

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] 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] 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 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] 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] 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] 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] 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

[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] 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

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()

[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

[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

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)

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] 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

[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] 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. __

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] 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] 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] 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

[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 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] 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] 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

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] 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] 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

[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] 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

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] 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] 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

[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] 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

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, 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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

[Tutor] Averaging a list of lists with a listcomp?

2007-04-25 Thread Terry Carroll
I have a list (of arbitrary length) of lists, each sublist having a fixed number N of items, all integers. I would like to produce a list of N items, each item of which is an integer which is the average of the elements in the same position of each of the sublists of the original list. I realiz

Re: [Tutor] Averaging a list of lists with a listcomp?

2007-04-26 Thread Terry Carroll
On Thu, 26 Apr 2007, John Fouhy wrote: > So, here is your one-line solution: > > >>> [sum(x)/len(x) for x in zip(*orig)] > [30, 20, 50] Beautiful. Thanks. I wasn't looking for a one-liner, exactly, but just something that was more straightforward and pythonic than what I was doing. But I fin

Re: [Tutor] How to test for a remainder from division

2007-05-15 Thread Terry Carroll
On Tue, 15 May 2007, Kent Johnson wrote: > Matt Smith wrote: > > > > Thanks for the help. For future reference how do I go look at the > > implementation of a particular function (the ones coded in Python, I > > don't know C)? > > Look in the lib directory that was installed with Python. The loc

Re: [Tutor] Starting with wxPython

2007-06-01 Thread Terry Carroll
On Tue, 22 May 2007, Alan Gauld wrote: > "Alan Gilfoy" <[EMAIL PROTECTED]> wrote > > > soon, and I plan to use wxPython to do so. What, do you think, is > > the best tutorial out there for wxPython? > > I'm working through the new wxPython book and highly recommend > it. I second that. I've

Re: [Tutor] Launch external application?

2007-06-04 Thread Terry Carroll
On Fri, 1 Jun 2007, Brad Tompkins wrote: > Is there an easy way to make a python script that will launch an external > application for me ? I'm using Windows XP and I'm trying to create a little > front end that will launch the VLC media player for me. In addition to Grant's approach, if your fi

Re: [Tutor] Finding all locations of a sequence

2007-06-14 Thread Terry Carroll
On Thu, 14 Jun 2007, Lauren wrote: > Subseq AU can bind to UA (which is normal) and UG (not so > normal) and I want to know where UA, and UG are in the large > RNA sequence, and the locations to show up as one...thing. How about something like this? =

[Tutor] Getting at sqlite schema info from within Python?

2007-06-25 Thread Terry Carroll
Is there any way of getting to the schema of an sqlite database from within Python? In particular, a list of tables in the DB. >From the sqlite command line, I can use the sqlite .tables command to get a list of tables in the database; and then the PRAGMA TABLE_INFO(tablename) to get the

Re: [Tutor] Getting at sqlite schema info from within Python?

2007-06-25 Thread Terry Carroll
On Tue, 26 Jun 2007, John Fouhy wrote: > On 26/06/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > > > Is there any way of getting to the schema of an sqlite database from > > within Python? In particular, a list of tables in the DB. > > Try 'select * f

Re: [Tutor] UTF-8 filenames encountered in os.walk

2007-07-03 Thread Terry Carroll
On Tue, 3 Jul 2007, William O'Higgins Witteman wrote: > Has anyone found a silver bullet for ensuring that all the filenames > encountered by os.walk are treated as UTF-8? Thanks. What happens if you specify the starting directory as a Unicode string, rather than an ascii string, e.g., if you'r

Re: [Tutor] UTF-8 title() string method

2007-07-03 Thread Terry Carroll
On Tue, 3 Jul 2007, Jon Crump wrote: > but where there are diacritics involved, title() gives me: > > AngoulMe, Angoumois. > > Can anyone give the clueless a clue on how to manage such unicode strings > more effectively? I think setting the locale is the trick: >>> s1 = open("text.txt").readlin

Re: [Tutor] Calculating Deflection angles

2007-07-04 Thread Terry Carroll
On Wed, 4 Jul 2007, nitin chandra wrote: > Hello Every One, > > I create a list of coordinates of 2 lines. > X11,Y11 & X12,Y12 as starting and ending of one line. > X21,Y21 & X22, Y22 as starting and ending of the 2nd line. > > Now is there any way to calculate the deflection angle between the t

  1   2   3   4   5   >