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

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 [EMAIL PROTECTED]
Yves Glodt wrote: > I need this (invalid example-html follows): > > > title of page > > > import time > > print "Hello, today is: %s" % (time.ctime()) > > ?> > > Cheetah template ? But I like Kid better as I don't want python in HTML, Kid IMO strikes the balance between python feature and XHTM

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): title of page Hello, today is: %s

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 -- http://ma

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 an

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

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/ -- http://mail.python.org/mai

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

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* expli

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 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

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 it... Bu

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, than

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 n

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 deci

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: >>> U

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 thi

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 d

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 wi

Re: append to non-existing list

2005-11-09 Thread [EMAIL PROTECTED]
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 > become enlightened.

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
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 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 (or shop

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 = [ro

Re: append to non-existing list

2005-11-09 Thread bruno at modulix
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' referenced before assignment > >

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
Juho Schultz 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' ref

Re: append to non-existing list

2005-11-09 Thread Yves Glodt
[EMAIL PROTECTED] wrote: > I am afraid you have to either go back to php or whatever programming > language that fits your style or change your style to fit python. sorry for offending... I just asked a question, and now I know one more thing about python... And btw I really am surprised by the

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 fair

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 -- http://mail.python.

Re: append to non-existing list

2005-11-09 Thread Juho Schultz
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' referenced before assignment > >

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 this cla

Re: append to non-existing list

2005-11-09 Thread Fredrik Lundh
Yves Glodt wrote: > 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' referenced before assignment > > I guess that's normal

Re: append to non-existing list

2005-11-09 Thread [EMAIL PROTECTED]
I am afraid you have to either go back to php or whatever programming language that fits your style or change your style to fit python. 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

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 for not talk

append to non-existing list

2005-11-09 Thread Yves Glodt
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' referenced before assignment I guess that's normal as it's the way python works..