Re: [Tutor] Hi

2010-11-06 Thread Alan Gauld
"Luke Pettit" wrote I was interested in which video tutorials Glen was watching, and if anyone else could recommend some video tutorials to watch, I don;t know what Glen was watching but thhere are a whole bunch of videos at showmedo.com Alan G. __

Re: [Tutor] Displaying Pictures & Text

2010-11-06 Thread Alan Gauld
"Patty" wrote I thought I wouldn't need Tkinter. I thought Tkinter is yet another addon library Tkinter is the standfard GUI toolkit for Python and as such comes as part of the standard library. (Although you do have to compile Python with that option enabled in some Linux distros)

Re: [Tutor] Displaying Pictures & Text

2010-11-06 Thread Alan Gauld
tutorials for both PIL and Tkinter on the Pythonware site: http://www.pythonware.com/products/pil/index.htm http://www.pythonware.com/products/tkinter/index.htm Or you can try the intro to GUI programming in my tuitorial. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] Interactive visualization in python

2010-11-07 Thread Alan Gauld
version is included in the Tix module which extends the basic Tkinter widgets. The documentation is not fantastic but ithere should be enough to get you going. I'm pretty sure wxPython will have one too. HTH, -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] trying to generate change in print output

2010-11-07 Thread Alan Gauld
econd message when it is equal to 1 tyou get the first. What did you expect? And how are you generating the repeated results? Do you have a loop somewhere or just repeatedly run the same code? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] List comprehension question

2010-11-07 Thread Alan Gauld
reas y is 7. But in C only the first is referred to as a cast. Not directly relevant in a Python thread but it can cause confusion if newbies see references to casting in the C sense and think it means type conversion. Just feeling picky, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] List comprehension question

2010-11-08 Thread Alan Gauld
)) if n%x == 0) I'd have expected ** to be significantly faster than calling the function, and given this is a performance tweak...? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@pytho

Re: [Tutor] List comprehension question

2010-11-08 Thread Alan Gauld
"Stefan Behnel" wrote Why use math.sqrt() instead of just using the ** operator? return sum(x for x in range(1, int(n**0.5)) if n%x == 0) Since this operation is only evaluated once in the whole runtime of the loop, I think readability beats the likely very tiny performance difference here

Re: [Tutor] List comprehension question

2010-11-08 Thread Alan Gauld
"Stefan Behnel" wrote On another note, getting rid of the list comprehension and using a generator expression will be even faster, since you won't have to build the list. I gave this suggestion a try. It is true for me when run in CPython 3.2: However, it is no longer true when I run the

Re: [Tutor] Server

2010-11-08 Thread Alan Gauld
settings. It's hard to be specific. If the code works on localhost it is unlikely to be the code at fault. More likely to be a network issue, either a wrong IP address, port address or, sorry, a firewall setting. -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] Too different 2.6 vs 2.7?

2010-11-08 Thread Alan Gauld
s stick with it for now till somebody in Ubuntu land fixes the issue. I still use 2.4 on my netbook, 2.5 on my Mac and 2.6 (and 3.1) on my desktop PC. I've been thinking of giving 2.7 a whirl but I'm in no hurry... -- Alan Gauld Author of the Learn to Program web sit

Re: [Tutor] Commercial or Famous Applicattions.?

2010-11-08 Thread Alan Gauld
here. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List comprehension question

2010-11-09 Thread Alan Gauld
"Richard D. Moores" wrote Question: When I dump in more that one line of any code (properly indented), after running it once, I've never known how to run it again without a redump. The up arrow just gets me one line at a time. So, how to do it? It depends on your IDE. On IDLE I think its

Re: [Tutor] variables question.

2010-11-10 Thread Alan Gauld
would normally? No. I guess this is more about HOW and WHERE I can make variables available for use. See my tutorial topic... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Tutor Digest, Vol 81, Issue 39

2010-11-10 Thread Alan Gauld
"marupalli charan" wrote Thanks, but first one not working!!! First one of what? Please edit the message to pprovide some context and pay attention to the instruxctions that you so helpfully posted: When replying, please edit your Subject line so it is more specific than "Re: Contents of T

Re: [Tutor] unicode nightmare

2010-11-10 Thread Alan Gauld
doesn't have u'\u0ec4' as a key but tr[v] is well definied ... OK, but the error is valid in that case. Which implies that you have bad data in CC. What exactly are you asking? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] put query result set into dictionary

2010-11-10 Thread Alan Gauld
DB' Despite the KeyError message its really because you are trying to use append on a non existent list: d = {} d[5].append(7) Traceback (most recent call last): File "", line 1, in KeyError: 5 Same error, no unicode in sight. HTH, -- Alan Gauld Author of the Learn to Program

[Tutor] Fw: unicode nightmare

2010-11-11 Thread ALAN GAULD
forward to the list Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Forwarded Message > From: danielle davout > To: Alan Gauld > Sent: Thursday, 11 November, 2010 4:19:22 > Subject: Re: [Tutor] unicode nightmare > > First thanks to

Re: [Tutor] A deeper explanation of ability to modify list elementsin-place

2010-11-12 Thread Alan Gauld
store the objects, just references to the objects - but those references could be pointers depending on implementation :-) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@pyt

Re: [Tutor] What is a "state variable"?

2010-11-12 Thread Alan Gauld
o consider what state is and why it is important in computing. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/m

Re: [Tutor] Tutor Digest, Vol 81, Issue 48

2010-11-12 Thread Alan Gauld
ne so it is more specific than "Re: Contents of Tutor digest..." Today's Topics: -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscri

Re: [Tutor] What is a "state variable"?

2010-11-12 Thread Alan Gauld
rovably correct implementations and are practical to build.(usually by building a dispatch table of states and their events) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubs

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

2010-11-14 Thread Alan Gauld
27;t need threads, just exit your method and wait for the user to do something and catch that event to restart your code. Leave it to the GUI. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tut

Re: [Tutor] Creating one file out of all the files in a directory

2010-11-14 Thread Alan Gauld
n\n') BTW you could use a single write with: output_file.write( '\n\n\n\n%s\n\n\n\n" % (filename, data) ) But thats largely a matter of personal style. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Recommend a MVC framework

2010-11-14 Thread Alan Gauld
ith Apache. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

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

2010-11-14 Thread Alan Gauld
licated to me! I am honestly not sure how all the control flows, but this loop is gone so hopefully it will not be a problem. You need to think about the control flow vfery carefully - after all you the programmer are supposed to be in charge of your program! And if you ever have to debug it you w

Re: [Tutor] What was your strategy?

2010-11-14 Thread Alan Gauld
new areas. I still refer to it regularly. Then I decided to write a tutorial on learning to program and chose Python as the preferred language. I also discovered the tutor list about the same time. The rest is history... or at least the list archive :-) -- Alan Gauld Author of the Learn to

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

2010-11-15 Thread Alan Gauld
ally one that is meant to last a long time but occasionally block input? You probably can find one on GUI design or event driven programming but the best advice I can offer is to think about the dialog/use case approach. Every time the user does something you have to think about how the system wi

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

2010-11-16 Thread Alan Gauld
t SourceForge the home of many OpenSource projects both large and small. But there is nothing like the formalised standards surrounding languages like C or COBOL or Java. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread Alan Gauld
really wanted to, but I suspect that is getting into advanced territory for you at this stage... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Assistance with Psuedocode

2010-11-17 Thread Alan Gauld
he result you expect (subject to rounding error) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Books...*

2010-11-18 Thread Alan Gauld
Python works at a much higher level, abstract concept and C works at a low level, close to memory. Finally, do you explicitly want dead tree books or Kindle type e-books or are you OK with web based resources? HTH, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] Python Books...*

2010-11-18 Thread ALAN GAULD
> > Finally, do you explicitly want dead tree books or Kindle type e-books > > or are you OK with web based resources? > > What exactly is dead tree book. sounds interesting Paper is made from dead trees... :-) Alan Gauld Author of the Learn To Program website http:

Re: [Tutor] new to python

2010-11-18 Thread Alan Gauld
OM via the Pythonwin library in the windows extensions package and Marrk Hammond's book Python Programming on Win32 provides extensive descriptions. Personally I prefer to interact with COM via VBScript as the Python route is (only slightly) more clunky. IMHO HTH, -- Alan Gauld Author of the

Re: [Tutor] new to python

2010-11-19 Thread Alan Gauld
"Alan Gauld" wrote COM = Common Object Model Oops, sorry. That should be COMPONENT Object Model... Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Simple counter to determine frequencies of words in adocument

2010-11-20 Thread Alan Gauld
to create a new one each time, otherwise the file will keep getting bigger everytime you run the code. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] JOB AD PROJECT

2010-11-20 Thread Alan Gauld
task for a first ever Python project! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] code quest

2010-11-20 Thread Alan Gauld
throw away the files... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Simple counter to determine frequencies of words in a document

2010-11-20 Thread ALAN GAULD
If the file is big use Peter's method, but 45 minutes still seems very long so it may be theres a hidden bug in there somehwew. However... > When I look at the current processes running on my computer, I see the > Python process taking 100% of the CPU. Since my computer has a > multi-core pr

Re: [Tutor] Simple counter to determine frequencies of words in a document

2010-11-20 Thread Alan Gauld
"Martin A. Brown" wrote * Somebody will be certain to point out a language or languages that provide some sort of facility to abstract the use of multiple processors without the explicit use of threads. ISTR Occam did that? Occam being the purpose designed language for the transputer,

Re: [Tutor] Simple counter to determine frequencies of words in adocument

2010-11-20 Thread Alan Gauld
"col speed" wrote Just my twopenneth, I'm a noob and I'm not going to try such a big file on my old machine, but: 1. Maybe create a *set* from the wordlist, loop through that, so you call "count" on wordlist only once. OR This would be an improvement but still involves traversing the en

Re: [Tutor] JOB AD PROJECT

2010-11-21 Thread Alan Gauld
wrote I am afraid only Alan has said something to me. Is it that solution would never come or u guys are waiting to gimme the best? I think we are waiting for a specific question. I said that your technology choice was OK for the project. What else do you want to know. You say you've don

Re: [Tutor] Simple counter to determine frequencies of words in adocument

2010-11-21 Thread Alan Gauld
version for now. You can run other python versions on the Mac alongside your default install but for now you have no good reason to do so. Keep life simple :-) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] lists, arrays and saving data

2010-11-21 Thread Alan Gauld
e Azimuth Angle (AZ): cosAZ = (sin(radians(D)) - sin(radians(lati)) * cos(radians(SZA))) / (cos(radians(lati))*sin(radians(SZA))) AZ = degrees(acos(cosAZ)) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] telnetlib - character hex00 missing

2010-11-22 Thread Alan Gauld
e = data[1:-1] # did we strip it correctly? if response.find(bytes.fromhex("00")) > -1: print ("There are hex00 characters") else: print ("No hex00 characters found") tn.close Others may have more info, but I'll be surprised if telnet

Re: [Tutor] Lambda function, was: Simple counter to determine frequencies of words in adocument

2010-11-22 Thread ALAN GAULD
> What I don't understand is the nature of the term 'item'. Is it a > variable? Yes, its just a descriptive name. You could have used x just as easily, Python doesn't know, nor care. It is just like in defining any normal function def f(x): return x is exactly the same as: def f(data): ret

Re: [Tutor] IDEs

2010-11-22 Thread Alan Gauld
really test your car's acceleration in a workshop test roller would you? You'd take it out on the road... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org T

[Tutor] Fw: Installing Pyserial for Python27 on Win 7

2010-11-22 Thread ALAN GAULD
Forwarding to the list Please send list mail to tutor@python.org not tutor-owner... - Forwarded Message > From: John Smith > To: tutor-ow...@python.org > Sent: Monday, 22 November, 2010 19:29:37 > Subject: Installing Pyserial for Python27 on Win 7 > > My OS is Win 7. I have the 64-bit

Re: [Tutor] "if n % 2 == 0" vs. "if not n % 2" compared for speed:aesthetics lose

2010-11-23 Thread Alan Gauld
"Richard D. Moores" wrote it was the way to go over "if n % 2 == 0". By my tests, it's 4.3% to 9.5% faster, depending on the integer tested - size and whether odd or even. See the speed testing script and results at . Did you try: if n % 2: pass else

Re: [Tutor] "if n % 2 == 0" vs. "if not n % 2" compared for speed:aesthetics lose

2010-11-23 Thread ALAN GAULD
> > Did you try: > > > > if n % 2: pass > > else: do it here? > > > > ie inverting the logic and omitting the equality test. > > Alan, since I'm doing comparison's, why do you suggest omitting the > equality test? Because the equality test with 0 might be slower than the implicit test of

Re: [Tutor] Lambda function, was: Simple counter to determine frequencies of words in adocument

2010-11-23 Thread ALAN GAULD
> OK, all of this is perfectly clear but what is still difficult for me > to understand is the following. If you remember the line of code in > question was: > > >sorted(word_table.items(), key=lambda item: item[1], reverse=True) > > This is supposed to return a list of tuples such as > >

Re: [Tutor] IDEs

2010-11-23 Thread Alan Gauld
ound up with over 50 reported bugs during Beta test... But that was much better than the 2000 bugs on an earlier project :-) But testing is hard. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist -

Re: [Tutor] variable numbers of for loops

2010-11-23 Thread Alan Gauld
"Mac Ryan" wrote I am not 100% sure I got the terms of your problem and I am neither an official tutor of this list, so disregard my comment if it is irrelevant... If you are a member of the list and contribute you are an official tutor. There are no high priests here :-) Alan G. _

Re: [Tutor] python script

2010-11-23 Thread Alan Gauld
interface standards. A Google search for python scsi will throw up a lot of hits... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] Help regarding lists, dictionaries and tuples (bob gailer)

2010-11-24 Thread Alan Gauld
mber return points def removePoints(attribute, number): return addPoints(attribute, -number) Now you can add and remove the points and the function will ensure there are only ever 30 points in total use. You would really need checks to ensure the attribute values and points never went ne

Re: [Tutor] re.Binding Events

2009-02-10 Thread ALAN GAULD
> I am mixing 2 examples given in "an-introduction-to- tkinter " > by Fredrik Lundh.(and got this code) > Today I got this error message > > Traceback (most recent call last): > File "", line 1, in >xx=app(root,event) > NameError: global name 'event' is not defined Which tells you that e

Re: [Tutor] re Binding Event

2009-02-10 Thread Alan Gauld
"prasad rao" wrote HelloI changed the code as follows.But still the callback function is not working. The he() is working well but clicking on the frame has no result. class app: def __init__(self,root): frame=Frame(root) frame.bind("", callback) Should this not be self.callback? def

Re: [Tutor] help with loop that is to be fed out of a word list

2009-02-10 Thread Alan Gauld
se!" return False return exits the function so the first letter you find that is not in a word you will exit. -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] IDLE

2009-02-10 Thread Alan Gauld
"WM." wrote A while back I made a big fuss about how IDLE indenting works. Kent was finally able to use language simple enough for me to understand. So I kept working IDLE. Today I got an error message. Somebody fixed it! It now indents just like all the other Python windows. Great going, S

Re: [Tutor] IDLE/phythonWin -- Who's On First? (Abbott and Costello)

2009-02-11 Thread Alan Gauld
"Wayne Watson" wrote Signature.htmlMy program in IDLE bombed with: == Exception in Tkinter callback Traceback (most recent call last): dialog = OperationalSettingsDialog( self.master, set_loc_dict ) tkSimpleDialog.Dialog.__init__(self, parent) self.wait_visibility() # wind

Re: [Tutor] IDLE

2009-02-11 Thread Alan Gauld
"WM." wrote Allen G.asked me how I made IDLE work. I did nothing on purpose. One can open Python into the IDLE window or into the program window. I assume you mean the editor window? Yes that will produce proper indentation, it is only the shell window that is broken because the >>> promp

Re: [Tutor] IDLE/phythonWin -- Who's On First? (Abbott and Costello)

2009-02-12 Thread ALAN GAULD
to favour the 3 window setup... Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ From: Wayne Watson To: Alan Gauld ; "tutor@python.org" Sent: Thursday, 12 February, 2009 5:09:01 AM Subject: Re: [Tutor] IDLE/phythonWin -

Re: [Tutor] Program to report if file was modified today

2009-02-12 Thread Alan Gauld
; else: pass You don't need the else:pass bit. It does nothing. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] [tutor] IDLE

2009-02-12 Thread Alan Gauld
"WM." wrote IDLE also now works perfectly, whether I open into IDLE or edit window. Below is a copy/paste: IDLE 2.6 >>> i = 9 >>> while i > 2: print i i -= 1 The problem occurs when you go to a second level block: if 42 > 66: print 'false' else:

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Alan Gauld
ill work with sorted(). Its not just the order you add items to the dict. To store an arbitrary order I suspect you would need to maintain a secondary list with the keys in the order of insertion. The most reliable way to dop that would be to subclass dict. Somebody may already have done that so its

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Alan Gauld
"Eric Dorsey" wrote config_names {'start_time': '18:00:00', 'gray_scale': True, 'long': 120.0} for i, x in config_names.items(): ... print i, x ... start_time 18:00:00 gray_scale True long 120.0 Thats pretty much a happy coincidence, there is no guarantee that it will work like that

Re: [Tutor] print function in python 2.6 and 3

2009-02-12 Thread Alan Gauld
"Sander Sweers" wrote I see more people posting answers with the new print() function only available in python 3 and in python 2.6 via an import from __future__. Now I am not confused by this but I can understand that people very new to python can get confused byt this. Especially people fol

Re: [Tutor] Detecting wx

2009-02-12 Thread Alan Gauld
"Ricardo Aráoz" wrote wx shell I want to establish a wx app. But if I'm in pythonWin I didn't think pythonwin was a wx application. I believe it's written in pure Windows, using the pywin extensions on top of Scintilla. But that aside I'd be interested in the answer to this one. there is a

Re: [Tutor] IDLE/phythonWin -- Who's On First? (Abbott and Costello)

2009-02-12 Thread Alan Gauld
"ALAN GAULD" wrote solved since about v2.3. However it does still through up issues, Ahem! That should of course be "throw up issues"! Sorry, Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ __

Re: [Tutor] List weirdness

2009-02-13 Thread Alan Gauld
"Moos Heintzen" wrote >>> d = [[]] >>> d[0][0]=1 IndexError: list assignment index out of range >>> d[0].append(1) >>> d [[1]] I guess I can't reference [0] on an empty list. Thats right. You can't assign a value to a position in a list that hasn't been created yet. It has nothing to do w

Re: [Tutor] Copy file function works, but not with adding the date copied

2009-02-13 Thread Alan Gauld
wrote I am modifying a simple program "copy file" from the tutorials Alan Gauld wrote. In it's first simpler instance (W/O date) it works beautifully. But I wanted to add the date the file was copied. I've kept it simple by pointing to a single file. The problem lies

Re: [Tutor] Calling variable from two different classes

2009-02-13 Thread Alan Gauld
"Hi" wrote I want to be able to call a variable from one of my classes to my main class (interface layout) and have it update every minute. Sp provuide an update method in the class that has the variable. Do not pass the variable to another class to update it, Objects should always do it to

Re: [Tutor] Copy file function works, but not with adding the date copied

2009-02-13 Thread Alan Gauld
"Marc Tompkins" wrote Here's a quick-and-dirty way to do what (I think) you want to do: Skip the first curly brace ("{") - find the next one. Just before it, insert a space + the datestamp text. That's it. If the OP is just working through my tutor I doubt if he will be able to do much

Re: [Tutor] Loops

2009-02-13 Thread Alan Gauld
"pa yo" wrote The way I have come up with to solve this problem is to put the following loop in: rawfeed = feedparser(http//twitter.com/foobar) feedstring = rawfeed.split('=',1)#this splits the feed at the first "=" headline = feedstring[0]#this is the text i

Re: [Tutor] Extract image from RTF file

2009-02-14 Thread Alan Gauld
"Bryan Fodness" wrote I have a large amount of RTF files where the only thing in them is an image. I would like to extract them an save them as a png. The link I posted on another thread claims to handle images in RTF files http://www.nava.de/2005/04/06/pyrtf/ HTH. -- Alan Ga

Re: [Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

2009-02-15 Thread Alan Gauld
"Wayne Watson" wrote Three questions about askopenfilename and enumerate. For askopenfilename: 1. Do I have to close the file before exiting from it? 2. How do I read each line of text in the file and quit when an eof is reached? This has nothing to do with askopenfilename! Askopenfilenam

Re: [Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

2009-02-15 Thread Alan Gauld
"Wayne Watson" wrote Thanks to your use of the word pillow it's not likely I will be able to find the link to the Library Reference more easily, strange as that may seem. You are right it seems very strange!? My browser's bookmark capabilities have put me in the corner of disorganization,

Re: [Tutor] General Feedback, Script Structure

2009-02-15 Thread Alan Gauld
"Damon Timm" wrote It works fine -- seems to do what I need -- but, to be very frank, I don't think it is very *pretty* ! But, I am not sure what the http://python.pastebin.com/m4e1694d5 Would be interested in any feedback (obviously, I should add some doc strings!). It doesn't look to

Re: [Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

2009-02-15 Thread Alan Gauld
"Wayne Watson" wrote I'm still looking for an explanation of " for (line_cnt, each_line) in enumerate(input_file)". Why the tuple? Apparently, line_count gets a line number, and each_line gets the string OK, Back up from the specific problem to the more general case. enumerate does not retu

Re: [Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

2009-02-15 Thread Alan Gauld
"John Fouhy" wrote for index, item in [9,8,7,6]: print index, item 0 9 1 8 2 7 3 6 You mean: for index, item in enumerate([9,8,7,6]): print index, item Oops, yes, thanks for catching that. It was fairly fundamental to the discussion! Alan G ___

Re: [Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

2009-02-16 Thread Alan Gauld
"Wayne Watson" wrote If you ever get a chance to try the Moz experiment above, I'd be interested in your reaction. I no longer have Mozilla loaded - far too resource hungry. I use IE, Firefox and Chrome plus occasionally Safari on my Mac. All of them move bookmarks using simple drag n drop

Re: [Tutor] *nix tail -f multiple log files with Thread

2009-02-16 Thread Alan Gauld
"Bill Campbell" wrote There is information on regular expressions in any book on python, perl, and other scripting languages. O'Reilly has a book ``Mastering Regular Expressions'' which is probably pretty good, but I have never read it. It is pretty much the definitive reference on regex.

Re: [Tutor] Control Variables and a Dictionary with a GUI Interface

2009-02-16 Thread Alan Gauld
"Wayne Watson" wrote The question here is how is sdict being used here in terms of its need within the GUI? Probably if I had written the program from scratch, I would have made all these variables global to Sentinel_GUI. Most programmers try to avoid global variables as a general principle

Re: [Tutor] exec "self.abc=22" ?

2009-02-16 Thread Alan Gauld
"Wayne Watson" wrote Python doesn't like the code in the Subject (unqualified exec not allowed in function). but easily likes self.abc="22". We'd need to see the code and traceback to guess why... However, I'd like to assemble the assignment as a string, as shown in Subject, and execute it

Re: [Tutor] Possible to change values of scalar function parameters?

2009-02-17 Thread Alan Gauld
wrote No, not a simple way at least. Possibly you can do it with hackery involving stack frames but I wouldn't recommend that. Either pass the values in some kind of container (list, dict, class instance) or return the new value and assign it in the caller. That's what I thought. Thank you!

Re: [Tutor] Changing the Attribute of a Variable

2009-02-18 Thread Alan Gauld
"Wayne Watson" wrote I'll look into Quick Edit. I use Snagit to screen capture. Quick edit allows you to use the mouse to select text on the console screen then use the Enter key to copy it to the clipboard. So to paste an error message into an email simple select it with the mouse, hit

Re: [Tutor] Changing the Attribute of a Variable

2009-02-18 Thread Alan Gauld
"Wayne Watson" wrote Maybe the web documents should warn about the horrors of eval. VBG. Possibly the same is true of exec? Yes the same is true of exec and also potentially execfile. All need to be used with extreme care where there is any risk of the executed code being tampered with out

Re: [Tutor] I have a question plz help

2009-02-20 Thread Alan Gauld
"rev pacce" wrote My mom and I have been trying to hack into the administrator account on our laptop my mom got from her job We don't deal with that kind of hacking on this list. But consider what might happen if you succeed. Suppose Mom's PC develops a fault and her IT people try to go

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Alan Gauld
"Wayne Watson" wrote I just ran the program again straight from the py file, and it put my the black window with my raw_input prompt. Thats why, when debugging, its often better to open the command window first and run the program from the OS prompt. That way you don't lose any text mes

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Alan Gauld
"Wayne Watson" wrote My assumption was is was fully a DOS window. No its a DOS window on steroids! Thee are a ton of improvements to the DOS shell in XP most of which are turned off by default. Take half an hour to go through the help screens for CMD and turn on the various registry set

Re: [Tutor] Problems with Python 3 and Tkinter

2009-02-21 Thread Alan Gauld
"Peter Anderson" wrote Additionally, is there any references to Python 3 and Tkinter other than the standard documentation (which is flimsy at best). There are a couple of other tutorials that have been upgraded to v3 but I suspect most, like mine, are still works in progress! Python 3 for

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-22 Thread Alan Gauld
"Wayne Watson" wrote tried XP's Help on command prompts. Not much there. Is there another source? When you say XPs help do you mean the GUI help tool? There isn't much in there. For DOS things use the DOS help tool. Type HELP CMD at the DOS prompt. Alan G.

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-22 Thread ALAN GAULD
> Under Start there's a ? icon that says Help and Support. Minimal info. Yes, although by exploring the links and using the Microsoft Knowledgebase panel on the left you do get more than I remembered. I just think the DOS HELP command is easier to use. However I did find a good overview on Te

Re: [Tutor] calling user defined function

2009-02-22 Thread Alan Gauld
"roberto" wrote i can define a function using the text editor provided by IDLE 3.0; then i'd like to call this function from the python prompt but when i try to do it, python warns me that function doesn't exist of course if i define the function directly using the >>> prompt, after that ever

Re: [Tutor] Exercises for Classes and OOP in Python

2009-02-23 Thread Alan Gauld
"Senthil Kumaran" wrote I am looking for a good material that would provide exercises (and possibly solutions to demo exercises) that illustrates the Object Oriented Programming constructs in Python. Can pointers? I'm not sure what exactly you have in mind but most tutorials will cover OOP

Re: [Tutor] regex help

2009-02-23 Thread Alan Gauld
"ish_ling" wrote 'a b c h' I would like a regex to Congratulations on a cclear explanation of what you want. With regex questions that is half the battle. I have figured out how to do this in a multiple-step process And there's nothing much wrong with multi step. with re.findall()

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-23 Thread ALAN GAULD
> Under Start there's a ? icon that says Help and Support. Minimal info. Yes, although by exploring the links and using the Microsoft Knowledgebase panel on the left you do get more than I remembered. I just think the DOS HELP command is easier to use. However I did find a good overview on Te

Re: [Tutor] extracting a column from many files

2009-02-23 Thread Alan Gauld
"Bala subramanian" wrote I want to extract 1a1 2a1 3a1 from file 1, similarly 1a2 2a2 3a2 from file 2 ( same columns) and then make a new output file of the following format 1a1 1a2 --- 2a1 2a2 --- 3a1 3a2 --- Similarly for the 2nd, 3rd, 4th..columns in the input files. OK, So you want

Re: [Tutor] Accessing callers context from callee method

2009-02-24 Thread Alan Gauld
wrote when i call a method foo from another method func. can i access func context variables or locals() from foo Yes and there are several ways to do it, but nearly always this is a bad idea. It will make foo almost totally unusable in any other context since it will rely on the calling fu

Re: [Tutor] Passing perimeters in dictionary values?

2009-02-24 Thread Alan Gauld
"nathan virgil" wrote in selection = raw_input("Choice: ") choices = {"0":quit, "1":crit.talk, "2":crit.eat, "3":crit.play} choice = choices[selection] choice() so that I can call methods from a dictionary, instead of having an excruciatingly long if structure. Unfortunately, the problem I'm

<    3   4   5   6   7   8   9   10   11   12   >