Re: [Tutor] In-place expansion of list members... possible?

2007-11-07 Thread John Fouhy
did, for example, tmpSegs = inString.split(self.SegTerm) for seg in tmpSegs: seg = 'bananas' I would expect tmpSegs to be unchanged. If it is changed, then that seems strange to me.. -- John. ___ Tutor maillist - Tut

Re: [Tutor] assignment question

2007-11-11 Thread John Fouhy
together to make a new one, you can use +: >>> x = [1, 2, 3] + [4] >>> x [1, 2, 3, 4] Hope this helps, -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tkinter Canvas Widget

2007-11-12 Thread John Fouhy
ere that you only want to draw your lines when the user has a button depressed..) To draw points, you could perhaps use canvas.create_oval with a small bounding box. HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] python 2.4 reading files - unexpected behaviour

2007-11-23 Thread John Gerdeman
5'] ['4', ' 3', ' 2'] instead of: ['3', ' 4', ' 5'] ['4', ' 3', ' 2'] ['3', ' 4', ' 5'] ['4', ' 3', ' 2'] Any help would be welcome. John signature.asc Description: Dies ist ein digital signierter Nachrichtenteil ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] altering a list of lists

2007-11-25 Thread John Fouhy
x = [3] >>> y = [x, x, x] >>> print y >>> y[1].append(2) >>> print y >>> print x Does anything you see here surprise you? Can you explain what is going on? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List processing question - consolidating duplicate entries

2007-11-27 Thread John Fouhy
ote that this will modify the jobs in your original list... if this is Bad, you can replace the last line with "... = job[:]") HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] update a ws.ListBox

2007-11-28 Thread John Gerdeman
Hello, I'm trying to create a gui using wxpython on ubuntu 6.10 (read, that some functions of wx differ on different OS). I have two Listbox items, Listbox1 and Listbox2. I want to update Listbox2 according to the choice made in Listbox1. I already looked at the wx API doc, but only found method

[Tutor] unsubscribe

2007-12-06 Thread John Merritt
___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Formatting timedelta objects

2007-12-10 Thread John Fouhy
0 minutes = (td.seconds % 3600) // 60 seconds = td.seconds % 60 return '%s:%s:%s' % (hours, minutes, seconds) HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Windows Os Programming

2007-12-10 Thread John Fouhy
Script Centre has a repository of python scripts: http://www.microsoft.com/technet/scriptcenter/scripts/python/default.mspx?mfr=true -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Parsing DICOMRT file

2007-12-12 Thread John Fouhy
On 13/12/2007, Bryan Fodness <[EMAIL PROTECTED]> wrote: > I am new to doing anything like this. I have looked at > http://www.leadtools.com/SDK/Medical/DICOM/ltdc1.htm and am > not sure how to proceed. I haven't much experience here, but this is how I'd proceed, I think: 1. Start by reading the

Re: [Tutor] Oops:

2007-12-17 Thread John Fouhy
one (assuming that setting student.row to None is the appropriate thing to do when it's blank) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Required method to make foo(*Vector(0,0,0)) work.

2007-12-18 Thread John Fouhy
f you're confused about python's *args / **kwargs syntax, this post I wrote a while ago might help: http://mail.python.org/pipermail/tutor/2007-April/053725.html Otherwise, as Kent says, we need more information. -- John. ___ Tutor m

Re: [Tutor] new guy problem, what's wrong with this program.

2008-01-13 Thread John Fouhy
sn't know what "Ture" is. In this case, I suspect you have misspelt "True". Programming languages are quite picky about correct spelling! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Morris
class Foo: '''Represents a foo''' def __init__(self, name): '''Initializes the person's data''' self.name = name print '(Initializing %s)' % self.name self.ot = Bar(self.name) print '(After Other - %s)' % self.name class Bar: def __init__(self, name): self.name

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Morris
On Jan 21, 2008 9:16 PM, John Morris <[EMAIL PROTECTED]> wrote: > class Foo: > '''Represents a foo''' > def __init__(self, name): > '''Initializes the person's data''' > self.name = name >

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Morris
Thanks, so I could/should do self.ot = Bar(self.name.copy()) instead On Jan 21, 2008 9:25 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > John Morris wrote: > > > Why does the pop in the Bar class nuke the srv k & v from Foo.name > > <http://Foo.name> as wel

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Fouhy
On 22/01/2008, John Morris <[EMAIL PROTECTED]> wrote: > I thought each class got it's own namespace and this sharing of mutable > objects is confusing me. Each class gets its own namespace, but names are different from objects. For example: >>> x = [1, 2, 3] >>

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Morris
So this seems like it will make scope/namespaces a bit interesting... Any good references on why this is this way? I.e., why assignment passes across scopes instead of copy. Or is it just explicit versus implicit? On Jan 21, 2008 9:32 PM, John Fouhy <[EMAIL PROTECTED]> wrote: > On 2

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Morris
Sort of. I see some light beginning to dawn ;). On Jan 21, 2008 9:16 PM, John Morris <[EMAIL PROTECTED]> wrote: > class Foo: > '''Represents a foo''' > def __init__(self, name): > '''Initializes the person's data''

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Fouhy
On 22/01/2008, John Morris <[EMAIL PROTECTED]> wrote: > So if you create an object way up in terms of scope (global), then all > python does is handle what names are available in a given scope to refer to > it. If you want a separate object you have to take care of that yourse

Re: [Tutor] dictionaries, objects and scoping...

2008-01-21 Thread John Morris
Thanks. I think this is understood better now. Thanks to everyone for their help. I was running low on ways to express this for clearer understanding. Awesomeness once again from [EMAIL PROTECTED] - John On Jan 21, 2008 10:18 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > John Mor

Re: [Tutor] Projects (fwd)

2008-01-23 Thread John Fouhy
", 8:"eight", 9:"nine"}' 'd[5]' 1000 loops, best of 3: 0.127 usec per loop Morpork:~ repton$ python -m timeit -s 'd = ["zero", "one", "two", "three", "four", "five", "six", "se

[Tutor] namespaces and the __dict__ function?

2008-01-25 Thread John Gunderman
does it store all current objects of that class in a __dict__? John Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs___ Tutor

Re: [Tutor] [tutor] Question on multithreading

2008-01-29 Thread John Fouhy
s anybody have an example where they have implemented this kind of > threading concept ?? How did you implement your stop button? Can you adapt that solution? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] NYC Python Users Meetup February Meeting Announcement....

2008-02-08 Thread John Clark
Please pardon the PSA: The New York City Python Users Meetup Group is planning on having our February meeting on February 12th, from 6:30pm - 8:00pm. For more information, please see: http://python.meetup.com/172/calendar/7082384/ Anyone in the NYC area interested in using Python, learning m

Re: [Tutor] read from standard input

2008-02-13 Thread John Fouhy
until it is > nothing to read. sys.stdin is a file-like object corresponding to standard in. You can do this: import sys special = 11 for line in sys.stdin: try: x = int(line) except ValueError: print 'Bad input.' break if x

[Tutor] Noob requesting help...

2008-02-16 Thread John Luke
Hi, I've recently started to get into Python, and I've made a bit a progress so far, but I still have a long way to go. Along my search for tutorials, I've come across this: # Waits until a password has been entered. Use Control-C to break out without # the password #Note that this must not be t

Re: [Tutor] How to deal with a thread that doesn't terminate

2008-02-19 Thread John Fouhy
he defines "hangs" as "waiting on an external event / signal / communicaiton that never happens". AFAIK, there's no good way to kill a thread (google for 'python kill thread' for lots of hits). IME most blocking operations have optional timeout parameters, so

[Tutor] how to parse a multiple character words from plaintext

2008-02-22 Thread John Gunderman
grab something until it sees a /t or ' '? I was thinking I could have it count ahead the number of spaces till the stopping point and then parse till that point using read(), but that seems sort of inefficient. Is there a better way to pull this off? Thanks in

Re: [Tutor] library to create venn diagrams?

2008-02-25 Thread John Fouhy
. ... also, how would you draw in two dimensions a Venn diagram of four mutually-intersecting sets? I can't see how it is possible in general.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python and displaying mathematical equations?

2008-03-03 Thread John Fouhy
ematical > equations. If you can describe your equations in MathML then there may be options for you -- a quick google for "python mathml" turned up a few hits -- e.g. http://sourceforge.net/projects/pymathml/ or http://www.grigoriev.ru/svgmath/ (if you ac

Re: [Tutor] Const on Python

2008-03-05 Thread John Fouhy
inking for themselves, and if you're silly enough to reassign a constant, you deserve whatever you get. Best just to make your variable names ALL_CAPS and write documentation saying they're constant :-) See also this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207 for

Re: [Tutor] Processing unix style timestamp

2008-03-06 Thread John Fouhy
008' >>> s[4:19] + s[23:], s[20:23] ('Feb 11 01:34:52 2008', 'CST') You should be able to parse the former with strptime(). You could then build a dictionary mapping timezones to offsets which you could add to the parsed time to produce a time in GMT. --

[Tutor] Network Tutorials

2005-08-21 Thread John Walton
Hello, everyone. I just began school, and they already assigned us science fair. Since I'm in 8th grade, I get to do demonstrations for our projects. > I'm probably going to demonstrate Python's networking> capabilities by writing a simple instant messenger program. I only have a few problems:

[Tutor] Network Programming Information and terminology

2005-08-21 Thread John Walton
ff I don't even know what it means). So, does anyone know any good websites with Network Programming information. Thanks! John __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around h

Re: [Tutor] Hello

2005-08-24 Thread John Purser
In Python that's Guido.Hail('All') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Walker Sent: Wednesday, August 24, 2005 16:49 To: tutor@python.org Subject: [Tutor] Hello all, Hello... I just finished a class given by Mark Lutz and I love python.

Re: [Tutor] Hello

2005-08-24 Thread John Purser
You know, I got that backwards and I can't tell you how much it's bugging me! All.Hail('Guido') Thanks. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Purser Sent: Wednesday, August 24, 2005 16:52 To: 'Eric Walker&#

Re: [Tutor] checking substrings in strings

2005-08-25 Thread John Fouhy
as introduced in Python 2.3. ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 'bar'

Re: [Tutor] Handling binary file

2005-08-25 Thread John Purser
to Windows.  Worked just fine.   John Purser From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julie LaiSent: Wednesday, August 24, 2005 18:20To: tutor@python.orgSubject: [Tutor] Handling binary file I have opened a file in binary mode. The 9th, 10th and 11th bytes contain

Re: [Tutor] (no subject)

2005-08-25 Thread John Fouhy
;> f.close() >>> f = file('foo', 'rb') >>> a = pickle.load(f) >>> b = pickle.load(f) >>> c = pickle.load(f) >>> a,b,c ('foo', 'bar', 'baz') Although, normally when I use pickle, I chuck everything into a tuple, so I can store/retrieve it all with a single dump/load command.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Ertl, John
Alberto If you don't mind having leading 0 then you could just do the random like you did then format it to 9 digits. You could give this a try num = random.randrange(,) num8 = "%09i" % num John Ertl -Original Message- From: Byron [mailto:[EMAIL P

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Ertl, John
Sorry for that you will have to change the %09 to a %08 to get 8 digits. I got a bit to fixated on the John Ertl -Original Message- From: Ertl, John Sent: Friday, August 26, 2005 2:23 PM To: Alberto Troiano; tutor@python.org Subject:RE: [Tutor] Generate 8

Re: [Tutor] Popen and Prompting

2005-08-30 Thread John Fouhy
so that, every time they ask for user input, they include in the prompt a certain unusual string. Then, any time your GUI detects this string in the program output, it can pop up a dialog box asking for user input. (just a suggestion ... I don't know the best w

Re: [Tutor] doh!

2005-09-01 Thread John Fouhy
On 02/09/05, Lane, Frank L <[EMAIL PROTECTED]> wrote: > I also learned that even if the tabs and spaces line up in the editor they > don't count the same and give you a syntax error. Hi Frank, What editor are you using? And does it have a proportional or a monospace

[Tutor] how to create a generic instance of an object?

2005-09-06 Thread John Burk
ass objects, not strings... I'm guessing that this works because it's all in the same module, so it knows that the things in the tuple iterated over in the foreach are classes. Any ideas? I'm an old hand at perl (10+ years), but very new to Python, so please be patient. John Burk ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] how to create a generic instance of an object?

2005-09-06 Thread John Fouhy
On 07/09/05, John Burk <[EMAIL PROTECTED]> wrote: > What I want to do is to pass in the assetType at runTime via an external > script, create a new instance of it, and then run that instance's > methods. That way I won't have to have 20 or more " if assetType

Re: [Tutor] how to create a generic instance of an object?

2005-09-07 Thread John Burk
-Original Message- From: Danny Yoo [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 06, 2005 6:55 PM To: John Burk Cc: tutor@python.org Subject: Re: [Tutor] how to create a generic instance of an object? Hi John, It sounds like you're trying to do some kind of dynamic li

Re: [Tutor] running scripts with windows

2005-09-14 Thread John Fouhy
o unix, you might like to install Cygwin (http://www.cygwin.com/) It gives you a bash shell in Windows. Quite nice. HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread John Fouhy
; [(i%2 == 1 and [list1] or [list2])[0].append(i) for i in range(10)] [None, None, None, None, None, None, None, None, None, None] >>> list1, list2 ([1, 3, 5, 7, 9], [0, 2, 4, 6, 8]) But I'm sure that using side-effects in a list comprehens

Re: [Tutor] Will the following code ever exit?

2005-09-16 Thread John Fouhy
ke this: ### answer, guess = add(num1, num2) ### This will get the return values of the function and put it into variables which you can access from the rest of your program. Hope this helps! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Iterating over sorted dictionary keys in one line

2005-09-18 Thread John Fouhy
in lst.sort()" as a reminder that there are side-effects that you need to be wary of. On the other hand, the new sorted() function creates a sorted copy, so it doesn't matter (but you should be aware of the extra memory requirements if you have big lists). -- John. ___

Re: [Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread John Fouhy
On 19/09/05, grouchy <[EMAIL PROTECTED]> wrote: > I've been playing with generating 1-D cellular automata, and this is the > fastest solution I've come up with so far. I haven't dug deep into your code --- but, I wonder if the array m

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

2005-09-20 Thread John Fouhy
7;m not a big fan of it, actually. It smells of Perl and those opaque one-liners that make use of implicit functions implicitely setting implicit variables... -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] words in networking I should probably know

2005-09-22 Thread John Walton
this project? Not the definitions, but just the words; I can look up the definitions on webopedia. It would be appreciated. Thanks! -John __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail

Re: [Tutor] stopping threads?

2005-09-28 Thread John Fouhy
lf.die = False def run(self): while not self.die: # do stuff def stop(self): self.die = True # HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Finding difference in two .gif

2005-09-30 Thread Ertl, John
oes anyone know how to isolate (hopefully small) image differences using PIL? Thank you, John Ertl Python 2.4, PIL 1.1.5 The simple code I have tried: import Image import ImageChops file1 = Image.open("/home/PT04_RH.2005072300.gif") file2 = Image.open("/home/PT04_RH.200

Re: [Tutor] Finding difference in two .gif

2005-09-30 Thread Ertl, John
All, Well I found the answer...getbox() gave me the bounding box and then I could just plot that portion of the two images. Python 2.4, PIL 1.1.5 The simple code I have tried: import Image import ImageChops file1 = Image.open("/home/PT04_RH.2005072300.gif") file2 = Image.open("/home/PT04_RH.

Re: [Tutor] Please look at my wordFrequency.py

2005-10-10 Thread John Fouhy
you combine your loops into one, you should be able to save a lot of time. eg: for e in saveRemovedForLaterL: L.append(e) counts = {} for word in L: if not word: # This skips empty words. continue try: counts[word] += 1 except KeyError: counts[word] = 1 F = [(count, word) for word, count in counts.iteritems()] -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tutor Digest, Vol 20, Issue 37

2005-10-10 Thread John Fouhy
do learn what you're doing :-) I recommend Thinking in Tkinter: http://www.ferg.org/thinking_in_tkinter/ -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] launching and monitor from make

2005-10-12 Thread Ertl, John
message to make? Thanks, John Ertl ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Ertl, John
Ewald, That easy...If you know. Thanks for the example and the help. Now lets see if I can modify the make file without upsetting the make god. Thanks again. John Ertl -Original Message- From: Ewald Ertl [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 12, 2005 7:40 AM To

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Ertl, John
Alan, Thanks, just as you and Ewald said it works great. Almost too easy...I have this feeling something will turn around a bite me once it goes to ops. Thanks again John Ertl -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 12

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Ertl, John
to get the number of files John -Original Message- From: Marc Buehler [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 12, 2005 11:10 AM To: tutor@python.org Subject:[Tutor] how to extract number of files from directory hi. i'm new to Python ... i would like

Re: [Tutor] help with elif statements

2005-10-12 Thread John Fouhy
Which is the first branch of your IF statement to be true if you enter, say 18? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] passing variable to python script

2005-10-13 Thread John Fouhy
1 2 foo ['testargv.py', '1', '2', 'foo'] If you want to do anything vaguely complicated, have a look at the getopt and optparse modules. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] multiple assignment

2005-10-17 Thread John Fouhy
t, repeat(None)), 7) >>> print a, b, c, d, e, f, g 1 2 3 None None None None >>> a, b, c, d = islice(chain(lst, repeat(None)), 4) >>> print a, b, c, d 1 2 3 None >>> a, b = islice(chain(lst, repeat(None)), 2) >>

Re: [Tutor] is mxDateTime recommended?

2005-10-20 Thread John Fouhy
e I've come across is that mxDateTime has a .strptime() function (for parsing a string like "10/12/2005"), and python DateTime doesn't (so you have to go via the time module). -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] pytunes (Was __slots__, struct, etc.)

2005-10-20 Thread John Fouhy
eople would solve this problem :-) ) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Dynamic Function Assignment

2005-10-20 Thread John Fouhy
('A', 'B', 'C'): if segment.upper().startswith(c): myObjects[c].doSomething(segment) If your MyObject instances are going to be constructed in a systematic way, then you could simplify your definition of myObjects a bit m

Re: [Tutor] pytunes (Was __slots__, struct, etc.)

2005-10-24 Thread John Fouhy
that artist down to position total/len(tracks). Repeat until all tracks have been selected :-) Generally it works well, except at the end of the playlist sometimes. See attachment for my implementation. (uses mmpython, which you can find on the net) -- John. On 21/10/05, Liam Clarke <[EMAIL P

Re: [Tutor] Tkinter Data Passing Problem

2005-10-24 Thread John Fouhy
cannot > figure out why. > > Can someone help? I'm not sure if I understand exactly --- but it is generally an error to make two root windows. If you want to have additional windows on your screen, look into the Toplevel() class. -- John. ___

Re: [Tutor] manipulating list of lists

2005-10-24 Thread John Fouhy
th python2.4, you can use the key= argument to sort. eg: >>> arr = [('a', 5), ('b', 3), ('c', 7), ('d', 1), ('e', 2)] >>> arr.sort(key=lambda x: x[1]) >>> arr [('d', 1), ('e', 2), ('b', 3), (&#x

Re: [Tutor] manipulating list of lists

2005-10-24 Thread John Fouhy
th python2.4, you can use the key= argument to sort. eg: >>> arr = [('a', 5), ('b', 3), ('c', 7), ('d', 1), ('e', 2)] >>> arr.sort(key=lambda x: x[1]) >>> arr [('d', 1), ('e', 2), ('b', 3), (&#x

Re: [Tutor] Tainted characters and CGI

2005-10-31 Thread John Fouhy
ertain HTML tags but letting others through. """ Link: http://www.mcs.vuw.ac.nz/~jester/zstr/ -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] draw lines

2005-11-06 Thread John Fouhy
Lundh's site: http://effbot.org/tkinterbook/canvas.htm -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Object instances

2005-11-06 Thread John Fouhy
we can get at testList2. >>> f.testList2 [] We can also get at testList in the same way --- but testList belongs to the class, not the instance. >>> f.testList [5] >>> f.testList is f.__class__.testList is Foo.testList True I guess the same thing happe

[Tutor] TKinter Question

2005-11-08 Thread John Fouhy
inally, you could try the Widget Construction Kit: http://effbot.org/zone/wck.htm This is quite new, however, so you might not get any help here (unless there's some WCK experts hiding here somewhere :-) ). -- John. ___ Tutor maillist - Tutor@python.

Re: [Tutor] Testing for gui

2005-11-08 Thread John Fouhy
environment. What happens if you try to create a GUI and X is not running? Maybe you could just try to create a Tkinter.Tk() --- if it throws a python exception (probably TclError), you could just catch that. -- John. ___ Tutor maillist - Tutor@python

Re: [Tutor] Problem appending to a list using a property within a class

2005-11-08 Thread John Fouhy
t;class ShoppingBag(object):". This is a somewhat annoying distinction that will hopefully go away in a future version of python (when all classes become new style). -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] [OT] triangulation

2005-11-09 Thread John Fouhy
c. are in (say) German? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Newbie Anxiety

2005-11-10 Thread John Fouhy
d. The range() function is useful for building lists like that, so we don't have to type it out manually. count to 9 for i in range(10): print i And, of course, once we've got range(), we can give it a variable limit (eg, n = 10; range(n)). Iteration is th

Re: [Tutor] iteritems() vs items()

2005-11-13 Thread John Fouhy
r loop is basically equivalent to this: it = s.iteritems() while True: try: key, value = it.next() except StopIteration: break # do something with key, value HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Converting a List/Tuple to delimited string

2005-11-13 Thread John Fouhy
gt;> lst = ['ab', 'cd', 'ef'] >>> ':'.join(lst) 'ab:cd:ef' In general, foo.join(lst) (where foo is a string) is equivalent to: def join(foo, lst): if not lst: return '' s = lst[0] for item in lst[1:]: s += foo

Re: [Tutor] Do I have to initialize TKInter before I can use it?

2005-11-14 Thread John Fouhy
e you having problems? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Do I have to initialize TKInter before I can use it?

2005-11-14 Thread John Fouhy
On 15/11/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: > > > John and all, > > I am having problems. The latest error message I got was: > Traceback (most recent call last): > File "D:\Python24\hockey.py", line 19, in -toplevel- > tkMessageBox.showinfo(&

Re: [Tutor] Do I have to initialize TKInter before I can use it?

2005-11-14 Thread John Fouhy
On 15/11/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: > John, > > I learned it from the docs on pythonware.com - the introduction to TKInter - > Standard Dialogs. > Since it doesn't exist, how can I show a info box before the main part of my > program? Ok, let'

Re: [Tutor] Creating Tkinter Menubars

2005-11-16 Thread John Fouhy
= option (like in Michael's post, which also works for me). ...wait, hang on. I don't own a Mac, but isn't the standard for Macintoshes to stick the menu bar along the top of the screen? Is it appearing up there instead? -- John. ___ Tutor ma

Re: [Tutor] compiled images

2005-11-17 Thread John Fouhy
binary string, you can use the StringIO module) There may be space or time issues --- you might want to experiment :-) --- but it will definitely be cross-platform. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Random Numbers

2005-11-20 Thread John Fouhy
one element from that list at random. For example, I can generate some random numbers in the range 0..9 like this: >>> import random >>> for i in range(10): ... print random.randrange(10) ... 8 2 0 9 7 5 8 0 7 9 >>> HTH! -- John. ___

Re: [Tutor] Tkinter modal dialogs

2005-11-21 Thread John Fouhy
Hi Karsten, You might want to look at Python MegaWidgets: http://pmw.sourceforge.net/ PMW is an alternative to Tix, built using only python and basic Tkinter. It has a scrolled listbox widget and a way of easily creating modal dialogs. -- John

Re: [Tutor] reduce with comprehension

2005-11-21 Thread John Fouhy
[7, 71, 72], [8], [9]] We can even go a level deeper! >>> [x for z in a for y in z for x in y] [1, 2, 3, 31, 32, 4, 5, 6, 7, 71, 72, 8, 9] Just make sure your depth is consistent throughout. And remember that that single-line expression is hiding nested FOR loops! -- John. _

Re: [Tutor] Ellipsis syntax

2005-11-21 Thread John Fouhy
ment your own classes if you want (say, if you want to implement multidimensional arrays). -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] command in menu and button

2005-11-22 Thread John Fouhy
back, it doesn't give it any arguments. But, that's OK. You can just define a new function: def callback(): os.system("Open my viewer &") menu.add_command(label="Open Viewer", command=callback) Does this help? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] sort list alphabetically

2005-11-23 Thread John Fouhy
his is more efficient, I believe, because the key function is only called once for each element, whereas cmp is called more than once. (we could use string.upper here instead of defining our own, but string.upper is deprecated these days...) -- John. ___

Re: [Tutor] reduce with comprehension

2005-11-24 Thread John Fouhy
. >>> def f(x, y): ... return x*y ... >>> arr = range(1, 10)# Don't want to include 0! >>> reduce(f, arr) # Our target 362880 >>> tmp = [1] >>> [f(x, y) for x in arr for y in [tmp[-1]] if tmp.append(f(x, y)) or True][-1] 362880 >>&

Re: [Tutor] reduce with comprehension

2005-11-24 Thread John Fouhy
ur target > > 362880 > > >>> tmp = [1] > > >>> [f(x, y) for x in arr for y in [tmp[-1]] if tmp.append(f(x, > > y)) or True][-1] > > 362880 > > >>> print 'Magic!' > > Magic! > > LOL I feel like I've accidentally

Re: [Tutor] Convert integer number to binary representation

2005-11-24 Thread John Fouhy
ActiveState that will do base conversion --- here's a simple one for binary numbers that takes advantage of the correspondence between binary and hexidecimal representations of numbers: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528 -- John. ___

Re: [Tutor] Read Excel file without COM

2005-11-29 Thread John Fouhy
ard time getting to that. It does a great > job writing Excel files. Yeah, I like pyExcelerator, but the documentation lacks in places :-) Just call pyExcelerator.parse_xls() on the filename you wish to parse. -- John. ___ Tutor maillist - Tutor@py

Re: [Tutor] Question

2005-11-29 Thread John Fouhy
. You could also try IDLE, which comes with python. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

<    1   2   3   4   5   6   7   8   9   10   >