Guide to the python interp. source?

Andreas Kostyrka andreas at kostyrka.priv.at
Sun Jul 28 10:45:08 EDT 2002


Am Sam, 2002-07-27 um 15.19 schrieb Tim Gahnström /Bladerman:
> I noticed, but thought that I just had missed it. I thought there must be
> some where for such a large project. But the problem is ofcourse ever
> present, "nobody likes to do documentation"
Well, start with the embedding/extending documantation.
> Maybe look into value/copy return as Alex Martelli mentioned. What I want is
> not really CBR but the, from Ada known "in out parameters" or the Pascall
> "var parameter".
var parameters are true call by reference. And it would make no sense in
a language design, because call by value semantics have cleaner
semantics.

f(i) with general reference semantics have unnice property, that I know
nothing about i after the call. Now there is nothing in the python
syntax that would make specifing which parameters should be reference
passed.

Additionally, the most important use CBR is passing out multiple return
values, which is obviously not needed in python:
def func(x,y,z):
	return (x+1,y+1,z+1)
a,b,c=func(d,e,f)

> > Probably easy.  Not quite sure what you mean here.
sys.stdout=open("somefile","w")
sys.stdout=cStringIO.StringIO()

> Didn't really mean anything briliant there, it was just small things that
> poped out of my head while I was writing.
> I meant I want all output (text, graphics, buttons, etc) in a certain window
> in the IDE I am creating.
> 
> > > better errormesages,
> > Examples?  Feel free to contribute these back to the project...
> 
> Ofcourse I will contribut them back if I create something there that is
> usefull for alot of people.
> Maybe the error messages I want to have is not so badly needed for
> experienced programmers but more for beginners.
> A traceback is for instance really cryptic to a novice programmer I want an
> errormessage to look loike this.
> 
> "The program stopped running for some unknown reason. It is likely an error
> on line 23 in the file "myprog.cod":
>     if (max(3)>variable):
> The error is probably caused by the call to the function max(). If you mean
> to call the built in function max it must have two arguments, namely "val1"
> and "val2" but you only supply it with one argument (constant 3).
> On the other hand it might also be a misspelled call to your own function
> maz() in "mylib.cod"
> "
But that is exactly not correct:
max(1,2)
max(1,2,3,4,5,6)
max((1,2,))
max([1,2,3,4,])

are all legal.
max(someObject)
might also be legal, if someObject is a user made list like object.

> Currently the errormessage looks like this instead:
> 
> "Traceback (most recent call last):
>   File "<pyshell#8>", line 1, in ?
>     if max(3)>variable:
> TypeError: min() or max() arg must be a sequence"
Well, this at least correct. (arg must be a sequence.)
While your nice message above is misleading.

Andreas





More information about the Python-list mailing list