Re: [Tutor] How to verify all things are equal to one another

2005-05-15 Thread Alan G
no doubt want to use xor: if not (a^b^c^d^e^f): do it :-) PS. The last works for primitive types but is not intended to be a serious suggestion!! HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___

Re: [Tutor] help with my python app

2005-05-17 Thread Alan G
If the code is slightly diffeent each time - although from a quick look this doesn't seem to be the case here - you can parameterise the function so you can pass in either the changing values or some flag to indicate which variant you need. It's all part of helping us to see the wood instead o

Re: [Tutor] How to convert hex representation of char? (Challenge part 8)

2005-05-18 Thread Alan G
print ord{'Q'} 81 so '\x14' is the character, it should just work... Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauldHTH, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Finding word in file

2005-05-18 Thread Alan G
state it. try: f = file() except IOError: print 'file not' If you do want to force an error to be raised you must use raise: try: raise IOError except IOError: print 'sure enough...' See my tutorial topic on errors for

Re: [Tutor] Python debugger under Tiger?

2005-05-18 Thread Alan G
> Does anyone know of a Python debugger that will run under OSX 10.4? > The Eric debugger was looked at, but it's highly unstable under > Tiger. Thanks. pdb should still work. Alan g ___ Tutor maillist - Tutor@python.org http://m

Re: [Tutor] Finding word in file

2005-05-19 Thread Alan G
ow? Does your tutorial cover that (i don't remember it doing so)? Two topics -- one on handling files the other on handling text. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Whle Loop to run again.

2005-05-19 Thread Alan G
iterations, try it this way: heads,tails = 0,0 while heads+tails < 100: coin = random.randrange(2) if coin == 1: heads += 1 else coin == 2: tails += 1 run = raw_input('run or exit? ') if run = 'run': continue else: break HTH, Alan G. _

Re: [Tutor] using -i flag with '''if __name__ == "__main__":'''

2005-05-20 Thread Alan G
ly they lose out in terms of raw editing power. I missed the original part of the post that prompted your decision, but the quoted comment above suggests a new aopproach to debugging, not necessarily a new debugger... Alan G. ___ Tutor maillist - T

Re: [Tutor] "classmethods"

2005-05-20 Thread Alan G
ead of returning them you store them in the object. Or am I missing something? It is possible to write true class methods but I'm not sure this is the best place to use them. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Comparing a string

2005-05-20 Thread Alan G
> I'm tryin compare a string with a value with style of pattern-matching. > > string = 'i686' > > if string == glob.glob(i?86): Use regular expressions and turn it around: import re s = 'i686' ex = re.compile('i?86') if ex.match(s): p

Re: [Tutor] printing documents

2005-05-20 Thread Alan G
done from Acrobat using: http://www.reportlab.org/rl_toolkit.html to create the PDF and the /p flag in acrobat. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] creating files on open()

2005-05-20 Thread Alan G
access mechanism in Python other than seek() You can't create fixed length records and navigate through them as you can in some other languages. (you can of course use format strings to fake this but its messier than true random record access) Alan G. __

Re: [Tutor] Python in HTML

2005-05-21 Thread Alan G
ript to be too terrible, what kind of problems are you having? PS I couldn't reply to the original message because it had beebn digitally signed. Please don't do that when posting to public mailing lists folks! (Well, not if you want a reply!) Alan G Author of the Learn to Program web

Re: [Tutor] main()

2005-05-21 Thread Alan G
run a file from the command line like python Hope.py then __name__ is set to __main__ > but why would I want to do this if __name__ == '__main__': So this line lets you create code that is executed when the file is run from the command line but not wh

Re: [Tutor] Debugger?

2005-05-21 Thread Alan G
finished" file and try exercising the functions classes one by one from the >>> prompt. Finally insert print statements at suitable points, and only after doing all of that try the debugger. The best debugger of all is the one between your ears! Alan G. _

Re: [Tutor] Python in HTML

2005-05-21 Thread Alan G
ing as you go. As soon as you get a feature working put it in a function. It keeps the working code and experimental stuff separate! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python in HTML

2005-05-22 Thread Alan G
y the songs and generate a random selection from the copy? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python in HTML

2005-05-22 Thread Alan G
y and it sometimes gives you some clues too. But the best bet is lots of write() statements IMHO. Also the fact its one big file shouldn't be a problem. Provided you make liberal use of functions to encapsulate the functionality and keep those together in the head of the html the

Re: [Tutor] __init__.py

2005-05-23 Thread Alan G
the fine detail, but essentially the init file often imports functions or classes that the package designer wants to appear as top level(in the package as opposed to being in a sub module). Also initialisation of package variables such as constants can be done there. HTH, Alan G Author of the

Re: [Tutor] passing variables between frames?

2005-05-23 Thread Alan G
arameter to an attribute of the object, self.parent say. Within the event handlers in the dialog you can now reference Frame1 as self.parent. HTH Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maill

Re: [Tutor] better resolution on time.sleep()?

2005-05-24 Thread Alan G
r tried in Python but can you use select()? I've used it in C for short duration intervals. Just a thought. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python won't play wav file

2005-05-24 Thread Alan G
else: break > ... to play a .wav music file. I tried w.play() but got an error that > module has no attribute 'play'. Have you used dir(w) to see what it does offer? Even better what does the documentation say? Have you tried help(w)? HTH, Alan G Author of the Learn to Program web

Re: [Tutor] Wizards in Tkinter

2005-05-24 Thread Alan G
ence. That way you can easily change the sequence, reuse frames over again within the same wizard etc etc. Hope that made sense, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@

Re: [Tutor] xml

2005-05-25 Thread Alan G
n to the end. > documentation is not always user-friendly for beginners!) It assumes you are a beginner to the library but not to XML and XML tutors generally assume you are new to XML not to http or HTML. So you need to start at the beginning of web technology and read your way up the tree.

Re: [Tutor] Covert numbers to hex fails

2005-05-25 Thread Alan G
tput = hex('%d' % (value)) WORKS - >>> hexoutput = hex(1234567890) Are you trying to insert a hex representation of the number into a string for printing? If so the easiest way is using string format characters: >>> print "In hex: %d = %X" % (42,42

Re: [Tutor] Python won't play .wav file

2005-05-26 Thread Alan G
control but that hardly counts!) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] (no subject)

2005-05-26 Thread Alan G
will simply print out the list of numbers from 0..255. Do you have a purpose in mind or are you simply wanting to observe chr() and ord() in action? Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tuto

Re: [Tutor] python problem

2005-05-26 Thread Alan G
if menu_choice == 1: etc... except NameError, TypeError: # handle error here break # only if you really need to.. print_menu() HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld

Re: [Tutor] Are Empty "Placeholder" Functions possible?

2005-05-26 Thread Alan G
lass MyClass: pass I use that a lot. Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] (no subject). Ord and Chr query

2005-05-26 Thread Alan G
Humans are intelligent but slow, computers are stupid but fast. You have to break every action down to the simplest level and get the sequence just right. But once you do get this stupid box responding to your every whim then it is a grat buzz! Alan G. ___ Tut

Re: [Tutor] better resolution on time.sleep()?

2005-05-26 Thread Alan G
> Rumor has it that Alan G may have mentioned these words: > > >Consuming 100% CPU won't make much difference, the CPU is running all > >the time anyway (when its not asleep). > > Not mine... my laptop runs a Crusoe processor, and it can automatically > scale it

Re: [Tutor] pattern matching problem

2005-05-26 Thread Alan G
> I have to write a function that will return the index of a line like this: > > gvcdgvcgdvagTVTVTVTVTVTHUXHYGSXUHXSU > > where it first becomes capital letters. I'd go with a regex search for that one... Alan g. ___ Tuto

Re: [Tutor] Formatted writing to a file

2005-05-27 Thread Alan G
'%25s' intiger (in this case 25) a variable? Just create the string outsoide the formatting line: fmtString = '%%ds' % width s = fmtString % data HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld _

Re: [Tutor] Formatted writing to a file

2005-05-28 Thread Alan G
> >Just create the string outsoide the formatting line: > > > >fmtString = '%%ds' % width > > I think it should be '%%%ds' % width Good catch Bob, you need the extra % to 'escape' the literal % character. Alan G. __

Re: [Tutor] increment operator

2005-05-28 Thread Alan G
> Is there a increment operator in python similar to c++ > like so "SomeVariable++" No. There is the shorthand += assignment but no ++ So x += 1 is the closest thing to x++ HTH, Alan G. ___ Tutor maillist - Tutor

Re: [Tutor] Planning a program with algorithm?

2005-05-31 Thread Alan G
psueudocode becomes a very powerful techniqie of seeing the "big picture" of your programs structure. Once you get above 500-1000 lines pseudo code starts to break down again - you need pseudo code for your pseudo code!! At this point you need to start looking at higher level design techniques

Re: [Tutor] Planning a program with algorithm?

2005-05-31 Thread Alan G
ct the detailed design from the code using a simple text filter like grep... The ISO 9000 quality auditors love it... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Planning a program with algorithm?

2005-05-31 Thread Alan G
e recommendation, but you do have to remember to ignore the heavy use of recursion if you are working in Python. Otherwise the basic concepts are very sound. And the formulistic approach to designing a function is excellent. Alan G. ___ Tutor m

Re: [Tutor] Strange IndexError

2005-06-01 Thread Alan G
loats. I've Python > 2.3.4. Usually when that kind of thing happens to me I've accidentally used a comma instead of a period. Are you sure you don't have self,_isNearMarker = ... So Python sees it like a,b = True Just a thought, Alan G. __

Re: [Tutor] Win32 Question

2005-06-01 Thread Alan G
ry to use it directly? Also checking the Win32 API it looks like: uint32 GetOwner( string User, string Domain ); expects a couple of parameters to hold the return values. I dunno how Winall handles that but it may be worth investigating. Alan G.

Re: [Tutor] List processing

2005-06-01 Thread Alan G
e values in > columns 1 and 5 were present as a pair more than once in the original file. My immediate answer would be to use awk. However if that's not possible or desirable then look at the fileinput module and the string.split function. Alan G _

Re: [Tutor] Building an SQL query

2005-06-02 Thread Alan G
essed' > for all of the ids in the list, but can not figure out how > to get this into a query to pass to the database. What have you tried? What happened? It should just be a case of using variable interpolation as you did for the Select. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Building an SQL query

2005-06-02 Thread Alan G
se we plan on growing our business. Unless ADOpy is very slow I wouldn't expect a huge performance increase since it will only be the compile phase, but if you hit the query a lot then maybe 5-10%. You are more likely to see the benefit in a drop CPU loading on the server. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] interactif or not

2005-06-03 Thread Alan G
several levels) as desired. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Postgresql+Python -tutorial?

2005-06-03 Thread Alan G
tu??? A linux distro maybe? (*) I'm currently using SqlLite for my online tutorial on database programming but the more I use it the less I like it! To the extent that I might change to one of the others even though it means a re-write of the tutorial topic... Alan G. __

Re: [Tutor] question about "hiding" a function/method in a class

2005-06-03 Thread Alan G
the SQL DDL directly? In fact even Visio can do that. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] insering into lists through slices

2005-06-03 Thread Alan G
more accurate one read the docs onslicing!) HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question about "hiding" a function/method in a class

2005-06-03 Thread Alan G
I'll be surprised if there aren't some at least - even if just demos with limited numbers of tables. The commercial tools are so cheap(relatively) that we've never even looked for freeware... Many of the UML tools (BOrland, iLogix, Rational Rose etc) have free trial versions which

Re: [Tutor] How to open a telnet session and have the python programwrite to it.

2005-06-06 Thread Alan G
am cannot be coaxed to write to > the telnet session (window). I have attempted the telnetlib, but the > problem is that the telnet window does not show up. Try pyexpect I think you have to download it though. Alan G. ___ Tutor maillist -

Re: [Tutor] Not getting what execl() should be doing...

2005-06-07 Thread Alan G
instead, or if on Python 2.4 the new commands(?) module. While your approach can be made to work it needs a fair amount of tweaking of environments and the like. popen otr commands should simplify life significantly. Alan G. ___ Tutor maillist - Tutor@pytho

Re: [Tutor] interactif or not

2005-06-07 Thread Alan G
tive = sys.stdin.isatty() > > if isinteractive: > > ... > > else: > > ... > > > > tested and it works ! Aha! I knew about tty on Unix so I looked in the os module for it, I never thought of it being a file method Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] repr()

2005-06-07 Thread Alan G
if you had done: >>> def myfunc(): print 'hello' >>> myfunc '' >>> > s = repr( myFunc() ) > print s Which assigns NOne to s and then prints the repr() of None > 'None' As it should. What did you think it should do? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] repr()

2005-06-07 Thread Alan G
us as to why you would ever want to though? It may be there's another solution to whatever the problem is. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] OO re-factoring (was Pythonese/Efficiency/Generalesecritique)

2005-06-08 Thread Alan G
8) test it in in conjunction with the other classes it uses. 9) repeat 6-9 until all classes are built and tested (or enough to implement some part of your application - a "use case"). 10) build the driver program/fuinctoion/object that will pull it all together into an application.

Re: [Tutor] #3 Text problem

2005-06-08 Thread Alan G
;t understand why I would want the modulus of anything. Modulus (ie remainder part of an integer division) is very useful for all sorts ofthings in programming, I'd be surprised if you never found a use for it! :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] finding path to resource files in a GUI application

2005-06-09 Thread Alan G
rc Within that file you define any settings you need including folder locations. Usually a combination of the above techniques is used, and a default myapprc(no dot) held someplace like /etc/myapp used if no environment variable is set or no valid local user file exists. Alan G. __

Re: [Tutor] Just a Python formatting question

2005-06-10 Thread Alan G
consistent inside a block, but to make it readable be consistent across all blocks! Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] learning how to use python

2005-06-10 Thread Alan G
n you post a message here it's worth including the code - if it's not hundreds of lines long! And also a cut n paste of the actual error message because, although they may not look friendly initially, Python errors are actually very informative once you know how to read them! Take care, A

Re: [Tutor] Newsreader list name?

2005-06-10 Thread Alan G
> > There must be others on this list using a newsreader and I would > appreciate the list name used. The trick is that you need to set up a new news account not the standard feed your ISP provides. The news server required is news.gmane.org And the news group you need to loo

Re: [Tutor] Can't figure out syntax error

2005-06-10 Thread Alan G
ings. This is best illustrated by a character. char c = '5'; // ascii value 53 int n; n = (int)c; // type cast makes n hold 53 n = atoi(c) // type convert makes n hold 5 Sorry for splitting hairs but clearing the terminology might he

Re: [Tutor] Newsreader list name?

2005-06-10 Thread Alan G
s. It is a new news service not available on your ISP news server. It is not just a new group. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Web browser

2005-06-11 Thread Alan G
s, but I coudn't understand them and make them > work... You can use COM to script IE but navigating the mysteries of COM is not easy, especoially if you haven't done it before. I suggest you look at urlib before going any further, but if you really need to have a r

Re: [Tutor] Counting MySQL Fields

2005-06-11 Thread Alan G
27;Tuple' object has no attribute 'num_fields' If results is a tuple then presumably the number of fields is just the len() of the tuple? HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] is this a bug global i ???

2005-06-14 Thread Alan G
l takes var i from outside of class A. > Can somebody explain this ??? You only need to declare global if you are modifying data if you only read it there is no need for explicit global statements. Alan G. ___ Tutor maillist - Tutor@python.org h

Re: [Tutor] Controlling Where My Program Ends

2005-06-16 Thread Alan G
> >>Never mind. I found it - sys.exit() You can do the same thing by raise SystemExit This avoids the need to import sys... Alan G. > >> > >>Sorry to have wasted the bandwidth/time. > >>-- > > > > > > This was in reference to a post ab

Re: [Tutor] can't see emacs timer in action

2005-06-16 Thread Alan G
e you start emacs. You can also bind it to a shortcut of your own - after all this is emacs you can do anything! :-) > I need to make shortcut for starting interpreter do you have any idea. record and save a macro M-x apropos macro is your friend...

Re: [Tutor] Clearing the Console Screen

2005-06-16 Thread Alan G
it from his site. The other ways are: Unix/LInux/MacOS/BSD: os.system('clear') DOS/Windows console: os.system('CLS') Generic: print '\n' * 100 # a 100 line screen... Or you could find the control codes for your screen and print them as

Re: [Tutor] Clearing the Console Screen

2005-06-16 Thread Alan G
is also an O'Reilly book on ncurses - the C version, and several online tutorials for the C version too. The Python module is a pretty straight translation of the C API to Python.) Alan G. > > Python actually gets a lot of this

Re: [Tutor] Clearing the Console Screen

2005-06-17 Thread Alan G
onsole-handbook.htm My bad. You are right. I've seen it used for windows console control and was told it worked for "any console", I assumed that included *nix but obviously not! Its not as impressive a feat as I thought in that c

Re: [Tutor] can't see emacs timer in action

2005-06-17 Thread Alan G
> but I don't understand why xemacs doesn't fix C-c C-c Neither do I. BTW Do you know if this is specific to xemacs? Or does it also apply to python mode in vanilla GNU emacs too? I really should get around to loading python-mode and trying it some d

Re: [Tutor] max(len(item)) for cols

2005-06-17 Thread Alan G
da = [['1', '2 ', '3'], ['longer ', 'longer', 'sort']] >>> mcw = [[len(r) for r in c] for c in tda] >>> mcw [[1, 2, 5], [11, 10, 4]] >>> mcw = [max([len(r) for r in c]) for c in td

Re: [Tutor] Logging stdout and stderr

2005-06-18 Thread Alan G
nix's "tee" utility works. Use tee? It's designed for this kind of thing and there are versions for Windoze too. I personally prefer to leave this kind of logging as a user option rather than embed it into my code. Alan G. ___

Re: [Tutor] database app

2005-06-19 Thread Alan G
lar, Access locks by pages (default 2K?) which can mean a lot of data rows being locked by a single update. Make sure as a minimum that you are not locking on reads! HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Layering Canvas widgets with Tkinter

2005-06-20 Thread Alan G
etc/... def menu1(): X=Canvas(root, width=200, height=200, bg="blue") but2=Button(X,text="back",command=mainmenu) but2.grid() return X The other option would e to pass main into menuN() as a parameter and use that instead of X but I prefer the approach ab

Re: [Tutor] Numbers & Characters As Dictionary Keys

2005-06-20 Thread Alan G
goodbye', goodbye)} for m in menu.keys(): print "%s\t%s" % (m,menu[m][0]) cmd = raw_input('pick one ').upper() menu[cmd][1]() Does that help? Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Every Other

2005-06-20 Thread Alan G
> What would be the most Pythonic way THats always going to be subjective but... > of printing (or extracting) every > other element of a list? I'd probably use range with a step of 2. for index in range(0,len(mylist),2): ptint mylist[index] Alan G Author of the Learn

Re: [Tutor] Every Other

2005-06-20 Thread Alan G
JOhn, > This is probably it: > >>> arr = range(20) > >>> arr[::2] You are probably right, I forgot that slicing now had a 3rd element... :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] not invoking the shell from python

2005-06-21 Thread Alan G
above but I assume # that was just a posting error? print cmd # for debug only os.popen(cmd) See if the line you are producing is what you think it should be. Try typing it in at the shell and see if you get the same effect? Without knowing the details of your data its hard to say much more. HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Numbers & Characters As Dictionary Keys

2005-06-21 Thread Alan G
splay of numbers etc etc. Take a look in the Python docs for string formatting. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] MySQL Connection Function

2005-06-21 Thread Alan G
rom mysql_Conn()? > Do I need to declare the cursor as a global variable? No you need to return it from your function. See the topic on modules and functions for more about returning values from functions. You might find you need to clear the cursor before using it too. HTH, Alan G Auth

Re: [Tutor] who called the class method?

2005-06-21 Thread Alan G
tance of another class? Those are all different scenarios which could be described by your paragraph above, which do you mean? Or is it something different again? Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld __

Re: [Tutor] Built-in modules

2005-06-21 Thread Alan G
. You can also just copy the module file List.py into a folder that's in your search path. That works too. But calling it List is probably bad since Python already has Lists. Maybe you could rename it something like NestedList? (Whatever that is!) HTH, Alan G.

Re: [Tutor] Class vs. Static Methods

2005-06-21 Thread Alan G
hared - this echos C's use of 'static' variables. Java and Object Pascal copied the name from C++ and now Python seems to have adopted both names just to accomodate all tastes! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Class vs. Static Methods

2005-06-22 Thread Alan G
would be a better approach IMHO... Neat, I understand, I think... Thanks Kent. Alan G. > >>> class Test(object): > ... @staticmethod > ... def static(): # no args > ... print 'I have no clue how I was called' > ... @classmethod > ... def cls(cls):

Re: [Tutor] List of regular expressions

2005-06-22 Thread Alan G
ve it pick the pattern that describes it better from the list. Define 'better'. Both regex describe it equally well, how is Python supposed to know which one is 'better'? You have to tell it by ordering your list according to your idea

Re: [Tutor] Class vs. Static Methods

2005-06-22 Thread Alan G
ach subclass. i never thought of using a try/except to add an attribute to subclasses based on cls. I like it. Thanks again Kent. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Changing what you've already printed

2005-06-22 Thread Alan G
t; For example, if I'm making a little noughts and crosses > game and I print the board: I'd use curses for this. Or better still a GUI. > I've programs do this on the command line in Linux, so > I assume it must be possible. Curses

Re: [Tutor] question about programmers

2005-06-22 Thread Alan G
und 30 but with a distribution from about 10 to over 70... Be really keen and write a python program to collect the answers parse out the ages and do the sums... :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Changing what you've already printed

2005-06-22 Thread Alan G
> BTW, if you happen to need this while drawing only a single line, the > "\r" char gets you at the beginning of the current line ! And '\h' should delete back one char. Between the two techniques you can control a single line, but not, sadly, a noughts

Re: [Tutor] Class vs. Static Methods

2005-06-23 Thread Alan G
e counter - which may be what you want under some circumstances, but it wouldn't know which of the subclasses was calling it so couldn't access their counters. I think thats right!? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Changing what you've already printed

2005-06-23 Thread Alan G
Python wrapper won't work... I suspect part of the problem is that the DOS terminal, even with ANSI mode switched on, which is not common nowadays, is still pretty limited compared to a VT100/200 terminal in terms of cursor control. Alan G. __

Re: [Tutor] samples

2005-06-23 Thread Alan G
Of course better still is a design document! > Does anyone have any little "gamelets" like these, There are several games on Useless Python, including my guessing games framework (which is from my book) and the heavily commented code is zipped up on Useless (hmgui.zip). But most of the

Re: [Tutor] Interesting problem

2005-06-23 Thread Alan G
must be a suitable bit of black magic that will serve it up on a plate. Doing some reading around the innards of classes should shed light on it. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with Tkinter teachers' report program?

2005-06-24 Thread Alan G
t. We did this with an Oracle Forms application about 12 years ago when tabbed displays were very new and very sexy! :-) Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@p

Re: [Tutor] fileinput problem

2005-06-25 Thread Alan G
program the same name as the module! HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] MineSweeper

2005-06-26 Thread Alan G
rate over the list to create and pack/grid/place each button. HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Alternative File I/O for Tuples

2005-06-26 Thread Alan G
#x27;,'w') prtfile.write(text) prtfile.close() os.system('lynx -p ./temp.html') > Is this a simple task, or am I jumping into deep water? :) > evangelinuxGNU Evangelist Given your signature its probably not too difficult, you can just send the basic text string to lpr

Re: [Tutor] super() and inherited attributes?

2005-06-28 Thread Alan G
o fix the itch use that, if you want to understand super() then that won't help and its over to someone else! :-) HTH, Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] mscvrt module question

2005-06-30 Thread Alan G
nd getch since you aren't prefixing the names with the module? Normally I'd expect to see Keyln = msvcrt.getch() > a=kbhit() > > Traceback (most recent call last): > [snip] > File "", line 0, in __main__ > NameError: name 'defined' is not defined Th

Re: [Tutor] HANDLING ERRORS

2005-06-30 Thread Alan G
except ValueError: > print "Oops! That was no valid number. Try again..." The except should align with the 'try' not the 'if' Does that help? Otherwise you need to give us a clue as to how it doesn't work. Do you get an error message?

  1   2   3   4   >