Re: [Tutor] function error

2010-09-30 Thread ALAN GAULD
Copy the code into a text file with a name ending in .py - lets call it myfile.py for now (if you have not already done so) >From a bash prompt type $ python myfile.py Then cut n paste any error messages into an email to the list Alan Gauld Author of the Learn To Program website h

Re: [Tutor] Doubly linked list

2010-09-30 Thread Alan Gauld
. Do you have a specific need for a doubly linked lists? They are very rarely required in Python because the standard list is sufficiently versatile for most purposes. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] inheritance problem

2010-09-30 Thread Alan Gauld
ou would fix it. If you don't understand what the error is saying then tell us and we can explain it, but in this case its pretty clearly stated and is one you have seen before. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] inheritance problem

2010-10-01 Thread Alan Gauld
d so I think it must be self.hands.pop() If you want to assign a card and cards are stored in self.cards why would you use self.hands.pop()? Surely it should be self.cards.pop()? HTH, -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] Mutable Properties

2010-10-01 Thread Alan Gauld
you get it. What you need to do is create your own kind of list that prints get/set when you access the list. It is the list you are manipulating not the test class. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] inheritance problem

2010-10-01 Thread Alan Gauld
"Roelof Wobben" wrote The cards are stored in a directory named cards. Correct. So how do you get a card from the collection stored in self.cards? This is not correct. Card is a list and not a directory. See this : self.cards = [] OK, if thats the mistake you made then you made two mis

Re: [Tutor] inheritance problem

2010-10-01 Thread ALAN GAULD
> > OOP is a step up from functions its true but you need to work to > > understand it or you will continue to get confused by trivial errors. > > Then appearently I don't work hard enough. > Im still getting confuse by this example. > > I wrote this piece : > > def print_hands(self): >

Re: [Tutor] Coin Toss Problems

2010-10-01 Thread Alan Gauld
wrote This is also a learner's advice, so just give it a shot. In the first function, set HEADS to 0 and TAILS to 0. In general thats good advice but Colleen was explicitly told to return HEADS and TAILS as strings. But using strings doesn't add much complexity overall in this case. Al

Re: [Tutor] Coin Toss Problems

2010-10-01 Thread Alan Gauld
me hints. Have another go and post the result if it doesn't work. -- 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] (de)serialization questions

2010-10-01 Thread Alan Gauld
so much interesting stuff to offer! Sqlite operating in-memory would be a good solution for you I think. You can get a basic tutorial on Sqllite and python in the databases topic of my tutorial... HTH, -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] data question

2010-10-02 Thread Alan Gauld
"Roelof Wobben" wrote As a test I would write a programm where a user can input game-data like home-team, away-team, home-score, away-score) and makes a ranking of it. In which datatype can I put this data in. I thought myself of a dictonary of tuples. A dictionary would be good for the

Re: [Tutor] function error

2010-10-02 Thread ALAN GAULD
> ## > import turtle, random > > def checkForward(distance): > old_position = turtle.position() > turtle._pen.up() > turtle.forward(distance) > forward_failed = outOfBounds() you set forward faile

Re: [Tutor] data question

2010-10-02 Thread ALAN GAULD
> I think this is what can work : http://www.daniweb.com/code/snippet216750.html > > I will try it. Good, that is exactly the kind of struicture I had in mind. Just put the data structure in a module, forget about the code and import it to the >>> prompt and play with it till you are sure you

Re: [Tutor] data question

2010-10-02 Thread Alan Gauld
"Roelof Wobben" wrote Perhaps a simple SQLlite database? Oke, there I can save the input data. But I have also need a data model for team, played_games, game_points, made_points and againts_points. So I think it cannot be done without using a class for games and one for ranking. If you

Re: [Tutor] how to learn python from scratch, (for simpe people)?

2010-10-02 Thread Alan Gauld
rd party tools but I actually think that for your purposes you can go with either. You will ultimately want to learn a Web framework like Django and that will be a bigger step than moving between Python versions. HTH, -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] Getting total counts (Steven D'Aprano)

2010-10-02 Thread Alan Gauld
other than the single key you are back to sequential processing. 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.pyt

[Tutor] Smart posting - Was: Re: Tutor Digest, Vol 80, Issue 11

2010-10-02 Thread Alan Gauld
o) 2. Re: data question (Alan Gauld) 3. Re: data question (Roelof Wobben) 4. Re: data question (Roelof Wobben) 5. Re: data question (Roelof Wobben) 6. Re: data question (Robert Berman) 7. Re: Coin Toss Problems (bob gailer) Please, do not post the entire digest. We don't have time

Re: [Tutor] Using contents of a document to change file names

2010-10-02 Thread Alan Gauld
verall program structure? Once we know more about where your specific problem lies we can give you a better answer. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscrib

Re: [Tutor] Smart posting - Was: Re: Tutor Digest, Vol 80, Issue 11

2010-10-03 Thread Alan Gauld
"James Mills" wrote I'm actually really surprised anyone actually uses and subscribes to mailing lists and wants to get digests. It's far easier (for me at least) to just get each email as it comes in. I use digests for several mailing lists - and used to use it on the tutorlist untilGMa

Re: [Tutor] (de)serialization questions

2010-10-03 Thread Alan Gauld
Maybe the top end of Glencoe? But the layer of low cloud wipes out too much to be sure. You're lucky to live in a beautiful place like Scotland I think so :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Matching relational data

2010-10-03 Thread Alan Gauld
? Its a stats problem. One of the best programming stats tools is R http://en.wikipedia.org/wiki/R_%28programming_language%29 There is a python bionding for R too. Although R may be overkill for what you want, but at least you'll know the theory and math are correct! HTH, -- Alan Gauld

Re: [Tutor] Change to Class-level Variable

2010-10-03 Thread Alan Gauld
accessing the instance variable not the class one. You can get at the class variable from the instance usind __class__ but usually you don'tneed to. You know the class in context or you want the instance data not the class data. f1.__class__.myid 'SPAM' HTH,

Re: [Tutor] Pythonic nested lists

2010-10-04 Thread Alan Gauld
... def setCell(self,x,y,value) def check(self):... Thus I'd build my rows and columns dynamically from the squares rather than the other way round. It just feels more natural to me. But your approach should work too. However I confess I haven't studied you code in detail.

Re: [Tutor] EXECUTING PYTHON AND SQL STAMENTS

2010-10-05 Thread Alan Gauld
"Susana Iraiis Delgado Rodriguez" wrote it throws me that "C:/Archivos" is not recognized as an executable external or internal command, programm or file. You can only use / in paths used by Python. You are passing this to the CMD processor via os.system so CMD complains. It expects / to

Re: [Tutor] specifying precision with scientific notation

2010-10-05 Thread Alan Gauld
scientific notation (is there a better way?) if p >= 0: Why not just limit = 10 n = 3 if a/ea <= limit else n = 2 # or whatever expression is needed to calculate n fmt = "%.%de + %.1e" % n else: print fmt % (a, ea) But I suspect I'm missing something in your reasoning

Re: [Tutor] creating a class

2010-10-05 Thread Alan Gauld
"T MURPHY" wrote how do i go about creating a class in python. class C: pass is the simplest way. But it's not very useful, being empty. But most tutorials discuss OOP, which one are you using? -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] specifying precision with scientific notation

2010-10-06 Thread ALAN GAULD
> But something like the "%.%de " %n is exactly what I am looking for - if I >could get it to work. Sorry my bad, I missed a % sign: >>> n=5 >>> "%%.%de" % n '%.5e' You need two %% to create a % in the output. Alan G. ___ Tutor maillist - Tut

Re: [Tutor] Scrapy vs. Beautiful Soup

2010-10-06 Thread Alan Gauld
mpfortable defining XPath statements - but thats not exactly a common skill! If you altready know XPath then scrapy would definitely be worth a try, if not I'd stick with BS. Just my opinion based on a very quick glance at the scrapy site. HTH, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-06 Thread Alan Gauld
nel: processLine(line) You can simplify or complexify that in many ways, and you can add a break check to speed it up if you only expect to process a few lines. And checkLine can be as simple or as complex as you like. HTH, -- Alan Gauld Author of the

Re: [Tutor] validating user input for cli app

2010-10-07 Thread Alan Gauld
7;Enter a: ') if not validC(c): c = None continue And since the input blocks are repeated you could even convert them to a function if you really cared or had a lot of fields. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] IDE for Python

2010-10-07 Thread Alan Gauld
PyDev on Eclipse is great if you already use Eclipse or if you are doing multi-language projects - and have a big modern PC... but which one do you recommend? Whatever best matches what you are trying to do and your existing experience. And that may be more than one! HTH, -- Alan Gauld

Re: [Tutor] PYTHON QUOTES ISSUE

2010-10-07 Thread Alan Gauld
subprocess.Popen(['C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr', line+'.shp', '-where', "LAYER='line'", b+'.shp']) Notice that you have quotes around the line following LAYER= Any suggestions? remove the quotes? And shift the d

Re: [Tutor] new turtle module

2010-10-07 Thread Alan Gauld
"roberto" wrote is it correct to overwrite the turtle.py and turtle.pyc files I'd overwrite the .py file but get Python to generate a new .pyc for you just to ensure compatibility. just type import turtle at the >>> prompt. HTH, Alan G ___ Tu

Re: [Tutor] list of dict question

2010-10-08 Thread Alan Gauld
tussen_uit ['voor'] = wedstrijd['uitscore'] stand.append(tussen_uit) Now you append a second dictionary to stand. On the next iteration you overwrite those two dictionaries with new values then append them to the list again. So you wind up with 2 copies of the update

Re: [Tutor] WRITING XLS FROM OS.WALK()

2010-10-09 Thread Alan Gauld
ftware engineers out of the "not invented here" mentality and into the reuse mentality. So encouraging beginners to get into the habit of "scavenge and adapt" is actually in line with current industry thinking. Just as an alternative view... :

Re: [Tutor] WRITING XLS FROM OS.WALK()

2010-10-09 Thread Alan Gauld
"Steven D'Aprano" wrote The specialist replied "The bill is $10 for my time, and $490 for knowing which was the right tool to use." Interesting modern variant on the version I heard A man's washing machine broke down so he called the plumber. The plumber looks at it for a few minutes th

Re: [Tutor] list of dict question

2010-10-09 Thread Alan Gauld
vesion any more than replacing white eggs with brown preserves the white ones. 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 option

Re: [Tutor] OpenMP

2010-10-09 Thread Alan Gauld
your algorithms and logical partitioning along with minmising disk and network access. These are the real performamce issues not CPU core usage. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - T

Re: [Tutor] WRITING XLS FROM OS.WALK()

2010-10-09 Thread Alan Gauld
th Python helps keep me grounded :-) -- 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] WRITING XLS FROM OS.WALK()

2010-10-09 Thread Alan Gauld
"David Hutto" wrote should learn to program in assembler (or even microcode) then move to C and then to Python(or similar) and finally to 4G languages. Even old schooler though would be that we're just directing electrical flow from an ac outlet through a dc converter and streaming it throu

Re: [Tutor] WRITING XLS FROM OS.WALK()

2010-10-09 Thread Alan Gauld
"David Hutto" wrote I'll put my questions in a knew thread if this is considered hijacking the OP. Well, it doesn''t have much to do with XLS files thats for sure so yes, if you are interested in further pursuing approaches to teaching programming a separate thread is probably better. :-)

Re: [Tutor] OpenMP

2010-10-09 Thread ALAN GAULD
Forwarding to the liist. Please use Reply All on responses. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Original Message > From: Ahmed AL-Masri > To: Alan Gauld > Sent: Saturday, 9 October, 2010 19:50:58 > Subject: Re: [Tutor] OpenMP

Re: [Tutor] WRITING XLS FROM OS.WALK()

2010-10-10 Thread Alan Gauld
see anything untoward in recommending glob to replace the use of the string based list comp for selection of the files, I just assemed you meant in conjunction with os.walk!. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] list of dict question

2010-10-10 Thread Alan Gauld
ou need to update it. Python uses references throughout, what you are suggesting would be a change to the normal way that Python uses names. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@

Re: [Tutor] Ide To use? Other extras to install?

2010-10-11 Thread Alan Gauld
then I'd say go with Eclipse and PyDev plugin because it works pretty much identically across OS's. Also Eclipse supports multiple languages so you can do your HTML, SQL and Python all in one tool. (*) - An editor window, a testing terminal and a >>> terminal. HTH, -- Alan G

Re: [Tutor] Hiding Superclass Methods

2010-10-11 Thread Alan Gauld
list of allowed operation names. Check the operation is in the list and then forward the request by name. That can save a lot of coding! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tuto

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-11 Thread Alan Gauld
27;, 'B-06,1349\n'...] That is, now I do get a list but as you can see I get the newline character as part of each one of the strings in the list. This is pretty weird. Is this a general problem with Macs? No, this is what you would expect. Reading from a file will give you the \n c

Re: [Tutor] list of dict question

2010-10-11 Thread Alan Gauld
made it even more elegant with: lst = [] for n in range(3): lst.append({n:str(n)}) # no explicit object name needed at all! And even more tight with: lst = [ {n:str(n)} for n in range(3)] HTH, -- Alan Gauld Author of the Learn to Program web sit

Re: [Tutor] dictionary and more

2010-10-11 Thread Alan Gauld
1' def f2(): print 'f2' dct = {'1': f1, '2': f2} # notice no parens, only a reference for key in dct: dct[key]() # use the parens here to call the func HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread Alan Gauld
default SQL does not guarantee any order. But if you specify an ORDER BY clause then it should be ordered as specified. Did you include an ORDER BY? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist -

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread Alan Gauld
"David Hutto" wrote > Did you include an ORDER BY? See three posts above, line 6. Looks like our posts crossed in transit :-) So you order by graphname, and you only have a single field of that name? But then when you put it into the list you only use part of graphname converted to a st

Re: [Tutor] urllib problem

2010-10-12 Thread Alan Gauld
o a lot of reading in the documebntation. Its really targeted at intermediate rather than novice programmers IMHO. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] pickle problem

2010-10-12 Thread Alan Gauld
ans you are not using pickle properly. Please read the documentation. Sorry to sound harsh but this is different to you trying to understand a tutorial and its exercises. This is supposed to be a challenge for you personally not the tutor list en-masse. If you get really stuck then ask for hints,

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-13 Thread Alan Gauld
you remove the call to strip() your code will return the result you expected. > What happens if you execute the SQL at the sqlite interactive > prompt? Does it give the same result? haven't used the sqlite prompt yet, Haven't needed to yet. You should. Consider it like the >

Re: [Tutor] Merging Text Files

2010-10-13 Thread Alan Gauld
es/filters etc on the final data. -- 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] Zip Command

2010-10-14 Thread Alan Gauld
ile module is a standard module that should work across platforms. But I have no idea which you are referring to from Byte of Python, sorry. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tuto

Re: [Tutor] Zip Command

2010-10-14 Thread Alan Gauld
hoose. 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] Writing elements of an array to a file using CSV module

2010-10-14 Thread Alan Gauld
se explain to me why data[0] is giving a numpy array rather than one element? I don't understand it, since I get: data[0] 0.0 No idea and since you haven't shown us where data comes from it would be pure speculation. Thats why I'm suggesting using str() or %s to see what Python thi

Re: [Tutor] Zip Command

2010-10-14 Thread ALAN GAULD
> >gzip - aka gunzip GNU opensource version - probably your best bet. >> >This is not correct. Gzip zip's format is not the same as the pkzip related >format used by Winzip and other "zip" utilities. Gzip also only compresses, >it >does not deal with multiple files. > > >Ah yes, I forgot g

Re: [Tutor] join question

2010-10-14 Thread Alan Gauld
"Roelof Wobben" wrote print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp]) So I thought that this would be the same : for p in zpp: test = zf.getinfo(p).comment print ''.join(test) But it seems not to work Can anyone explain why not ? Because it's not the same. test

Re: [Tutor] Converting from unicode to nonstring

2010-10-14 Thread Alan Gauld
resentation spook you into doing things in a way you wouldn't if it was normal raw_input you were using. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To uns

Re: [Tutor] Converting from unicode to nonstring

2010-10-14 Thread Alan Gauld
y bizarre error dump at you... Relying on eval() reading your database content as if it were Python code - which is what it does - is a risky strategy. But, heh, it's your data, your project, so as long as you understand the risks then it's your decision. :-) -- Alan Gauld Author of the

Re: [Tutor] Statistic-Program Problems! Please Help Quickly!

2010-10-14 Thread Alan Gauld
what my teacher means to do when it comes to inputting different values of x. Another problem for another email :-) Take a look at the functions and modules topic of my tutor for a reminder of how to write function. HTH, -- Alan Gauld Author of the Learn to Program web sit

Re: [Tutor] Moving my C++ code to Python?

2010-10-15 Thread Alan Gauld
thon which may work for you What would be the overhead cost of having a large structure that needs to be passed to and from the C/C++ modules? I'm no expert so can't say for sure but since Pythion tends to operate with references I'd hope not too much. HTH, -- Alan Gauld Autho

Re: [Tutor] 'module' object has no attribute (setting aclass attribute)

2010-10-16 Thread Alan Gauld
"Tim Johnson" wrote conventions and named your class with a leading uppercase. ... I didn't know there was such a convention. Its not universally observed but it is common, not just in Python but in most OOP languages. It goes back at least as far as SmallTalk80, and maybe even to Simul

Re: [Tutor] High Low Game

2010-10-18 Thread Alan Gauld
ot; print "guess higher." You don't need this since you print it in the next line anyway! main() This could become the "print prompt" line... While there are flaws in the logic it looks like it should work after a fashion, aso that brings me back to the que

Re: [Tutor] pydoc?

2010-10-18 Thread Alan Gauld
tend not to use it much... YMMV 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] Problem with python

2010-10-19 Thread Alan Gauld
ance of an answer... 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] Writing Scripts.

2010-10-20 Thread Alan Gauld
ello printed on screen. Try that and if it doesn't work tell us what happened, including the exact text of any error messages you see. There are better ways to run the programs once you get itall set up properly but for now we will be best to stick to basics! HTH, -- Alan Gauld Auth

Re: [Tutor] updating a Csv file

2010-10-20 Thread Alan Gauld
vent of an error (if you save the original as a .bak or similar). 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://mai

Re: [Tutor] Stopping a webservice

2010-10-20 Thread Alan Gauld
but those are probably the two simplest depending on your use case. 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://ma

Re: [Tutor] Importing photo-python

2010-10-21 Thread Alan Gauld
"steven nickerson" wrote i I would like to somehow import and output a photo to the screen via tkinter window Check out the PhotoImage widget. It can be inserted into a Text field or Canvas. HTH, Alan G. ___ Tutor maillist - Tutor@python.or

Re: [Tutor] LCM

2010-10-21 Thread Alan Gauld
thing3 = x/thing TypeError: unsupported operand type(s) for /: 'int' and 'str' See above comments. You need to retyhink your algorithm and pay attention to assigning results to variables. And once you have done that you may want to make x a parameter of calc(), or at least decl

Re: [Tutor] Stopping a webservice

2010-10-21 Thread ALAN GAULD
Forwarding to list "Timo" wrote >> >> >>The plans are to run this on my webserver. I created a webpage with a start >>>and stop button, the starting works great. But how could I remember this >>>class to call "class.shutdown = True" any given time when I press the stop >>>button? >>> > There

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Alan Gauld
s into 4 bits because its not a sequence(not iterable). 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] What does "TypeError: 'int' object is not iterable"mean?

2010-10-22 Thread Alan Gauld
s this better: float2n(1.234567, '3') maybe... -- 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] What does "TypeError: 'int' object is not iterable"mean?

2010-10-23 Thread Alan Gauld
"Steven D'Aprano" wrote It would have to be a *very* old version. The use of * as the width parameter in format strings goes back to the Dark Ages of Python 1.5: ... I believe this is a virtual copy of string formatting from C, in which case it probably goes back to the 80s or even the 70s

Re: [Tutor] searching for newlines does not work!

2010-10-23 Thread Alan Gauld
his point try printing your strings (using print()) and you will see the difference: test = r"a \n b \n c \n" # using raw 'r' test2 = """ ... a ... b ... c ... """ test3 = "a \n b \n c \n" # no raw 'r' print(test) a \n b \

Re: [Tutor] Scripting-Puzzle Pirates

2010-10-24 Thread Alan Gauld
e obtained so it could be read and a script used upon it. Probably, but as this is a Python mailing list you are probably asking in the wrong place. Try a Javascript forum or better still, one dedicated to the game in question. -- Alan Gauld Author of the Learn to Program web site http:

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Alan Gauld
mething that's already there in Python 2.6 or 3.1 (the 2 I have)? There may well be functions in some of the modules that do it but the approach above suffices for most applications. 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] (no subject)

2010-10-29 Thread Alan Gauld
"Steven D'Aprano" wrote is actually being executed. There are very few programming tasks harder than trying to debug code that doesn't actually contain any bugs, or contains bugs different from the ones you are seeing, because the code you are actually executing is something different from

Re: [Tutor] File transfer

2010-10-31 Thread Alan Gauld
odule. The only snag is the other end needs to be running an ftp server. 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://

Re: [Tutor] How to notify/handle an error?

2010-10-31 Thread Alan Gauld
# do stuffs with valid project except : HandleError() 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] Complete Shutdown

2010-11-01 Thread Alan Gauld
upon! The whole concept is evil. Administrator rights are required for good reason and are a protection against bad things happening to your data and programs. Work with it not against it and be grateful it's there. -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] rights

2010-11-01 Thread Alan Gauld
"Chris King" wrote How do you give a script right to read a folder? You give the user account executing the script rights to read the folder. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] rights

2010-11-01 Thread Alan Gauld
k like? 3) How are you running it? 4) What error messages do you get? Also, is it a folder you are trying to read or a file? They are not the same. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist

Re: [Tutor] Complete Shutdown

2010-11-01 Thread Alan Gauld
7;t without changing user. If the OS allows it you can do it from Python, but how will depend on the OS! -- 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 su

Re: [Tutor] unittest + tkinter

2010-11-02 Thread Alan Gauld
"Wayne Werner" wrote I'm trying my hand at test driven development via the unittest module. Since my program is using Tkinter, my thought is that I need to create the main window. The only problem is that when I launch the main loop, further lines of code aren't executed. Thats a feature

Re: [Tutor] if statement

2010-11-02 Thread Alan Gauld
"Glen Clark" wrote confirmed = int(input("Are you happy with this? (y/n): ") if confirmed == "y": count the parens. It thinks you are trying to do: confimed = int(input('') if foo else bar) HTH, -- Alan Gauld Author of the Learn to

Re: [Tutor] if statement

2010-11-02 Thread Alan Gauld
"Glen Clark" wrote On a side note.. I didn't know you could do something like this: x = z if Yes it's python's equivalent to the C style foo = testVal() ? bar : baz Also found in other languages (Java, Javascript, Perl?) Alan G. ___ Tu

Re: [Tutor] Displaying picture and Text

2010-11-04 Thread Alan Gauld
he picture itself if that is necessary. That should not be necessary, if you tell Python the filepath it can load the specific file you select. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor

Re: [Tutor] Displaying picture and Text

2010-11-04 Thread Alan Gauld
"Alan Gauld" wrote ...a picture is supposed to display with a few lines of text below it. To do this you will need to use some kind of GUI. The simplest option is probably to use the Text widget in Tkinter I just had a thought. The simplest option might be to use HTML to creat

Re: [Tutor] Displaying picture and Text

2010-11-04 Thread Alan Gauld
"Alan Gauld" wrote fhdl = Image.open("C:\Users\StarShip\PyProgs\\bbsparkle.gif") fhdl.show() The Tkinter PhotoImage object can display jpg. I can't recall if it does gifs. Sorry I got that wrong, it can display gifs but not jpgs (despite the fact that jpg

[Tutor] Fw: rights

2010-11-05 Thread ALAN GAULD
fowarding to group, please use reply-all when replying. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Forwarded Message > From: Chris King > To: Alan Gauld > Sent: Friday, 5 November, 2010 0:48:51 > Subject: Re: [Tutor] rights > >

Re: [Tutor] Looking for a tutor to review my code and provideconstructive feedback.

2010-11-05 Thread Alan Gauld
, but (re)using modules rather than writing from scratch is another way to make your code both more readable and more reliable. Regards, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org

Re: [Tutor] querying the name of a calling python file

2010-11-05 Thread Alan Gauld
or missing a trick... Is the way I'm getting the file name the recommended way or did I pick up a bit of flaky advice? There may be cases where it will work and argv[0] won't but until you prove that you need it I'd go with argv[] -- Alan Gauld Author of the

Re: [Tutor] Server

2010-11-05 Thread Alan Gauld
"Chris King" wrote If you are using Windows, turn off the built-in firewall. That's what fixed my problems. ~Corey also, it is on the same network, so the server shouldn't be a problem I think Corey means the firewall on your PC if you have one. It could be blocking outgoing traffic to u

Re: [Tutor] Reading the CDROM in Linux

2010-11-05 Thread Alan Gauld
"Terry Carroll" wrote On Windows, I do something along the lines of this: startpoint="D:/" for (root, dirs, files) in os.walk(startpoint): (stuff) What would I use for startpoint in Linux? I don't use Ubuntu so don;t know the standard anmswer there but it will depend on where t

Re: [Tutor] Displaying picture and Text & Downloads

2010-11-05 Thread Alan Gauld
"Patty" wrote I had a followup question for you all - and would like to know the answer to Alan's question about print quality - below - A Google search led me to this page which seems to offer a solution using PIL anmd a module called ImageTk: http://codeidol.com/python/python3/A-Tkinter-

Re: [Tutor] Reading the CDROM in Linux

2010-11-06 Thread Alan Gauld
"Steven D'Aprano" wrote I usually mount cdroms on /dev/cdrom Surely that's where you mount cdroms *from*? I can't think that using /dev/cdrom as the mount point would be a good idea! Oops, yes, that should be /usr/cdrom, sorry. Alan G. ___

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