Re: [Tutor] Running a python script as root.

2010-07-04 Thread Alan Gauld
operations in a development environment. You may only use your PC as a single user environment but *nix doesn't know that! sudo is there for a reason, learn to love it, as it protects you from yourself -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] endless loop

2010-07-05 Thread Alan Gauld
show me why it is going into Endless loop? Because you wrote iit that way. This is one reason recursion is hard, you must make 100% certain that there is a terminatin condition that will somehow get you out again... HTH, -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] Help return a pattern from list

2010-07-05 Thread Alan Gauld
n list if s.endswith('.mp3')] But for the specific case of file extensions the os.path.splitext() is a better solution. -- 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] I can't know how to use the "press the enter key to exit"command

2010-07-06 Thread Alan Gauld
you are using Python v3 use input() 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] Tkinter mainloop()

2010-07-06 Thread Alan Gauld
etter to keep your event handlers short enough that they return to the mainloop which will then redraw as necessary for you. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org

Re: [Tutor] newbie to gui programming

2010-07-06 Thread Alan Gauld
e plotting libraries if you need to display graphs etc. You can compare very simple GUIs in Tkinter and wxPython in the GUI topic of my tutor, and a slightly more complex GUI in the Case Study topic. HTH, -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] Tkinter mainloop()

2010-07-07 Thread Alan Gauld
Tkinter? Use the event_generate() method. Alternatively use the after() method with a short delay - say 10ms... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] newbie to gui programming

2010-07-07 Thread Alan Gauld
u need to the base C++. This is one of the reasons I mainly use Tkinter - because I already knew the underlying Tk and I can use those same skills in Lisp and Ruby and Perl UI code. You pays your money and makes your choice! :-) -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] what is wrong with the syntax?

2010-07-10 Thread Alan Gauld
wrong way round. It should be: reversed(list(wording)) I see Steve has already picked up most of the other mistakes. -- 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] Function returns 'None'

2010-07-11 Thread Alan Gauld
the calling function so we return None. else: return carryover This returns a value to the calling function, but in the recursive case that returned vaklue uis thrown away as the comment above shows. you need to add a return statement where you call recursively. HTH, --

Re: [Tutor] Python Documentation Clarification

2010-07-12 Thread Alan Gauld
"Huy Ton That" wrote Just not grokking it correctly and I can't seem to track down where the documentation formatting is defined within the python.org documentation... It is confusing I agree, but the style goes back to the dawn of computing - certainly further back than me! I remember seei

Re: [Tutor] Request for help learning the right way to deal with listsin lists

2010-07-13 Thread Alan Gauld
Thre are many options, you need to decide which best suits your problem. 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] Response to Alan re: list of lists response

2010-07-13 Thread Alan Gauld
heir purposes nowadays. Not at all but the first thing you do in any data processing problem is take the input data and store it how you want it, not how it arrives! But how you want it will depend on what you are trying to do with it! That's why the many responses vary - it depends on how

Re: [Tutor] Response to responses about list of lists: a metaexercise in mailinglist recursion

2010-07-14 Thread Alan Gauld
"Steven D'Aprano" wrote If you're starting a new discussion, or raising a new question, make a fresh, blank email, put a descriptive title in the subject line, and put tutor@python.org as the To address. If you're replying to an existing message, using reply is fine, but just trim the quote

Re: [Tutor] I don't understand this code

2010-07-14 Thread Alan Gauld
xplanation of functions, parameters and arguments in the "Modules and Functions" topic of my tutorial. 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] Handling 'None' (null) values when processing sqlite cursorresults

2010-07-14 Thread Alan Gauld
of a string fit for printing. Then you just print the records as normal. But for this scenario the complexity of building a class may not be worth it. The key principle is do not try to store your data in a display format. 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] GUI Creation Aide

2010-07-14 Thread Alan Gauld
r it!) then it may be worth paying for something that really does a good job. 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] Global name not found, though clearly in use

2010-07-14 Thread Alan Gauld
"Corey Richardson" wrote defined the variable, I would understand, but I haven't. The entirety of my (incomplete and buggy) code is now available here: http://pastebin.com/QTNmKYC6 There are quite a few errors here, one is that many of your class's methods don't have self as their first pa

Re: [Tutor] Searching a text file's contents and comparing them toa list

2010-07-14 Thread Alan Gauld
ersion of line again, or if you are planning on writing it out to another file then this is fine. If you are going to use it again its probably better to strip() and asign to itelf: line = line.strip() Also you might find rstrip() slightly safer if you have any unusual characters at

Re: [Tutor] Handling 'None' (null) values when processing sqlite cursorresults

2010-07-14 Thread Alan Gauld
"Christian Witts" wrote You need a display function that can strip out the nulls as needed. A simple list comprehension or generator expression would work in this case: print ' '.join(str(field) for field in data if field is not 'None') The problem with that is if you're relying on a se

Re: [Tutor] str format conversion help

2010-07-14 Thread Alan Gauld
ve you the hex representation. So... print "[%s]" % ('-'.join([hex(v) for v in theValue]) ) should be close... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Searching a text file's contents and comparing them toalist

2010-07-14 Thread Alan Gauld
You can sort the lists before printing... I think I want some kind of incremental counter going on in the loop to prevent them from overwriting themselves, or a way to store multiple variables, but I'm not sure how to do that. No need for counters, just append() to a list. -- Alan

Re: [Tutor] str format conversion help

2010-07-15 Thread ALAN GAULD
> print "[%s]" % ('-'.join([hex(v) for v in theValue]) ) Oops, that leaves 0x at the front of each byte. You could strip that off with print "[%s]" % ('-'.join([hex(v)[2:] for v in theValue]) ) Sorry, Alan G. ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Python Book recomandation!

2010-07-15 Thread Alan Gauld
gless. The one that is best for you can only be decided by you! 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] How to deal failed function and 0xDEADBEEF type errors...

2010-07-15 Thread Alan Gauld
the parentheses after the function name, even if there is nothing inside them. Otherwise you are referring to a function *object* - which is what the print statement told you... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ I even tried running all the c

Re: [Tutor] now = ctime()[11:20]

2010-07-17 Thread Alan Gauld
): return ctime()[11:20] Or am I missing something? -- 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] A file containing a string of 1 billion random digits.

2010-07-17 Thread Alan Gauld
t before creating it? There may be a better representation. Just a thought, -- 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] A file containing a string of 1 billion random digits.

2010-07-17 Thread ALAN GAULD
ing on the longest sequence you are looking for (a chunk of twice that size is a good guide) The seek() tell() and read() methods are your friends for this kind of work Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ ___ Tutor

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-17 Thread Alan Gauld
ry (and in the background read the next again from file and lose the top chunk). This resulted in a user experience that looked like the whole file was in memory but in fact only about 6Kb was (3 screens full). HTH, -- Alan Gauld Author of the Learn to P

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread Alan Gauld
"Richard D. Moores" wrote I earlier reported that my laptop couldn't handle even 800 million. What do you mean, "couldn't handle"? Couldn't handle 800 million of what? Obviously not bytes, I meant what the context implied. Bytes. Look back in this thread to see my description of my laptop's

Re: [Tutor] Help with Hangman program

2010-07-19 Thread Alan Gauld
"John Palmer" wrote I have the program working nearly as I want it to be. The only problem is, that when the user is prompted to enter its chosen word, (I am using a raw input) and the word is typed in, it shows in the line above, Take a look at the getpass module. HTH, --

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread Alan Gauld
becomes 0 where is the random number The same thing can be done in two steps with: fmt = "%0%dd" % n # eg. gives "%04d" if n is 4 return fmt % randrange() But the asterisk is neater (and faster) but can become hard to read, and debug, if over-used -

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread ALAN GAULD
> 4 and executed many times. Seems the 0 in 0 is > there when a is a 3-digit number such as 123. > In that case a zero is prefixed to 123 to produce > 0123. Or if just 23, 2 zeros are prefixed, etc. > Correct? Yes, the zero indicates that the string should be padded with zeros to the

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread ALAN GAULD
Heres what I did: Search Google for "Python format strings" and from the first link click on String Formatting operations in the contents pane: http://docs.python.org/library/stdtypes.html#string-formatting-operations Read item number 4. :-) Alan Gauld Author of the Learn To Progr

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread ALAN GAULD
Wikipedia is a little more helpful but not Python oriented: http://en.wikipedia.org/wiki/Printf#printf_format_placeholders Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Original Message > From: Richard D. Moores > To: ALAN GAULD >

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread Alan Gauld
ngs in my v3 tutor - I'nm aiming to teach generic skills and % formatting is much more generic than the new Python style formatting. (And much less verbose!) Before that, maybe, was the Trinity.. Nah, that still wins - a divine mystery :-) -- Alan Gauld Author of the Learn to

Re: [Tutor] Contents of Tutor digest, help with Hangman program

2010-07-19 Thread Alan Gauld
#x27;s something i'm missing with this module? like raw_input you can supply a prompt to getpass() import getpass as gp gp.getpass() Password: 'gghg' gp.getpass("Number?") Number? 'hjggjkh' HTH, -- Alan Gauld Author o

Re: [Tutor] searching for multiple strings in line.starswith()

2010-07-19 Thread Alan Gauld
;,'#Centroid','#End']: line.startswith() returns a boolean result - True or False Neither of these is in your list so the if test always passes. You need to apply startwith to each item in your list. You could use a list comprehension/generator expression - or find another appro

Re: [Tutor] Help with hangman

2010-07-19 Thread Alan Gauld
umentation it says: "If echo free input is unavailable getpass() falls back to printing a warning message to stream and reading from sys.stdin and issuing a GetPassWarning." What OS and terminal are you using? It may be possible to enable echo free input... -- Alan Gauld Autho

Re: [Tutor] System Window

2010-07-19 Thread Alan Gauld
"Jacob Bender" wrote I was wondering if there was a way to program a new window using Tkinter so that a one-billion digit number could fit, instead of in the system window, which dumps numbers once they fill up the screen. I know that it would take me days to read all of the numbers, but tha

[Tutor] has it gone quiet or is it just me?

2010-07-21 Thread Alan Gauld
I haven't had any tutor messages in 2 days. Do I have a problem or are things just very quiet suddenly? The archive isn't showing anything either which makes me suspicious. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription op

Re: [Tutor] has it gone quiet or is it just me?

2010-07-21 Thread Alan Gauld
OK, from the fact I got two replies and Luke hasn't had anything either I'll assume all is ok and things are just quiet :-) "Alan Gauld" wrote in message news:i27cac$uc...@dough.gmane.org... I haven't had any tutor messages in 2 days. Do I have a problem or a

Re: [Tutor] position of an element in list:

2010-07-23 Thread Alan Gauld
elp() facility. help(str) Would have probably got your answer a lot faster than posting a question and waiting for replies. We don't mind helping but for these kinds of question its usually quicker to try a help(), dir() or even a Google search first. It saves your time and ours. HTH, --

Re: [Tutor] can i run the last saved input again

2010-07-24 Thread Alan Gauld
d a particular input file... Then the logic becomes: if flag == 'f': datafilefile is command line arg else datafile is userfile if flag != 'n' and datafile exists: read input from datafile else read input from user HTH, -- Alan Gauld Author of the Lear

Re: [Tutor] can i run the last saved input again

2010-07-24 Thread Alan Gauld
h for the specific example the OP gave they are all either inappropriate or bad ideas. -- 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] hot to run python script at the startup

2010-07-24 Thread Alan Gauld
shells use different startup files. This is more about Linux than Python. To run the python script just add a line like: python abc.py in whichever file you decide is most appropriate. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] xml question

2010-07-26 Thread Alan Gauld
ably deserves an XML file... -- 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] xml question

2010-07-26 Thread Alan Gauld
ect the data strucures you will be using in the code and the parsing will be easier and the XML more intuitive. YMMV... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Alan Gauld
"Richard D. Moores" wrote Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? I don't think you need kbhit() or the sleep(.1) The if kbhit test will only pass if the key is actually

Re: [Tutor] Running .py files in shell

2010-07-27 Thread Alan Gauld
nstalled and have attempted to install PyObjC, which is referenced as a prerequisite to PyGame and GASP. I get the following error when attempting to install PyObjC: Check the MacPython web site, I'm sure I used an install package when I played with PyObjC... HTH, -- Alan Gauld Author of th

Re: [Tutor] Running .py files in shell

2010-07-28 Thread Alan Gauld
its own to start a Python interpreter session. You type, in Unix shell, python file.py to get Python to execute file.py You can find a box explaining some of this in my tutor in the Style topic, near the bottom... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.m

Re: [Tutor] Calculating and returning possible combinations ofelements from a given set

2010-07-28 Thread Alan Gauld
ndeed thats normal. But changing them is almost always a very bad idea! def myProduct(*args, **kwds): # do something with input data # call itertools.product(args, kwds) # do something with the output # return a result HTH, -- Alan Gauld Author of the Learn to Program web sit

Re: [Tutor] Order Of Operations Question

2010-07-28 Thread Alan Gauld
evl * gravity * areaSphere Why don't you use the value you calculated above? Now if you divide by 10 instead of multiplying by 10 you get a different of 2 in the exponent? print(masEarthAtmoInKgPerSqM) 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 input() and unicode string

2010-07-28 Thread Alan Gauld
pt and you will then be able to see the error. That should help you debug it. 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 subscriptio

Re: [Tutor] Newbie question - syntax - BeautifulSoup

2010-07-28 Thread Alan Gauld
e? There is a fairly good tutorial for Beautiful Soup here: http://www.crummy.com/software/BeautifulSoup/documentation.html Is that the one you meant? Did you find the section "Searching By CSS class"? If so we need more specific questionws about what you don't understand. If not, try readin

Re: [Tutor] Newbie question - syntax - BeautifulSoup

2010-07-28 Thread Alan Gauld
for loop thus iterates over the rows of the first table with class=spad. There might be slightly more to it than that, its a long time since I played with BS... Which help file? Well, maybe not a file, but the text produced by typing: help(BeautifulSoup) Ah, in that case you should definite

Re: [Tutor] Python Help - How to end program

2010-07-29 Thread Alan Gauld
loop else condition! ie while True: break else: print 'never executed' print 'exited' HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Alan Gauld
llback(line) TypeError: 'file' object is not callable The error says that its expecting a callable and you are passing a file object. My guess is you need to create a function that writes to the file and pass that to ftp. You could use myfile.write maybe - thats what the documentatio

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Alan Gauld
nslated. So you would have the extra decoding step to do manually. But binary transfer does simplify the transfer process. But if its not an EBCDIC machine then I'd definitely consider binary transfer for ftp. -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] string editing

2010-07-31 Thread Alan Gauld
if you do help(str) you can read about all the options. You might also find the Handling Text topic of my tutorial helpful. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@pyt

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Alan Gauld
onto a server that I do not host myself? No. There are ways that are easier than others but server programming is not simple. And converting desktop apps to server apps is non trivial. Of course you can write apps that can be run on a desktop or a server as needed but they have to be bui

Re: [Tutor] Python - RPG Combat System

2010-07-31 Thread Alan Gauld
You did ", my_dmg, "damage!" print if choice == 1: mo_hp = mo_hp - my_dmg print "The Lich King is at %s Hit Points\nYou did %s damage\n" % (mo_hp, my_dmg) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan

Re: [Tutor] web-based python?

2010-08-01 Thread Alan Gauld
artial topic that I did on web programming did include some of the basic stuff with lots of links to Wikipedia articles. You can find it on the v2 tutor under writing web clients, but its very draft and incomplete... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] sys.exit help

2010-08-01 Thread Alan Gauld
import sys try: ...sys.exit() ... except SystemExit: ...print 'caught exit' ...raise ... caught exit However thats usually the wrong way to do it. Better to have your program exit naturally and have the control logic in the code control when it finishes. HTH, -- Alan Gauld Author of

Re: [Tutor] How to get script to detect whether a file exists?

2010-08-02 Thread Alan Gauld
ckling() to match those in create_pickle_file() For bonus points create a PickleFile class that has dump(), load() and repickle() methods - and uses __init__() for create obviously. The class can store the file name for convenience. HTH, -- Alan Gauld Author of the Learn to Program web si

Re: [Tutor] how to get str() to use my function?

2010-08-05 Thread Alan Gauld
ng object | will be returned instead. | | Methods defined here: | | __abs__(...) | x.__abs__() <==> abs(x) | | __add__(...) | x.__add__(y) <==> x+y | | __and__(...) | x.__and__(y) <==> x&y | | __cmp__(...) -- More -- HTH, -- Alan Gauld Author of the Learn

Re: [Tutor] access class through indexing?

2010-08-05 Thread Alan Gauld
w what you are doing it's usually best to ignore the temptation! :-) 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:

Re: [Tutor] string to list

2010-08-05 Thread Alan Gauld
e complex. And you could use a parser if the rules are very complex. 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] how to do excel in python

2010-08-05 Thread Alan Gauld
an use CSV files - just save the spreadsheet as CSV - and manipulate it that way using the standard csv module. HTH -- 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] Distributing Python Code for Commercial Porpoises?

2010-08-06 Thread Alan Gauld
versions and OS. Its most likely a location or PATH setting 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] modify csv textfile

2010-08-07 Thread Alan Gauld
rever you like. Now which bit of that is causing you grief? -- 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] os.urandom()

2010-08-07 Thread Alan Gauld
as an argument! When I try it I get 6 bytes back. Does that help? -- 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.

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Alan Gauld
ile developing. But those traps are hiding errors that will crop up in the real world. Always test deployable code in a real, native execution environment - outside the development tool and outside the development folder structure too. Include the installation process (whether automated or manual) in

Re: [Tutor] os.urandom()

2010-08-07 Thread Alan Gauld
re? Alan, are you using Windows, as I am? Yes. XP. website-permitted, but stronger passwords could be generated with the use of os.urandom(). At this point, I think not. You probably could but it would take a lot of work for very little benefit. HTH, -- Alan Gauld

Re: [Tutor] os.urandom()

2010-08-07 Thread Alan Gauld
"Richard D. Moores" wrote (*)The fact its 5 is odd since you seem to pass 6 as an argument! When I try it I get 6 bytes back. For some reason I never spotted the L at the end of the string last time. So it was 6 bytes. I suspect the L was read (by me) as the L at the end of a Long integer

Re: [Tutor] os.urandom()

2010-08-08 Thread Alan Gauld
"Richard D. Moores" wrote So if os.urandom() had been written so that it printed only hex, b'l\xbb\xae\xb7\x0ft' would have been b'\x6c\xbb\xae\xb7\x0f\x74' , right? Yes except that its not urandomthat is printing those values. urandom returns a string of bytes. Its the Python interpreter c

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-08 Thread Alan Gauld
"Wayne Watson" wrote I find it interesting that any Python book I've seen doesn't deal with distributing programs in some form or another. Yes thats a good point. Most books (including mine) focus on how to write code. Very few tell you how to distrubute it! And that's not just in Python,

Re: [Tutor] Question about strings

2010-08-09 Thread Alan Gauld
range for newbies. There are some languages that start indexing at 1 but they get into all sorts of complications in other areas, most language designers have settled for zero based indexes as the best overall solution. HTH, -- Alan Gauld Author of the Lear

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Alan Gauld
on mathematical set notation, you can define a set of numbers using a (somewhat) similar construct. You will find a basic description in the Functional Programming topic of my tutorial. HTH, -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] Module for browsing Windows?

2010-08-11 Thread Alan Gauld
pic of my tutorial. 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] Executing Python from TCL

2010-08-11 Thread Alan Gauld
TCL Hash tables. You could probably do some C level integration using Boost or SWIG or somesuch but I doubt the benefit would be worth it. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mai

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Alan Gauld
"Laurens Vets" wrote next to each other. I came up with the following (Please ignore the fact that I'm trying to avoid an IndexError in a stupid way :)): Others have answered your question. I'll suggest that instead of using indexes its easier to just cache the last two values in variable

Re: [Tutor] Executing Python from TCL

2010-08-12 Thread Alan Gauld
d design of the app. But you may still find you need to use a native Tcl parser if speed is an issue. (Then again, if speed was a big issue you probably wouldn't be working in Tcl or even Python!) HTH -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] Performance list vs. deque for [-1]

2010-08-12 Thread Alan Gauld
last element in each... What kind of container will the collections sit in? -- 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] string conversion according to the terminal

2010-08-13 Thread Alan Gauld
t('?') ?name with spaces s 'name with spaces' f = open(s,'w') f.write('hello world\n') f.close() f = open(s) f.read() 'hello world\n' f.close() ^Z C:\Documents and Settings\Alan Gauld>dir n* Volume in drive C is SYSTEM Volume Ser

Re: [Tutor] is it possible to call a setter property during classinstantiation?

2010-08-13 Thread Alan Gauld
you simply carrying bad habits over from statically typed programming experience? I can't tell the context so it may be that you really do need to check a lot of types, but it is quite unusual and does usually lead to a lot of extra work. Python is not Java or C++ etc... Just a though

Re: [Tutor] Callbacks and exception handling

2010-08-13 Thread Alan Gauld
ntil the fireworks function, they will not show up in myFunc. 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] elif statement

2010-08-13 Thread Alan Gauld
t myself! Essentially you need to ignore the >>> offset in the if line. 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] is it possible to call a setter property during classinstantiation?

2010-08-14 Thread ALAN GAULD
so we don't usually care too much about types. Are you sure you >>really need all that type checking code? ...I included a type check for a string to make sure that a future programmer (or myself) wouldn't try to pass in a list of lines after a text has been split. Other code internal to th

Re: [Tutor] Multiple inheritance for mixin attributes

2010-08-16 Thread Alan Gauld
ing code, use delegation for that. FWIW I've worked on projects using MI with a single class inheriting 7 parent classes, if done properly and deliberately MI is nothing to worry about. The problems only occur when MI is abused and not designed IMHO -- Alan Gauld Author of the Lear

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Alan Gauld
d to trawl the dictionary whatever you do (unless you get very sophisticated and build a double dictionary class, but then insertions get slow because you have to update both versions...) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] Schema change in ElementTree

2010-08-16 Thread Alan Gauld
"Stefan Behnel" wrote Note that it's best to hit "reply" when responding to other people's postings. Or on the tutor list make that ReplyAll! :-) Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: ht

Re: [Tutor] reading from 2 file output to 1

2010-08-17 Thread Alan Gauld
eadline() file3.write(line1A + line1B) except IOError: reached end of one of the files, figure out how to handle it... That looks like it should be simpler than the code you posted... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] box drawing characters

2010-08-18 Thread Alan Gauld
You would probably have to build your UI twice. This is one area where real GUIs work better than a terminal. HTH, -- 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] Error Using exec to Run Module Files

2010-08-18 Thread Alan Gauld
wrote exec(open('script1.py').read()) Traceback (most recent call last): File "", line 1, in File "", line 1 %!PS-Adobe-3.0 ^ SyntaxError: invalid syntax What is going on/ Looks like your script1.py file is actually a postscript file. exec expects to see valid Python code, it can'

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Alan Gauld
ersions of my tutorial on my web site. -- 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] box drawing characters

2010-08-18 Thread Alan Gauld
Looks interesting, a new one for me, thanks for posting. Alan G. "Ewald Horn" wrote in message news:aanlktinmkzyxbd0t7rldyexhbanw1tnfzac5z2gee...@mail.gmail.com... Hi Bill, have you given UniCurses a spin? See http://pyunicurses.sourceforge.net/ for more information. I recall finding it on

Re: [Tutor] Immutable objects

2010-08-19 Thread Alan Gauld
l'.x = 4 Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'x' 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] question about a exercise.

2010-08-19 Thread Alan Gauld
e time so in mu opion first make the part which prints out 3 lines and then expand to 9 lines and then expand to the function clear_screen Yes thats good thinking. HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] Multiple file open

2010-08-20 Thread Alan Gauld
##SyntaxError: invalid syntax The except needs to align with the try. try: #code here except: HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscr

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