Re: append to non-existing list

2005-11-10 Thread Yves Glodt
bruno at modulix wrote: Yves Glodt wrote: (snip) ok I see your point, and python's... (just FYI, and not to start a flamewar ;-): In php, the [] means append to an array object. yes, I know this. If the array does not exist yet, it's created. Which is what I don't like. It should

Re: append to non-existing list

2005-11-10 Thread [EMAIL PROTECTED]
Yves Glodt wrote: Which raises another question... :-) Is there a possibility to bring together apache and python in a way that I can embed python into html? What do you mean ? Or even, write a smallish webserver in python (using twisted maybe) whose only purpose is to serve pages and

Re: append to non-existing list

2005-11-10 Thread Fredrik Lundh
Yves Glodt wrote: Is there a possibility to bring together apache and python in a way that I can embed python into html? http://www.onlamp.com/pub/a/python/2004/02/26/python_server_pages.html http://www.modpython.org/live/mod_python-3.2.2b/doc-html/pyapi-psp.html#pyapi-psp /F --

Re: append to non-existing list

2005-11-10 Thread Yves Glodt
[EMAIL PROTECTED] wrote: Yves Glodt wrote: Which raises another question... :-) Is there a possibility to bring together apache and python in a way that I can embed python into html? What do you mean ? I need this (invalid example-html follows): html h1title of page/h1 ?py import time

Re: append to non-existing list

2005-11-10 Thread [EMAIL PROTECTED]
Yves Glodt wrote: I need this (invalid example-html follows): html h1title of page/h1 ?py import time print pHello, today is: %s/p % (time.ctime()) ? /html Cheetah template ? But I like Kid better as I don't want python in HTML, Kid IMO strikes the balance between python feature

Re: append to non-existing list

2005-11-10 Thread Steven D'Aprano
On Wed, 09 Nov 2005 20:45:52 +0100, bruno at modulix wrote: If the array does not exist yet, it's created. Which is what I don't like. It should crash. Perhaps not *crash* as such. Raise an exception perhaps. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list

Re: append to non-existing list

2005-11-10 Thread Mike Meyer
Yves Glodt [EMAIL PROTECTED] writes: Which raises another question... :-) Is there a possibility to bring together apache and python in a way that I can embed python into html? Lots of ways. Most of them aren't really Python, but look a lot like it. PSP is most like PHP/ASP/etc., and I

append to non-existing list

2005-11-09 Thread Yves Glodt
...?!? My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves -- http://mail.python.org/mailman/listinfo

Re: append to non-existing list

2005-11-09 Thread dcrespo
Hi I think there's no way to append to a non existing list. Sorry about my question, but the English is my second language, and I don't know what is the meaning of IHMO (or IMHO). I googled and found that it means In My Humbled Opinion, is that true? Thanks and accept my appologies

Re: append to non-existing list

2005-11-09 Thread [EMAIL PROTECTED]
to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves -- http://mail.python.org/mailman/listinfo/python-list

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
the way python works...?!? My question is: Is there no way to append to a non existing list? how do you expect Python to figure out what kind of empty object you want ? /F -- http://mail.python.org/mailman/listinfo/python-list

Re: append to non-existing list

2005-11-09 Thread skip
Yves My question is: Is there no way to append to a non existing list? My question in return is: How is Python supposed to know that pkcolumns is supposed to be a list instead of some other type of object that happens to define an append() method? For example, my code might contain

Re: append to non-existing list

2005-11-09 Thread Juho Schultz
normal as it's the way python works...?!? My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves

Re: append to non-existing list

2005-11-09 Thread [EMAIL PROTECTED]
If PHP is heavily influenced by Perl(as I read some where), the variable name determine it I believe. @myvar is an array ? [EMAIL PROTECTED] wrote: I don't know php, but would also have to wonder how it knows to create a list instead of an integer (for example). Skip --

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
[EMAIL PROTECTED] wrote: Yves My question is: Is there no way to append to a non existing list? My question in return is: How is Python supposed to know that pkcolumns is supposed to be a list instead of some other type of object that happens to define an append() method? I am fairly

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
by the amount of answers that my question rose, in so little time! thanks all! There is a lot I don't like about python but if you have to use it, you have to cope with it. Yves Glodt wrote: My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
guess that's normal as it's the way python works...?!? My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards

Re: append to non-existing list

2005-11-09 Thread bruno at modulix
that's normal as it's the way python works...?!? yes sir. My question is: Is there no way to append to a non existing list? No. Definitively. And that's a Good Thing(tm). How would you use something that doesn't exist ??? I am lazy for declaring it first, s/declaring/instantiating/ If you were

Re: append to non-existing list

2005-11-09 Thread [EMAIL PROTECTED]
Juho Schultz wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in

Re: append to non-existing list

2005-11-09 Thread Thomas Bellman
Yves Glodt [EMAIL PROTECTED] writes: I guess that's normal as it's the way python works...?!? Yes, that's the way Python works. My question is: Is there no way to append to a non existing list? The next time you go shopping at your local super-market, do *not* get a shopping-cart

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
I guess that's normal as it's the way python works...?!? yes sir. My question is: Is there no way to append to a non existing list? No. Definitively. And that's a Good Thing(tm). How would you use something that doesn't exist ??? I am lazy for declaring it first, s/declaring

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
[EMAIL PROTECTED] wrote: Thomas Bellman wrote: The next time you go shopping at your local super-market, do *not* get a shopping-cart (or shopping-basket, or any similar container). As you pick up the things you want to buy, try to put them into the non-existing cart. Perhaps you will then

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
Yves Glodt wrote: I am fairly new to python (and I like it more and more), but I can not answer this question... As I said, where I come from it is possible, and how they do it is explained a little here: http://lu.php.net/manual/en/language.types.type-juggling.php but that page doesn't

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
Max M wrote: Yves Glodt wrote: bruno at modulix wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable

Re: append to non-existing list

2005-11-09 Thread Max M
Yves Glodt wrote: bruno at modulix wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums'

Re: append to non-existing list

2005-11-09 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: x = 10 + 20 # should this be 30 or 1020 or 1020 or ...? I think Perl handles this case pretty well and sane. In fact, this strict but dynamic type checking is quite painful to work with, especially the new decimal class. I can do a : decimal + int but not decimal +

Re: append to non-existing list

2005-11-09 Thread Roy Smith
Yves Glodt [EMAIL PROTECTED] wrote: My question is: Is there no way to append to a non existing list? Nope. The problem (well, part of the problem, anyway) is that when you do: foo.append (bar) what's happening is you're calling foo's append method. If foo doesn't already exist, it has

Re: append to non-existing list

2005-11-09 Thread Roy Smith
In article [EMAIL PROTECTED], Yves Glodt [EMAIL PROTECTED] wrote: You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in sqlsth] I will look into this, maybe it's what I need, thanks! The list

Re: append to non-existing list

2005-11-09 Thread Steven D'Aprano
On Wed, 09 Nov 2005 13:46:52 +0100, Yves Glodt wrote: My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing

Re: append to non-existing list

2005-11-09 Thread Mike Meyer
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Fredrik Lundh wrote: x = 10 + 20 # should this be 30 or 1020 or 1020 or ...? I think Perl handles this case pretty well and sane. In fact, this strict but dynamic type checking is quite painful to work with, especially the new decimal class.

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
Mike Meyer wrote: Float doesn't handle implicit conversion to anything but but builtin types. In particular, it doesn't check to see if the object beinng added has a __float__ method, and invoke that to do the conversion if it does. that's because __float__ is there to let you control what

Re: append to non-existing list

2005-11-09 Thread bruno at modulix
Yves Glodt wrote: (snip) ok I see your point, and python's... (just FYI, and not to start a flamewar ;-): In php, the [] means append to an array object. yes, I know this. If the array does not exist yet, it's created. Which is what I don't like. It should crash. [] *is* explicit for

Re: append to non-existing list

2005-11-09 Thread Mike Meyer
Fredrik Lundh [EMAIL PROTECTED] writes: Mike Meyer wrote: Float doesn't handle implicit conversion to anything but but builtin types. In particular, it doesn't check to see if the object beinng added has a __float__ method, and invoke that to do the conversion if it does. that's because

Re: append to non-existing list

2005-11-09 Thread James Stroud
On Wednesday 09 November 2005 07:00, Yves Glodt wrote: I will never mention any p-language except python in this list anymore... +1 QOTW -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ --