Re: [Tutor] list comprehensions

2009-10-08 Thread Gregor Lingl
Christer Edwards schrieb: I've been studying python now for a few weeks and I've recently come into list comprehensions. Some of the examples that I've found make sense, and I find them readable and concise. In particular I'm referring to the python docs on the topic (http://docs.python.org/tut

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Gregor Lingl
Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the command line shows I'm using 2.62: C:\Documents and Settings\Riley>python Python 2.

Re: [Tutor] demo/turtle

2009-07-22 Thread Gregor Lingl
roberto schrieb: On Wed, Jul 22, 2009 at 7:06 PM, Alan Gauld wrote: "roberto" wrote i'd like to download the demo/turtle directory but i could not find the correct link; i need it to run the exampled cited in http://docs.python.org/library/turtle.html can you tell me where to find

Re: [Tutor] Replace a character by index

2009-07-16 Thread Gregor Lingl
Christian Witts schrieb: Wayne wrote: Hi, ... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Strings are essentially a list already of

Re: [Tutor] window graphics

2009-07-02 Thread Gregor Lingl
Hi David, Python 3 (preferably 3.1) has a very easy to use graphics module in the standard library: the turtle module. It has a lot of capabilities, but alas, its working with geometrical objects and doesn't allow to adress single pixels . Get started by writing: >>> from turtle import *

Re: [Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

2009-06-17 Thread Gregor Lingl
matthew andriani schrieb: Hi Guys, I wrote this program for some practice to get into python..I'm trying to find fun ways to learn the language so if anyone has a challenge on this basic level using loops that sounds exciting please let me know.. If you think this program can be improved ple

Re: [Tutor] serious problem with graphics module

2009-06-04 Thread Gregor Lingl
Alan Gauld schrieb: "W W" wrote Do you (or sombody else) know how to get ipython working with Python 2.6 (you know, the Python release, which has that new turtle module ;-) ) doesn't install on my Windows box... other than that I've got no experience with it I thought the new turtle

Re: [Tutor] serious problem with graphics module

2009-06-02 Thread Gregor Lingl
Lie Ryan schrieb: roberto wrote: On Tue, May 26, 2009 at 12:45 AM, Gregor Lingl wrote: I know one situation in which can happen what you describe: ... ok, it works all right now the minor issue is that i could not create the shortcut with the -n flag as you pointed out

Re: [Tutor] serious problem with graphics module

2009-05-25 Thread Gregor Lingl
roberto schrieb: hello everyone Hello Roberto, First question: Do you use Python from the command line (terminal) or do you use IDLE? I ask this, because these two show different behaviour. i have a problem with python 3.0 graphics module: no problem while importing the module impor

Re: [Tutor] serious problem with graphics module

2009-05-25 Thread Gregor Lingl
bob gailer schrieb: roberto wrote: hello everyone i have a problem with python 3.0 graphics module: no problem while importing the module import turtle but when i issue any command like: t = turtle.pen() t = turtle.forward(60) Your code fails for me at turtle.pen A

Re: [Tutor] serious problem with graphics module

2009-05-25 Thread Gregor Lingl
roberto schrieb: hello everyone i have a problem with python 3.0 graphics module: no problem while importing the module import turtle but when i issue any command like: t = turtle.pen() t = turtle.forward(60) nothing appears on the screen, only a blank window, wit

Re: [Tutor] beginners resources list, Python education events

2009-04-16 Thread Gregor Lingl
wesley chun schrieb: hey all, ... Python: Visual QuickStart Guide (Fehily, 2001) This is outdated. There is a new one: Toby Donaldson: Python: Visual QuickStart Guide (2008) Learn to Program Using Python (Gauld, 2000) ONLINE How to Think like a Computer Scientist http://openbookproject

Re: [Tutor] Event Handling--Key Press, Mouse Movement ...

2009-04-13 Thread Gregor Lingl
Wayne Watson schrieb: Sometime ago, one of my posts brought a response brief exchange on event handling*. Where might I find more about event handling with respect to the keyboard, and particularly with a mouse. In the latter case, I'm interested in finding the pixel position of the mouse on

Re: [Tutor] TOT: what does the "@" operator mean?

2008-12-16 Thread Gregor Lingl
Marc Tompkins schrieb: By the way, (totally off-topic, of course, my apologies): what do all y'all call the "@" operator? Here in the States, we call it the "at-sign", which I find boring; I believe "sleepycat" is a Scandinavian thing (I picked it up in some long-forgotten article); some Russi

Re: [Tutor] Questions about the new turtle module in Python 2.6b2

2008-08-15 Thread Gregor Lingl
a special trick: the pause() function + boolean variable running. update() is used to make the program check the event-queue. (This would not be necessary, I think, if you draw rectangles slowly using goto(), because in this case the animation itself automatically uses update() frequently.) Hop

Re: [Tutor] Questions about the new turtle module in Python 2.6b2

2008-08-09 Thread Gregor Lingl
Dick Moores schrieb: At 03:12 AM 8/9/2008, Dick Moores wrote: 4. For my random_rectangles.py program I've started to try out the new turtle. (See the current state of random_rectanglesV16_web.py at < http://py77.python.pastebin.com/d3e842821>.)

Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by abug in turtle.py

2008-08-08 Thread Gregor Lingl
Hi Dick, just to show you a bit of the versatility of the new turtle module I've prepared to tiny rectangle-generator program examples. They intentionally use different programming styles and also turtle graphics techniques different from the ones you used to accomplish something similar to what

Re: [Tutor] Ongoing trouble with Turtle's end_fill() - Important note!

2008-08-08 Thread Gregor Lingl
P.S.: If you are interested, you can download a series of sample programs covering a broad range from very easy to fairly advanced, which intend to show some features and capabilities of the new turtle module from here: http://svn.python.org/view/python/trunk/Demo/turtle/ These will be includ

Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by abug in turtle.py

2008-08-08 Thread Gregor Lingl
Dick Moores schrieb: Here better tracer() should come in! 'Deprecated in version 2.6'?? And the doc gives nary a clue how to use it. http://docs.python.org/dev/library/turtle.html#turtle.tracer tracer is only deprecated as a Turtle-method, because it doesn't concern single turtles but

Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by abug in turtle.py

2008-08-07 Thread Gregor Lingl
Hi Dick, first of all, thanks for your efforts using the new turtle module and reporting about your experiences and the problems you ran into. I've already made some remarks on it in a former reply in this thread. On Thu, Aug 7, 2008 at 11:26 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: ... 2.

Re: [Tutor] Ongoing trouble with Turtle's end_fill()

2008-08-07 Thread Gregor Lingl
Alan Gauld schrieb: "Dick Moores" <[EMAIL PROTECTED]> wrote 1. The turtle has some behavior I don't see how to eliminate. If you refer to lines 223, 225, 227, 229, etc., you'll see that the turtle always faces in the direction it is moving when drawing a rectangle. That is correct behaviour f

Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by a bug in turtle.py

2008-08-06 Thread Gregor Lingl
Kent Johnson schrieb: On Tue, Aug 5, 2008 at 6:49 PM, Dick Moores <[EMAIL PROTECTED]> wrote: For a while now I've had trouble with end_fill(). Sometimes I can use it to fill a figure such as a square, triangle or rectangle, but sometimes not. Here's a barebones script using end_fill(). As

Re: [Tutor] returning two values

2008-03-21 Thread Gregor Lingl
elis aeris schrieb: is it possible to return two values? Yes: >>> def return2(): return "this", "that" >>> return2() ('this', 'that') >>> a,b=return2() >>> a 'this' >>> b 'that' >>> Regards, Gregor _

Re: [Tutor] Stupid Pythony Newbie Question: Basic Operators;

2008-03-16 Thread Gregor Lingl
Michael Lim schrieb: > Sorry guys, this is a newbie question... can someone please help me > with what the following 2 basic operators do in like simple english: > > 1. > > ^ This operator performs a logical operation, the exclusive or, also xor, for the binary digits af two integer numbers. The

Re: [Tutor] How to improve

2007-07-12 Thread Gregor Lingl
taserian schrieb: > I've been programming for years before encountering Pythoin, but in > much more verbose languages, and I appreciate the fact that Python is > so terse and still accomplishes so much. Still, I have difficulty > thinking in Python, and tend to revert to longer programs for what

Re: [Tutor] arguments

2007-02-15 Thread Gregor Lingl
[EMAIL PROTECTED] schrieb: >Hi list, > >I have a function with two arguments (say f(x,y)) >and second which returns tuple (say def g(): return (xx,yy)) > >my question is how to put returned values from g() as >arguments to f ? > > There is a special *-operator, which inserts the components of an

[Tutor] Alias for a class name

2006-07-12 Thread Gregor Lingl
Hi everyoen, say in some module I have defined a class Pen and I want an alias for the class name, say Turtle I can do this: class Turtle(Pen): pass or simply (after having defined Pen): Turtle = Pen Are those two variants different in effect? Are there pros or cons for one of both varian

Re: [Tutor] no loops

2006-07-11 Thread Gregor Lingl
Christopher Spears schrieb: IF you know that it's 2 seconds after midnight, how many hours, minutes, seconds after midnight ist this. If you should compute this by hand, how would you proceed? Best wishes, Gregor > I am working on another problem from "How To Think > Like A Computer Scienti

[Tutor] for teachers and students: xturtle.py a new tutle graphics module

2006-06-25 Thread Gregor Lingl
xturtle.py, extended turtle graphics a new turtle graphics module for Python and Tkinter Version 0.9 of xturtle.py has been released. It can be found at: http://ada.rg16.asn-wien.ac.at/~python/xturtle xturtle should work properly on all major platforms (Mac, Linux and Windows) Feedback would be

Re: [Tutor] How do I do cubic roots and cubic exponents (and higher roots and exponents) in Python?

2006-05-09 Thread Gregor Lingl
Danny Yoo schrieb: > > >>How do I do cubic (and higher) roots ... >> > >I think you're looking for the '**' operator. Like addition and >multiplication, it can take in two numbers. > >## > > 2 ** 2 >4 > > And they also can be floating point numbers >>> 2 **

[Tutor] Argument check

2006-05-04 Thread Gregor Lingl
hen chackargs had to get information about its caller (name, locals) from elsewhere (the callstack?). I don't know if this is possible at all, not to say how to accomplish it. Do you have some hints? Where could I find code-examples which sol

[Tutor] simple question about numeric types

2006-05-02 Thread Gregor Lingl
Hi! Is there a simpler/fster way to check if a value has int or float type (i.e. is a "real number") than: v= if isinstance(v, int) or isinstance(v, float): (v must not be complex) Regards, Gregor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mo

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Gregor Lingl
Kent Johnson schrieb: > Gregor Lingl wrote: > >>Thanks, Kent for the hint. It works (of course). >>Skimming through this part of the docs I discovered, that there is a >>special method __deepcopy__. So I also tried using this, adding >> >&

Re: [Tutor] question concerning deepcopy

2006-04-29 Thread Gregor Lingl
Kent Johnson schrieb: > Gregor Lingl wrote: > >>Hi all of you, ... >>> from copy import deepcopy >> >>> class Vec(tuple): >> def __new__(cls, x, y): >> return tuple.__new__(cls, (x,y)) >> def __abs__(self

[Tutor] question concerning deepcopy

2006-04-28 Thread Gregor Lingl
\lib\copy.py", line 336, in _reconstruct y = callable(*args) File "C:\Python24\lib\copy_reg.py", line 92, in __newobj__ return cls.__new__(cls, *args) TypeError: __new__() takes exactly 3 arguments (2 given) Explanation? Remedy? Bug? Workaround? Regards, Gregor -- G

Re: [Tutor] Tkinter, Frame and Canvas question.

2006-02-23 Thread Gregor Lingl
as(self, background='#00', borderwidth=0) > canvas2 = Tkinter.Canvas(self, background='#00', borderwidth=0) > > canvas1.pack(pady=0) > canvas2.pack(pady=0) > > if __name__ == '__main__': > myapp = App() > myapp

Re: [Tutor] two ways

2005-11-11 Thread Gregor Lingl
Liam Clarke schrieb: >Hi Shi, > >For what you're doing, nothing at all. > >When you use a colon, slice syntax, it defaults to [start:end] so p = >a[:] is the same as >p = a[0:len(a)] > > > But in fact there is a difference. I'll show you: >>> a=range(5)### creates a list-object >>> id(a)

Re: [Tutor] [OT] triangulation

2005-11-09 Thread Gregor Lingl
rench/Spanish > counterpart. > I know that this definitely (still) exists for Logo in German Gregor > Ismael > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Gregor Lingl R

Re: [Tutor] [OT] triangulation

2005-11-09 Thread Gregor Lingl
riginal Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of Gregor Lingl > Sent: Thursday, 10 November 2005 1:44 p.m. > To: tutor@python.org > Subject: Re: [Tutor] triangulation > > > > > Alex Hunsley schrieb: > >>Shi Mu

Re: [Tutor] any code to draw parabola or curve?

2005-11-09 Thread Gregor Lingl
Both! See attachment Regards, Gregor Shi Mu schrieb: any code to draw parabola or curve? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33

Re: [Tutor] triangulation

2005-11-09 Thread Gregor Lingl
/tutor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mobil: +43 664 140 35 27 Website: python4kids.net ## Run this program and create a polygon without ## intersecting edges by clicking the vertices with the mouse from Tkinter import * def area2(A,B,C): &quo

[Tutor] Annoying problem when importing a file (caused by IDLE?)

2005-09-12 Thread Gregor Lingl
- although I don't know where they come from. Is there a simple way to check this assumption (e.g. using some simple editor, which shows these "unfriendly" characters.) 4) I urgently feel, that I have to stop these annoyances. Do you know how I can do this? Desperately Gregor

Re: [Tutor] one line code

2005-04-05 Thread Gregor Lingl
Pierre Barbier de Reuille schrieb: Mmmhhh ... not strictly one line but ... import re float_str = re.compile(r"^\s*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?\s*$") val = [ ( (float_str.match(s) and [float(s)]) or [s])[0] for s in l2 ] It's not really "readable" but well ... it works ^_^ Pierre This c

[Tutor] appearance of old postings

2005-03-25 Thread Gregor Lingl
Hi, there just appeared a couple of postings from a Jan 2004 thread (on primes) on this list again. (two of them by me) To me it's completely unclear why and how this could happen. Does anybody know ...? Gregor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mobil:

[Tutor] SORRY (wrong adress) - (appearance of old postings)

2005-03-25 Thread Gregor Lingl
Ooops, I put the wrong address into my recent posting, which was intended to go to the edu-sig list. Forget it! Sorry for the inconvenience, Gregor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mobil: +43 664 140 35 27 Website: python4kids.net

Re: [Tutor] primes - sieve of odds

2005-03-23 Thread Gregor Lingl
finite prime number generator. Has anybody any suggestions? Gregor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mobil: +43 664 140 35 27 Website: python4kids.net ___ Tutor maillist - Tutor@python.org http://mail.python.org/m

Re: [Tutor] primes - sieve of odds

2005-03-20 Thread Gregor Lingl
//2 nums[start::p] = [False]*(1+((maximum-3)//2-start)//p) return [2] + filter(None, nums) Perhaps not very elegant. But approximately twice as fast as the former version. Best wishes, Gregor Sean Perry schrieb: Gregor Lingl wrote: The following variation of your sieve, using exten

Re: [Tutor] primes (generator)

2005-03-20 Thread Gregor Lingl
Karl Pflästerer schrieb: On 19 Mrz 2005, [EMAIL PROTECTED] wrote: [Code] Maybe sombody likes... I did it ... : def sieve (max): max = max + 1 border = round(max**0.5) nums = range(0, max) nums[0] = nums[1] = None for p in nums: if p: if p >= border: break

Re: [Tutor] primes (Cautious remark on Python and Scheme)

2005-03-18 Thread Gregor Lingl
Concerning my previous posting - perhaps it would suffice to summarize: While Python is a language for the "pragmatic" lover, Scheme is much more "fundamentalistic". (thought-) *PROVOKING*? Gregor ___ Tutor maillist - Tutor@python.org http://mail.pytho

Re: [Tutor] primes (Cautious remark on Python and Scheme)

2005-03-18 Thread Gregor Lingl
m: as always when writing not only about technical facts but about opinions and values in English, I'm a bit axious if I was able to express correctly what I wanted to say. Hmmm. Hope that I didn't create any misunderstandings .... Danny Yoo schrieb: On Thu, 17 Mar 2005, Gregor Lingl wrote: H

Re: [Tutor] primes (generator)

2005-03-18 Thread Gregor Lingl
7;d be interested in them .. Maybe sombody likes to compare these algorithms to the ones mentioned before in this thread. I would be interested in the results. Regards, Gregor Danny Yoo schrieb: On Thu, 17 Mar 2005, Gregor Lingl wrote: Hi! Who knows a more concise or equally concise but more eff

[Tutor] primes

2005-03-17 Thread Gregor Lingl
Hi! Who knows a more concise or equally concise but more efficient expression, which returns the same result as [x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]] Gregor P.S.: ... or a more beautiful one ;-) ___ Tutor maillist - Tutor@py

Re: [Tutor] Advanced Calculator Program...

2005-02-19 Thread Gregor Lingl
___ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/list

Re: [Tutor] Instance into another instance

2005-02-19 Thread Gregor Lingl
n I do to solve that? The idea of the class is to be able to create a "tree". Where each node can have subnodes, which in turn can have their subnodes... Thanks Ismael _______ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo

Re: [Tutor] Trying out Tkinter with problems

2005-02-19 Thread Gregor Lingl
t;Quit", "Do you really wish to quit?"): self.master.destroy() I'm not sure if this is the canonical way of exiting a Tkinter-App :-( (Perhaps somebody knows more.) Hope this helps, Gregor TIA - Adam -- Gregor Ling

Re: [Tutor] how to read from a txt file

2005-02-17 Thread Gregor Lingl
t out, I'd do more damage. I yield the floor as I am off to write "Don't post untested code 1000 times. (I will say I suspect it is the readline vs. readlines, but then hopefully no one is reading this ;-) Sheepishly, bran vdB ___ Tutor maillist

[Tutor] How to sum rows and columns of a matrix?

2005-01-31 Thread Gregor Lingl
maybe also for slices ?) All comments, hints, solutions are welcome. Regards, Gregor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33 98 Mobil: +43 664 140 35 27 Autor von "Python für Kids" Website: python4kids.net ___

Re: [Tutor] German Tutorials auf Deutsch

2005-01-10 Thread Gregor Lingl
mliche viele Themen. Ara ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien Telefon: +43 1 713 33

Re: [Tutor] am I missing another simpler structure?

2004-12-16 Thread Gregor Lingl
Kent Johnson schrieb: It's probably worth pointing out that these two functions are not entirely equivalent: def t1(): if condition: return True return False def t2(): return condition ... >>> if t1(100) == True: print '100 is True' ... 100 is True >>> if t2(100) == True: print '100

Re: [Tutor] am I missing another simpler structure?

2004-12-16 Thread Gregor Lingl
Brian van den Broek schrieb: If my original bit of code, the structure was like: output_value = False if condition: output_value = True return output_value Mine would be like yours if transformed to: if condition: return True return False Hi Brian! Do you mean, that condition is something

Re: [Tutor] A little Tkinter question

2004-12-15 Thread Gregor Lingl
Gregor Lingl schrieb: Marilyn Davis schrieb: Hi Tutors, I'm reviewing GUIs and wondering: When you pack a component, and you specify fill = BOTH, how is this different from expand = YES? Hi Marilyn, This is a bit tricky and hard to explain, so I recommend playing around with this little pr

Re: [Tutor] A little Tkinter question

2004-12-15 Thread Gregor Lingl
d=1) and so on. These Examples are from Chapter 5, several others concerning the packer can be found at: https://secure.manning.com/catalog/view.php?book=grayson&item=source Hope this helps Gregor Thank you for any insight. Marilyn Davis ___ Tutor ma

Re: [Tutor] Simple RPN calculator

2004-12-08 Thread Gregor Lingl
Terry Carroll schrieb: On Mon, 6 Dec 2004, Chad Crabtree wrote: Bob Gailer wrote: For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input and prints -0.0481481 8 lines of Python. That indeed is less than 100. Took about 7 minutes to code and test.