Re: [Tutor] List comprehension for dicts?

2010-08-20 Thread Alan Gauld
loop is the best solution for now. I've always wanted an until clause in the LC structure: result = [i%2 for i in seq until i>10] -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@p

Re: [Tutor] flow problem with a exercise

2010-08-20 Thread Alan Gauld
def is_even(arg): return not arg%2 def is_odd(argument): uitkomst=is_even(argument) return uitkomst and this to: def is_odd(arg): return not is_even(arg) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] flow problem with a exercise

2010-08-20 Thread ALAN GAULD
Please use ReplyAll when responding to posts from the tutor list. > I don''t understand it complety. > return not arg%2 >> >> Why use not here ? >> >> I think that arg%2 is True not makes it false. > >For an even number arg % 2 will be 0 which Python considers to be False. So for a True res

Re: [Tutor] design of Point class

2010-08-20 Thread Alan Gauld
much of the power of inheritance. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ Here's a (very rough) first cut at the constructor and a generic distance function for the n-dimensional case: class PointND(object): def __init__(self, a_list):

[Tutor] Windows Power Shell

2010-08-21 Thread Alan Gauld
A recent windows update delivered the Windows Power Shell to my desktop. I'd heard of this but never used it till now. I've only started playing with it but it is essentially DOS on steroids. It brings Windows users a shell that seems to be very close to Unix shells like Bash in power and flex

Re: [Tutor] prime test problem

2010-08-21 Thread Alan Gauld
"Roelof Wobben" wrote It worked now. x=x+1 must have the same indention als the if then and the return. Or more specifically, it must be indented further than the while statement. The fact thatv the other commands inside the while loop happen to be an if/else is incidental x=1 while x <

Re: [Tutor] Tutor Digest, Vol 78, Issue 99 -- Prime numbers

2010-08-22 Thread Alan Gauld
"Nick" wrote I think I'm doing everything correctly now, but please tell me what I'm not-- if such is the case. One last thing - change the subject line to reflect the actual subject. Alan G. ___ Tutor maillist - Tutor@python.org To unsub

Re: [Tutor] Writing a prime number program using upper bound of square root of n

2010-08-22 Thread Alan Gauld
"Nick" wrote Is there a way I can set my email program to insert the ">" symbol to mark what I'm replying to without manually doing it? Give us a clue. What is your email program? You can do it in most programs but the method will be different in each! HTH,

Re: [Tutor] design of Point class

2010-08-23 Thread Alan Gauld
ry/except...) is the best - ie most pragmatic - solution. But that should be the least favourite choice, try to maintain interfaces if possible. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist

Re: [Tutor] find() problem

2010-08-24 Thread Alan Gauld
and what is not working the way you expect. In this case you could print out the start, index and character values. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Databases in Python

2010-08-24 Thread Alan Gauld
name - at least thats how Python sees 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] Retriving previous user inputs in a gui

2010-08-24 Thread Alan Gauld
mat or whatever? Yes, it could be in whatever. CSV, XML, ConfigParser or even plain text. 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] Retriving previous user inputs in a gui

2010-08-24 Thread Alan Gauld
module name to access its contents - or use the from moo import * format, but that introduces even more risk! I strongly recommend that you think again and use a data format config file. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Controlling a device with ioctl's?

2010-08-24 Thread Alan Gauld
"Joe Veldhuis" wrote control a piece of hardware using ioctl's on its device node. I've never tried this from Python but #include fd = open("/dev/dvb/adapter1/frontend0", O_RDWR) Notice the fd - that means file descriptor not file pointer. So ioctl takes a file descriptor in C and

Re: [Tutor] Retriving previous user inputs in a gui

2010-08-25 Thread Alan Gauld
"Karim" wrote Is there any equivalent to JAVACC in python (or lex yacc) to create grammary for config or format file? Thats kind of what ConfiogParser does - it gives you tools to read/write a config file. If you don't mind the data not being human readable you could also use the shelve

Re: [Tutor] python: can't open file 'ex1.py' : [Errno 2] No such fileor directory

2010-08-25 Thread Alan Gauld
have many files called myscript.py in your file system. PYTHONPATH is used only by Python and only for imports. PATH is used only for executables. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mailli

Re: [Tutor] why does this fail

2010-08-25 Thread Alan Gauld
ng) (The parens aren't necessary but I think make it clearer that we are printing the evaluation of an expression not just a string with missing quotes...) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] why does this fail

2010-08-25 Thread Alan Gauld
import string string.replace(aString, aChr, another) # use string module But its better to do aString.replace(aChr, another) # use string method HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mai

Re: [Tutor] Function object

2010-08-25 Thread Alan Gauld
water, so I'll ignore that for now! :-) You will find a slightly different explanation in the Functional Programming topic of my tutorial HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mai

Re: [Tutor] design of Point class

2010-08-25 Thread Alan Gauld
maybe. And the Point class implementation of those conversions may be trivial. There are seveal ways to do this and none of them are perfect and none of them are "right" - although a few of them might be considered "wrong"!. HTH, -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Alan Gauld
ass with a floating point number? Then you call getY using the class rather than the instance? I'm confused - and so is Python... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@pyth

Re: [Tutor] why does this fail

2010-08-26 Thread Alan Gauld
u can check the documentation for the string methods using help(str) I don't want to put you off the tutorial because it is quite a good tutor, but I never noticed it was still promoting the use of the string module before - very odd! -- Alan Gauld Author of the Learn to Program web site htt

Re: [Tutor] Trouble with exercise regarding classes

2010-08-26 Thread Alan Gauld
ojectile.getY(cball) This explicitly provides the self argument instead of Python doing it for you when you use the instance. We can use this technique when calling inherited methods inside a class method definition. Anywhere else its best to use the instance to call a method. HTH, -- Alan Gauld Aut

Re: [Tutor] exercise problem

2010-08-26 Thread Alan Gauld
at least it does for me! :-) -- 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 import statement

2010-08-27 Thread Alan Gauld
"Bill Allen" wrote *from tkinter import * from tkinter import ttk These two lines tell Python that our program needs two modules. The first, "tkinter", is the standard binding to Tk, which when loaded also causes the existing Tk library on your system to be loaded. The second, "ttk", is Py

Re: [Tutor] exercise problem

2010-08-27 Thread Alan Gauld
t append() the answer to uitkomst 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] help, complete beginner please!

2010-08-28 Thread Alan Gauld
oth. His tusks are made" print "of gold. To the east is a painting of Mother Theresa. Under the painting" print "is a baby's crib. The only doors you see are to the south and west." promptThree = raw_input("What would you like to do? ")

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Alan Gauld
r personal needs and objectives its impossible to be any more specific. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tuto

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread Alan Gauld
cking upper and lower boundaries as well as midrange and out of range values plus various types of invalid inputs. 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] can this be done easerly

2010-08-30 Thread Alan Gauld
more easily ? Yes, you can do it all at the word level and you can remove the characters you don't want rather than testing for their presence etc. Look at the documentation for strip() you will see that you can provide a list of characters that you want removed. So a single call

Re: [Tutor] can this be done easerly

2010-08-30 Thread ALAN GAULD
> I tried your suggestion with strip and it looks like this : > import string You don't need this now > def extract_words(s): >word= "" You dont need this > s2=[] > s = string.lower(s) > s = s.replace( "--", " ") You probably don't need this either - just add '-' to the str

Re: [Tutor] can this be done easerly

2010-08-30 Thread ALAN GAULD
back to an explicit loop. He is using your original character based approach but with isalpha() instead of the ord() checks Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ > >From: Roelof Wobben >To: alan.ga...@btinternet.com >Sent: Monday, 30 August, 20

Re: [Tutor] Help with Object Oriented Programming

2010-08-30 Thread Alan Gauld
s on the OO principles. Bruce Eckel - Thinking in Java - One of the very few books on Java that does a good job of teaching OO. He was going to do a Thinking in Python but I think it died :-( And finally the original Design Patterns book by the Gang of Four. Its a bit heavy but the information

Re: [Tutor] __new__ over __init__

2010-09-01 Thread Alan Gauld
ever use it, but many do. (FWIW Perl has a similar shortcut and Perl fans use it a lot!) Try: 5+5 10 A = 1+2 print _ 10 A 3 print _ 3 HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist

Re: [Tutor] How to print the installed web browser

2010-09-01 Thread Alan Gauld
rrent user or for all users? -- 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 the installed web browser

2010-09-01 Thread Alan Gauld
"Nick Raptis" wrote Ooops! Sorry if I caused any confusion, I thought the goal was to print the default browser, not all of the installed ones. Silly me. Still, the "Preferred applications" tool seems to know that info (so to give you a choice) so it might be something to dig into. The prob

Re: [Tutor] Exec function problem

2010-09-01 Thread Alan Gauld
n a function? And it is running the file but getting an undefined name. odd. What happens if you run execfile() from a new interpreter prompt? CodeFile=open('DemandModel.py', 'r') exec(CodeFile) What happens if you use import (assuming you store in somewhere in sys.path..

Re: [Tutor] How to print the installed web browser

2010-09-01 Thread Alan Gauld
ed out many office type programs include the ability to act as a basic browser nowadays. Even trhe Eclipse IDE can display HTML pages. Does that count? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillis

Re: [Tutor] Begginer Python Problems - Urgent! Due by tomorrow morning.

2010-09-03 Thread Alan Gauld
tly what you told it to do. Where should the reading of numbers come in? And what would you do with the numbers when you got them? You might find the "Talking to the user" topic of my tutorial useful. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] Begginer Python Problems - Urgent! Due by tomorrowmorning.

2010-09-03 Thread Alan Gauld
"Dipo Elegbede" wrote you should type something like: x = raw_input('Enter a Number: ') x is a variable that takes whatever value you type in. However, if it were python 2.6, type: x = input('Enter a Number: ') Actually the other way round. input() for Python v 3 and raw_input() for Python

Re: [Tutor] best practices for where to set instance member variables

2010-09-04 Thread Alan Gauld
self.erase() self.draw(X,Y) Now subclasses only need to implement draw and erase and they get move() for free. class Foo: def __init__(self, a): self.a = self._f1(a) def _f1(self, a): return a This one is nearly always better. -- Alan Gauld Author of the Learn to Program web

Re: [Tutor] Creating custom GUI elements

2010-09-04 Thread Alan Gauld
nor tweak to an existing widget. But there is no real alternative. The good news is that once you get it right the final app that uses it will be a snap by comparison! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] why do i get None as output

2010-09-06 Thread Alan Gauld
t! And in fact, a list of empty strings is not the same as an empty list... 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] Simple Python Problem

2010-09-06 Thread Alan Gauld
r more information. RESTART What is your name? Keith I think there is a trick in V2.7 to make it act more like v3 but someone else will need to tell you what it is... :-) HTH, -- Alan Gauld Aut

Re: [Tutor] Simple Python Problem

2010-09-06 Thread ALAN GAULD
> > I think there is a trick in V2.7 to make it act more like v3 but someone > > else will need to tell you what it is... :-) >Other than changing the input() to raw_input() for Python 2 compatibility, And of course you can do that using input = raw_input > the following statement could be a

Re: [Tutor] exercise correct ??

2010-09-06 Thread Alan Gauld
3 # But in that tuple 5 is on position 3. Is the exercise here wrong ? No because the start position is 4 so you don;t see the 5 in position 3. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _

Re: [Tutor] Multiple versions of python and paths problems

2010-09-06 Thread Alan Gauld
it should work, and you may need to create a startup DOS file to set them before executing python... 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

Re: [Tutor] slicing a string

2010-09-06 Thread Alan Gauld
ices give you the first item to one less than the second index, so for a 4 letter word you need an index of of -5... "test"[-1:-4:-1] 'tse' "test"[-1:-5:-1] 'tset' HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

Re: [Tutor] exercise correct ??

2010-09-07 Thread ALAN GAULD
Oke, the 4 is a starting point for the index. > >Next problem. > >The begin looks like this : > > index_of(5, (1, 2, 4, 5, 6, 10, 5, 5), 4) > >But in the module I get this result : > >val = 5 >seq = (1, 2, 4, 5, 6, 10, 5, 5 > >So the 4 is not avaible anymore. > Yes it is. It is the start par

Re: [Tutor] Multiple versions of python and paths problems

2010-09-07 Thread Alan Gauld
Then run the batch files (create shortcuts if you like) as needed. 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

Re: [Tutor] Python command calls the wrong version!

2010-09-08 Thread Alan Gauld
I am new to Python, having perviously used IDL for all my scripts. I was hoping to use Python and so I have just downloaded and installed version 2.6 using the mac installer. That all went fine. I then opened up X11, all fine. Why did you open X11? If you used the Mac installer(*) it shoul

Re: [Tutor] sort problem

2010-09-08 Thread Alan Gauld
ython will do. For example try: "123".join([5,6,7]) Can you see what Python has done? Use the >>> prompt it is one of the most powerful tools you have. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] how to create a persistent dictionary w/ cpickle?

2010-09-08 Thread Alan Gauld
"Carter Danforth" wrote Hi, I'm trying to a create a basic addressbook for practice. I'm using a dictionary with cpickle, though I'm not sure how to persistently store each instance in the dictionary. Below is the code I have so far. If you use a dictionary it makes more sense to use shelv

Re: [Tutor] (no subject)

2010-09-12 Thread Alan Gauld
ASnd which version of Python and which Operationg System. These are all useful bits of information that help us to help you. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsu

Re: [Tutor] What Design Pattern for Document class (NOT URGENT)

2010-09-12 Thread Alan Gauld
s, parsers etc - but you want to shield your client code from them as much as possible. 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 subscr

Re: [Tutor] recursive problem

2010-09-12 Thread Alan Gauld
entation and Python's culture that we are all adults here usually means you don't need to. 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 chan

Re: [Tutor] recursive problem

2010-09-12 Thread Alan Gauld
to include examples using VBScript and Javascriopt to illustrate alternate approaches. You pick your favourite and run with it, but recognise the limits... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillis

Re: [Tutor] design question

2010-09-12 Thread Alan Gauld
from the behaviour of the GUI (controller) and the display(views) Read up on the MVC pattern on Wikipedia. Build the core application code in your models. Display them in views. Use a controller(or occasionally controllers) to manage the interactions. HTH, -- Alan Gauld Author of the

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Alan Gauld
ey stayed. In practice classmethod will be a better choice. IMHO at least :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] tree problem

2010-09-12 Thread Alan Gauld
"Lie Ryan" wrote In this case, the only reason why you hit the recursion limit is if you have a directory which is 1000 deep (quite unlikely, Windows has a directory depth limit much lower than that). Or you accidentally have a recursive directory - one that contains a shortcut to a folder

Re: [Tutor] recursive problem

2010-09-12 Thread ALAN GAULD
> > If you do need to avoid accidentally launching missiles then you need > > to do some type checking - although ideally using isinstance() instead > > of type(). But in the majority of cases some sensible documentation > > and Python's culture that we are all adults here usually means you >

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Alan Gauld
"Steven D'Aprano" wrote A little more information... static methods are quite common[1] in Java and C++, where people feel the need (or in the case of Java, are forced by the language) to make every function a method. static methods in C++ are normally reserved for use as class methods (alt

Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-13 Thread Alan Gauld
cant OOP project that did not use class methods somewhere in its design. But they tend not to be used in the typical small-scale code used in tutorials, so it's hard for a newbie to really get a feel for how they are used and why. -- Alan Gauld Author of the Learn to Program we

Re: [Tutor] wierd replace problem

2010-09-13 Thread Alan Gauld
or item in letter_items: print item[0] Backslashes are awkward characters because they are used for several different special purposes as well as being characters in their own right. If you had tried replacing almost any other character you would not have gotten confused. HTH, -- Alan Gauld Autho

Re: [Tutor] (no subject)

2010-09-14 Thread Alan Gauld
n. OTOH If you realized that but genuinely believe that open() is not returning an open file object then you will need to give us some more context - ideally some sample code and any error messages. Please tell us which OS you are using too. HTH, -- Alan Gauld Author of the Learn to Program web site

Re: [Tutor] wierd replace problem

2010-09-14 Thread Alan Gauld
"Steven D'Aprano" wrote OK,. Thats replacing a double slash in the data Er, surely not... I think you've confused backslashes and forward slashes. Or something. '\\' is a single backslash, not a double, because the first backslash is the escape character. A double backslash can be writt

Re: [Tutor] input problem

2010-09-14 Thread Alan Gauld
ata == "hello": fun() Or if you want to collect the results: results = [fun() for data in data_collection if data == "hello"] How you get the data into data_collecton I leave as an excercise! :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.m

Re: [Tutor] how best to implement paginated data in CLI

2010-09-14 Thread Alan Gauld
ker for a big result set. 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] help with integers

2010-09-14 Thread Alan Gauld
variable name. Python is trying to convert the string "myvar" to an int, which it can't. BTW When posting it is best to send the code plus entire error message, it greatly helps us debug the problem. -- Alan Gauld Author of the

Re: [Tutor] how best to implement paginated data in CLI

2010-09-15 Thread Alan Gauld
or for each screen in page display screen process data So if you are sure you will only ever have about 100 records you can omit the cursor paging. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor ma

Re: [Tutor] list dll functions?

2010-09-15 Thread Alan Gauld
t and hopefully some documentation! But often nowadays DLLs expose a COM object model and you have a COM browser built into Pythonwin. That will give you a windows explorer type view of the objects and their operations. If the DLL is purely perocedural then that won't help. HTH, -- Alan Gauld Author of

Re: [Tutor] Writing to Sound

2010-09-15 Thread Alan Gauld
ng. That probably depends on what you are searching for. I'm not clear from your description what you want to do. -- 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] list dll functions?

2010-09-15 Thread ALAN GAULD
hose you can see the parameters etc. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ - Original Message > From: Alex Hall > To: Alan Gauld > Sent: Wednesday, 15 September, 2010 15:57:43 > Subject: Re: [Tutor] list dll functions? > &

Re: [Tutor] intercepting and recored I/O function calls

2010-09-15 Thread Alan Gauld
ceably. I'd normally recommend using C for something like this. 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.py

Re: [Tutor] working with empty lists

2010-09-16 Thread Alan Gauld
equences they use regularly and start to "type ahead" which makes for a very efficient operation.) It's usually better to keep the command number as part of the menu data and then sort the command in order based on that. Just a thought, -- Alan Gauld Author o

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to run at command line?

2010-09-16 Thread Alan Gauld
x line has not died out and still gets new releases. Eventually the library owners will port their code but until then you need to use the version of python they are written for. You cannot mix them reliably. -- Alan Gauld Author of the Learn to Program web site http://www.al

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to runat command line?

2010-09-16 Thread Alan Gauld
t again its not follprooof, it just handles the most common cases. See the documentation for v3 for more details. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or chan

Re: [Tutor] intercepting and recored I/O function calls

2010-09-16 Thread Alan Gauld
"Jojo Mwebaze" wrote I am using centos, however i don't even have admin privileges. Which API are you referring to? The OS API - Win32 in Windows or the Unix standard library etc Alan G ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] Function behavior

2010-09-16 Thread Alan Gauld
e. Functions should reurn their results. Try reading the functions and modules topic in my tutorial to see if that helps. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To uns

Re: [Tutor] "Overloading" methods

2010-09-16 Thread Alan Gauld
gs its possible to abuse it. You can usually achieve similar ends with classes and/or dispatch tables. 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

Re: [Tutor] robots question

2010-09-16 Thread Alan Gauld
ame defeated = check_collisions(robots, player, junk) File "/root/workspace/test2/src/test.py", line 74, in check_collisions for thing in robots + junk: TypeError: can only concatenate list (not "dict") to list But this is v

Re: [Tutor] plotting pixels

2010-09-17 Thread Alan Gauld
"Bill Allen" wrote Is there a simple way to plot pixels in Python, without resorting to turtle graphics? James already mentioned matplotlib but you can just draw on a canvas. It depends on what you are trying to do. For plotting pixels I would not use turtle graphics. That would be a fairl

Re: [Tutor] intercepting and recored I/O function calls

2010-09-17 Thread Alan Gauld
"Jojo Mwebaze" wrote My applogies to begin with, it seems i didnt state my problem clearly for this particular case - perharps I/O was not the best way to describe my problem. Hmmm, perhaps not! :-) Specifically, i would like to track all inputs/output to modules/functions - if a module

Re: [Tutor] Remove a dictionary entry

2010-09-18 Thread Alan Gauld
the lenth of the list and delete the list so put that together as you did before: for row in d : # row is actually the key if len(row) == 1 :# so use the key to get the real row del row # WRONG #' and delete the row, again using the key HTH, -- Alan Gauld Auth

Re: [Tutor] Remove a dictionary entry

2010-09-18 Thread Alan Gauld
"Alan Gauld" wrote I ended up with this : Version 3 : for i,row in d[:].iteritems() : # BUG : TypeError: unhashable type if len(row) < 2 : del d[i] You are getting too complicated. You don't need the slice and you don't need iteritems. You have a dictionary

Re: [Tutor] class problem

2010-09-18 Thread Alan Gauld
ur print P gave me a clue to what the assignment is about. When you print the object it gives you a hex value I think they want you to extract that value and convert it to decimal to see if its the same as the value id() gives you. At least that's the only sane thing I can think it means!

Re: [Tutor] plotting pixels

2010-09-18 Thread ALAN GAULD
> It appears that the Tk canvas widget does not support simply plotting a >pixel. > Correct, and I agree it seems odd, but in practice drawing either lines or ovals of one-pixel do the equivalent job - albeit a little more slowly. > The primitive obviously exists in the underlying code, I

Re: [Tutor] What are "singletons" good for?

2010-09-19 Thread Alan Gauld
"Steven D'Aprano" wrote < much sense about singleton v global> and think this makes their code "better". (I blame the Go4 for making a religion out of design patterns which exist only to work around Java's limitations.) In fact the original design patterns were based around Smalltalk'

Re: [Tutor] Can this be done easly

2010-09-19 Thread Alan Gauld
"Roelof Wobben" wrote When I change everything to this : class Rectangle(object): def _init_(self, base_point, width=0, length=0): self.base_point = base_point self.width = width self.length = length punt = Point(3,4) rechthoek = Rectangle (punt,20,30) I get this mes

Re: [Tutor] pure function problem

2010-09-28 Thread Alan Gauld
uitkomst is a instance of tijd which has a attribute minutes. No it doesn't if seconds <= 60. -- 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 s

Re: [Tutor] I am looking for a book on Beginners who never programmedbefore or have no experience in programming

2010-09-28 Thread Alan Gauld
get stuck refer to the second best to see how it covers the same topic. If you still can't understand ask questions here. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Issues In Terminal

2010-09-28 Thread Alan Gauld
"Marc Tompkins" wrote The parentheses are optional in 2.6, mandatory in 3. In 2.6, print and print() are alternate ways to invoke the print statement Not strictly true. They often give the same results but not always, see a recent thread on this. In particular print ('a','b') is quite

Re: [Tutor] function error

2010-09-28 Thread Alan Gauld
tion()[1] I can't see it in your code sample but I'd check carefully that your parens() all balance correctly and are in the right place... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor mai

Re: [Tutor] Basics

2010-09-28 Thread Alan Gauld
rials suited to your needs on the Python web site. They nearly all have exercises in one form or other. If you are already fairly experienced you might find the Python Challenge web site a fun way to learn too. HTH, -- Alan Gauld Author of the Learn to Program web site http://w

Re: [Tutor] Python Help

2010-09-28 Thread Alan Gauld
r, writing down the values of each variable in the function for each time through the loop. Are they what you expect? HTH, -- 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] I am looking for a book on Beginners who neverprogrammed before or have no experience in programming

2010-09-28 Thread Alan Gauld
"Steven D'Aprano" wrote I've never heard of "Head First Programming" -- how are they unconventional? They are a bit too "cutesy" for my liking, slow to get to any depth but engaging for the sound-byte generation. Lots of cartoons and jokes. I'd say its a bit like O'Reilly's take on the Dummie

Re: [Tutor] Writing a txt from dbf

2010-09-29 Thread Alan Gauld
already showed you how to add a \n when writing the data to the file. Have you tried that? Are you still having problems? -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscri

Re: [Tutor] function error

2010-09-29 Thread Alan Gauld
s a non standard error trace so presumably you are running it inside an IDE of some kind? It may be the IDE is masking the true error. What happens if you just execute the code from a shell prompt in a console window? Can you send the error trace from that? HTH -- Alan Gauld Author of the

Re: [Tutor] Runnig a windows.exe from python

2010-09-29 Thread Alan Gauld
The documentation has numerous examples and the "Using the OS" topic of my tutorial has some info too. HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscri

Re: [Tutor] system()? popen2()? How to execute a command & save itsoutput?

2010-09-30 Thread Alan Gauld
;t do it from within Python. 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

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