Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-28 Thread Alan Gauld
could do is put your classes in another module and then import that module. Or you could put the tuple initialisation into a function. But its probably easiest to just move the definition to the bottom of the file... HTH, -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] general import VS importing inside a function

2009-08-29 Thread Alan Gauld
python takes 3 to 5 seconds to respond, and if am only going to use like 4 or 5 function inside NumPy i think is better to say just "from Numpy import foo, bar, qux etc" Thats a different question. :-) If you are only using a few names from the module the "from x imporrt y " s

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-29 Thread ALAN GAULD
> What is still unclear to me, is what the staticmethods are for, though: > since the reference to the object instance or to the class object are > stripped away from the call, I wonder why not to use a module function > instead. First recall that xsstatic methods were historically the first att

Re: [Tutor] How to convert binary files back to text files?

2009-08-29 Thread Alan Gauld
ing a tet file as if it were binary, thats different again - and slightly more doable. Could you explain what exacvtly you are trying to do - and why? Maybe we can help? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] update html pages using python

2009-08-29 Thread Alan Gauld
indicating status. That should be fairly straightforward with any of the html parser modules available 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] Dealing with bitfields in Python

2009-08-30 Thread Alan Gauld
perations and Flags" which explains the idea 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] update html pages using python

2009-08-30 Thread Alan Gauld
eautiful Soup has never claimed to be the fastest! I hope that clarifies any confusion. -- 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] word replace

2009-08-30 Thread Alan Gauld
le word only. Caveat: Regex are much harder to work with than simple strings. Be prepared for a lot of trial and error to get the patterns just right. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist

Re: [Tutor] Displaying .jpg in Tkinter (Python 3.1)

2009-08-31 Thread Alan Gauld
label can be an image too, but am not certain. The trick is to crate an PhotoImage object from your file and insert that into the widget. To change the widget you modify the image object not the widget. See here for more info: http://effbot.org/tkinterbook/photoimage.htm HTH, -- Alan Gauld

Re: [Tutor] Tracking variable changes in a different application

2009-09-02 Thread Alan Gauld
ocedure when an item (table, row,column) changes. That stored procedure can notify your app of the change. Of course that relies on you having access to the same database as the other app, but that sounds very likely in this scenario. HTH, -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] Rounding to n significant digits

2009-09-02 Thread Alan Gauld
lower since it calls several functions but I haven't timed it. def round_to_n(x, n): fmt = "%%.%de" % (n) return float( fmt % x) import math def round_figures(x, n): return round(x, int(n - math.ceil(math.log10(abs(x) HTH, -- Alan Gauld Author of

Re: [Tutor] Boolean operations

2009-09-02 Thread Alan Gauld
there are usually cleaner solutions especially since Pyton 2.5 introduced a ternary operator -- 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 opti

Re: [Tutor] I always get this message as a reply

2009-09-02 Thread Alan Gauld
"Kristina Ambert" wrote It feels like I'm getting spam or something. Geneviève DIAGORN to me Genevieve sets her vacation reminder when she is out of the office. Unfortunately she doesn't turn off her tutor subscription! And equally unfortunately her autoresponder doesn't recognise addresses

Re: [Tutor] Tracking variable changes in a different application

2009-09-02 Thread ALAN GAULD
Not in general. Variables change too quickly for that to be viable - think >>about a loop counter in a while loop, it could change millions of times per second! >> >> >Could you not use an observer pattern here to do that? > >http://en.wikipedia.org/wiki/Observer_pattern > You could but the d

Re: [Tutor] Input validation

2009-09-03 Thread Alan Gauld
e exceptions to catch the ,erm, exceptions... So you could do try: param.readlines() except AttributeError: # not a file like object try param.uppercase() except AttributeError: # not a string And so on. HTH, -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] Best Practice: Subroutines and Loop logic

2009-09-03 Thread Alan Gauld
that by inverting the if test: for word in lData: if word not in lWords: test, wrd = sub1(word) if test ==1: word=wrd else: print word " not found.\n" That only calls sub1 when needed and only does it once even then HTH, --

Re: [Tutor] Help deciding between python and ruby

2009-09-04 Thread Alan Gauld
mmunity, web documents/tutors, 3rd party libraries etc. And finally your own tastes and programming requirements. What kind of programming will you be doing? Either way its not a one way street, learn either one and you will pick up the other very quickly. They are very similar both in style and e

[Tutor] Looping quesion [WAS: Re: (no subject)]

2009-09-05 Thread Alan Gauld
But any reasonable tutorial for beginners should cover loops. Try mine for example... :-) -- 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 subsc

Re: [Tutor] run command

2009-09-05 Thread Alan Gauld
d simple python file, for an example, hello.py, which is free of error. (2) I called python from the same working folder using command 'python' Instead of just python type python hello.py -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] A basic question

2009-09-06 Thread Alan Gauld
. everytime. If I then sent this try_python.py to someone else with Ubuntu would it run on their system? Yes provided they use chmod on it too. You can find more about the chmod and shebang stuff in the Style topic off my tutorial inside the Note for Unix Users near the bottom. -- Alan Gauld

Re: [Tutor] Simple Game

2009-09-06 Thread Alan Gauld
am anything! So go for it, and if you get stuick as here. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.

Re: [Tutor] Help deciding between python and ruby

2009-09-06 Thread Alan Gauld
es OOP and use it just as you would non OOP Python. And of course so many of Python's types are now objects that it's virtually impossible to write a truly non OOP program in Python! So that point is rather moot for the Python/Ruby debate. - IMHO of course :-) -- Alan Gauld Author of

Re: [Tutor] Tutor Digest, Vol 67, Issue 22

2009-09-06 Thread Alan Gauld
ements. In Python they are restricted to if/elif/else Sometimes known as conditionals. See the branching topic in my tutor for more detail. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@pyt

Re: [Tutor] (no subject)

2009-09-08 Thread Alan Gauld
letter is not a vowel. You need a new count variable and keep index just for iterating in the loop.. 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 c

Re: [Tutor] working with multiple sets

2009-09-08 Thread Alan Gauld
"kevin parks" wrote What would this look like if i want to use a straight up built-in dictionary type and not the collections.defaultdict. Not too different: import collections def foo(): lookup = collections.defaultdict(list) x = range(10) y = range(5, 15) z = range(8, 22) sets = {'x

Re: [Tutor] Pyduino

2009-09-08 Thread Alan Gauld
o get the most out of a tool like Arduino you probably do need a language like C vthat is conceptuially closer to the machine than to the user -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist

Re: [Tutor] working with multiple sets

2009-09-08 Thread Alan Gauld
picking that one up Doug. -- 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)

2009-09-08 Thread Alan Gauld
"Christian Witts" wrote What about range(0, -n, -1) ? That would need to have a starting value of -1 and an end value of -(len(phrase)+1). Of else you can start at length - 1, end at zero and a step value of -1. Another option, using "normal" range values but negative indexing is fo

Re: [Tutor] working with multiple sets

2009-09-08 Thread Alan Gauld
assignment, othewise you just get None stored... 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] web2py vs django

2009-09-09 Thread Alan Gauld
my advice is just pick one and stick with it! -- 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] wxpython question

2009-09-09 Thread Alan Gauld
you mean. But the standard wxPython layout managers should control all that for you. Look into the docs for FlexGrid and Grid Bag sizers. They are probably the most powerful sizers but also take more effort to use of course. HTH, -- Alan Gauld Author of the Learn to Progr

Re: [Tutor] (no subject)

2009-09-10 Thread Alan Gauld
"C or L Smith" wrote Or (and I'll duck after I pass on what I just happened across today on the web): ### for i in range(len(word)): print word[~i] ### Neat trick! Now what does ~ do?... the bitwise inverse. So it relies on the rules of complementing the binary value to effectively add

Re: [Tutor] Threads very simple examle

2009-09-10 Thread Alan Gauld
t least two network interfaces running so its usually less of an issue. How can I make it running in several threads? I'll leave the threading part to someone else. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] (no subject)

2009-09-10 Thread Alan Gauld
recommend it, most programmers would struggle to figure out what was going on and probably think ~ was a typo for - I suspect) See wikipedia for more on twos-complement, and the related trick , which is also used sometimes, of ones-complement. -- Alan Gauld Author of the Learn to Pr

Re: [Tutor] Vista UAC

2009-09-10 Thread Alan Gauld
"Dj Gilcrease" wrote wondering if there was a way with a standard install of python 2.6 that I can check if I have the correct privileges and if not relaunch the app required privileges. I haven't checked what the standard os functions do on Windows but you can always use ctypes to access t

Re: [Tutor] include remote module

2009-09-12 Thread Alan Gauld
r complete control, otherwise you could be executing any old bit of random, possibly maliciouis code! So some basic security checks - a checksum at least or, better still, a digital signature embedded in a comment would be a good idea! HTH, -- Alan Gauld Author of the Learn to Program web

Re: [Tutor] include remote module

2009-09-14 Thread Alan Gauld
"Eike Welk" wrote called this sort of script right after boot up. They could have the absolute most current version of an application from my server launched on their box and if their data from that application was For this kind of application you could tansfer *.tar.gz or *.rmp files and

Re: [Tutor] New guy question...

2009-09-14 Thread Alan Gauld
"Warren" wrote while True: line = input() Beats me, it works OK on my XP box. try: number = int(line) except ValueErr as err: Are you sure this shouldn't be ValueError rather than ValueErr? It won't be causing your current problem but it might cause your next one! :-) Now, w

Re: [Tutor] breaking out of a function that takes too long

2009-09-15 Thread Alan Gauld
operator there may be peak periods when people go online based on local patterns of usage, especially if its ot a big company - they might only have a couple of 2M pipes say to the core network. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Parsing html tables and using numpy for subsequentprocessing

2009-09-16 Thread Alan Gauld
ename strings. ''' files = os.listdir(path) return files Since you are just returning the result of listdir you could achieve the same effect by simply aliasing listdir: get_files = os.listdir Much less typing! HTH, -- Alan Gauld Author of the Lea

Re: [Tutor] Executing a command from a specific directory

2009-09-16 Thread Alan Gauld
o this but the preferred route is using the subprocess module. You can see examples of several of the options in the Using the OS topic in my tutorial, under the heading "Manipulating Processes". HTH, -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] html color coding: where to start

2009-09-17 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote column is the word, and the second is the composite part of speech tag. For example, Al is a DETERMINER, wlAy is a NOUN and At is a PLURAL NOUN SUFFIX Al+wlAy+AtDET+NOUN+NSUFF_FEM_PL Al+mtHd+pDET+ADJ+NSUFF_FEM_SG I'd create a dictionary wit

Re: [Tutor] Using the time module to extract a semi-random number

2009-09-17 Thread Alan Gauld
"Patrick Sabin" wrote import random number = random.randint(0,59) The latter looks clearer to me. Me too, but if the object is to get the learner using the time module it doesn't help! :-) But if the object is really to get a random number then its much better... Alan G. __

Re: [Tutor] Simple Program

2009-09-17 Thread Alan Gauld
r the kind words. If you can offer ideas for improvement I'm always happy to hear. Thats how it improves! And since I;m still working on the latest update for v3 its a good time for suggestions! -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Calling a dictionary entry inside of a function

2009-09-18 Thread Alan Gauld
Corey Richardson wrote: I am trying to use a parameter of a function to call a word inside a dictionary. Here is my code wordList = { 'Apple' : ["A delicious snack"], 'Word' : ["This code is not working..."], } def define(word): print wordList['Word'] You put quotess around word whic

Re: [Tutor] Determine Filetype

2009-09-19 Thread Alan Gauld
ad...@gg-lab.net wrote: if OBJECT in LIST: Well, but i'd like to read the page of the python tutorial regarding this. I'm not able to locate it. Can you help me? Not everything is covered in the odfficial tutorial, its only meant to be an introduction to the language. You should find it in

Re: [Tutor] Determine Filetype

2009-09-20 Thread Alan Gauld
ad...@gg-lab.net wrote: The search feature of the web site is quite effective! :-) simple to be used if you're looking for a very common word ("in") and don't know other keys to find it. To be honest I was being a bit optimistic but I did just type "in" for the search and the first 5 or so h

Re: [Tutor] What is this an example of (and how can i use it?)

2009-09-20 Thread Alan Gauld
kevin parks wrote: called, and what it is an example of. I guess there are generators and iterators now and it seems this might be an example of one of those new This is a generator expression. It is like a list comprehension (you know about those right?) except it doesn't create the list it

Re: [Tutor] What is this an example of (and how can i use it?)

2009-09-20 Thread Alan Gauld
kevin parks wrote: This is a generator expression. That's unfortunate news for me. It is like a list comprehension (you know about those right?) Yes. I know and use and love them daily. If you can grok comprehensions then you are only a step away from generator expressions. Most of the

Re: [Tutor] eazy python question involving functions and parameters

2009-09-20 Thread Alan Gauld
Just think: 4 players left means that this is the semi final. What a brilliant answer! It tells him how to do it if he just stops and thinks but gives nothing away. I love it. :-) Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or c

Re: [Tutor] eazy python question involving functions and parameters

2009-09-21 Thread Alan Gauld
And to remove all doubt wesley chun wrote: again, the easiest way to differentiate b/w the 2 is whether or not it results in some Python object. if it doesn, it's an expression; if not, it's a statement. Should say ... if it does, it's an expression You'll find my explanation of expre

Re: [Tutor] How to get homework help (was need to hire a tutor... )

2009-09-22 Thread Alan Gauld
I'm new on this list <*waves hello to everyone*>, welcome to the tutor list <*waves back*> :-) trick to getting help here with homework is pretty much the same as most other tech lists. Absolutely so, and well summarised. Alan G. http://www.alan-g.me.uk/

Re: [Tutor] Challenge

2009-09-22 Thread Alan Gauld
Ali Sina wrote: I wrote this code but I know its wrong. Although it works properly: Thereis adfference between "works properly" (ie does what it should) and "runs without errors" :-) You need to read up a bit more on boolean expressions flips=0 h='heads' t='tails' while True: flips+=1

Re: [Tutor] calling a superclass method after overriding it

2009-09-22 Thread Alan Gauld
inside a method. You use exactly the same mechanisms. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python win32 drive mapping help

2009-09-22 Thread Alan Gauld
on the title bar and choosing properties. Once quick-edit is on, you can select any rectangle from a console window, and copy it to clipboard with right-click. Or even just hit return after selecting the area to copy... HTH, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] calling a superclass method after overriding it

2009-09-22 Thread Alan Gauld
ere except TypeError: super() It makes the purpose of the code obvious. But if type(name) != str: super() else: # other stuff here is clearer still -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] how to define a function with multple parameters

2009-09-22 Thread Alan Gauld
and Modules topic in my tutorial as an alternative source of info... -- 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] calling a superclass method after overriding it

2009-09-22 Thread ALAN GAULD
> In this case, is there any argument against checking for None? Or is > it better to do a type check for a string? > > if name is None: > super() > else: > # do stuff That might be ok if string or None are the only types you could get. Checking for not string will catch any number

Re: [Tutor] Python 2.3.5 question

2009-09-23 Thread Alan Gauld
ges you have - the whole error message not just the last line. -- 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 print a message backwards

2009-09-23 Thread Alan Gauld
the original message each time. So obviously you need to print something else! If you are counting one letter at a time maybe you should print one letter at a time? However/... Others have given you a big hint about using slicing instead so I'll leave you to research that yourself. -- Alan

Re: [Tutor] how to print a message backwards

2009-09-23 Thread ALAN GAULD
> Is there a significant difference in speed, style, or any pythonesque > reasoning between Alan's solution and > print message[::-1] Yes, the for loop doing one character at a time will be much slower than using a slice. The slice is more pythonic but less general. A reverse loop is something

Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread Alan Gauld
at? :") if fatness > candyNumber: print "HA! Nice try, but no. You don't have that many candies" else print "HA! You ate the candy! Sucker. You are now", Python cares abourt indentation level. align the else w

Re: [Tutor] Super class

2009-09-25 Thread Alan Gauld
erred super/child and C++/Java preferred base/sub Historic accidents bedevil programming jargon making it a minefield of confusion for beginners! -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - T

Re: [Tutor] Confusion with $PATH

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

Re: [Tutor] python win32 drive mapping help

2009-09-26 Thread Alan Gauld
stalled/enabled on all PCs but nowadays is usually there. I haven't had a case of it being missing since we stopped using the Windows 9X series of OS. Just a thought. PS. There are similarly simple methods for adding/removing Printers too. -- Alan Gauld Author of the Learn to Program web site ht

Re: [Tutor] need help with conditionals

2009-09-26 Thread Alan Gauld
t, its not a bad tutorial, shame about this exercise! -- 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] need help with conditionals

2009-09-26 Thread Alan Gauld
you running the program - so we can see what you are typing as input. Using eval() like this is very prone to user error and also considered bad practice! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] [Reply]need help with conditionals

2009-09-26 Thread Alan Gauld
currently redirects to geocities but that too is closing shortly so it will eventually be the true home for the tutor! (Its getting increasingly difficult to find independant (non ISP) free web space on the net these days :-( ) -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] Accessing windows from Linux build

2009-09-28 Thread Alan Gauld
e worried! I assume you've already tried a Google search to see if somebody has done it before? -- 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 subs

Re: [Tutor] What language should I learn after Python?

2009-10-06 Thread Alan Gauld
d a minimal JavaScript knowledge and it too has some interesting concepts behind it once you get past doing cut n paste mash ups. (eg protocol based OOP). You can get the basics of JavaScript by comparing it with Python in my tutorial... Pick one and have fun. If its not fun don't bust a

Re: [Tutor] What language should I learn after Python?

2009-10-07 Thread Alan Gauld
ime (early-mid '80s). Ah, nostalgia... -- 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 language should I learn after Python?

2009-10-07 Thread Alan Gauld
"Serdar Tumgoren" wrote Programming Paradigms for Dummies, by Peter Norvig http://lambda-the-ultimate.org/node/3465 Thanks for posting the link. I hadn't seen it before but it made interesting reading. Although maybe digging a tad deeper than the OP had in mind! -- Alan

Re: [Tutor] [OT] Secure coding guidelines

2009-10-10 Thread Alan Gauld
d to catching invalid data *values* not invalid data types. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python 3 and tkinter Radiobuttons

2009-10-10 Thread Alan Gauld
u need to assign a value to the StringVar? Othewise how does Python know which of your buttons is supposed to be the selected option? But I'm no expert, I rarely use radio buttons... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] Python 3 and tkinter Radiobuttons

2009-10-11 Thread Alan Gauld
"Kent Johnson" wrote Without the v.set() it starts with no button selected. With v.set() it starts with one button selected. Either way it satisfies the OP's requirement; which one is correct depends on his needs. Unfortunately on Windows it seems to set them all selected without the var s

Re: [Tutor] class with objects

2009-10-11 Thread Alan Gauld
ect 1") ship2 = Ship("object 2") ship3 = Ship("object 3") Ship.status() What do you expect the output to be? And what is it really? Are they different? Why? 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] Carriage return

2009-10-12 Thread Alan Gauld
programs when they run, it is just a nuisance when working in the editor. Some editors are intelligent enough to deal with this transparently - eg. I think vim and Scite both do this. If you regularly edit on both OS then it might be worth moving from IDLE to one of those editors. HTH, -- Alan Ga

Re: [Tutor] complete neophyte question here

2009-10-12 Thread Alan Gauld
don't know how to explain HOW i wrote it because it just sort of happened. I was sitting home one night and it just came out itself. I know that's not much of an explanation but there it is. Just like great art... :-) HTH, -- Alan Gauld Author of th

Re: [Tutor] Porting PHP web app to Python GUI

2009-10-12 Thread Alan Gauld
ning curve for any GUI is prettty high though, and Dabo's visual designer will take one part of that pain away. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubs

Re: [Tutor] Porting PHP web app to Python GUI

2009-10-12 Thread Alan Gauld
ng EasyGUI so I don;t think it would be a good choice here. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyt

Re: [Tutor] Automaton/transitional grammar query

2009-10-12 Thread Alan Gauld
"kevin parks" wrote I been using that flatten function since 1970. Prolly pilfered from Tim Peters or Effbot. Are you sure about that date? If you did get it from Tim or F/ it certainly wouldn't have been in Python back then! :-) Alan G

Re: [Tutor] Switching to other version of Python

2009-10-12 Thread Alan Gauld
"Corey Richardson" wrote My school has python 2.4. I have python 2.6, and I find it perfectly wonderful. However, I am contemplating the switch, and am wondering, what is your personal opinion on why or why not to use 3.x? Thanks for the help in advance, Well your Python 3 programs won't

Re: [Tutor] What is Curses and why do they call it that.

2009-10-12 Thread Alan Gauld
word cursor and the typical reaction of programmers forced to use curses to build a "GUI"! :-) 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 cha

Re: [Tutor] What is Curses and why do they call it that.

2009-10-13 Thread Alan Gauld
e one does not want to take fingers off of home keys or numeric keypads. That is entirely possible in a pure GUI, its only bad design that prevents it! Default focus and tab order settings are available on virtually every GUI toolkit, its just that the designers often don't give much thought t

Re: [Tutor] Curses - What does it do and why is it called this?

2009-10-13 Thread Alan Gauld
I in Tkinter or somesuch. 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] Shebang (#!) in the first line of a python script

2009-10-13 Thread Alan Gauld
ter. This is a somewhat fragile mechanism and if you have two versions of Python installed or the associations get broken it may fail but most of the time it works fine. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

[Tutor] GUI Buttons

2009-10-13 Thread Alan Gauld
ButtonList: button['state'] = NORMAL 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] Changing text colors on WinXP py2.6.2

2009-10-13 Thread Alan Gauld
"Tim Golden" wrote No. ANSI escapes don't work on Windows. Wouldn't the ANSI codes work if ANSI.SYS were loaded? I thought you could still load ANSI.SYS it just wasn't normally there? The help system says you should load it in config.nt with: device=c:\winnt\system32\ansi.sys But I admi

Re: [Tutor] Changing text colors on WinXP py2.6.2

2009-10-13 Thread Alan Gauld
"Dave Angel" wrote Other things to consider: cygwin curses works on cygwin too so a much wider set of choices there. Alan G ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/l

Re: [Tutor] Recursive user input collection problem

2009-10-13 Thread Alan Gauld
;) getinput(variable,prompt) You don;t return the value from getinput(). Just add a return in front of the call... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org T

Re: [Tutor] GUI Buttons

2009-10-14 Thread ALAN GAULD
> But when is the configure() method more appropriate to change e.g. the button > status? configure is better when you need to change more than one attribute of a widget at a time. The dictionary style access is just a convenience feature. If you prefer you can use configure() all the time.

Re: [Tutor] namespaces and global

2009-10-14 Thread Alan Gauld
ute? Is there a specific reason to use a global variable when use of globals is normally considered bad practice? I'm curious? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To u

Re: [Tutor] PyWin32 - Library of functions to interact with windows?

2009-10-14 Thread Alan Gauld
am with a single Text widget on which you write your output. Then you can colour it any way you like. Learning how to build GUIs wioll take a bit of effort but a lot less than trying to use the Win32API to modify a cmd window! Take a look at the Event driven oprogramming topic in my tutorial for an

Re: [Tutor] PyWin32 - Library of functions to interact with windows?

2009-10-14 Thread Alan Gauld
"Scott Nelson" wrote myself and I recently found some C code on the web [2] that does this and I translated that into to Python and pywin. It can be done in about 4 lines of Python. Yes, its much easier than I expected. I had never seen the SetConsoleTextAttribute API call before nor the

Re: [Tutor] Masking operation

2009-10-14 Thread Alan Gauld
"Wayne" wrote I've searched "Python masking" and various other terms in Google and the python docs and came up with nothing useful. Try the Using the OS topic in my tutorial. There is a sidebar in there about using the bitwise operators to do masking about half

Re: [Tutor] Changing the color of text in the windows shell (WinXP/python 2.6.2)

2009-10-15 Thread Alan Gauld
colorPrint(strings): for string in strings: textcolor(string[1]) print string[0], colorPrint([("There are", 0),(str(apples_left),4),("left in the basket.",7),("\n",0) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.

Re: [Tutor] Recursive user input collection problem

2009-10-15 Thread Alan Gauld
ecause I'm (yet again) playing with Lisp and therefore thinking recursively about problems rather than thinking loops. :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread Alan Gauld
epr to present the object in a more readable style - where readable is subjective. 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 opti

Re: [Tutor] Most pythonic input validation

2009-10-16 Thread Alan Gauld
ice (%d) should be between %d and %d" % (choice, minVal, maxVal) ) 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] PyWin32 - Library of functions to interact with windows

2009-10-16 Thread Alan Gauld
rver and turn off the redirect (hopefully this weekend!) -- 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

<    9   10   11   12   13   14   15   16   17   18   >