WinXP, Python3.1.2, dir-listing to XML - problem with unicode file names

2010-04-03 Thread kai_nerda
Hi,

OS = Windows XP (German language)
Python = 3.1.2

I need to write a directory listing into a XML file.
And after hours of trying and searching i have no clue.

My main problem is that the file and folder names can
have characters of different languages like
German, Turkish, Russian, maybe else.

Because Python 3.1 is better with unicode, I
decided to use that instead of 2.6

For testing I have created the following files:
http://img340.imageshack.us/img340/3461/files.png
(google for the words
russia, turkish, deutsch, france
to find websites with special characters and copy & paste)

And this is the code I have now:

# -*- coding: iso-8859-1 -*-
# inspired by:
# http://www.dpawson.co.uk/java/dirlist.py
# (for Python ~2.4)

import sys
print ('filesystemencoding: ' + sys.getfilesystemencoding())
print ('defaultencoding:' + sys.getdefaultencoding())


from pprint import pprint
import os.path
from stat import *
from xml.sax.saxutils import XMLGenerator

def recurse_dir(path, writer):
for cdir, subdirs, files in os.walk(path):
pprint (cdir)
writer.startElement('dir', { 'name': cdir })
for f in files:
uf = f.encode('utf-8')
pprint (uf)
attribs = {'name': f}
attribs['size'] = str(os.stat(os.path.join(cdir,f))[ST_SIZE])
pprint (attribs)
writer.startElement('file', attribs)
writer.endElement('file')
for subdir in subdirs: 
recurse_dir(os.path.join(cdir, subdir), writer)
writer.endElement('directory')
break

if __name__ == '__main__':
directory = 'c:\\_TEST\\'
out = open('C:\\_TEST.xml','w')

writer = XMLGenerator(out, 'utf-8')
writer.startDocument()
recurse_dir(directory, writer)

out.close()


And this is the output:
-
filesystemencoding: mbcs
defaultencoding:utf-8
'c:\\_TEST\\'
b'1 English.txt'
{'name': '1 English.txt', 'size': '0'}
b'2 German \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f.txt'
{'name': '2 German äöüß.txt', 'size': '0'}
b'3 France \xc3\xa1\xc3\xa0\xc3\xa2\xc3\xba\xc3\xb9\xc3\xbb.txt'
{'name': '3 France áàâúùû.txt', 'size': '0'}
b'4 Russia 
\xd0\xa0\xd0\xbe\xd1\x81\xd1\x81\xd1\x96\xd0\xb9\xd1\x81\xd0\xba\xd0\xb0\xd1\x8f
 \xd0\x98\xd0\xbc\xd0\xbf\xd0\xb5\xd1\x80\xd1\x96\xd1\x8f.txt'
Traceback (most recent call last):
  File "test.py", line 36, in 
recurse_dir(directory, writer)
  File "test.py", line 22, in recurse_dir
pprint (attribs)
  File "F:\Dev\Python31\lib\pprint.py", line 55, in pprint
printer.pprint(object)
  File "F:\Dev\Python31\lib\pprint.py", line 132, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
  File "F:\Dev\Python31\lib\pprint.py", line 238, in _format
write(rep)
  File "F:\Dev\Python31\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 19-28: 
character maps to 
-

I also tried the line:
attribs = {'name': uf}
with this result:
-
filesystemencoding: mbcs
defaultencoding:utf-8
'c:\\_TEST\\'
b'1 English.txt'
{'name': b'1 English.txt', 'size': '0'}
Traceback (most recent call last):
  File "test.py", line 36, in 
recurse_dir(directory, writer)
  File "test.py", line 23, in recurse_dir
writer.startElement('file', attribs)
  File "F:\Dev\Python31\lib\xml\sax\saxutils.py", line 127, in startElement
self._write(' %s=%s' % (name, quoteattr(value)))
  File "F:\Dev\Python31\lib\xml\sax\saxutils.py", line 68, in quoteattr
data = escape(data, entities)
  File "F:\Dev\Python31\lib\xml\sax\saxutils.py", line 34, in escape
data = data.replace("&", "&")
TypeError: expected an object with the buffer interface
-
Maybe this 'data = data.replace("&", "&")' in saxutils is wrong?
Maybe there should be a version for "byte datatype"?


Thank you!


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string

2010-04-03 Thread Peter Otten
Patrick Maupin wrote:

> On Apr 2, 4:32 pm, Peter Otten <__pete...@web.de> wrote:
> 
>> _split = re.compile(r"(\d+)").split
>> def split(s):
>> if not s:
>> return ()
>> parts = _split(s)
>> parts[1::2] = map(int, parts[1::2])

   # because s is non-empty parts contains at least one
   # item != "", and parts[x] below cannot fail with an
   # IndexError
>> if parts[-1] == "":
>> del parts[-1]
>> if parts[0] == "":
>> del parts[0]
>> return tuple(parts)
>>
> 
> That's certainly faster than a list comprehension (at least on long
> lists), but it might be a little obscure why the "if not s:" is
> needed, 

The function is small; with a test suite covering the corner cases and 
perhaps a comment* nothing should go wrong.

(*) you can certainly improve on my attempt

> so unless Thomas has a really long result list, he might want
> to just keep the list comprehension, which is (IMO) very readable.

Generally speaking performing tests of which you know they can't fail can 
confuse the reader just as much as tests with unobvious interdependencies.

> Alternatively, this is halfway between the previous example and the
> list comprehension:
> 
> _split = re.compile(r"(\d+)").split
> def split(s):
> parts = _split(s)
> parts[1::2] = map(int, parts[1::2])
> for index in (-1, 0):
> if parts and parts[index] == "":
> del parts[index]
> return tuple(parts)

I don't think that this is similar to the list comprehension approach 
because it only tests the first and the last item instead of the whole list.
Both variants should therefore perform equally well for all but the empty 
string argument. If that is a theoretical case you are free to choose the 
more readable variant.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to run python without python

2010-04-03 Thread Lie Ryan
On 04/03/10 06:24, John Bokma wrote:
>>
>> you think virtualbox could help? i wonder if one could run linux/
>> py2exe virtually on a win machine and get it working.
> 
> Of course that works, a virtual windows machine is just a windows
> machine ;-).
> 
> Also that you can't do a "cross compilation" sounds to me more a
> limitation of the tool than a true impossibility.

Much like me writing French...

-- 
http://mail.python.org/mailman/listinfo/python-list


Incorrect scope of list comprehension variables

2010-04-03 Thread Alain Ketterlin

Hi all,

I've just spent a few hours debugging code similar to this:

d = dict()
for r in [1,2,3]:
d[r] = [r for r in [4,5,6]]
print d

THe problem is that the "r" in d[r] somehow captures the value of the
"r" in the list comprehension, and somehow kills the loop interator. The
(unexpected) result is {6: [4, 5, 6]}. Changing r to s inside the list
leads to the correct (imo) result.

Is this expected? Is this a known problem? Is it solved in newer
versions?

This is python 2.6.4, on a stock ubuntu 9.10 x86-64 linux box. Let me
know if more detail is needed. Thanks in advance.

-- Alain.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Incorrect scope of list comprehension variables

2010-04-03 Thread Chris Rebert
On Sat, Apr 3, 2010 at 3:30 AM, Alain Ketterlin
 wrote:
> I've just spent a few hours debugging code similar to this:
>
> d = dict()
> for r in [1,2,3]:
>    d[r] = [r for r in [4,5,6]]
> print d
>
> THe problem is that the "r" in d[r] somehow captures the value of the
> "r" in the list comprehension, and somehow kills the loop interator. The
> (unexpected) result is {6: [4, 5, 6]}. Changing r to s inside the list
> leads to the correct (imo) result.
>
> Is this expected? Is this a known problem? Is it solved in newer
> versions?

Quoting http://docs.python.org/reference/expressions.html#id19 :

Footnotes
[1] In Python 2.3 and later releases, a list comprehension “leaks” the
control variables of each 'for' it contains into the containing scope.
However, this behavior is deprecated, and relying on it will not work
in Python 3.0

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Incorrect scope of list comprehension variables

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 12:30:32 +0200, Alain Ketterlin wrote:

> Hi all,
> 
> I've just spent a few hours debugging code similar to this:
> 
> d = dict()
> for r in [1,2,3]:
> d[r] = [r for r in [4,5,6]]
> print d

This isn't directly relevant to your problem, but why use a list 
comprehension in the first place? [r for r in [4,5,6]] is just [4,5,6], 
only slower.

I presume that is just a stand-in for a more useful list comp, but I 
mention it because I have seen people do exactly that, in real code, 
without knowing any better. (I may have even done so myself, once or 
twice.)


> THe problem is that the "r" in d[r] somehow captures the value of the
> "r" in the list comprehension, and somehow kills the loop interator. The
> (unexpected) result is {6: [4, 5, 6]}.

Actually, no it doesn't kill the loop at all. You have misinterpreted 
what you have seen:

>>> d = dict()
>>> for r in [1,2,3]:
... print r
... d[r] = [r for r in [4,5,6]]
... print d
...
1
{6: [4, 5, 6]}
2
{6: [4, 5, 6]}
3
{6: [4, 5, 6]}

 

> Changing r to s inside the list
> leads to the correct (imo) result.
> 
> Is this expected? Is this a known problem? Is it solved in newer
> versions?

Yes, yes and yes.

It is expected, because list comprehensions leak the variable into the 
enclosing scope. Yes, it is a problem, as you have found, although 
frankly it is easy enough to make sure your list comp variable has a 
unique name. And yes, it is fixed in Python 3.1.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to run python without python

2010-04-03 Thread David Cournapeau
On Sat, Apr 3, 2010 at 2:23 AM, Chris Rebert  wrote:
> On Fri, Apr 2, 2010 at 10:09 AM, danmcle...@yahoo.com
>  wrote:
>> On Apr 1, 5:54 pm, Chris Rebert  wrote:
>>> On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund
>>>  wrote:
>>> > On Fri, Apr 2, 2010 at 1:36 AM, Spencer  wrote:
>>> >> Is there a way to developing a script on linux and give it
>>> >> to someone on microsoft, so that they could run it on microsoft
>>> >> without installing python?
> 
>>> one can't generate such a standalone executable for a different
>>> operating system from that which one's computer runs.
>>
>> that's not entirely true. i just built a standalone exe for win 7 from
>> my win xp machine.
>
> s/operating system/platform
>
> Good luck getting PyInstaller to output for Windows when being run on
> a *nix box.

Doesn't py2exe works under wine ? I have had great success building
windows installers on linux through wine (although not with py2exe),

cheers,

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo

Patrick Maupin ha scritto:

On Apr 2, 2:41 pm, Andreas Waldenburger 
wrote:


While everyone else is mocking you: Can you please elaborate on why you
want to know and what kind of problem you're trying to solve with this?
Also, don't you think you should have picked a maths forum for this
kind of question?


Methinks the OP is fluent in the way of choosing newsgroups.
According to google, he has posted 6855 messages in 213 groups.

http://groups.google.com/groups/profile?enc_user=ul3SQhIYmLD0Oj5Yxp-liP3Vw9uApbyajUBv9M9XLUB2gqkZmQ

And I can't speak for anybody else, but I just assumed it was an April
Fool's question.  I meant to be laughing with the OP, not at him, so
sorry if I misunderstood.


no no you understood prfectly *but* the thing is i am a regular in an 
italian language math ng which is haunted by a crackpot who insists that 
1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger", 
so i took a semi-serious stance and made a few posts as a statistical 
tentative to "convince" said crackpot that the world is not going crazy 
(but maybe he is)


thanks

ps: note that my nickname is not unique, and there are a few people 
whith the same one... and i didn't ever post using googlegroups

--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Steve Holden
superpollo wrote:
> Patrick Maupin ha scritto:
>> On Apr 2, 2:41 pm, Andreas Waldenburger 
>> wrote:
>>
>>> While everyone else is mocking you: Can you please elaborate on why you
>>> want to know and what kind of problem you're trying to solve with this?
>>> Also, don't you think you should have picked a maths forum for this
>>> kind of question?
>>
>> Methinks the OP is fluent in the way of choosing newsgroups.
>> According to google, he has posted 6855 messages in 213 groups.
>>
>> http://groups.google.com/groups/profile?enc_user=ul3SQhIYmLD0Oj5Yxp-liP3Vw9uApbyajUBv9M9XLUB2gqkZmQ
>>
>>
>> And I can't speak for anybody else, but I just assumed it was an April
>> Fool's question.  I meant to be laughing with the OP, not at him, so
>> sorry if I misunderstood.
> 
> no no you understood prfectly *but* the thing is i am a regular in an
> italian language math ng which is haunted by a crackpot who insists that
> 1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
> so i took a semi-serious stance and made a few posts as a statistical
> tentative to "convince" said crackpot that the world is not going crazy
> (but maybe he is)
> 
> thanks
> 
> ps: note that my nickname is not unique, and there are a few people
> whith the same one... and i didn't ever post using googlegroups

If you think you will persuade a crackpot to drop his lunacy by logical
argument you are clearly an optimist of the first water. But since I
like a challenge (and bearing in mind this is OT so I don't claim to be
an expert) you might try first of all persuading him to agree to the
commutativity of multiplication (i.e. x * y == y * x for any x and y).

If he agrees to that, then get him to agree that x * 1 == x for any x.

If he agrees to that, then set x = 1/2 and see if he'll agree that 1/2 *
1 == 1/2.

If he does, then surely he must also agree that 1 * 1/2 == 1/2, i.e.
multiplication can indeed "make things smaller".

Good luck, though. Crackpots aren't generally responsive to appeals to
rational thinking.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Mensanator
On Apr 3, 8:00 am, superpollo  wrote:
> Patrick Maupin ha scritto:
>
>
>
>
>
> > On Apr 2, 2:41 pm, Andreas Waldenburger 
> > wrote:
>
> >> While everyone else is mocking you: Can you please elaborate on why you
> >> want to know and what kind of problem you're trying to solve with this?
> >> Also, don't you think you should have picked a maths forum for this
> >> kind of question?
>
> > Methinks the OP is fluent in the way of choosing newsgroups.
> > According to google, he has posted 6855 messages in 213 groups.
>
> >http://groups.google.com/groups/profile?enc_user=ul3SQhIYmLD0Oj5Y...
>
> > And I can't speak for anybody else, but I just assumed it was an April
> > Fool's question.  I meant to be laughing with the OP, not at him, so
> > sorry if I misunderstood.
>
> no no you understood prfectly *but* the thing is i am a regular in an
> italian language math ng which is haunted by a crackpot who insists that
> 1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
> so i took a semi-serious stance and made a few posts as a statistical
> tentative to "convince" said crackpot that the world is not going crazy
> (but maybe he is)

I seriously doubt your crackpot friend actually believes that.
Probably more troll than crackpot. Showing him articles and
programs that prove your premise will accomplish nothing.

However, if you personally wanted information on programming
with rational numbers, you came to the right place.

>
> thanks
>
> ps: note that my nickname is not unique, and there are a few people
> whith the same one... and i didn't ever post using googlegroups

What does it mean, "super chicken?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo

Steve Holden ha scritto:

superpollo wrote:

Patrick Maupin ha scritto:

On Apr 2, 2:41 pm, Andreas Waldenburger 
wrote:


While everyone else is mocking you: Can you please elaborate on why you
want to know and what kind of problem you're trying to solve with this?
Also, don't you think you should have picked a maths forum for this
kind of question?

Methinks the OP is fluent in the way of choosing newsgroups.
According to google, he has posted 6855 messages in 213 groups.

http://groups.google.com/groups/profile?enc_user=ul3SQhIYmLD0Oj5Yxp-liP3Vw9uApbyajUBv9M9XLUB2gqkZmQ


And I can't speak for anybody else, but I just assumed it was an April
Fool's question.  I meant to be laughing with the OP, not at him, so
sorry if I misunderstood.

no no you understood prfectly *but* the thing is i am a regular in an
italian language math ng which is haunted by a crackpot who insists that
1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
so i took a semi-serious stance and made a few posts as a statistical
tentative to "convince" said crackpot that the world is not going crazy
(but maybe he is)

thanks

ps: note that my nickname is not unique, and there are a few people
whith the same one... and i didn't ever post using googlegroups


If you think you will persuade a crackpot to drop his lunacy by logical
argument you are clearly an optimist of the first water. But since I
like a challenge (and bearing in mind this is OT so I don't claim to be
an expert) you might try first of all persuading him to agree to the
commutativity of multiplication (i.e. x * y == y * x for any x and y).

If he agrees to that, then get him to agree that x * 1 == x for any x.

If he agrees to that


he does not, since "you cannot multiply something, and not getting some 
more of it" ... he is stuck with the latin etimology of "multiply" 
("multiplicare" means "increase quantity", like in the fish and bread 
miracle)


--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo

Mensanator ha scritto:

On Apr 3, 8:00 am, superpollo  wrote:

Patrick Maupin ha scritto:






On Apr 2, 2:41 pm, Andreas Waldenburger 
wrote:

While everyone else is mocking you: Can you please elaborate on why you
want to know and what kind of problem you're trying to solve with this?
Also, don't you think you should have picked a maths forum for this
kind of question?

Methinks the OP is fluent in the way of choosing newsgroups.
According to google, he has posted 6855 messages in 213 groups.
http://groups.google.com/groups/profile?enc_user=ul3SQhIYmLD0Oj5Y...
And I can't speak for anybody else, but I just assumed it was an April
Fool's question.  I meant to be laughing with the OP, not at him, so
sorry if I misunderstood.

no no you understood prfectly *but* the thing is i am a regular in an
italian language math ng which is haunted by a crackpot who insists that
1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
so i took a semi-serious stance and made a few posts as a statistical
tentative to "convince" said crackpot that the world is not going crazy
(but maybe he is)


I seriously doubt your crackpot friend actually believes that.
Probably more troll than crackpot. Showing him articles and
programs that prove your premise will accomplish nothing.


probably so, but you cannot imagine the traffic he generates...


However, if you personally wanted information on programming
with rational numbers, you came to the right place.


thanks

ps: note that my nickname is not unique, and there are a few people
whith the same one... and i didn't ever post using googlegroups


What does it mean, "super chicken?


yea!

http://www.renegadechickens.com/chickens/Toons/superchicken.gif
--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Steve Holden
superpollo wrote:
> Steve Holden ha scritto:
[...]
>> If he agrees to that, then get him to agree that x * 1 == x for any x.
>>
>> If he agrees to that
> 
> he does not, since "you cannot multiply something, and not getting some
> more of it" ... he is stuck with the latin etimology of "multiply"
> ("multiplicare" means "increase quantity", like in the fish and bread
> miracle)
> 
Ah, so he's talking semantics, not mathematics. Absolutely no point
expecting agreement on a common sense basis, then. Particularly when he
takes such a narrow-minded view.

In short, he has his head up his ass.

Would he agree that two halves make a whole? If so, he appears to deny
the commutativity of multiplication. Such people are amusing for the
first ten minutes, but I am sure he has managed to bore everyone to
death by now.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Martin P. Hellwig

On 04/03/10 14:38, Steve Holden wrote:



If you think you will persuade a crackpot to drop his lunacy by logical
argument you are clearly an optimist of the first water. But since I
like a challenge (and bearing in mind this is OT so I don't claim to be
an expert) you might try first of all persuading him to agree to the
commutativity of multiplication (i.e. x * y == y * x for any x and y).

If he agrees to that, then get him to agree that x * 1 == x for any x.

If he agrees to that, then set x = 1/2 and see if he'll agree that 1/2 *
1 == 1/2.

If he does, then surely he must also agree that 1 * 1/2 == 1/2, i.e.
multiplication can indeed "make things smaller".

Good luck, though. Crackpots aren't generally responsive to appeals to
rational thinking.



I am replying to this post not because I disagree but because it 
postalogically  fits the best (I am by no means an expert either).


IMHO, the crackpot in this regard is actually partially right, 
multiplication does mean that the number must get bigger, however for 
fractions you multiply four numbers, two numerators and two 
denominators. The resulting numerator and denominator by this 
multiplication get indeed bigger.


--
mph

--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Matthew Barnett

superpollo wrote:

Steve Holden ha scritto:

superpollo wrote:

Patrick Maupin ha scritto:

On Apr 2, 2:41 pm, Andreas Waldenburger 
wrote:

While everyone else is mocking you: Can you please elaborate on why 
you
want to know and what kind of problem you're trying to solve with 
this?

Also, don't you think you should have picked a maths forum for this
kind of question?

Methinks the OP is fluent in the way of choosing newsgroups.
According to google, he has posted 6855 messages in 213 groups.

http://groups.google.com/groups/profile?enc_user=ul3SQhIYmLD0Oj5Yxp-liP3Vw9uApbyajUBv9M9XLUB2gqkZmQ 




And I can't speak for anybody else, but I just assumed it was an April
Fool's question.  I meant to be laughing with the OP, not at him, so
sorry if I misunderstood.

no no you understood prfectly *but* the thing is i am a regular in an
italian language math ng which is haunted by a crackpot who insists that
1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
so i took a semi-serious stance and made a few posts as a statistical
tentative to "convince" said crackpot that the world is not going crazy
(but maybe he is)

thanks

ps: note that my nickname is not unique, and there are a few people
whith the same one... and i didn't ever post using googlegroups


If you think you will persuade a crackpot to drop his lunacy by logical
argument you are clearly an optimist of the first water. But since I
like a challenge (and bearing in mind this is OT so I don't claim to be
an expert) you might try first of all persuading him to agree to the
commutativity of multiplication (i.e. x * y == y * x for any x and y).

If he agrees to that, then get him to agree that x * 1 == x for any x.

If he agrees to that


he does not, since "you cannot multiply something, and not getting some 
more of it" ... he is stuck with the latin etimology of "multiply" 
("multiplicare" means "increase quantity", like in the fish and bread 
miracle)



Do he also think that division always makes it smaller? What about
division by a half?
--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:

> I am replying to this post not because I disagree but because it
> postalogically  fits the best (I am by no means an expert either).
> 
> IMHO, the crackpot in this regard is actually partially right,
> multiplication does mean that the number must get bigger, however for
> fractions you multiply four numbers, two numerators and two
> denominators. The resulting numerator and denominator by this
> multiplication get indeed bigger.

But you're not multiplying four numbers, you're multiplying two numbers. 
One-half is not "two numbers", that would be a tuple or a list or 
possibly a coordinate pair. One-half is a single number, the number which 
if you double it gives one.

Fortunately multiplication is consistent. Multiplying the two numbers 0.5 
and 0.5 is exactly the same as multiplying 1*1 and 2*2 then dividing to 
get a single number. It's not the same as multiplying 1*1 and 2*2 to get 
two numbers, 1 and 4.

You say that multiplication means that the number "must get bigger". 

5*1 = 5
5*0 = 0
5*-2 = -10

I hope you won't try to argue that 5, 0 and -10 are all bigger than 5.

There really is no point trying to dignify superpollo's friend's 
assertion on the basis of some technicality. His argument is no different 
from the argument that says that pythons are snakes, and therefore python 
can't be a programming language and this newsgroup can't possibly exist. 
Words can have multiple meanings, and meanings can shift. Multiply may be 
derived from a word which, once upon a time, meant to get bigger, but 
that's not what multiply means. I don't like to dismiss somebody I've 
never met, but on the basis of what superpollo says, yes, he's a crackpot.

Either that or about age four. When I was four I strongly believed that 
"one hundred" and "a hundred" were different numbers. I argued (not very 
convincingly, but with great vehemence) to my teacher and my parents that 
you counted up to ninety-nine, then a hundred, a hundred and one, a 
hundred and two, ... a hundred and ninety-nine, *one* hundred.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Patrick Maupin
On Apr 3, 9:43 am, "Martin P. Hellwig" > IMHO, the crackpot in this
regard is actually partially right,
> multiplication does mean that the number must get bigger, however for
> fractions you multiply four numbers, two numerators and two
> denominators. The resulting numerator and denominator by this
> multiplication get indeed bigger.

That argument is great!  Just make sure that you've managed to leave
before the class has to learn about irrational numbers that don't
*have* numerators and denominators ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Patrick Maupin
On Apr 3, 8:00 am, superpollo  wrote:
> > sorry if I misunderstood.
>
> no no you understood prfectly *but* the thing is i am a regular in an
> italian language math ng which is haunted by a crackpot who insists that
> 1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
> so i took a semi-serious stance and made a few posts as a statistical
> tentative to "convince" said crackpot that the world is not going crazy
> (but maybe he is)

If I read correctly (using my non-existent Italian, and heavily
relying on my tiny bit of Spanish and a lot of google translate), it
appears that you are what I would call a high-school math/science
teacher, who takes students to competitions?

Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread superpollo

Patrick Maupin ha scritto:

On Apr 3, 8:00 am, superpollo  wrote:

sorry if I misunderstood.

no no you understood prfectly *but* the thing is i am a regular in an
italian language math ng which is haunted by a crackpot who insists that
1/2 * 1/2 cannot be 1/4, "because multiplication means getting bigger",
so i took a semi-serious stance and made a few posts as a statistical
tentative to "convince" said crackpot that the world is not going crazy
(but maybe he is)


If I read correctly (using my non-existent Italian, and heavily
relying on my tiny bit of Spanish and a lot of google translate), it
appears that you are what I would call a high-school math/science
teacher, who takes students to competitions?


right -- almost! i don't take them to competitions (i am not an official 
trainer) but sometimes give some general advice to students who would be 
inclined to compete, if they ask me.


bye


--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Martin P. Hellwig

On 04/03/10 16:17, Steven D'Aprano wrote:

On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:


I am replying to this post not because I disagree but because it
postalogically  fits the best (I am by no means an expert either).

IMHO, the crackpot in this regard is actually partially right,
multiplication does mean that the number must get bigger, however for
fractions you multiply four numbers, two numerators and two
denominators. The resulting numerator and denominator by this
multiplication get indeed bigger.


But you're not multiplying four numbers, you're multiplying two numbers.
One-half is not "two numbers", that would be a tuple or a list or
possibly a coordinate pair. One-half is a single number, the number which
if you double it gives one.



I disagree with you there, but I only disagree with you on the 
definition of the syntax, not with the logic nor the explanation.
I am not going to argue about syntax, since I don't think I would make a 
great argument (being the devil's advocate) and also because I believe 
when argued correctly, agreeing on disagreement of syntax allows even 
the greatest untruth be true and false at the same time.


Excuse me please I need to feed Schroedinger's cat :-)

--
mph



--
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string

2010-04-03 Thread Patrick Maupin
On Apr 3, 4:17 am, Peter Otten <__pete...@web.de> wrote:
> Patrick Maupin wrote:
> > On Apr 2, 4:32 pm, Peter Otten <__pete...@web.de> wrote:
>
> >> _split = re.compile(r"(\d+)").split
> >> def split(s):
> >>     if not s:
> >>         return ()
> >>     parts = _split(s)
> >>     parts[1::2] = map(int, parts[1::2])
>
>        # because s is non-empty parts contains at least one
>        # item != "", and parts[x] below cannot fail with an
>        # IndexError
>
> >>     if parts[-1] == "":
> >>         del parts[-1]
> >>     if parts[0] == "":
> >>         del parts[0]
> >>     return tuple(parts)
>
> > That's certainly faster than a list comprehension (at least on long
> > lists), but it might be a little obscure why the "if not s:" is
> > needed,
>
> The function is small; with a test suite covering the corner cases and
> perhaps a comment* nothing should go wrong.
>
> (*) you can certainly improve on my attempt
>
> > so unless Thomas has a really long result list, he might want
> > to just keep the list comprehension, which is (IMO) very readable.
>
> Generally speaking performing tests of which you know they can't fail can
> confuse the reader just as much as tests with unobvious interdependencies.

Yes, I see your point.  The list comprehension will only treat the
ends differently, and will always pass the middle, so someone could be
confused about why the comprehension is there in the first place.  I
guess I'm used to doing this same thing on lists that *could* have
empty strings in the middle (with more complicated regular expressions
with multiple match cases), so I didn't consider that.

> > Alternatively, this is halfway between the previous example and the
> > list comprehension:
>
> > _split = re.compile(r"(\d+)").split
> > def split(s):
> >     parts = _split(s)
> >     parts[1::2] = map(int, parts[1::2])
> >     for index in (-1, 0):
> >         if parts and parts[index] == "":
> >             del parts[index]
> >     return tuple(parts)
>
> I don't think that this is similar to the list comprehension approach
> because it only tests the first and the last item instead of the whole list.
> Both variants should therefore perform equally well for all but the empty
> string argument. If that is a theoretical case you are free to choose the
> more readable variant.

I agree that "halfway" was not a very precise way of describing the
differences.  Like your solution, this only tests the outer elements.
Like the list comprehension, no short-circuit test before doing the
re.split is required.  Also like the list comprehension, the act of
doing the same operation on multiple elements is refactored such that
operation is only coded once.

BUT...

All of this is just a user preference, and is extremely minor compared
to the observation that re.split() and extended string slicing can be
combined to give a very elegant solution to the problem!

Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list


passing command line arguments to executable

2010-04-03 Thread mcanjo
I have an executable (I don't have access to the source code) that
processes some data. I double click on the icon and a Command prompt
window pops up. The program asks me for the input file, I hit enter,
and then it asks me for and output filename, I hit enter a second time
and it goes off and does its thing and when it is finished running the
Command Prompt goes away and I have my new output file in the same
directory as my executable and input file. I would like to be able to
batch process a group of files. I thought about using "os.spawnv()" in
a loop and at each iteration of the loop passing in the file in and
out names but that didn't work. Does anyone have any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing command line arguments to executable

2010-04-03 Thread Patrick Maupin
On Apr 3, 11:09 am, mcanjo  wrote:
> I have an executable (I don't have access to the source code) that
> processes some data. I double click on the icon and a Command prompt
> window pops up. The program asks me for the input file, I hit enter,
> and then it asks me for and output filename, I hit enter a second time
> and it goes off and does its thing and when it is finished running the
> Command Prompt goes away and I have my new output file in the same
> directory as my executable and input file. I would like to be able to
> batch process a group of files. I thought about using "os.spawnv()" in
> a loop and at each iteration of the loop passing in the file in and
> out names but that didn't work. Does anyone have any ideas?

You need to look at the subprocess module, and use pipes.

Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing command line arguments to executable

2010-04-03 Thread Simon Brunning
On 3 April 2010 17:09, mcanjo  wrote:
> I have an executable (I don't have access to the source code) that
> processes some data. I double click on the icon and a Command prompt
> window pops up. The program asks me for the input file, I hit enter,
> and then it asks me for and output filename, I hit enter a second time
> and it goes off and does its thing and when it is finished running the
> Command Prompt goes away and I have my new output file in the same
> directory as my executable and input file. I would like to be able to
> batch process a group of files. I thought about using "os.spawnv()" in
> a loop and at each iteration of the loop passing in the file in and
> out names but that didn't work. Does anyone have any ideas?

Have a look at the subprocess module.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get a method instance through 'getattr' but not superclass's method

2010-04-03 Thread Radhakrishna Bhat
thanks. It is working for simple classes. But now i am trying for complex
objects.

myclassinstance.__class__.dict__ returns 

Looping through the same returned dictproxy gives attributes of superclass.
What am i doing wrong?


On Fri, Mar 12, 2010 at 12:15 AM, Gabriel Genellina
wrote:

> En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
>  escribió:
>
>
>  I am using getattr to get a method instance from a class. But it also
>> returns methods from the superclass. How to detect if an attribute is from
>> superclass?
>>
>
> You may look it up directly in the class dictionary (__dict__)
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Mensanator
On Apr 3, 10:17 am, Steven D'Aprano  wrote:
> On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:
> > I am replying to this post not because I disagree but because it
> > postalogically  fits the best (I am by no means an expert either).
>
> > IMHO, the crackpot in this regard is actually partially right,
> > multiplication does mean that the number must get bigger, however for
> > fractions you multiply four numbers, two numerators and two
> > denominators. The resulting numerator and denominator by this
> > multiplication get indeed bigger.
>
> But you're not multiplying four numbers,

You are if you're using Rationals.

> you're multiplying two numbers.

Because they're expressed as Decimals.

> One-half is not "two numbers",

Sometimes it is.

> that would be a tuple

Like this?

>>> gmpy.mpq('0.5')
mpq(1,2)


> or a list or
> possibly a coordinate pair. One-half is a single number,

When dealing with crackpots, it does not help to use the
wrong arguments. When multiplying gmpy.mpq(2,3) by gmpy.mpq(2,3),
the numerator and denominator have both indeed gotten bigger.
The trick is that when combined, the overall result is smaller.

> the number which
> if you double it gives one.
>
> Fortunately multiplication is consistent. Multiplying the two numbers 0.5
> and 0.5 is exactly the same as multiplying 1*1 and 2*2 then dividing to
> get a single number. It's not the same as multiplying 1*1 and 2*2 to get
> two numbers, 1 and 4.
>
> You say that multiplication means that the number "must get bigger".

Yes, not in every case, but in many cases it does. You need to point
out that it is wrong EVEN IN THE CASES WHERE IT'S TRUE. It is a
Non Sequitur - it does not follow that a number must be bigger if
the numerator and denominator have each gotten larger.

>
> 5*1 = 5
> 5*0 = 0
> 5*-2 = -10
>
> I hope you won't try to argue that 5, 0 and -10 are all bigger than 5.

Yes, but these special cases don't help. It needs to be pointed out
that the argument is wrong even in cases like 2/3 * 2/3.

>
> There really is no point trying to dignify superpollo's friend's
> assertion on the basis of some technicality. His argument is no different
> from the argument that says that pythons are snakes, and therefore python
> can't be a programming language and this newsgroup can't possibly exist.
> Words can have multiple meanings, and meanings can shift. Multiply may be
> derived from a word which, once upon a time, meant to get bigger, but
> that's not what multiply means. I don't like to dismiss somebody I've
> never met, but on the basis of what superpollo says, yes, he's a crackpot.
>
> Either that or about age four. When I was four I strongly believed that
> "one hundred" and "a hundred" were different numbers. I argued (not very
> convincingly, but with great vehemence) to my teacher and my parents that
> you counted up to ninety-nine, then a hundred, a hundred and one, a
> hundred and two, ... a hundred and ninety-nine, *one* hundred.
>
> --
> Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Emile van Sebille

On 4/3/2010 8:46 AM Patrick Maupin said...

On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
regard is actually partially right,

multiplication does mean that the number must get bigger, however for
fractions you multiply four numbers, two numerators and two
denominators. The resulting numerator and denominator by this
multiplication get indeed bigger.


That argument is great!  Just make sure that you've managed to leave
before the class has to learn about irrational numbers that don't
*have* numerators and denominators ;-)


Ahh, but no ones arguing that irrational numbers don't get bigger -- 
even before you multiply them!


Emile

--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Steve Holden
Mensanator wrote:
[...]
> When dealing with crackpots, it does not help to use the
> wrong arguments. [...]

Correct. Unfortunately, it doesn't help  to use the right ones either.
In fact, that could almost be a definition of "crackpot" (and alas now
we approach territory where we risk offending the religious, so I will
cease and desist).

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Patrick Maupin
On Apr 3, 11:59 am, Emile van Sebille  wrote:
> On 4/3/2010 8:46 AM Patrick Maupin said...
>
> > On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
> > regard is actually partially right,
> >> multiplication does mean that the number must get bigger, however for
> >> fractions you multiply four numbers, two numerators and two
> >> denominators. The resulting numerator and denominator by this
> >> multiplication get indeed bigger.
>
> > That argument is great!  Just make sure that you've managed to leave
> > before the class has to learn about irrational numbers that don't
> > *have* numerators and denominators ;-)
>
> Ahh, but no ones arguing that irrational numbers don't get bigger --
> even before you multiply them!

True, but being an optimist, just as (-1 * -1 == +1) (which
admittedly, I had a hard time trying to explain to my father years
ago), and just as (not not True == True) and just as multiplying two
imaginary numbers can have a real result, I was hoping that it would
also be the case that having a discussion with an irrational person
about irrational numbers could have a rational result.  Of course,
that hope was incredibly naive of me, since most operations with
irrational numbers which do not involve either closely related
irrational numbers or zero will also result in irrational numbers.  I
think induction will show that this property (that an irrational
number can make any result that it is involved in irrational) can also
be applied to irrational people and discussions.  ;-)

Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing command line arguments to executable

2010-04-03 Thread mcanjo
On Apr 3, 11:15 am, Patrick Maupin  wrote:
> On Apr 3, 11:09 am, mcanjo  wrote:
>
> > I have an executable (I don't have access to the source code) that
> > processes some data. I double click on the icon and a Command prompt
> > window pops up. The program asks me for the input file, I hit enter,
> > and then it asks me for and output filename, I hit enter a second time
> > and it goes off and does its thing and when it is finished running the
> > Command Prompt goes away and I have my new output file in the same
> > directory as my executable and input file. I would like to be able to
> > batch process a group of files. I thought about using "os.spawnv()" in
> > a loop and at each iteration of the loop passing in the file in and
> > out names but that didn't work. Does anyone have any ideas?
>
> You need to look at the subprocess module, and use pipes.
>
> Regards,
> Pat


I tried doing the following code:

from subprocess import Popen
from subprocess import PIPE, STDOUT
exefile = Popen('pmm.exe', stdout = PIPE, stdin = PIPE, stderr =
STDOUT)
exefile.communicate('MarchScreen.pmm\nMarchScreen.out')[0]

and the Command Prompt opened and closed, no exceptions were generated
but the program didn't run. Am I doing something wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing command line arguments to executable

2010-04-03 Thread Patrick Maupin
On Apr 3, 12:20 pm, mcanjo  wrote:
> On Apr 3, 11:15 am, Patrick Maupin  wrote:
>
>
>
> > On Apr 3, 11:09 am, mcanjo  wrote:
>
> > > I have an executable (I don't have access to the source code) that
> > > processes some data. I double click on the icon and a Command prompt
> > > window pops up. The program asks me for the input file, I hit enter,
> > > and then it asks me for and output filename, I hit enter a second time
> > > and it goes off and does its thing and when it is finished running the
> > > Command Prompt goes away and I have my new output file in the same
> > > directory as my executable and input file. I would like to be able to
> > > batch process a group of files. I thought about using "os.spawnv()" in
> > > a loop and at each iteration of the loop passing in the file in and
> > > out names but that didn't work. Does anyone have any ideas?
>
> > You need to look at the subprocess module, and use pipes.
>
> > Regards,
> > Pat
>
> I tried doing the following code:
>
> from subprocess import Popen
> from subprocess import PIPE, STDOUT
> exefile = Popen('pmm.exe', stdout = PIPE, stdin = PIPE, stderr =
> STDOUT)
> exefile.communicate('MarchScreen.pmm\nMarchScreen.out')[0]
>
> and the Command Prompt opened and closed, no exceptions were generated
> but the program didn't run. Am I doing something wrong?

I don't use communicate because I've never gotten it to do what I
want.  I also don't use Windows.  I have a linux solution that allows
me to feed stuf into a pipe, but I don't think it will work under
Windows because it uses os functions to block on empty pipes that
Windows doesn't support.

You might read PEP 3145 -- it addresses some of the issues, and there
is some code to help, I think:

http://www.python.org/dev/peps/pep-3145/

Regards,
Pat

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread MRAB

Patrick Maupin wrote:

On Apr 3, 11:59 am, Emile van Sebille  wrote:

On 4/3/2010 8:46 AM Patrick Maupin said...


On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
regard is actually partially right,

multiplication does mean that the number must get bigger, however for
fractions you multiply four numbers, two numerators and two
denominators. The resulting numerator and denominator by this
multiplication get indeed bigger.

That argument is great!  Just make sure that you've managed to leave
before the class has to learn about irrational numbers that don't
*have* numerators and denominators ;-)

Ahh, but no ones arguing that irrational numbers don't get bigger --
even before you multiply them!


True, but being an optimist, just as (-1 * -1 == +1) (which
admittedly, I had a hard time trying to explain to my father years
ago), and just as (not not True == True) and just as multiplying two
imaginary numbers can have a real result, I was hoping that it would
also be the case that having a discussion with an irrational person
about irrational numbers could have a rational result.  Of course,
that hope was incredibly naive of me, since most operations with
irrational numbers which do not involve either closely related
irrational numbers or zero will also result in irrational numbers.  I
think induction will show that this property (that an irrational
number can make any result that it is involved in irrational) can also
be applied to irrational people and discussions.  ;-)


The square root of 2 is irrational, but if you multiply it by itself
then the result isn't irrational, so not all operations involving
irrational numbers will result in an irrational result (unless that's
what you mean by "closely related irrational numbers").
--
http://mail.python.org/mailman/listinfo/python-list


Re: (a==b) ? 'Yes' : 'No'

2010-04-03 Thread John Bokma
Steve Howell  writes:

> In languages like Ruby/Perl the inverted if statement is also a useful
> idiom to emphasize concisely that code is exceptional in nature:
>
> def quotient(m, n)
>  # guard code
>  return None if n == 0
>
>  # happy path
>  return m / n
> end

Still, in Perl I prefer:

sub quotient {

my ( $m, $n ) = @_;
$n != 0 or return;

return $m / $n;
}

but I guess it depends a lot on what you're used to read.

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Patrick Maupin
On Apr 3, 12:39 pm, MRAB  wrote:
> Patrick Maupin wrote:
> > On Apr 3, 11:59 am, Emile van Sebille  wrote:
> >> On 4/3/2010 8:46 AM Patrick Maupin said...
>
> >>> On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
> >>> regard is actually partially right,
>  multiplication does mean that the number must get bigger, however for
>  fractions you multiply four numbers, two numerators and two
>  denominators. The resulting numerator and denominator by this
>  multiplication get indeed bigger.
> >>> That argument is great!  Just make sure that you've managed to leave
> >>> before the class has to learn about irrational numbers that don't
> >>> *have* numerators and denominators ;-)
> >> Ahh, but no ones arguing that irrational numbers don't get bigger --
> >> even before you multiply them!
>
> > True, but being an optimist, just as (-1 * -1 == +1) (which
> > admittedly, I had a hard time trying to explain to my father years
> > ago), and just as (not not True == True) and just as multiplying two
> > imaginary numbers can have a real result, I was hoping that it would
> > also be the case that having a discussion with an irrational person
> > about irrational numbers could have a rational result.  Of course,
> > that hope was incredibly naive of me, since most operations with
> > irrational numbers which do not involve either closely related
> > irrational numbers or zero will also result in irrational numbers.  I
> > think induction will show that this property (that an irrational
> > number can make any result that it is involved in irrational) can also
> > be applied to irrational people and discussions.  ;-)
>
> The square root of 2 is irrational, but if you multiply it by itself
> then the result isn't irrational, so not all operations involving
> irrational numbers will result in an irrational result (unless that's
> what you mean by "closely related irrational numbers").

Yes, I think I am closely related to myself.  But in addition to that
particular disclaimer, I qualified the statement with "most" and I
also mentioned that zero is special.  I stand by the assertion that if
you take a random assortment of non-zero numbers, some irrational,
some rational, and a random assortment of numeric operators, that most
operations involving an irrational number will have an irrational
result.

Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list


"JOBS IN CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA" "ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA" http://j

2010-04-03 Thread saima81
"JOBS IN CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS"
"ACCOUNTS JOBS IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN
CANADA" "ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNERS" "ACCOUNTS JOBS
IN CANADA" "FINANCE JOBS IN CANADA" MEDICAL JOBS IN CANADA"
"ENGINEERING JOBS IN CANADA" "SPORTS JOBS IN CANADA"
http://jobsincanada-net.blogspot.com/   "JOBS IN
CANADA" "CANADA JOBS" "JOBS IN CANADA FOR FOREIGNE

Re: off topic but please forgive me me and answer

2010-04-03 Thread Andreas Waldenburger
On Sat, 03 Apr 2010 13:13:38 -0400 Steve Holden 
wrote:

> Correct. Unfortunately, it doesn't help  to use the right ones either.
> In fact, that could almost be a definition of "crackpot" (and alas now
> we approach territory where we risk offending the religious, so I will
> cease and desist).

Except that you didn't. ;)

/W

-- 
INVALID? DE!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good Intermediate Tutorials

2010-04-03 Thread python
Pick an arbitrary point in time, and begin reading this mailing
list's archives. I guarantee you will learn alot.

Malcolm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C-style static variables in Python?

2010-04-03 Thread Stephen Hansen

On 2010-04-02 20:24:46 -0700, Patrick Maupin said:


On Apr 2, 10:11 pm, Stephen Hansen  wrote:


I don't know if properties are really faster or slower then a
__getattr__, but I find them a lot cleaner if I want to delay some
calculation until needed like that.


Well, the relative speed of properties vs. __getattr__ can become
irrelevant in at least two ways:

1) If the __getattr__ only calculates the value one time and then
stuffs it into the instance dictionary, now you are really comparing
the relative speed of properties vs. lookup of an attribute in the
instance dict.  If you're at all concerned about speed, I think there
is a clear winner here.


I concede it would probably be notably faster, but there's a big 
difference between "at all concerned about speed" and "optimizing a 
profiled bottleneck".


The speed difference between direct attribute lookup and properties may 
be notable, but that doesn't make a clear winner here. Now that I have 
(with either method) optimized the expensive value-calculation 
operation such that it only happens on-demand and once, I now have to 
weigh further optimization.


Is the difference in speed between a standard attribute lookup and a 
property fetch worth losing the clarity the property brings over the 
__getattr__ solution, especially considering the __getattr__ creates a 
fuzzy 'sometimes this code is responsible, othertimes the dict is' 
situation that someone may down the road miss in maintenance?


For me, usually not-- unless profiling pushes me to reconsider. But 
everyone makes these calls differently.



2) There is a single __getattr__ function, vs. one property for every
attribute that needs a property.  In cases where you can somehow
easily compute the attribute names as well as the attribute values,
__getattr__ can be a *lot* less code than defining dozens of
properties.


I don't really mind a lot of properties, if they're simple. Then again, 
I often prefer regular ol' attributes where possible :) However, if I'm 
doing a dispatching sort of mechanism, or a situation where the "name" 
isn't something static, set in stone or pre-defined-- then certainly, 
__getattr__ is a fine solution. I don't mind it where its the clearest 
way to accomplish a goal.


--
--S

... p.s: change the ".invalid" to ".com" in email address to reply privately.

--
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Martin P. Hellwig

On 04/03/10 16:46, Patrick Maupin wrote:

On Apr 3, 9:43 am, "Martin P. Hellwig">  IMHO, the crackpot in this
regard is actually partially right,

multiplication does mean that the number must get bigger, however for
fractions you multiply four numbers, two numerators and two
denominators. The resulting numerator and denominator by this
multiplication get indeed bigger.


That argument is great!  Just make sure that you've managed to leave
before the class has to learn about irrational numbers that don't
*have* numerators and denominators ;-)


Yeah but those numbers have their own problems anyway, one of them being 
that you are never sure how big/small they actually are, so by that 
logic you could argue that if you can not give an exact measure for a 
given number, bickering over it size after an operation is pretty 
pointless (pun intended) :-)


Beside the only number that really matters is 42 ;-)

--
mph
--
http://mail.python.org/mailman/listinfo/python-list


Re: WinXP, Python3.1.2, dir-listing to XML - problem with unicode file names

2010-04-03 Thread Mark Tolonen
"kai_nerda"  wrote in message 
news:hp69ri+a...@egroups.com...

Hi,

OS = Windows XP (German language)
Python = 3.1.2

I need to write a directory listing into a XML file.
And after hours of trying and searching i have no clue.

My main problem is that the file and folder names can
have characters of different languages like
German, Turkish, Russian, maybe else.

Because Python 3.1 is better with unicode, I
decided to use that instead of 2.6

For testing I have created the following files:
http://img340.imageshack.us/img340/3461/files.png
(google for the words
russia, turkish, deutsch, france
to find websites with special characters and copy & paste)

And this is the code I have now:

# -*- coding: iso-8859-1 -*-
# inspired by:
# http://www.dpawson.co.uk/java/dirlist.py
# (for Python ~2.4)

import sys
print ('filesystemencoding: ' + sys.getfilesystemencoding())
print ('defaultencoding:' + sys.getdefaultencoding())


from pprint import pprint
import os.path
from stat import *
from xml.sax.saxutils import XMLGenerator

def recurse_dir(path, writer):
for cdir, subdirs, files in os.walk(path):
pprint (cdir)
writer.startElement('dir', { 'name': cdir })
for f in files:
uf = f.encode('utf-8')
pprint (uf)
attribs = {'name': f}
attribs['size'] = str(os.stat(os.path.join(cdir,f))[ST_SIZE])
pprint (attribs)
writer.startElement('file', attribs)
writer.endElement('file')
for subdir in subdirs:
recurse_dir(os.path.join(cdir, subdir), writer)
writer.endElement('directory')


This should be:

  writer.endElement('dir')


break

if __name__ == '__main__':
directory = 'c:\\_TEST\\'
out = open('C:\\_TEST.xml','w')


The above line opens the file in the default file system encoding 'mbcs' 
(cp850 on your system).  Try:


   out = open('C:\\_TEST.xml','w',encoding='utf8')

Regards,
-Mark


writer = XMLGenerator(out, 'utf-8')
writer.startDocument()
recurse_dir(directory, writer)

out.close()




--
http://mail.python.org/mailman/listinfo/python-list


Re: Get a method instance through 'getattr' but not superclass's method

2010-04-03 Thread Gabriel Genellina

Please reply inline; top posting is harder to read.


On Fri, Mar 12, 2010 at 12:15 AM, Gabriel Genellina
wrote:


En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
 escribió:

 I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to detect if an attribute is  
from

superclass?


You may look it up directly in the class dictionary (__dict__)


En Sat, 03 Apr 2010 13:37:45 -0300, Radhakrishna Bhat  
 escribió:>



thanks. It is working for simple classes. But now i am trying for complex
objects.

myclassinstance.__class__.dict__ returns 

Looping through the same returned dictproxy gives attributes of  
superclass.

What am i doing wrong?


Could you provide a failing example?
It works for me in this case:


py> class MyClass(int):
...   "This is my derived class"
...   foo = 1
...   def bar(self): pass
...
py> MyClass

py> MyClass.__dict__

py> MyClass.__dict__.keys()
['__module__', 'bar', '__dict__', 'foo', '__weakref__', '__doc__']
py> for name in MyClass.__dict__:
...   print '%s: %.30r %.30r' % (name, getattr(MyClass,name),  
getattr(int,name,'*does*not*exist*'))

...
__module__: '__main__' '__builtin__'
bar:  '*does*not*exist*'
__dict__:  integer\n\n

foo and bar are new attributes. __module__, __dict__, __weakref__ and  
__doc__ are different from the base class.

If you want to filter out the last four:

- ignore all attribute names starting and ending with two underscores:
  if name[:2] == '__' == name[-2:]: continue

- ignore all attributes already present in the base class.
  if hasattr(int, name): continue

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


How to access args as a list?

2010-04-03 Thread kj



Suppose I have a function with the following signature:

def spam(x, y, z):
# etc.

Is there a way to refer, within the function, to all its arguments
as a single list?  (I.e. I'm looking for Python's equivalent of
Perl's @_ variable.)

I'm aware of locals(), but I want to preserve the order in which
the arguments appear in the signature.

My immediate aim is to set up a simple class that will allow me to
iterate over the arguments passed to the constructor (plus let me
refer to these individual arguments by their names using an
instance.attribute syntax, as usual).

The best I have managed looks like this:

class _Spam(object):
def __init__(self, x, y, z): 
self.__dict__ = OrderedDict(())
for p in inspect.getargspec(_Spam.__init__).args[1:]:
self.__dict__[p] = locals()[p]

def __iter__(self):
return iter(self.__dict__.values())


but rolling out inspect.getargspec for this sort of thing looks to
me like overkill.  Is there a more basic approach?

P.S. this is just an example; the function I want to implement has
more parameters in its signature, with longer, more informative
names.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread Andreas Waldenburger
On Sat, 3 Apr 2010 22:58:43 + (UTC) kj  wrote:

> The best I have managed looks like this:
> 
> class _Spam(object):
> def __init__(self, x, y, z): 
> self.__dict__ = OrderedDict(())
> for p in inspect.getargspec(_Spam.__init__).args[1:]:
> self.__dict__[p] = locals()[p]
> 
> def __iter__(self):
> return iter(self.__dict__.values())

Looks like you're trying to be lazy by doing extra hard work. Anything
wrong with this (?):

class Spam(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
self.arguments = (x, y, z)

def __iter__(self):
return iter(self.arguments)  # iter(...) kinda optional

With what little I know about your use case, that's how I would do it.

/W


-- 
INVALID? DE!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread Tim Chase

kj wrote:



Suppose I have a function with the following signature:

def spam(x, y, z):
# etc.

Is there a way to refer, within the function, to all its arguments
as a single list?  (I.e. I'm looking for Python's equivalent of
Perl's @_ variable.)


It sounds like you want the "*" operator  for arguments:

  def foo(*args):
print "Args:", repr(args)
print " Type:", type(args)
for i, arg in enumerate(args):
  print " Arg #%i = %s" % (i, arg)
  foo(1)
  foo("abc", "def", 42)
  # pass a list as args
  lst = [1,2,3]
  foo(*lst)

There's also a keyword form using "**":

  def foo(*args, **kwargs):
print "Args:", repr(args)
print " Type:", type(args)
print "Keyword Args:", repr(kwargs)
print " Type:", type(kwargs)
for i, arg in enumerate(args):
  print " Arg #%i = %s" % (i+1, arg)
for i, (k, v) in enumerate(kwargs.items()):
  print " kwarg #%i %r = %s" % (i+1, k, v)
  foo(1, "hello", something="Whatever", baz=42)
  # pass a list and a dict:
  lst = [1,2,3]
  dct = {100:10, 200:11}
  foo(*lst, **dct)

Both prevent introspection, so if you want the auto-generated 
help to populate with named arguments, you'd have to use the 
inspection method you're currently using.  But generally, if you 
want to be able to treat the args as lists/tuples/dicts, you 
don't care about the names given.


-tim




--
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread MRAB

kj wrote:



Suppose I have a function with the following signature:

def spam(x, y, z):
# etc.

Is there a way to refer, within the function, to all its arguments
as a single list?  (I.e. I'm looking for Python's equivalent of
Perl's @_ variable.)

I'm aware of locals(), but I want to preserve the order in which
the arguments appear in the signature.

My immediate aim is to set up a simple class that will allow me to
iterate over the arguments passed to the constructor (plus let me
refer to these individual arguments by their names using an
instance.attribute syntax, as usual).

The best I have managed looks like this:

class _Spam(object):
def __init__(self, x, y, z): 
self.__dict__ = OrderedDict(())

for p in inspect.getargspec(_Spam.__init__).args[1:]:
self.__dict__[p] = locals()[p]

def __iter__(self):
return iter(self.__dict__.values())


but rolling out inspect.getargspec for this sort of thing looks to
me like overkill.  Is there a more basic approach?

P.S. this is just an example; the function I want to implement has
more parameters in its signature, with longer, more informative
names.


I think the closest approach to what you're asking is to capture the
arguments as a list and then bind them to local names:

def spam(*args):
x, y, z = args
# etc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread Rolando Espinoza La Fuente
On Sat, Apr 3, 2010 at 6:28 PM, kj  wrote:
> Is there a way to refer, within the function, to all its arguments
> as a single list?  (I.e. I'm looking for Python's equivalent of
> Perl's @_ variable.)
>

def spam(*args, **kwargs):
print args
print kwargs

class Spam:
def __init__(self, *args, **kwargs):
print args
print kwargs

That's what are you looking for?

Regards,

~Rolando
-- 
http://mail.python.org/mailman/listinfo/python-list


Question on templates and python logging

2010-04-03 Thread David LePage
Hi -
I have been struggling with this problem for quite some time and was hoping 
somebody could give me some pointers.

I have a wxPython front end wizard that collects some information and outputs 
some HTML pages (not hosted by a web server, but viewable locally on the 
machine running the application).

The problem that i'm trying to solve is taking data collected along the way and 
outputting this into these HTML pages. 

One of the pages is simply collecting debug information about the execution of 
the program. 
All logging is  currently being done using the python logging library.

Due to the fact that my HTML files need to be populated in the  tags, I 
wanted to write directly to the proper HTML page based on the logging level 
message (INFO, DEBUG, etc).

Something like this works nicely if you have a dictionary storing the data:

def template():
  return open("html/html.tmpl", 'r').read() % vars
  
print template("html/Logs.html", { 'body' : "A test body field" })


But in my case, some of the data could be MB in size and I didn't want to 
read/write that entire load of data before displaying the pages if at all 
possible. 
I was hoping I could tie the logging classes into something like this, where I 
was leveraging an HTML template, but also taking advantage of the logging 
library since it works nicely for me today.

Does anybody have any suggestions on how they might approach this problem?

thanks!

DLP



  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread kj
In  kj  writes:

>Suppose I have a function with the following signature:

>def spam(x, y, z):
># etc.

>Is there a way to refer, within the function, to all its arguments
>as a single list?  (I.e. I'm looking for Python's equivalent of
>Perl's @_ variable.)

>I'm aware of locals(), but I want to preserve the order in which
>the arguments appear in the signature.

>My immediate aim is to set up a simple class that will allow me to
>iterate over the arguments passed to the constructor (plus letS me
   
>refer to these individual arguments by their names using an
 ^^^
>instance.attribute syntax, as usual).
 ^

The underlined portion explains why __init__(self, *args) fails to
fit the bill.

>P.S. this is just an example; the function I want to implement has
>more parameters in its signature, with longer, more informative
>names.

Andreas, perhaps this paragraph explains why I find your solution
unappealing:  it requires typing the same thing over and over,
which increases the chances of bugs.  That's the reason I avoid
such repetitiveness, not laziness, as you so were so quick to accuse
me of.

~K
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread kj
In  kj  writes:

>In  kj  writes:

>>Suppose I have a function with the following signature:

>>def spam(x, y, z):
>># etc.

>>Is there a way to refer, within the function, to all its arguments
>>as a single list?  (I.e. I'm looking for Python's equivalent of
>>Perl's @_ variable.)

>>I'm aware of locals(), but I want to preserve the order in which
>>the arguments appear in the signature.

>>My immediate aim is to set up a simple class that will allow me to
>>iterate over the arguments passed to the constructor (plus letS me
>   
>>refer to these individual arguments by their names using an
> ^^^
>>instance.attribute syntax, as usual).
> ^

>The underlined portion explains why __init__(self, *args) fails to
>fit the bill.

The minute I hit "send" I realized that this is wrong.  Sorry.

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (a==b) ? 'Yes' : 'No'

2010-04-03 Thread Lawrence D'Oliveiro
In message , Steve 
Holden wrote:

> Lawrence D'Oliveiro wrote:
>
>> By the way, you don’t need the parentheses.
> 
> But at the same time, if you don't *absolutely know* you don't need the
> parentheses ...

But you can “abolutely know”—it’s all spelled out here 
. Just keep that page 
open every time you write Python code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread Andreas Waldenburger
On Sat, 3 Apr 2010 23:52:42 + (UTC) kj  wrote:

> In  kj  writes:
> 
> [snip]
> >P.S. this is just an example; the function I want to implement has
> >more parameters in its signature, with longer, more informative
> >names.
> 
> Andreas, perhaps this paragraph explains why I find your solution
> unappealing:  it requires typing the same thing over and over,
> which increases the chances of bugs.  That's the reason I avoid
> such repetitiveness, not laziness, as you so were so quick to accuse
> me of.
> 
First up: I am sorry, I did not mean to offend. I apologize if I did.

But I stand by my point: If this class is the only instance of this
pattern, you'll only do this once. I see no reason to automate
something that will run only once anyway.

>From your own reply to the above it seems that the *args-notation
solves your problem (if I understand correctly). Since I'm patronizing
by nature, I'd like to weigh in on this: The approach you describe
seems like a Perl-ism[1]. *args is meant for variable argument lists.
Using it as a shortcut for "many formal parameters" is misuse of that
feature (not the worst kind, but not very good either). In addition to
creating the impression that the function takes a variable number of
arguments, it breaks introspection/self-documentation. Also, "many
formal parameters" can be a signal to rethink the approach altogether.
I feel that if a function has more than 6 or so parameters, I'm missing
an opportunity to simplify my code.

All of the above is philosophy, of course, and mine to boot, so feel
free to ignore my rambling. But maybe you can elaborate a bit on why
you need names *and* sequence of your parameters preserved and why
there need to be so many of them. Perhaps a fresh perspective on this
will yield a less problematic approach.

Then again, maybe I have wasted your time enough already. ;)

/W

-- 
INVALID? DE!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread Grant Edwards
On 2010-04-03, kj  wrote:
> In  kj  writes:
>
>>Suppose I have a function with the following signature:
>
>>def spam(x, y, z):
>># etc.
>
>>Is there a way to refer, within the function, to all its arguments
>>as a single list?  (I.e. I'm looking for Python's equivalent of
>>Perl's @_ variable.)
>
>>I'm aware of locals(), but I want to preserve the order in which
>>the arguments appear in the signature.
>
>>My immediate aim is to set up a simple class that will allow me to
>>iterate over the arguments passed to the constructor (plus letS me
>
>>refer to these individual arguments by their names using an
>  ^^^
>>instance.attribute syntax, as usual).
>  ^
>
> The underlined portion explains why __init__(self, *args) fails to
> fit the bill.

then add the line below:

   x,y,z = *args

-- 
Grant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encryption source code with md5

2010-04-03 Thread Lawrence D'Oliveiro
In message <4baf3ac4$0$22903$e4fe5...@news.xs4all.nl>, Irmen de Jong wrote:

> On 28-3-2010 12:08, Lawrence D'Oliveiro wrote:
>
>> Don’t use MD5.
> 
> Also, md5 is not an encryption algorithm at all, it is a secure hashing
> function.

You can use hash functions for encryption.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 09:35:34 -0700, Mensanator wrote:

> On Apr 3, 10:17 am, Steven D'Aprano  cybersource.com.au> wrote:
>> On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:
>> > I am replying to this post not because I disagree but because it
>> > postalogically  fits the best (I am by no means an expert either).
>>
>> > IMHO, the crackpot in this regard is actually partially right,
>> > multiplication does mean that the number must get bigger, however for
>> > fractions you multiply four numbers, two numerators and two
>> > denominators. The resulting numerator and denominator by this
>> > multiplication get indeed bigger.
>>
>> But you're not multiplying four numbers,
> 
> You are if you're using Rationals.

That is sheer unadulterated nonsense.

A rational number (element of Q) is not a pair of numbers, it is a unique 
single point on the real number line R which does not depend on either 
the way you calculate it, or the representation you use to write it.

The single number 1/2 can be written as any of 1/2, 2/4, 5/10, 1234/2468 
or any of an infinite number of ratios representations. It can be written 
as a decimal expansion 0.5, or a binary expansion 0.1, or the negative-
binary expansion 1.5, or as the base-eleven infinite expansion that 
starts as 0.5...

Numbers can also be written as continued fractions. The continued 
fraction representation for 1/2 is unexciting and happens to include two 
digits: [0; 2]. But the continued fraction representation of (say) 5/7 is 
[0; 1, 2, 2]. 5/7 isn't four numbers, or three, or two. It is one number.

You might as well argue that 43/92 is "four numbers" -- you have a 4, and 
3, and 9, and a 2, hence four numbers. The argument that 1/2 is two 
numbers is exactly as foolish as that.


>> you're multiplying two numbers.
> 
> Because they're expressed as Decimals.

No, the number of operands is independent of the types of the operands. 
Multiplication is a binary operator: it takes exactly two arguments. Not 
four, or six, or one. Regardless of whether I write:

Fraction(1,2)*Fraction(7,14)
Decimal('0.5')*Decimal('0.5')
0.5*0.5
MyFraction.from_roman('I', 'II')*MyContinedFraction([0, 2, 0, 0, 0])

I still have two numbers being multiplied.


>> One-half is not "two numbers",
> 
> Sometimes it is.

Only on Bizarro world.


>> that would be a tuple
> 
> Like this?
> 
 gmpy.mpq('0.5')
> mpq(1,2)

No, that's not a pair of numbers. It is a single number, equal to:

  ∑(i=1,∞,9/10**i)
--
  (ln(e)+sin(5π/2))

which is also a single number.


>> or a list or
>> possibly a coordinate pair. One-half is a single number,
> 
> When dealing with crackpots, it does not help to use the wrong
> arguments. 

And you think that telling the crackpot that he is right, multiplication 
always leads to bigger numbers, is somehow going to convince him that he 
is wrong about multiplication always leading to bigger numbers?



> When multiplying gmpy.mpq(2,3) by gmpy.mpq(2,3), the
> numerator and denominator have both indeed gotten bigger.

So what? "One quarter" is bigger (longer) than "one half". Your point is?

And in any case:

>>> Fraction(3, 4)*Fraction(2, 3)
Fraction(1, 2)

Would you still like to argue that the numerator and denominator always 
get bigger when you multiply two fractions?



> The trick is that when combined, the overall result is smaller.

 
>> the number which
>> if you double it gives one.
>>
>> Fortunately multiplication is consistent. Multiplying the two numbers
>> 0.5 and 0.5 is exactly the same as multiplying 1*1 and 2*2 then
>> dividing to get a single number. It's not the same as multiplying 1*1
>> and 2*2 to get two numbers, 1 and 4.
>>
>> You say that multiplication means that the number "must get bigger".
> 
> Yes, not in every case, but in many cases it does.

That makes no sense. It "must" get bigger, except for the cases where it 
doesn't? Or to put it another way: No, multiplication doesn't necessarily 
make numbers bigger.


>> 5*1 = 5
>> 5*0 = 0
>> 5*-2 = -10
>>
>> I hope you won't try to argue that 5, 0 and -10 are all bigger than 5.
> 
> Yes, but these special cases don't help. It needs to be pointed out that
> the argument is wrong even in cases like 2/3 * 2/3.

The argument is that multiplication ALWAYS makes numbers bigger. Martin, 
out of some misguided and confused sense that the representation of a 
number was somehow relevant, argued that this is correct. It's not 
correct, not even for integers, let alone rationals.

This is why I said that Martin should stop trying to justify the 
crackpot's belief that multiplication always makes numbers bigger, even a 
little bit. It's not even true for integers. It's not even true for 
positive (non-zero) integers. Arguments about numerators and denominators 
are just red-herrings.

If the crackpot claimed that dolphins were fish, does it help to say he's 
partly right because dolphins live in water and have fins and a tail and 
a head just like fish? No. He wou

Re: off topic but please forgive me me and answer

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 10:56:37 -0700, Patrick Maupin wrote:

>> The square root of 2 is irrational, but if you multiply it by itself
>> then the result isn't irrational, so not all operations involving
>> irrational numbers will result in an irrational result (unless that's
>> what you mean by "closely related irrational numbers").
> 
> Yes, I think I am closely related to myself.  But in addition to that
> particular disclaimer, I qualified the statement with "most" and I also
> mentioned that zero is special.  I stand by the assertion that if you
> take a random assortment of non-zero numbers, some irrational, some
> rational, and a random assortment of numeric operators, that most
> operations involving an irrational number will have an irrational
> result.


There are an infinite number of rational numbers. There are an infinite 
number of irrational numbers. But the infinity of the rationals is 
countable (1, 2, 3, 4, ... or aleph-0) while the infinity of the 
irrationals is uncountable (c or aleph-1), so there are infinitely more 
irrationals than rationals.

To put it another way, even though there are an infinite number of 
rationals, they are vanishingly rare compared to the irrationals. If you 
could choose a random number from the real number line, it almost 
certainly would be irrational.

(This is not to be confused with floats, which of course are all rational 
numbers.)


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (a==b) ? 'Yes' : 'No'

2010-04-03 Thread Steven D'Aprano
On Sun, 04 Apr 2010 12:26:05 +1200, Lawrence D'Oliveiro wrote:

> In message , Steve
> Holden wrote:
> 
>> Lawrence D'Oliveiro wrote:
>>
>>> By the way, you don’t need the parentheses.
>> 
>> But at the same time, if you don't *absolutely know* you don't need the
>> parentheses ...
> 
> But you can “abolutely know”—it’s all spelled out here
> . Just keep that page
> open every time you write Python code.

Or, when in doubt, you can add redundant parentheses. It makes no 
difference to the runtime, and vanishingly small difference to the 
compile-time, and sometimes it aids readability.

Writing the absolutely minimal code necessary to do what you want is not 
necessarily the best approach in all cases. I find, for instance, that 
redundant parentheses aid readability of complex logical and arithmetic 
expressions, especially if you include whitespace.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encryption source code with md5

2010-04-03 Thread Steven D'Aprano
On Sun, 04 Apr 2010 13:21:34 +1200, Lawrence D'Oliveiro wrote:

> In message <4baf3ac4$0$22903$e4fe5...@news.xs4all.nl>, Irmen de Jong
> wrote:
> 
>> On 28-3-2010 12:08, Lawrence D'Oliveiro wrote:
>>
>>> Don’t use MD5.
>> 
>> Also, md5 is not an encryption algorithm at all, it is a secure hashing
>> function.
> 
> You can use hash functions for encryption.

The purpose of encryption is for the holder of the secret key to be able 
to reverse the encryption easily and reliably, while nobody else can. 
Hash functions fail on three counts.

Since there is no secret key to a hash function, if you can reverse it, 
so can anyone. That alone rules it out as encryption.

Secondly, hash functions are generally difficult to reverse. For 
cryptographic hash functions, ideally they should be impossible to 
reverse short of trying every possible input.

Thirdly, even when reversible, hash functions have collisions. 
Consequently, you can't be sure whether you have found the intended 
message, or merely some random string which happens to accidentally hash 
to the same value.

Admittedly if you found a message that *made sense*, you could make a 
probabilistic argument that it probably was the original message. The 
shorter the message, the more you could be confident that you had found 
the right one: there is probably only one short, grammatically correct, 
semantically meaningful English sentence of less than ten words that has 
a MD5 hex digest of 22008290c5d1ff0bd5fae9e425b01d41, so if you find one, 
it probably will be "Meet at railway station at 3pm".

On the other hand, there are a very large number of (say) 20GB data files 
that hash to 22008290c5d1ff0bd5fae9e425b01d41, and probably no practical 
way of distinguishing the true message from the false collisions. Even if 
you can distinguish them, since the cost of reversing the hash is 
prohibitive, every false positive hurts you a lot.

Of course, none of this is to prohibit using a hash function as a 
component of a larger encryption scheme.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 11:17:36 +0200, Peter Otten wrote:

>> That's certainly faster than a list comprehension (at least on long
>> lists), but it might be a little obscure why the "if not s:" is needed,
> 
> The function is small; with a test suite covering the corner cases and
> perhaps a comment* nothing should go wrong.
> 
> (*) you can certainly improve on my attempt
> 
>> so unless Thomas has a really long result list, he might want to just
>> keep the list comprehension, which is (IMO) very readable.
> 
> Generally speaking performing tests of which you know they can't fail
> can confuse the reader just as much as tests with unobvious
> interdependencies.


I'm not sure I agree with you.

Tests which you know can't fail are called assertions, pre-conditions and 
post-conditions. We test them because if we don't, they will fail :)



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Patrick Maupin
On Apr 3, 9:24 pm, Steven D'Aprano  wrote:
> To put it another way, even though there are an infinite number of
> rationals, they are vanishingly rare compared to the irrationals. If you
> could choose a random number from the real number line, it almost
> certainly would be irrational.

Yet another correspondence between the set of numbers and the set of
people ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string

2010-04-03 Thread Alf P. Steinbach

* Steven D'Aprano:


Tests which you know can't fail are called assertions, pre-conditions and 
post-conditions. We test them because if we don't, they will fail :)


:-)

It's the umbrella law.


Cheers,

- Alf
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to access args as a list?

2010-04-03 Thread Steven D'Aprano
On Sat, 03 Apr 2010 22:58:43 +, kj wrote:

> Suppose I have a function with the following signature:
> 
> def spam(x, y, z):
> # etc.
> 
> Is there a way to refer, within the function, to all its arguments as a
> single list?  (I.e. I'm looking for Python's equivalent of Perl's @_
> variable.)

Does this help?

>>> def spam(a, b, c=3, d=4):
... pass
...
>>> spam.__code__.co_varnames
('a', 'b', 'c', 'd')

The hardest part is having the function know its own name.

I see that you are already using the inspect module. That almost 
certainly is the correct approach. I'd be surprised if inspect is too 
heavyweight, but if it is, you can pull out the bits you need into your 
own function.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string

2010-04-03 Thread Patrick Maupin
On Apr 3, 10:00 pm, Steven D'Aprano  wrote:
> Tests which you know can't fail are called assertions, pre-conditions and
> post-conditions. We test them because if we don't, they will fail :)

Well, yes, but that can get rather tedious at times:

a = 1
assert 0 < a < 2
b = a + 3
assert 2 < b - a < 4
c = b * 5
assert not c % 5

At least, I usually ameliorate the pain a little bit by not bothering
to print any debugging information at the assertions until one of them
actually fails; otherwise I'd *never* get any real coding done :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question on templates and python logging

2010-04-03 Thread Gabriel Genellina
En Sat, 03 Apr 2010 20:42:20 -0300, David LePage   
escribió:


The problem that i'm trying to solve is taking data collected along the  
way and outputting this into these HTML pages.

[...]
I was hoping I could tie the logging classes into something like this,  
where I was leveraging an HTML template, but also taking advantage of  
the logging library since it works nicely for me today.


Try this recipe:
http://code.activestate.com/recipes/577025-loggingwebmonitor-a-central-logging-server-and-mon/

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: How to keep effects of image filters going for some seconds?

2010-04-03 Thread Vincent Ren
On Mar 22, 6:00 am, Terry Reedy  wrote:
> On 3/21/2010 3:23 AM, Ren Wenshan wrote:
>
>
>
> > Hello, every pythoner.
>
> > Firstly, I want to mention that English is my second language, so
> > maybe there are some sentences which makes you confused, sorry.
>
> > I have been learning Panda3D, an open source 3D engine, these days.
> > Now, I'm trying to write a small game for fun and practice. However,
> > I've ran into a problem.
>
> > I want to make some speicaleffectsand there is my code:
>
> > def ventose(self):
>
> >      global potato_HP
>
> >      if potato_HP[0] == 1 and potato_HP[1] == 0:
> >      if random()>  .30:
> >          self.filters.setCartoonInk(separation = 0.8)
> >          self.robotVincent.resetHead.start()
> >          self.decreaseVincentHP()
> >              Wait(3)
> >              self.fliters.delCartoonInk()
>
> > However, it doesn't work, the CartoonInk effect will never been shown
> > in my game and I don't want my game to wait three seconds, what I need
> > is tokeepthe effect for a period of time while the game run as well.
>
> The generic answer is to turn CartoonInk on and set a timed event for
> now+ 3 secs to turn it off. You will have to understand how to interact
> with the Panda event loop. For a more specific answer, follow Donn's
> advice -- Panda forum. I know there was one when I looked at Panda a
> year ago.
>
> > Besides that, I also want to show a counting back like "3", then "2",
> > then "1", finally "Go".
>
> Ok, instead to events set 1 sec in future.
>
> Terry Jan Reedy

thx, I've sloved my proble with doMethodLater()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Incorrect scope of list comprehension variables

2010-04-03 Thread Tim Roberts
Alain Ketterlin  wrote:
>
>I've just spent a few hours debugging code similar to this:
>
>d = dict()
>for r in [1,2,3]:
>d[r] = [r for r in [4,5,6]]
>print d

Yes, this has been fixed in later revisions, but I'm curious to know what
led you to believe that a list comprehension created a new scope.  I don't
that was ever promised.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Build A Home Internet Business For Extra Income Stream

2010-04-03 Thread Earn Money
Why build a residential home internet concern in the primary place?
Believe it or not, the the human race saving is changing. While
Multinational expanding to total saving, employees are the Mainly
vulnerable classify of folks. Therefore, looking into A secondary
earnings
like build a residential home internet concern happen to An increasing
viable option in favor of many. Why you indicate to build an Internet
based concern in the midst of other..

For Details visit on
http://internetcafeincome.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good Intermediate Tutorials

2010-04-03 Thread Andrew Ellis
That's actually why I picked up this list, and it's done a lot to help.
+1 for sure

On Sat, Apr 3, 2010 at 2:52 PM,   wrote:
> Pick an arbitrary point in time, and begin reading this mailing list's
> archives. I guarantee you will learn alot.
>
> Malcolm
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
Andrew
http://blog.psych0tik.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: off topic but please forgive me me and answer

2010-04-03 Thread Mensanator
On Apr 3, 9:03 pm, Steven D'Aprano  wrote:
> On Sat, 03 Apr 2010 09:35:34 -0700, Mensanator wrote:
> > On Apr 3, 10:17 am, Steven D'Aprano  > cybersource.com.au> wrote:
> >> On Sat, 03 Apr 2010 15:43:41 +0100, Martin P. Hellwig wrote:
> >> > I am replying to this post not because I disagree but because it
> >> > postalogically  fits the best (I am by no means an expert either).
>
> >> > IMHO, the crackpot in this regard is actually partially right,
> >> > multiplication does mean that the number must get bigger, however for
> >> > fractions you multiply four numbers, two numerators and two
> >> > denominators. The resulting numerator and denominator by this
> >> > multiplication get indeed bigger.
>
> >> But you're not multiplying four numbers,
>
> > You are if you're using Rationals.
>
> That is sheer unadulterated nonsense.

You obviously don't understand the workings of computers.

>
> A rational number (element of Q) is not a pair of numbers,

Duh. Everybody knows that. But sometimes it is represented
by a pair of numbers such as 1/2 or mpq(1,2).

> it is a unique
> single point on the real number line R which does not depend on either
> the way you calculate it,

There are no "real number lines" inside my computer.

> or the representation you use to write it.

And if you want the computer to do a calculation, then you are
dependent on its representation.

>
> The single number 1/2 can be written as any of 1/2, 2/4, 5/10, 1234/2468
> or any of an infinite number of ratios representations. It can be written
> as a decimal expansion 0.5, or a binary expansion 0.1, or the negative-
> binary expansion 1.5, or as the base-eleven infinite expansion that
> starts as 0.5...

But we are only discussing those representations that are
a pair of numbers: numerator & denominator. Now look who's
talking nonsense, bringing up things like 0.5...

>
> Numbers can also be written as continued fractions. The continued
> fraction representation for 1/2 is unexciting and happens to include two
> digits: [0; 2]. But the continued fraction representation of (say) 5/7 is
> [0; 1, 2, 2]. 5/7 isn't four numbers, or three, or two. It is one number.

You're on a roll, aren't you?

>
> You might as well argue that 43/92 is "four numbers" -- you have a 4, and
> 3, and 9, and a 2, hence four numbers. The argument that 1/2 is two
> numbers is exactly as foolish as that.

Are you really that stupid?

>
> >> you're multiplying two numbers.
>
> > Because they're expressed as Decimals.
>
> No, the number of operands is independent of the types of the operands.
> Multiplication is a binary operator: it takes exactly two arguments. Not
> four, or six, or one. Regardless of whether I write:
>
> Fraction(1,2)*Fraction(7,14)
> Decimal('0.5')*Decimal('0.5')
> 0.5*0.5
> MyFraction.from_roman('I', 'II')*MyContinedFraction([0, 2, 0, 0, 0])
>
> I still have two numbers being multiplied.

And you claim that the internal workings of all the above are
the same?

>
> >> One-half is not "two numbers",
>
> > Sometimes it is.
>
> Only on Bizarro world.

I thought you were supposed to be a Python expert?
That you're supposed to understand the difference
between an object and its contents?

Is [1,2,3,4] one number? Of course not, it's four numbers
that are part of one object. A Rational is two numbers,
one object. Yes, squaring a Rational does mean multiplying
two objects, but you know damn well that it involves four
numbers.

>
> >> that would be a tuple
>
> > Like this?
>
>  gmpy.mpq('0.5')
> > mpq(1,2)
>
> No, that's not a pair of numbers.

Yes, it is. Two numbers, one object. Perhaps you need to
read the Tutorial?

> It is a single number, equal to:

The word you want here is "object". This is exactly the reason
these words were invented. They're probably spinning in their grave.

>
>   ∑(i=1,∞,9/10**i)
> --
>   (ln(e)+sin(5π/2))
>
> which is also a single number.

"Object".

>
> >> or a list or
> >> possibly a coordinate pair. One-half is a single number,
>
> > When dealing with crackpots, it does not help to use the wrong
> > arguments.
>
> And you think that telling the crackpot that he is right, multiplication
> always leads to bigger numbers, is somehow going to convince him that he
> is wrong about multiplication always leading to bigger numbers?

Of course not. But it may help the OP understand that's one of the
main fallacies that crackpots often engage in. Focusing on something
that's true but is a Non Sequitur.

>
> > When multiplying gmpy.mpq(2,3) by gmpy.mpq(2,3), the
> > numerator and denominator have both indeed gotten bigger.
>
> So what? "One quarter" is bigger (longer) than "one half". Your point is?

That in this case, multiplication did, in fact, make things larger.
It didn't make the object larger, but the numbers it contains are.
The crackpot focuses on the numbers while ignoring the object.
For you to say only the object matters and it's smaller makes you
just as wrong as the crackpot.

>
> And in 

Re: Incorrect scope of list comprehension variables

2010-04-03 Thread Steve Howell
On Apr 3, 9:58 pm, Tim Roberts  wrote:
> Alain Ketterlin  wrote:
>
> >I've just spent a few hours debugging code similar to this:
>
> >d = dict()
> >for r in [1,2,3]:
> >    d[r] = [r for r in [4,5,6]]
> >print d
>
> Yes, this has been fixed in later revisions, but I'm curious to know what
> led you to believe that a list comprehension created a new scope.  I don't
> that was ever promised.

Common sense about how programming languages should work?  As
confirmed by later revisions?

-- 
http://mail.python.org/mailman/listinfo/python-list