Re: [Tutor] (no subject)

2009-03-24 Thread Alan Gauld
"Daniele" wrote * I cant get a code to work for this bottom half, Can anyone help me OK, since we've started giving solutions... Hi Jared, try this: for i in range(-10,11): print '*'*(11-abs(i)) This is simpler using for n in range (10,0,-1): print '*' * n HTH, -- Alan

Re: [Tutor] (no subject)

2009-03-24 Thread Alan Gauld
"Daniele" wrote for i in range(-10,11): print '*'*(11-abs(i)) Apologies, this is actually more powerful than my solution which only addressed the immediate concern of printing decreasing lines. This of course covers both sides of the triangle. It was only when I thought that it should

Re: [Tutor] (no subject)

2009-03-24 Thread ALAN GAULD
> I am sorry , some how how i missed it . code you pls explain this. > for i in range(-10,11): > print '*'*(11-abs(i)) OK, the range() function returns a list of numbers from -10 to +10. the for loop assigns i to each value in turn The print statement prints out the asterisk repeated (11-

Re: [Tutor] Evaluating Swahili Part of Speech Tagging. How can I writea Python script for that?

2009-03-24 Thread Alan Gauld
Hi, That was an interesting post, but I'm not sure what you want help with. Is it the word splitting? Is it writing the POS tagger? Is it comparing tthe POS tagger to the standard? Or all of these? Alan G. "Emad Nawfal (عماد نوفل)" wrote in message news:652641e90903240835o610d013dsd6a81f4675c4

Re: [Tutor] Question about Python.

2009-03-25 Thread Alan Gauld
"T" wrote I'm working on Paper, Rock, Scissors in Python. I need to make it a loop, and test the values (1, 2, 3, /Rock/Paper/Scissors) yet, but i'm kind of stuck. Could you help me? What exactly puzzles you? You know you need a loop so you presumably realize that you need to repeat some

Re: [Tutor] problem of windmill on ssl website

2009-03-25 Thread Alan Gauld
"Coco Yeh" wrote I have problem using windmill with a ssl website (https). The browser does not go to the website, showing a tutor page instead. How can I resolve this? My initial response was to say "ask on a windmill list," but, not having heard of windmill, I googled and discovered

Re: [Tutor] Using C in python

2009-03-25 Thread Alan Gauld
"amit sethi" wrote what are the ways in which i can use C in python programs . You can't use C directly what you can do is access libraries written in C. In fact quite a few of the standard libraries are written that way. So it depends what you want to do. If you have C source code that yo

Re: [Tutor] Posting to Tkinter NG in new.gmane.org

2009-03-26 Thread Alan Gauld
"Wayne Watson" wrote My e-mail address is valid. Any ideas? I've compacted related Trash folders, etc It should be news.gmane.org... Or is that just a typo? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinf

Re: [Tutor] printing files

2009-03-26 Thread Alan Gauld
"Bala subramanian" wrote for files in flist: handle=open(flist).readlines() print>>out, handle print>>out, handle[1:] Should do it? You might need to handle line endings though... Alan G. ___ Tutor maillist - Tutor@python.org http:/

Re: [Tutor] Posting to Tkinter NG in new.gmane.org

2009-03-26 Thread Alan Gauld
"Wayne Watson" wrote My e-mail address is valid. Any ideas? I've compacted related Trash folders, etc It should be news.gmane.org... Or is that just a typo? In that case you probably need to tell us more. Can you read the group OK in TBird? What other settings are you using? I can'

Re: [Tutor] printing files

2009-03-26 Thread ALAN GAULD
Use '\n'.join(handle[1:]) It will create a string from your list with newline as separator. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ From: Bala subramanian To: Alan Gauld Sent: Thursday, 26 March, 2009 6:11:59

Re: [Tutor] Updating Python on Mac OS X 10.5.6

2009-03-26 Thread Alan Gauld
"NBarnes" wrote Fortress). It seems like Python would be a good choice for such a relatively simple project, and I've been wanting to learn Python. seems reasonable), but I understand that we've since moved on to Python 2.6? And that Python 3.0 is out? Is 3.0 mature enough to support this

Re: [Tutor] printing files

2009-03-26 Thread Alan Gauld
"Kent Johnson" wrote On Thu, Mar 26, 2009 at 2:58 PM, ALAN GAULD wrote: Use '\n'.join(handle[1:]) It will create a string from your list with newline as separator. The lines from readlines() include the newlines already. Ah, OK, I couldn't remember if readlines

Re: [Tutor] Left Alignment -- Tkinter

2009-03-27 Thread Alan Gauld
Try packing the frame to the left and set it to expand. HTH, Going on vacation Bye Alan G. "Wayne Watson" wrote in message news:49cd0d40.5090...@sbcglobal.net... Signature.htmlThe code below is clearly not shifting the contents of the frame to the left. It's supposed to look like

Re: [Tutor] range() fractional increment

2009-03-31 Thread Alan Gauld
"james carnell" wrote example: x row = 25 : col = 10 x row = 26 : col = 10.3 x row = 27 : col = 10.6 0x000 row = 28 : col = 11 for col in range(10,12, 0.3): #<- Crash Bang doesn't work 0.3 = zero = infinite loop? If you know the limits (rather than their being variables) you c

Re: [Tutor] Left Alignment -- Tkinter

2009-04-01 Thread Alan Gauld
"W W" wrote Good news... I got it! Here's something that's often a good idea when debugging overlapping layouts (especially when you didn't design the parent!) - use different backgrounds! Yes, or for Frames use a relief value to see where the frame bounds are. Here's my changes (also f

Re: [Tutor] PIL Handbook in pdf Format?

2009-04-02 Thread Alan Gauld
"Wayne Watson" wrote I plainly had a copy of the Subject pdf in the past. ... . A search of my PC shows nothing. Try this: http://www.ezgoal.com/house/final.asp?software=201967 Its what I use to produce the PDF version of my website. The tool presents a web site within an app that allows

Re: [Tutor] Learn as You Go. Tkinter, PIL, Pmw, etc. and Toolkits--Choices

2009-04-05 Thread Alan Gauld
"Wayne Watson" wrote I get the feeling, particularly with Tkinter and PIL, that I'm dealing with antiquated tools, and documentation. They are both quite old and therefore quite stable. They do what they do well and don't need to change very often. That is a Good Thing in that they are reli

Re: [Tutor] Learn as You Go. Tkinter, PIL, Pmw, etc. and Toolkits--Choices

2009-04-05 Thread Alan Gauld
"Wayne Watson" wrote > The grid is a perfectly good layout manager but like all such > tools it works in a particular way and has lots of options. Some To me grid looks like simple arithmetic, +, -, * and /, but someone left out the description (in a fictitious book on arithmetic) of "/ "(

Re: [Tutor] Learn as You Go. Tkinter, PIL, Pmw, etc. and Toolkits--Choices

2009-04-05 Thread Alan Gauld
"Wayne Watson" wrote manipulation - actually creating and editing GIF/JPEG images etc The interaction stuff you need to do using the GUI toolkit. The GUI toolkit, Pmw, Tkinter? Yes exactly. Or wxPython or PyGtK or whatever, they will all provide a canvas type widget which you can progr

Re: [Tutor] base n fractional

2009-04-05 Thread Alan Gauld
"Chris Castillo" wrote I need some help converting the fractional (right side of the decimal) to base 10. I have this but it doesn't work Frankly, based on your algorithm, I'm not sure what exactly you want to do but taking the above statement as a starting point I'd convert the fractional

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread Alan Gauld
"Benjamin Serrato" wrote formatting of my zip arguments is incorrect. Since I am unsure how to communicate best so I will show the code, the error message, and what I believe is happening. Thats pretty close to communicating the best way! :-) zip_command = zipfile.ZipFile(target, 'w').writ

Re: [Tutor] base n fractional

2009-04-06 Thread Alan Gauld
"Chris Castillo" wrote well i want to use a for loop to work from the right most digit to the left most digit at a negative 1 increment. For each digit i want to divide it by 1/base and add the next digit. Then I need to take that sum and multiply it by 1/b to get the decimal equivalent so

Re: [Tutor] Please use plain text.

2009-04-06 Thread Alan Gauld
"Wayne Watson" wrote Personally, I'd rather see these mail lists turn into forums formats. Web forums are far less useful than mailing lists for technical groups. They require internet access and a browser to read them. Many require a graphical browser so don't work in text mode terminals.

Re: [Tutor] Executing a GUI from another GUI with a click of a button

2009-04-06 Thread Alan Gauld
"Chris Lee" wrote Before I tell you about my problems, I ask for your consideration as I am a newbie at python... That's OK, its what the tutor list is for! :-) I was having problems as I tried to open another program within a program (both programs are Tkinter UIs) OK, That can be trick

Re: [Tutor] (no subject)

2009-04-07 Thread Alan Gauld
"Sifis Sifakis" wrote I'm a student in Applied Informatics and i need to make a project in Python. More specificaly,i have to create a simple online bookstore using Python. We don;t do homework for you but we are happy to help with pointers and bug fixing. Could you also send me some sampl

Re: [Tutor] unicode to plain text conversion

2009-04-07 Thread Alan Gauld
"Pirritano, Matthew" wrote I am a total newbie. I have a very large file > 4GB that I need to convert from Unicode to plain text. I used to just use dos when the file was < 4GB but it no longer seems to work. Can anyone point me to some python code that might perform this function? When you s

Re: [Tutor] Python Lists--A Suggestion

2009-04-07 Thread Alan Gauld
"Wayne Watson" wrote I offered in that thread that it might be useful to allow people to post images and videos. They can sometimes be very useful One response was that such sites are generally available. Indeed and posting big images or any size video in a mailing list would be very

[Tutor] Using Easygui in Python v3

2009-04-09 Thread Alan Gauld
I'm currently updating my tutorial to cover Python V3. I thought it miight be good to include some stuff on EasyGUI for the user input topic and on checking the web site it said Easygui was compatible with Python v3. However after downloading and installing I get a "No module named StringIO" e

Re: [Tutor] Using Easygui in Python v3

2009-04-09 Thread Alan Gauld
"Alan Gauld" wrote user input topic and on checking the web site it said Easygui was compatible with Python v3. However after downloading and installing I get a "No module named StringIO" error under Python v3. OK, Not much digging required. StringIO has moved to

Re: [Tutor] How to write server which listens to specific port

2009-04-10 Thread Alan Gauld
. At the most basic level you can use the socket module and do it all from scratch, but if its a higher lervel protocol there may be higher level modules already written that will help. We need to know a lot more about the problem and the environment - what kind of computer/OS etc. -- Alan Gauld

Re: [Tutor] ideas on how to process a file

2009-04-10 Thread Alan Gauld
hought about using regular expressions to pull the data I need. You probably don;t need regex, but it depends on what exactly you want to filter/extract. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] OOP / Classes questions

2009-04-10 Thread Alan Gauld
on that in a few minures... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] OOP / Classes questions

2009-04-10 Thread Alan Gauld
an then inspect the event to find out which key was pressed, where the mouse moved to, etc As I say thats just a slightly different way to think about objects and OOP I personally find it very helpful, you may too. If not, don't worry about it! :-) --

Re: [Tutor] Problem with converting Python to EXE using py2exe

2009-04-10 Thread Alan Gauld
and have a registry setting or config file or environment variable specify where that directory is. You can then read the config data at startup and use that to create the path for the image. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] Problem with converting Python to EXE using py2exe

2009-04-11 Thread ALAN GAULD
> That's a great idea Mr. Gauld! > But I have no idea how to do that... > can you maybe write a small example for a newb like me?? pretty please with > cheese on top?? > > > base = pic(file="base.gif") > > > > > > Now, I'm just wondering... for the "base.gif" part, would it be better > > > to

Re: [Tutor] Problem with converting Python to EXE using py2exe

2009-04-11 Thread Alan Gauld
"Dave Angel" wrote To use a relative path base = pic(file=root+"/base.gif") I would get 'root' this way, rather than requiring anything to be set up by the install (registry, environment vars, config): Good idea, I forgot that in Python you can find the full path that way. Too used to w

Re: [Tutor] Python Dice Game

2009-04-11 Thread Alan Gauld
value2 = randrange(1,7) die2.setValue(value2) value3= randrange(1,7) die3.setValue(value3) value4 = randrange(1,7) die4.setValue(value4) value5 = randrange(1,7) die5.setValue(value5) rlist = [value1,value2,value3,value4,

Re: [Tutor] How to programmatically EDIT a python file using an editorof my choice ?

2009-04-12 Thread Alan Gauld
lly, if on Unix, you should probably respect the EDITOR or VISUAL environment variables since they reflect the users editor preferences so the code should look like: ed = os.getenv('EDITOR') vi = os.getenv('VISUAL') editor = vi or ed if editor: subprocess.Popen().call([editor,

Re: [Tutor] How to programmatically EDIT a python file using an editorof my choice ?

2009-04-12 Thread Alan Gauld
"Dominique" wrote I tried several other ways without any success: subprocess.Popen(args = ["notepad++.exe", filename]) subprocess.Popen(args = ["C:\Program Files\Notepad++\notepad++.exe", filename]) I wonder if it is due to the location of the softwares. In a way. I think it's because you

Re: [Tutor] Reading a "Raw "Image File

2009-04-12 Thread Alan Gauld
"Wayne Watson" wrote raw_image=raw_file.read() One more question, when I tried (no 'wb') read(size=307200), why di read balk at size, syntactically. It doesn't balk at the size syntactically it finds what it thinks is an End Of file character code in the data and stops reading. Tha

Re: [Tutor] Using Easygui in Python v3

2009-04-12 Thread Alan Gauld
"Wayne Watson" wrote Possibly contact Steve Ferg? Yes I did that and Steve has included my fix in the latest version. He also kindly gave a plug to my tutorial :-) I've now included a section on EasyGui in my "Talking to the User" topic in the Python v3 version. -- Alan G Author of the Le

Re: [Tutor] Tkinter and Antialiasing

2009-04-12 Thread Alan Gauld
a graphic then generating the graphic as an image and loading the image into the canvas might work better. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.py

Re: [Tutor] get bytes back from string representation?

2009-04-13 Thread Alan Gauld
n what the bytes actually represent. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Using numpy Array Capabilities

2009-04-13 Thread Alan Gauld
he above from a loop in Python, and generated hex equivalents in the last list. It might help to see those loops because it might explain the reasoning behind the apparently arbitrary decisions. Can numpy do this simply without resorting to loops? Can't

Re: [Tutor] Event Handling--Key Press, Mouse Movement ...

2009-04-13 Thread Alan Gauld
set of GUI programming more than it is specifically Pythonic. The events themselves tend to be GUI specific - Windows being slightly different to X Windows or MacOS for example. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] How to write server which listens to specific port

2009-04-14 Thread Alan Gauld
ou can use a higher level module if one is available. Raw sockets should only be needed if you are doing bespoke communications between processes. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist

Re: [Tutor] path to executing .py file

2009-04-14 Thread Alan Gauld
"Access denied!" Is that mean my script has no power to delete it? More likely the user running the script does not have the correct access permissions or someone else is using the repository at the time thus locking it. HTH, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] python books

2009-04-14 Thread Alan Gauld
ic for you. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Trouble understanding modifying parent class..

2009-04-14 Thread Alan Gauld
hod passing the name and value so that the A default never gets used in B instances. The OOP topic in my tutor describes this in more detail. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mail

Re: [Tutor] python dictionary

2009-04-14 Thread Alan Gauld
setdefault() was effectively instantaneous. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] oops concepts

2009-04-14 Thread Alan Gauld
concurrent sequential machines and state automata theory and any text book on formal simulation techniques. HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.o

Re: [Tutor] OOP

2009-04-15 Thread Alan Gauld
fficulties figuring what it is all about. If you can show us an example and tell us what you don't understand we might be able to give more specific answers. Also please tell us which version of Python you are using and which Operating System. -- Alan Gauld Author of the Lear

Re: [Tutor] colours in IDLE

2009-04-15 Thread Alan Gauld
a variable name etc -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Import Modules

2009-04-15 Thread Alan Gauld
ut the direct import makes for shorter coding, especially if you use the function a lot. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Here's something to talk about

2009-04-15 Thread Alan Gauld
ame = tableName Which you do here! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread Alan Gauld
"Emile van Sebille" wrote Redundant, yes; syntax error, no. IIRC, semi-colons are optional line terminators. statement terminators I think. ie you can have several statements on a line by separating with semicolons: x=5; print x+2 7 Alan G __

Re: [Tutor] Import Modules

2009-04-16 Thread ALAN GAULD
> In general, importing a package does not give access to members of a > sub-package. You have to explicitly import the subpackage. For > example, > > In [1]: import xml > In [2]: xml.dom.Node > --- > AttributeError

Re: [Tutor] importance of Docstring

2009-04-16 Thread Alan Gauld
ou can import them and read the doctrings wiothout actually opening the code in an editor (which you would need to do for normal comments) So they are not essential but they do have a very real use beyond simple comments.. I say a bit more about docstrings in my tutorial topic "Ad

Re: [Tutor] Building VST's with Python

2009-04-16 Thread Alan Gauld
x27;m not sure if it works for other platforms. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] print output

2009-04-16 Thread Alan Gauld
iables separated by newlines or just put all 3 commands on a sinlgle line separated by semicolons: print 5; print 6; print 7 5 6 7 HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tu

Re: [Tutor] beginners resources list, Python education events

2009-04-16 Thread Alan Gauld
lthough well on the way now... The freenetpages site is scheduled to close and they are not allowing any updates, hence the move -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@

Re: [Tutor] for loop

2009-04-16 Thread Alan Gauld
he other says 'chic', just as you told it to. In every other respect your code is identical so the output is identical. Python just does what you tell it to, it is not actually intelligent, it just interprets the commands you give it. HTH, -- Alan Gauld Author of the Learn to Pr

Re: [Tutor] beginners resources list, Python education events

2009-04-16 Thread Alan Gauld
"wesley chun" wrote i'm trying to collate a complete newbie-to-programming list of resources and was wondering if you could help me fill in the holes... thx in advance! What about the free (and even the pay for) videos on the ShowMeDo site. I thought they were pretty good especially for sh

Re: [Tutor] list to string and string to list

2009-04-16 Thread Alan Gauld
split(',')] newlist [1, 2, 3, 4, 5] Provided your original data doesn't have commas to start with it should work, I think... And the data needs to be pretty homogenous to allow a single conversion function. -- Alan Gauld Author of the

Re: [Tutor] importance of Docstring

2009-04-17 Thread Alan Gauld
or in a design document for the bigger application level how! Those are my personal rules of thumb. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Functions output

2009-04-17 Thread Alan Gauld
nction! Again second call to the same function valuse outside the function: [10, 20, 30] values inside this function: [10, 20, 30] HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Reading from files problem

2009-04-20 Thread Alan Gauld
could put the for loop inside the Student class __init__ method so it boils down to: for line in gradesfile: s = Student(line) students[s.id] = s In fact you could cram it all into one line with another list comprehension, but that seems like a step too far to me...

Re: [Tutor] Reading from files problem

2009-04-20 Thread Alan Gauld
"Scott SA" wrote May have been a bad assumption on my part as I envisioned pickling a dict. and that just got too complicated. A pickled dict? That would be a shelve mebbe? PS. My email is acting up, did my prev. message actually make it to the list? Yes, I saw it just after sending m

Re: [Tutor] Looping

2009-04-20 Thread Alan Gauld
epetitions): for n in range(repetitions): # your old func code here And call it: func(repetitions=10) # use keyword for clarity of purpose HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mail

Re: [Tutor] py-editdist

2009-04-20 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote e...@emad-desktop:~/Desktop/py-editdist-0.3$ python setup.py build running build gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall editdist.c:22:20: error: Python.h: No such file or directory Looks like you need the Python source code installed,

Re: [Tutor] parse text for paragraghs/sections

2009-04-20 Thread Alan Gauld
t list archives will reveal several discussions. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] py-editdist

2009-04-20 Thread ALAN GAULD
I mean you need a source installation not a binary one, it is looking for python.h which is one of the C header files in the Python source code. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ From: Emad Nawfal (عماد نوفل) To

Re: [Tutor] Looping

2009-04-20 Thread Alan Gauld
"Matt" wrote As an aside, why use range rather than xrange? I was under the impression that xrange is a generator and therefore more memory efficient. xrange was a kludge to improve on range's memory efficiency but it is a horrible name that obscures the code. Also it does not exist in v3 s

Re: [Tutor] Reading from files problem

2009-04-21 Thread ALAN GAULD
> this worked for me fine. I'm glad you solved tyour problem. But you have done so in an extremely inefficient way, both inefficient in the way it uses computer resources - both CPU and storage, and inefficient in the way it uses your time - way more code than you need. If you only need an answ

Re: [Tutor] Organizing my code, should I use functions?

2009-04-22 Thread Alan Gauld
very closely aligned with formal methods in Computer Science and formal languages such as Z or VDM For most programmers functional programming is at least as big a conceptual leap from procedural or imperative programming as OOP. I'll comment on the code separately. -- Alan Gauld Author of

Re: [Tutor] Don't understand error messages.

2009-04-22 Thread Alan Gauld
= '' while True:#151 DisplayBoard(HANGMANPIX, MissedLetters, CorrectLetters, First time through the program MissedLetters is empty so the for loop never executes and Blanks is not initialised. The second for loop then fails. You need to initialise Blanks at the head of the function. HTH,

Re: [Tutor] testing framework

2009-04-23 Thread Alan Gauld
"spir" wrote My app is about parsing, which input and output usually both are big and complicated *strings*. So that I find the command line model really unappropriate for expressing test cases and their expected results. Any hint/pointer/comment welcome, What about using command line red

Re: [Tutor] sorting algorithim

2009-04-24 Thread Alan Gauld
s in range(len(list)-1, 0, -1): You could use list slicing here: for passes in list[-2::-1]: But you might find using a while loop is easier than a for loop for bubble sort -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] Threading...

2009-04-24 Thread Alan Gauld
cking tests etc will slow things down too. Its a good idea to have as many rows as you want to run tests and have alternate queries hit opposite ends of the table, or better still have several similar tables and round-robin the queries. Just some common gotchas with database performance testing. HTH,

Re: [Tutor] Python help

2009-04-25 Thread Alan Gauld
dprice' / 10) + taxed price = student you must assign a value to a variable you cannot assign a variable to an expression. Also, I thought the students got a discount? This provides a surcharge! print "your student price is 'student' else print "have a nice day&

Re: [Tutor] Is it syntactic,semantic or runtime?

2009-04-25 Thread Alan Gauld
ind the problem then let us know what you have discovered when you post. Just some thoughts for the future, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/m

Re: [Tutor] # what do I do now to kill the the Windows program which has finished its work?

2009-04-25 Thread Alan Gauld
launch the program in a thread. You can then try killing the thread which may kill the program, or if not, use the Windows API to kill the program (gets messy). This is easier on Unix in my experience! HTH -- Alan Gauld Author of the Learn to Progr

Re: [Tutor] I may have solved my problem with killing tasks in Windows

2009-04-25 Thread Alan Gauld
if ret==WAIT_TIMEOUT: TerminateProcess(p._handle, 1) return None return p.wait() -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to run a .py file or load a module?

2009-04-27 Thread Alan Gauld
Offlist response... Nice answer Denis, you neatly covered all the loose ends from previous answers that I was just about to pick up on! :-) "spir" wrote in message news:20090427101523.5fc09...@o... Le Sun, 26 Apr 2009 22:35:36 +0100, Dayo Adewunmi s'exprima ainsi: How can I a) Open my she

Re: [Tutor] How many types of the constructor

2009-04-27 Thread Alan Gauld
Widgets in most GUIs work. You call the widget with a specifically named subset of parameters. For example: from Tkinter import * top = Tk() Label(top, text="OK", foreground="Blue).pack() Label(top, text="Cancel").pack() top.mainloop() The second label just adopts the default colour

Re: [Tutor] How to run a .py file or load a module?

2009-04-27 Thread Alan Gauld
"Alan Gauld" wrote Offlist response... Oops, not offlist! Just as well I didn't say anything offensive! :-) Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] finding mismatched or unpaired html tags

2009-04-28 Thread Alan Gauld
nd there is a Python wrapper: http://utidylib.berlios.de/ although I've never used it. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] finding mismatched or unpaired html tags

2009-04-29 Thread Alan Gauld
"Lie Ryan" wrote documents were generated by another computer ie. they are not web page documents. If the source document was generated by a computer, and it produces invalid markup, shouldn't that be considered a bug in the producing Elementree parses xml, the source docs are html. Va

Re: [Tutor] Dictionary, integer, compression

2009-04-29 Thread Alan Gauld
there anything that made you think they might be? HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Add newline's, wrap, a long string

2009-04-29 Thread Alan Gauld
= {'CBUILD':None, 'ACCEPT_KEYWORDS: None, } for line in fname: for keyphrase in data: if keyphrase in line: output = line.split('"')[1] data[keyphrase] = textwrap.fill(output, 80)

Re: [Tutor] Add newline's, wrap, a long string

2009-04-29 Thread Alan Gauld
x27;] Don't bother storing in variables just use the dictionary directly in your print statements. Learn to love and use Python's collections. They are the secret of much of Python's power. Just some thoughts, -- Alan Gauld Author of the Learn to Program web site http://www

Re: [Tutor] Running subProcesses in parallel for mixed external Windows.exe and Python functions on specified CPUs.

2009-05-01 Thread Alan Gauld
uspect you would be better trying on the main comp.lang.python newsgroup. That having been said I am constantly surprised by the breadth of specialist knowledge on this list so you may yet get an answer here! -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Alan Gauld
earch(r'Domains', line): print line But if it is a simple string you are searching for regex is overkill and probably slower than using in. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tut

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Alan Gauld
"Steve Willoughby" wrote if re.search != (r'Domains:', line): Because you are assigning a tuple containing a string and a line of text to a name which is currently bound to a function object (re.search) Actually, he's COMPARING the two, not assigning. But comparing a function object and a

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Alan Gauld
"Alan Gauld" wrote How do I make this code print lines NOT containing the string 'Domains'? Don't use regex, use in: for line in log: if "Domains" in line: print line Should, of course, be if "Domains&qu

Re: [Tutor] Iterating over a long list with regular expressions andchanging each item?

2009-05-04 Thread Alan Gauld
# replacement loop for line in source: this iterates over the characters in the string. Remove the two source lines above and use for line in open(source_name): HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] returning the entire line when regex matches

2009-05-04 Thread Alan Gauld
ob in the OS topic in my tutorial. Look under the heading 'Manipulating Files' HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Iterating over a long list with regular expressions andchanging each item?

2009-05-04 Thread Alan Gauld
null null'), 'adj' : T('adj null null'), 'adv' : T('adv null null'),} (Yes, I know PEP8 says *not* to add spaces to line up assignments or other related values, but I think there are isolated cases where it does help to see wha

Re: [Tutor] Advanced String Search using operators AND, OR etc..

2009-05-04 Thread Alan Gauld
l search tools (and what can't!) There is a very basic introduction in my tutorial which unfortunately doesn't cover all that you need here but might be a good starting point. The python HOWTO is another good start and goes a bit deeper with a different approach: http://docs.python.o

<    5   6   7   8   9   10   11   12   13   14   >