Re: [Tutor] wx.Notebook query in wxpython

2006-08-10 Thread John Fouhy
how the respective tab and unchecking should hide > it. [...] Hi Amresh, I suggest you try asking on the wxPython list, [EMAIL PROTECTED] (you will probably have to subscribe first). The people on that list are both very knowledgable and very

Re: [Tutor] Rock, Paper, Scissors

2006-08-10 Thread John Fouhy
oice >if human.choice == computer.choice: >print "Draw!" >elif human.choice == 'rocks' and computer.choice == > 'paper': >print "Computer wins!" >computer.points = compute

[Tutor] self (again)

2006-08-13 Thread John Aherne
d by reference if several people log in at once and run the code. Hope I have explained myself so people can understand what I mean. Looking forward to the light of understanding. Regards John Aherne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] key_press_event

2006-08-13 Thread John CORRY
xt entry box. Is there a way to catch the key_press (in this case the 'a') and check to see if it is a number. If it is not a number, ignore it. If it is a number accept it. Why does the 'a' appear in 'atest'. It is like the code works first, sets the text to

Re: [Tutor] [pygtk] key_press_event

2006-08-13 Thread John CORRY
Sandro, That's exactly what I need. Thanks, John. > def callback3(self,data,widget): > > input = data.get_text() > print input > data.set_text("test") If you don't return True, default callback will be called that ins

Re: [Tutor] how to remove html ags

2006-08-14 Thread John Fouhy
On 15/08/06, anil maran <[EMAIL PROTECTED]> wrote: > hi luke > i tried to do this for 2 weeks using the regexps > i couldnt find it > and hence i was asking you guys > thanks > anil What have you tried? What problems we

Re: [Tutor] Global variables

2006-08-14 Thread John Fouhy
> > in fermat: > > fac = strongfac(z) > print fac > > prints [0,0,0] > > And most of the time it does not misbehave like this. Can you post actual code to illustrate the problem? Don't post your entire module; just show us the functions involved, the input t

Re: [Tutor] threading

2006-08-15 Thread John Fouhy
read): def run(self): self.running = True while(self.running): # do stuff def stop(self): self.running = False In this case, the you call .stop() on your Worker object, and the thread will exit when it next gets to the top of th

Re: [Tutor] (no subject)

2006-08-17 Thread John Fouhy
On 18/08/06, Amadeo Bellotti <[EMAIL PROTECTED]> wrote: > thank you but IDLE doesnt seem to work on Suse 9.2 do you know a way to fix > it? Why not -- what goes wrong? Is there an error message? -- John. ___ Tutor maillist - Tutor@pyt

Re: [Tutor] (no subject)

2006-08-17 Thread John Fouhy
l, but I expect that you can fix this by installing a package called something like "python-tkinter". -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Making a better main() : Critique request

2006-08-20 Thread John Fouhy
ong type. I've only just started playing with it myself, but it looks pretty nifty :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] custom container subclassing list-- slices are lists!?

2006-08-21 Thread John Fouhy
t; Have you tried implementing __getitem__ and __setitem__ for slice objects? (see http://docs.python.org/ref/sequence-methods.html and http://docs.python.org/ref/sequence-types.html#l2h-231) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] custom container subclassing list-- slices are lists!?

2006-08-21 Thread John Fouhy
this handled by list? Should be handled by the list. For instance if x is a list, then list(x) is a copy of x (y=list(x) is equivalent to y=x[:]). But you should be able to test this easily enough.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] banners

2006-08-23 Thread John Fouhy
#x27; ## '] def getWidth(self): return max(len(s) for s in self.rows) def getRow(self, i): return self.rows[i] Then to print a string: s = 'John Fouhy' letters = [Letter(c) for c in s] for i in range(HEIGHT): for letter in letters: print &#x

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

2006-08-23 Thread John Fouhy
What does the python interpreter tell you when you run the code? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Adding the current working directory to the Windows path

2006-08-23 Thread John Fouhy
ystem variables list control. Click "Edit" and make the changes you want... Remember the days when information like this was actually _documented_? :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

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

2006-08-23 Thread John Fouhy
s where the syntax error is, sure enough. Your editor told you; you didn't need to ask us. In order to fix this bug, you need to figure out what you want to achieve with this line of code, and then look at the documentation or tutorials to figure out how to write the code correctly. -- John. _

Re: [Tutor] Query to the tutor mailing list

2006-08-24 Thread John Fouhy
ead throughout each chapter. Also, creating good problems seems to me like it would be a difficult thing to do, without plagiarising existing works. Have you tried looking at programming books, or online tutorials (eg, Alan Gauld's? Or I think "How to think like a computer scient

Re: [Tutor] Displaying in columnar / tabular form

2006-08-24 Thread John Fouhy
w, s) will be the string s, padded to width w. (I always forget whether it gets padded on the left or on the right, but you can always reverse it by adding a -: '%-*s' ) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A list of ints to a strings

2006-08-25 Thread John Fouhy
gt;>> z '1 2 3 4 5' If you want to put one number on each row, you can use the newline character '\n' as a separator instead: >>> '\n'.join(y) '1\n2\n3\n4\n5' >>> print '\n'.join(y) 1 2 3 4 5 HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] making independent program?

2006-08-28 Thread John Fouhy
hing goes wrong), especially if you can find someone to throw a sample setup.py at you. There are people on this list who can help.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How would I make a program that password protects on an inactivity timer?

2006-08-28 Thread John Fouhy
tually used global grab before (it's pretty bad manners!), but I think it will restrict all input to itself, and refuse attempts to let anything else have focus. Not certain, though. But it may be worth a try. -- John. ___ Tutor maillist - Tutor@pytho

Re: [Tutor] Can you tell me whats wrong with this code?

2006-08-30 Thread John Fouhy
int and understand what it does, but they won't know exactly what "rand" does without looking through the rest of your code. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] GUI Programing

2006-08-31 Thread John Fouhy
ld get something written in the traditional, C++ style. Until you learn to recognise the latter and transform it to the former, you may find learning from the web difficult. Both Tkinter and wxpython should work across all platforms. -- John. _

Re: [Tutor] Hi All

2006-09-02 Thread John Purser
- Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor What he said! John Purser -- Be careful! Is it classified? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] pretty_printing

2006-09-03 Thread John Fouhy
ling to accept the odd error. I'm not sure how you want to go about colourizing things, though. If you have a postscript printer, you could generate your own postscript, maybe.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] File open error

2006-09-04 Thread John Fouhy
uot;, "r") > TypeError: an integer is required Looks like you're redefining 'open' somewhere. Look through your code; do you have anything like: def open(...): or open = or from ... import open or from ... import * ? -- John. __

Re: [Tutor] A simple list question...

2006-09-07 Thread John Fouhy
etter way to achieve my objective (ie. a list method > for generating the cleaned list?) cleanedlist = list(set(mylist)) If you don't have python 2.4+, you will need to import the sets module. Also, depending on what you are doing with cleanedlist, you could just leave it as a set

[Tutor] Dates

2006-09-09 Thread John CORRY
",)) for row in c.fetchall(): print row row = str(row) c.close() Is there a way to format the date so that the Select statement works? Thanks, John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Dates

2006-09-10 Thread John CORRY
_weekst >= date(?) and rt_weekst <= date(?) and rt_type == ?', (c,d,"R",)) ProgrammingError: ('37000', 229, '[Microsoft][ODBC Visual FoxPro Driver]Too few arguments.', 4579) Thanks for any suggestions. John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Dates

2006-09-10 Thread John CORRY
(a,b,"R",) db = mx.ODBC.Windows.DriverConnect('DSN=tnt') c = db.cursor() c.execute(sql) As you rightly pointed out, I needed to get my sql string formatted and working before putting it anywhere near the c.execute command. Many thanks, John. __

Re: [Tutor] Traversing Excel Columns

2006-09-11 Thread John Fouhy
Will there be internal blanks? You could just scan for Cells(row, col).Value in (None, ''). Otherwise, run makepy.py (if you haven't already) on Excel, and then look through the code it generates. It will show you all the methods you can call, and what arguments they expe

Re: [Tutor] Traversing Excel Columns

2006-09-12 Thread John Fouhy
do this (one-time only), your code should run faster. Also, you will get meaningful help(), and you can look at the code it produces to get a quick list of all the available methods, and what arguments they expect. You can run it from the command line, or you can run it from the menu of the pythonwin

Re: [Tutor] Methods and classes

2006-09-13 Thread John Fouhy
self.x = 1 self._y = 2 self.__z = 3 f = Foo() print f.x print f._y print f.__z > I'm 'trying' to write clear pythonic code since in all reality it gives > a nice polish to the code when compared to writing c style. I don't think you'll find many here who disagree with that :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] what happens when...

2006-09-13 Thread John Fouhy
do you get? What do you think it means? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Methods and classes

2006-09-13 Thread John Fouhy
ain because it can't find one with that name. If you write: def increment(): self.value = self.value + 1 then you're referring to this variable called "self", but where is it coming from? There's no global variable "self", it's not one of the p

Re: [Tutor] (no subject)

2006-09-14 Thread John Fouhy
open('/Users/timothy/Desktop/t' , 'r') for line in input: # ... So, in the body of the for loop, all you would need to do is decide what to call the new file, open the file, write line to it, and then close it. -- John. ___

Re: [Tutor] arrays

2006-09-14 Thread John Fouhy
ave an earlier version of python, you can define your own comparison function: def myCmp(x, y): return cmp(keyToInt(x), keyToInt(y)) arr.sort(myCmp) You can also use the decorate-sort-undecorate idiom, which may be faster than a custom comparison function if the list is very large. decorated =

Re: [Tutor] tuples versus lists

2006-09-14 Thread John Fouhy
Generally, you should use a tuple when you have different things that you want to clump together to make one data structure. Whereas you should use a list when you have multiple things that are the same, that you want to iterate over. -- John

Re: [Tutor] looping problem

2006-09-23 Thread John Fouhy
o see evidence before committing to that statement :-) ) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] opening files

2006-09-25 Thread John Purser
hon.org/mailman/listinfo/tutor Hello Max, my_file = open('c:\\path\to\file\file.txt', 'r') my_file.readlines() my_file.close() Really, it's so simple it's hard to come up with directions. Just do it. John Purser ___

Re: [Tutor] Is my Python install hosed?

2006-10-01 Thread John Fouhy
t;, "credits" or "license" for more information. >>> raise SystemExit Morpork:~ repton$ >From IDLE: IDLE 1.1.3 >>> raise SystemExit Traceback (most recent call last): File "", line 1, in -toplevel- raise SystemExit SystemExit >>&

Re: [Tutor] Creating Adventure Games Python Port - Chapter 2

2006-10-01 Thread John Fouhy
#x27;tails']) 'tails' >>> [random.choice(['heads', 'tails']) for i in range(10)] ['tails', 'tails', 'heads', 'tails', 'tails', 'tails', 'heads', 'heads', 'heads', 'heads'] -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] One of my 'baby step' programs

2006-10-01 Thread John Fouhy
; for i in range(10): ... break ... else: ... print 'foo' ... >>> for i in range(10): ... pass ... else: ... print 'foo' ... foo >>> There was a discussion of for..else linked in Dr Dobb's Python URL recently: http://grou

Re: [Tutor] One of my 'baby step' programs

2006-10-02 Thread John Fouhy
ss', which is python's do-nothing statement. So the loop will exit normally, and the else: clause will execute (resulting in the string 'foo' being printed). Does this help? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] My number-guessing program

2006-10-02 Thread John Fouhy
e should tell people to use random.randrange instead of random.randint! (random.randrange takes up to 3 arguments with exactly the same meanings as range()) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] save configuration of one application.

2006-10-03 Thread John Fouhy
.py or the old > code will be used instead. The python interpreter should check the timestamps on foo.py vs foo.pyc, and recompile if it thinks things have changed. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Integer division Help requested

2006-10-03 Thread Joseph John
    Advice requested   Thanks   Joseph John     ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Menus / Mac

2006-10-09 Thread John Fouhy
(MBPro, Tiger) Remember that macs have a universal menu bar. If you click on the window it created, the menubar at the top should change appropriately. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] multithreading random()

2006-10-09 Thread John Fouhy
/wiki/Double_precision and here: http://en.wikipedia.org/wiki/IEEE_floating-point_standard Basically, floating point numbers are of the form "x times 2**y", where x is a binary number between 1 and 10 (that's binary 10, decimal 2). 53 bits means 53 binary digits of precision (

Re: [Tutor] multithreading random()

2006-10-09 Thread John Fouhy
to seed from current time). """ g = Random(firstseed) result = [g] for i in range(num - 1): laststate = g.getstate() g = Random() g.setstate(laststate) g.jumpahead(delta) result.

Re: [Tutor] multithreading random()

2006-10-10 Thread John Fouhy
random.py before I found those, though. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] multithreading random()

2006-10-10 Thread John Fouhy
;t include the 'L': >>> str(999L) '999' >>> repr(999L) '999L' I think the answer is "approximately, yes". But you have to be a bit careful with talking about floating point nu

Re: [Tutor] Help me with this Tkinter code

2006-10-10 Thread John Fouhy
On 11/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > shouldn't you mainloop your root? By convention, you should, but you don't have to. mainloop is mainloop; calling it on root just makes it easy to find. -- John. ___ Tutor

[Tutor] Tip: Firefox quicksearch for module docs

2006-10-10 Thread John Fouhy
the search bar, and go straight to http://www.python.org/doc/current/lib/module-random.html. Nifty :-) (more quick searches here: http://wormus.com/leakytap/Internet/CustomKeywordspython ) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to check whether a file exists or not??

2006-10-12 Thread John Fouhy
f.write('Hello ') >>> f.close() >>> f = open('foo', 'a') >>> f.write('world!') >>> f.close() >>> f = open('foo', 'r') >>> f.read() 'Hello world!' -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] A puzzle for you

2006-10-13 Thread John Fouhy
>From the python_dev LiveJournal community --- Predict the outcome of the following code: ## from random import * seed() [choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0] ## -- John. ___ Tutor maillist - Tutor@python.org h

Re: [Tutor] How to save and later open text from a wxTextCtrl widget to a text file?

2006-10-16 Thread John Fouhy
eAsButton.Bind(wx.EVT_BUTTON, saveas) You could also modify save() to automatically call saveas() if self.filename is not set. (just be careful of recursion if the user clicks cancel!) Loading is the same except in the opposite direction. Look at wx.Text

Re: [Tutor] extracting numbers from a list

2006-10-16 Thread John Fouhy
1])], zip(map((1).__add__, lst[1:]), lst[2:])) ... >>> pairs(a) [(10, 15), (16, 18), (19, 20), (21, 25), (26, 30), (31, 40)] -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] How to save and later open text from a wxTextCtrl widget to a text file?

2006-10-16 Thread John Fouhy
On 17/10/06, Pine Marten <[EMAIL PROTECTED]> wrote: > > Thank you John for the code but I still can't get it to work and to simply > save the contents of the text box to a file. Here is the code I have which > just makes a panel with a text control and two buttons, "

Re: [Tutor] A puzzle for you

2006-10-17 Thread John Fouhy
On 18/10/06, Terry Carroll <[EMAIL PROTECTED]> wrote: > On Sat, 14 Oct 2006, John Fouhy wrote: > > > >From the python_dev LiveJournal community --- > > > > Predict the outcome of the following code: > > > > ## > > from random import * > > s

Re: [Tutor] Searching list items.

2006-10-17 Thread John Fouhy
bject. So, you can do this: for line in contents: m = re.search('something', line) if m: print line[m.start():m.end()] match objects become more powerful when you start using groups or named groups in your regular expressions. See the documentation for more :-) -- John

Re: [Tutor] Location of found item in list.

2006-10-18 Thread John Fouhy
tion. Um, I'm still a bit confused. Suppose item == list2[10]. Does that mean you want to print item and list2[10]? Won't that just mean you print item twice? You can find the position of an element in a list by using the list.index() method, but I'm still not sur

Re: [Tutor] Location of found item in list.

2006-10-18 Thread John Fouhy
On 19/10/06, Chris Hengge <[EMAIL PROTECTED]> wrote: > The point of this script is to read a text file that has a bunch of code > that calls external files. Then read the directory where all the files are.. > I build a list from the text file (this works correct), and I build a list > from the dire

Re: [Tutor] Location of found item in list.

2006-10-18 Thread John Fouhy
t '%20s%20s%20s' % ('Fail!', item, '') You can modify near_match if you have some other definition of what you want it to return. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Location of found item in list.

2006-10-18 Thread John Fouhy
prizes for writing the shortest code possible, or for using the fewest language features you can.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] property built-in

2006-10-19 Thread John Fouhy
There's also a good point made here: http://www.artima.com/forums/flat.jsp?forum=122&thread=119914 Basically, if you want a read-only attribute, you _can_ create it by using the built-in property as a decorator: @property def x(self): return self.__x equivalent to def

Re: [Tutor] Please comment on this code...WORD FREQUENCY COUNTER

2006-10-23 Thread John Fouhy
x27;, say 'frequencies' instead of 'item' say 'word' So you could end up with: textfile = open(fname, 'r') for line in textfile: for word in line.split(): # do something with word HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] can i pass a list to a function and get one back ?

2006-10-23 Thread John Fouhy
On 23/10/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > or for that matter >return range(some_var:some_var+5) [nit-pick] That would be range(some_var, some_var+5) :-) -- John. ___ Tutor maillist - Tutor@python.org http://mai

Re: [Tutor] Self, Scopes and my unbelievable muddleheadedness.

2006-10-25 Thread John Fouhy
__init__? Then to use: gadflyDB = GadflyConnection(...) I'm not sure what you want to do with your database, so I can't really give you a bigger use example. But do you see what is going on? In createDB(), you create a new gadfly connection, and then assign it to 'self.d

Re: [Tutor] Suggestions about documenting a function

2006-10-30 Thread John Fouhy
randomList(1, 9, 9)) == range(1, 10) >>> randomList(1, 10, 0) == [] >>> randomList(4, 3, 2) AssertionError >>> randomList(7, 8, 5) AssertionError >>> randomList(-5, 7, 9) AssertionError """ (those things at the end

Re: [Tutor] Mapping to object attributes

2006-10-31 Thread John Fouhy
.FieldStorage() widget = Widget() for form_field in form_field_object_map: setattr(widget, form_field_object_map[form_field], form.getvalue(form_field)) HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] str.strip() help

2006-11-01 Thread John Fouhy
t;> 'I want to strip words.' .strip() only removes text from the beginning and end of the string. eg: >>> myStr = 'my words are what I want to strip' >>> print myStr.strip('my') words are what I want to strip You can use

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread John Fouhy
sec per loop Morpork:~ repton$ python -m timeit -s 'import re' -s 'r = re.compile("[0-9A-Za-z_.-]")' 'r.match("J")' 100 loops, best of 3: 1.16 usec per loop -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Amazing power of Regular Expressions...

2006-11-06 Thread John Fouhy
h("J")' -s means "startup code". So, 'import re' and 're.compile(...)' happen only once, before the main test starts. You can read help on timeit by typing 'import timeit; help(timeit)' in the python console. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Ruby Code Blocks vs. Python Lambdas

2006-11-07 Thread John Fouhy
: PEP3099 (http://www.python.org/dev/peps/pep-3099/) makes this seem unlikely.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with Elementtree ...how to access the attributes..

2006-11-09 Thread John Fouhy
structure -- perhaps: Bill Gates Steve Jobs Larry Wall That way, you could do: >>> founderElements = companiesByName['ndtv'].findall('founder') >>> founders = [f.text for f in founderElements] and that would give you the founder names in a list, regar

Re: [Tutor] Help me with this problem relating to datetime

2006-11-15 Thread John Fouhy
nge. Which part are you having trouble with? To convert a string into a Date or Datetime object, use time.strptime(), and then build a Datetime from the resulting time_tuple. (in Python2.5, I think, the datetime module has its own strptime() function, w

Re: [Tutor] .sort(key = ???)

2006-11-16 Thread John Fouhy
Since this is a common thing to do, there is a function in the operator module that you can use, instead of defining your own: import operator a.sort(key=operator.itemgetter(4)) (operator.itemgetter(4) will return a function that is basically equivalent to item4() above) HTH! -- John. ___

Re: [Tutor] .sort(key = ???)

2006-11-16 Thread John Fouhy
orate: Morpork:~/offlode repton$ python -m timeit -s 'import math' -s 'import operator' -s 'a = [(i, math.sin(i)) for i in range(1)]' 'b = [(e[1], e) for e in a]' 'b.sort()' '[e[1] for e in b]' 10 loops, best of 3: 33.9 msec per loop Ho hum.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with the following code..

2006-11-23 Thread John Fouhy
(x0+w, y0) (x0+w, y0+h) (x0, y0+h) I suggest experimenting to figure out which... -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] shebang question

2006-11-25 Thread john maclean
t; what is the difference between > #!/usr/bin/python > and > #!/usr/bin/env python > ? > > thanks > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/t

[Tutor] adjust key bindings

2006-11-26 Thread John CORRY
t;z" key press and assign a "Down" key press but I can't get the "Down" key press to register on the Treeview in the GUI. Any thoughts greatly appreciated. Thanks, John. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf

Re: [Tutor] python exceptions

2006-11-26 Thread John Fouhy
agine the Tkinter mainloop() does something like: try: callback() except: # print trace to stderr This is the only possibility I can think of at the moment. But there could be other things going on, which is why we'd like to see an example. -- John.

Re: [Tutor] python exceptions

2006-11-26 Thread John Fouhy
s opposed to, say, part of the interpreter), it's just not code that you've written yourself. Different GUIs might do things differently.. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help with Tkinter, please

2006-11-26 Thread John Fouhy
On 27/11/06, Dick Moores <[EMAIL PROTECTED]> wrote: > Well, I'm having a terrible time with grid(). I do have the 6 buttons > in the same row, but they're a real mess. Someone please run this and > tell me how to get them looking better. I'm not certain exactly what layout you want, but have a loo

Re: [Tutor] to learn

2006-11-26 Thread John Fouhy
as well, but it will lack the mac-specific features. macports will make installing some modules easy, though. For what it's worth, I am using python on a mac and I am not using the macports version. Hope this helps. -- John. ___ Tutor maillist

Re: [Tutor] help with Tkinter, please

2006-11-26 Thread John Fouhy
. Process events ==> call "exit" button callback. 7. Python exits. So, you can see why clicking your exit button won't interrupt the calculation in progress. The only way you can do that is if you can get the event loop to start looking for events again before the callback finish

Re: [Tutor] moving from pack to grid in tkinter

2006-11-26 Thread John Fouhy
. The root window Tk(), and any windows you create using Toplevel(), will display themselves. Other widgets need to be put inside a frame and pack()ed or grid()ded (or place()d). HTH! -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] adjust key bindings

2006-11-27 Thread John CORRY
# Ctrl-S > 0x14: 'tree', # Ctrl-T > ord('0'): 'bookmark_0', > ord('1'): 'bookmark_1', > ... > > > with such a keytable I am able to bind different 'def's to every > existing

Re: [Tutor] e: moving from pack to grid in tkinter

2006-11-27 Thread John Fouhy
the same frame. > Well thanks anyway. The pdf has really confused me. > Is there an official tkinter.org doc reference or something? Um, not really. There are official Tk docs (at http://tcl.tk), and a few sites around with Tkinter docs (effbot, New Mexico Tech), but

Re: [Tutor] Convert string to file handle

2006-11-27 Thread John Fouhy
nce reasons i want to run this > entire process within the physical memory! Have a look at the StringIO module: http://www.python.org/doc/current/lib/module-StringIO.html -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to generate permutations of a given string

2006-11-27 Thread John Fouhy
n.org/pipermail/tutor/2005-May/038059.html -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Extract from Word Doc

2006-11-28 Thread John Fouhy
('myworddoc.doc').read() >>> t = ''.join(c for c in s if c in string.letters+string.digits+string.punctuation+string.whitespace) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Best Known Method for Filtering redundant list items.

2006-11-30 Thread John Fouhy
fact, you can think of a set as a dictionary where the values are always True (or something), and you only care about the keys. eg: >>> import itertools >>> list1 = ['1', '1', '2', '3', '4'] >>> list2 = dict(zip(list1, itertools.repeat(True))).keys() >>> list2 ['1', '3', '2', '4'] -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Why is startfile unavailable on my mac?

2006-12-04 Thread John Fouhy
On 05/12/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > The docs for os.startfile() say it is available on Windows only. Hmm, well you could do a basic Mac version of startfile like this: def startfile(fn): os.system('open %s&#x

Re: [Tutor] Integer?

2006-12-05 Thread John Fouhy
depending on exactly what you mean by "integer". -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Starting over with Python

2006-12-13 Thread John Carmona
After quite a while away from Python, I have decided to re-study Python. I am interested to learn Python to support my love for Cryptography. I have a first very easy question (did some search on Google but could not find anything helpful). I realise that this is very basic so be gentle with me.

Re: [Tutor] Best method for filtering lists in lists...

2006-12-19 Thread John Fouhy
lem])) return lst According to timeit, this is over five times slower than the one-line solution: def nodupes2(lst): return [list(y) for y in set(tuple(x) for x in lst)] Finally, neither of these are order-preserving... -- John. ___ Tutor maillis

Re: [Tutor] Embedding strings in a python script

2007-01-03 Thread John Fouhy
by cvs? What about this: cvs_header=''' ### # # @Header:@ # # @Revision:@ # @Author:@ # @Date:@ # '''.replace('@', '$') ? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

<    3   4   5   6   7   8   9   10   11   >