[Tutor] passing unknown no of arguments

2009-02-05 Thread amit sethi
How do you pass arguments of unknown no. of arguments to a function. Also how can i run my python scripts in a web browser. -- A-M-I-T S|S ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] inheriting different builtin types

2009-02-05 Thread Willi Richert
Hi, http://objectmix.com/python/710201-dynamically-changing-base-class.html may be of interest. wr On Mittwoch, 4. Februar 2009 14:27:17 spir wrote: > Hello, > > I have a strange problem and cannot see a clear method to solve it. > I would like to build a custom type that is able to add some in

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Senthil Kumaran
On Thu, Feb 5, 2009 at 1:37 PM, amit sethi wrote: > How do you pass arguments of unknown no. of arguments to a function. You use * operator ( indirection) in the function definition for arguments and you pass the variable number of number arguments as a list. For e.g. >>> def foo(*args): ...

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Alan Gauld
"amit sethi" wrote How do you pass arguments of unknown no. of arguments to a function. search the docs for *args and *kwargs Also how can i run my python scripts in a web browser. In general you can't. You would need to have a Python interpreter in your browser. The only reliable way t

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Senthil Kumaran
On Thu, Feb 5, 2009 at 2:27 PM, Alan Gauld wrote: > In general you can't. You would need to have a Python interpreter > in your browser. Alan, I think he was referring to CGI programming. Given the nature of his first question. Well continuing the discussion further, I saw a post by Bret Cannon o

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Alan Gauld
"Senthil Kumaran" wrote Also how can i run my python scripts in a web browser. What you are asking for is Python CGI programming. Look out for chapters for Alan's book. I think he has covered from the basics. If you mean how do you write dynamic web pages using Python then indeed it is CG

[Tutor] named list

2009-02-05 Thread spir
Hello, python world! I'm looking for a way to implement a kind of "named" list, or named tree, with the following requirements: * Each item is named (or key-ed), like in a dict. * Each item (node) can be either a terminal item (leaf) or a sub-list (branch). * There may be items with the same nam

Re: [Tutor] [Visualpython-users] tkinter and visual with objects

2009-02-05 Thread Bruce Sherwood
The following works to produce a window with nothing displayed in it: ball = sphere() ball.visible = 0 Another scheme would be this: scene.range = 1 ball = sphere(radius=1e-6) The point is that Visual doesn't create a window unless there is something to display. Bruce Sherwood Mr Gerard Ke

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Kent Johnson
On Thu, Feb 5, 2009 at 3:57 AM, Alan Gauld wrote: > In general you can't. You would need to have a Python interpreter > in your browser. The only reliable way to run code in a browser is > to use JavaScript. AFAIK MS Silverlight allows you to run .NET languages in your browser, including IronPyt

Re: [Tutor] named list

2009-02-05 Thread Kent Johnson
On Thu, Feb 5, 2009 at 5:09 AM, spir wrote: > Hello, python world! > > I'm looking for a way to implement a kind of "named" list, or named tree, > with the following requirements: > > * Each item is named (or key-ed), like in a dict. > * Each item (node) can be either a terminal item (leaf) or a

Re: [Tutor] inheriting different builtin types

2009-02-05 Thread Kent Johnson
On Wed, Feb 4, 2009 at 8:27 AM, spir wrote: > Hello, > > I have a strange problem and cannot see a clear method to solve it. > I would like to build a custom type that is able to add some informational > attributes and a bunch attribute to a main "value". The outline is then: > > class Custom(X):

[Tutor] Killing a socketserver

2009-02-05 Thread Michael Bernhard Arp Sørensen
Geeting, my masters. How do I kill/shutdown a socket server running in its own thread either from handle() or from outside of the tread? Any thing will do. It's python version 2.5.2, so the newer shutdown method in version 2.6 does not work here. Thanks in advance. -- Med venlig hilsen/Kind re

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread spir
Le Thu, 5 Feb 2009 08:57:15 -, "Alan Gauld" a écrit : > > "amit sethi" wrote > > > How do you pass arguments of unknown no. of arguments to a function. > > search the docs for *args and *kwargs > Or simply pass a tuple: def myPrint(thing): print thing thing_of_things = (1,'a',[

Re: [Tutor] Sort of database & "family tree" question

2009-02-05 Thread spir
Le Wed, 4 Feb 2009 22:33:45 -, "Alan Gauld" a écrit : > > "Timo" wrote > > class Person: > def __init__(self, parser): > self.first = parser.get(person, 'firstName') > > > > Hey Alan, thanks for that explanation! > > > > But the class you gave, does almost the

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Dave Rankin
On Thu, Feb 5, 2009 at 3:57 AM, Alan Gauld wrote: > > In general you can't. You would need to have a Python interpreter > > in your browser. The only reliable way to run code in a browser is > > to use JavaScript. I'm very new to Python, but I've also been wondering about this. It would seem to

[Tutor] Install/upgrade question

2009-02-05 Thread cclpianos
Hello, I am very new to programming and have been using Python on my Mac mini 1.66. I'm a bit confused by the install procedure as I have two different versions on my machine. I didn't know that it came pre-installed on my mac (version 2.3) and went to the DL site for 2.61. Well it download

Re: [Tutor] Install/upgrade question

2009-02-05 Thread Kent Johnson
On Thu, Feb 5, 2009 at 12:06 PM, wrote: > My main question is "How do I get the downloaded version to replace what's > on my system? Don't; leave the system copy alone, there are system components that use it. > As it is, I can open the IDLE and it verifies I have installed version 2.61. > But

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Alan Gauld
"Kent Johnson" wrote in your browser. The only reliable way to run code in a browser is to use JavaScript. AFAIK MS Silverlight allows you to run .NET languages in your browser, But how many browsers currently support Silverlight? After all IE supports VBScript too but its the only one. E

Re: [Tutor] Killing a socketserver

2009-02-05 Thread Alan Gauld
"Michael Bernhard Arp Sørensen" wrote How do I kill/shutdown a socket server running in its own thread either from handle() or from outside of the tread? Any thing will do. kill -9 pid if you are on *nix? Or do you need to do it from code? Or is it only the thread you want to kill? Are y

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Kent Johnson
On Thu, Feb 5, 2009 at 1:02 PM, Alan Gauld wrote: > > "Kent Johnson" wrote >> AFAIK MS Silverlight allows you to run .NET languages in your browser, > > But how many browsers currently support Silverlight? >From the Silverlight FAQ: Silverlight will support all major browsers on both Mac OS X, L

Re: [Tutor] Killing a socketserver

2009-02-05 Thread Kent Johnson
On Thu, Feb 5, 2009 at 7:26 AM, Michael Bernhard Arp Sørensen wrote: > Geeting, my masters. > > How do I kill/shutdown a socket server running in its own thread either from > handle() or from outside of the tread? Any thing will do. > > It's python version 2.5.2, so the newer shutdown method in ve

Re: [Tutor] passing unknown no of arguments

2009-02-05 Thread Alan Gauld
"Kent Johnson" wrote From the Silverlight FAQ: Silverlight will support all major browsers on both Mac OS X, Linux and on Windows. I briefly tried and failed to get it working on MacOS X and lost interest. Looks like I might be a bit premature in ignoring it. I'll have another go... Al

[Tutor] confusing enumerate behavior

2009-02-05 Thread عماد نوفل
Hi Tutors, I'm a little, actually a lot confused by the behavior of the enumerate function here. I have a text and I want to get each word within the context of the three preceding and the three following words. I tried this: #BEGIN my_input = "one two three four five six seven eight nine ten" tex

[Tutor] Python 2.6.1 + Linux Ubuntu (Gutsy Gibbon)

2009-02-05 Thread Eric Dorsey
I am trying to teach myself Linux, and so I'm running Ubuntu (Gutsy Gibbon) as a virtual machine. I went to terminal, started up Python and realized it was version 2.5 so I thought I'd just upgrade to 2.6.1 After doing some Googling around, it seems that Ubuntu is highly reliant on Python 2.5, so u

Re: [Tutor] confusing enumerate behavior

2009-02-05 Thread Alan Gauld
"Emad Nawfal (عماد نوفل)" wrote I'm a little, actually a lot confused by the behavior of the enumerate Its not enumerate thats confusing you its indexing. my_input = "one two three four five six seven eight nine ten" text = my_input.split() for i,v in enumerate(text): line = text[i-3],

Re: [Tutor] Python 2.6.1 + Linux Ubuntu (Gutsy Gibbon)

2009-02-05 Thread عماد نوفل
On Thu, Feb 5, 2009 at 8:24 PM, Eric Dorsey wrote: > I am trying to teach myself Linux, and so I'm running Ubuntu (Gutsy Gibbon) > as a virtual machine. I went to terminal, started up Python and realized it > was version 2.5 so I thought I'd just upgrade to 2.6.1 After doing some > Googling aroun

Re: [Tutor] Install/upgrade question

2009-02-05 Thread Kent Johnson
On Thu, Feb 5, 2009 at 9:29 PM, wrote: > Hi Kent, > Thanks for your very quick reply. I'll be as succinct as possible. > On Feb 5, 2009, at 10:48 AM, Kent Johnson wrote: > Last login: Thu Feb 5 18:55:15 on console > Welcome to Darwin! > p-ws-computer:~ pw$ python > Python 2.3.5 (#1, Nov 26 2007

[Tutor] Designing a Dialog in Python

2009-02-05 Thread Wayne Watson
Title: Signature.html When I used VBasic many years ago, it had the ability to design a dialog and then attach it to the code. Is there something like this available for Python? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N)

Re: [Tutor] confusing enumerate behavior

2009-02-05 Thread jitendra gupta
On Fri, Feb 6, 2009 at 5:43 AM, Emad Nawfal (عماد نوفل) wrote: > Hi Tutors, > I'm a little, actually a lot confused by the behavior of the enumerate > function here. I have a text and I want to get each word within the context > of the three preceding and the three following words. I tried this: