[RELEASE] Python 2.7.2 release candidate 1

2011-05-30 Thread Benjamin Peterson
On behalf of the Python development team, I'm happy to announce the immediate
availability of Python 2.7.2 release candidate 1.

2.7.2 is the second in bugfix release for the Python 2.7 series. 2.7 is the last
major verison of the 2.x line and will be receiving bug fixes while new feature
development focuses on 3.x.

2.7 includes many features that were first released in Python 3.1. The faster io
module, the new nested with statement syntax, improved float repr, set literals,
dictionary views, and the memoryview object have been backported from 3.1. Other
features include an ordered dictionary implementation, unittests improvements, a
new sysconfig module, auto-numbering of fields in the str/unicode format method,
and support for ttk Tile in Tkinter.  For a more extensive list of changes in
2.7, see http://doc.python.org/dev/whatsnew/2.7.html or Misc/NEWS in the Python
distribution.

To download Python 2.7.2rc1 visit:

 http://www.python.org/download/releases/2.7.1/

The 2.7.2 changelog is at:

 http://hg.python.org/cpython/file/439396b06416/Misc/NEWS

2.7 documentation can be found at:

 http://docs.python.org/2.7/

This is a preview release. Assuming no major problems, 2.7.2 will be released in
two weeks. Please report any bugs you find to

 http://bugs.python.org/


Enjoy!

--
Benjamin Peterson
Release Manager
benjamin at python.org
(on behalf of the entire python-dev team and 2.7.2's contributors)
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[ANN] PyYAML-3.10: YAML parser and emitter for Python

2011-05-30 Thread Kirill Simonov


 Announcing PyYAML-3.10


A new bug fix release of PyYAML is now available:

http://pyyaml.org/wiki/PyYAML


Changes
===

* Do not try to build LibYAML bindings on platforms other than CPython
  (Thank to olt(at)bogosoft(dot)com).
* Clear cyclic references in the parser and the emitter
  (Thank to kristjan(at)ccpgames(dot)com).
* LibYAML bindings are rebuilt with the latest version of Cython.
* Dropped support for Python 2.3 and 2.4; currently supported versions
  are 2.5 to 3.2.


Resources
=

PyYAML homepage: http://pyyaml.org/wiki/PyYAML
PyYAML documentation: http://pyyaml.org/wiki/PyYAMLDocumentation

TAR.GZ package: http://pyyaml.org/download/pyyaml/PyYAML-3.10.tar.gz
ZIP package: http://pyyaml.org/download/pyyaml/PyYAML-3.10.zip
Windows installers:
http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.5.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.6.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py3.0.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py3.1.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py3.2.exe

PyYAML SVN repository: http://svn.pyyaml.org/pyyaml
Submit a bug report: http://pyyaml.org/newticket?component=pyyaml

YAML homepage: http://yaml.org/
YAML-core mailing list: 
http://lists.sourceforge.net/lists/listinfo/yaml-core



About PyYAML


YAML is a data serialization format designed for human readability and
interaction with scripting languages.  PyYAML is a YAML parser and
emitter for Python.

PyYAML features a complete YAML 1.1 parser, Unicode support, pickle
support, capable extension API, and sensible error messages.  PyYAML
supports standard YAML tags and provides Python-specific tags that allow
to represent an arbitrary Python object.

PyYAML is applicable for a broad range of tasks from complex
configuration files to object serialization and persistance.


Example
===

 import yaml

 yaml.load(
... name: PyYAML
... description: YAML parser and emitter for Python
... homepage: http://pyyaml.org/wiki/PyYAML
... keywords: [YAML, serialization, configuration, persistance, pickle]
... )
{'keywords': ['YAML', 'serialization', 'configuration', 'persistance',
'pickle'], 'homepage': 'http://pyyaml.org/wiki/PyYAML', 'description':
'YAML parser and emitter for Python', 'name': 'PyYAML'}

 print yaml.dump(_)
name: PyYAML
homepage: http://pyyaml.org/wiki/PyYAML
description: YAML parser and emitter for Python
keywords: [YAML, serialization, configuration, persistance, pickle]


Copyright
=

The PyYAML module is written by Kirill Simonov x...@resolvent.net.

PyYAML is released under the MIT license.
--
http://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


SQLObject 1.0.1

2011-05-30 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.0.1, a bugfix release of branch 1.0
of SQLObject.



What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/1.0.1

News and changes:
http://sqlobject.org/News.html


What's New
==

* A syntax incompatibility was fixed in SQLiteConnection that prevented
  SQLObject to be used with Python 2.4.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: float(nan) in set or as key

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 04:29:19 +, Chris Torek wrote:

 In article 4de31635$0$29990$c3e8da3$54964...@news.astraweb.com, Steven
 D'Aprano  steve+comp.lang.pyt...@pearwood.info wrote:
That's also completely wrong. The correct way to test for a NAN is with
the IEEE-mandated function isnan(). The NAN != NAN trick is exactly
that, a trick, used by programmers when their language or compiler
doesn't support isnan().
 
 Perhaps it would be reasonable to be able to do:
 
 x.isnan()
 
 when x is a float.

Better than a float method is a function which takes any number as 
argument:


 import math, fractions, decimal
 math.isnan(fractions.Fraction(2, 3))
False
 math.isnan(decimal.Decimal('nan'))
True


You can even handle complex NANs with the cmath module:

 import cmath
 cmath.isnan(complex(1, float('nan')))
True




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


Re: float(nan) in set or as key

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 04:15:11 +, Steven D'Aprano wrote:

 On Mon, 30 May 2011 11:14:58 +1000, Chris Angelico wrote:
 
 So, apart from float(nan), are there actually any places where real
 production code has to handle NaN? I was unable to get a nan by any of
 the above methods, except for operations involving inf; for instance,
 float(inf)-float(inf) == nan. All the others raised an exception
 rather than return nan.
 
 That's Python's poor design, due to reliance on C floating point
 libraries that have half-hearted support for IEEE-754, and the
 obstruction of people who don't understand the usefulness of NANs.

That last comment mine is a bit harsh, and I'd like to withdraw it as 
unnecessarily confrontational.



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


Re: scope of function parameters

2011-05-30 Thread Laurent Claessens

Le 29/05/2011 23:42, Ben Finney a écrit :

Peter Pearsonppearson@nowhere.invalid  writes:


 Python works in terms of objects having names, and one
 object can have many names.


Or no names. So it's less accurate (though better than talking of
“variables”) to speak of Python objects “having names”.


Could you give an example of an object that has no name ? I've missed 
something ...


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


Re: scope of function parameters

2011-05-30 Thread Chris Rebert
On Mon, May 30, 2011 at 12:12 AM, Laurent Claessens moky.m...@gmail.com wrote:
 Le 29/05/2011 23:42, Ben Finney a écrit :
 Peter Pearsonppearson@nowhere.invalid  writes:

  Python works in terms of objects having names, and one
  object can have many names.

 Or no names. So it's less accurate (though better than talking of
 “variables”) to speak of Python objects “having names”.

 Could you give an example of an object that has no name ? I've missed
 something ...

def foo():
return 5

print(foo())

The int object 5 has no name here.

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


Re: scope of function parameters

2011-05-30 Thread Laurent



 Could you give an example of an object that has no name ? I've missed
 something ...


def foo():
 return 5

print(foo())

The int object 5 has no name here.


Cool. I was thinking that 5 was the name, but
 5.__add__(6)
  File stdin, line 1
5.__add__(6)
^
SyntaxError: invalid syntax

while

 a=5
 a.__add__(6)
11


Very well. I learned something today.
Thanks
Laurent
--
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-30 Thread Daniel Kluev
On Mon, May 30, 2011 at 6:12 PM, Laurent Claessens moky.m...@gmail.com wrote:
 Could you give an example of an object that has no name ? I've missed
 something ...

 object()
object object at 0xb73d04d8

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-30 Thread Terry Reedy

On 5/30/2011 3:38 AM, Laurent wrote:


Cool. I was thinking that 5 was the name, but
  5.__add__(6)
File stdin, line 1
5.__add__(6)



Try 5 .__add__(6)

Modules, classes, and functions have a .__name__ attribute (I call it 
their 'definition name') used to print a representation. As best I can 
remember, other builtin objects do not.


--
Terry Jan Reedy

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


Re: 3.1.4 release candidate 1

2011-05-30 Thread Alain Ketterlin
Raymond Hettinger pyt...@rcn.com writes:

 On May 29, 3:44 pm, Benjamin Peterson benja...@python.org wrote:
 On behalf of the Python development team, I'm happy as a swallow to announce 
 a
 release candidate for the fourth bugfix release for the Python 3.1
 series, Python
 3.1.4.

 The Pi release of Python :-)

And the same day we get the e release of Python...

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


Re: scope of function parameters

2011-05-30 Thread Laurent Claessens

Le 30/05/2011 11:02, Terry Reedy a écrit :

On 5/30/2011 3:38 AM, Laurent wrote:


 Cool. I was thinking that 5 was the name, but
5.__add__(6)
 File stdin, line 1
 5.__add__(6)



Try 5 .__add__(6)


What is the rationale behind the fact to add a space between 5 and 
.__add__ ?

Why does it work ?

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


Best way to compute length of arbitrary dimension vector?

2011-05-30 Thread Gabriel
Well, the subject says it almost all: I'd like to write a small Vector
class for arbitrary-dimensional vectors.

I am wondering what would be the most efficient and/or most elegant
way to compute the length of such a Vector?

Right now, I've got

  def length(self): 
# x.length() = || x ||
total = 0.0
for k in range(len(self._coords)):
  d = self._coords[k]
  total += d*d
return sqrt(total)

However, that seems a bit awkward to me (at least in Python ;-) ).

I know there is the reduce() function, but I can't seem to find a way
to apply that to the case here (at least, not without jumping through
too many hoops).

I have also googled a bit, but found nothing really elegant.

Any ideas?

Best regards,
Gabriel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 11:08:23 +0200, Laurent Claessens wrote:

 Le 30/05/2011 11:02, Terry Reedy a écrit :
 On 5/30/2011 3:38 AM, Laurent wrote:

  Cool. I was thinking that 5 was the name, but
 5.__add__(6)
  File stdin, line 1
  5.__add__(6)


 Try 5 .__add__(6)
 
 What is the rationale behind the fact to add a space between 5 and
 .__add__ ?
 Why does it work ?

Because . is an operator just like + *  etc.

 s = hello world
 s . upper ( )
'HELLO WORLD'


In the case of integer literals, you need the space, otherwise Python 
will parse 5. as a float:


 5.
5.0
 5.__add__
  File stdin, line 1
5.__add__
^
SyntaxError: invalid syntax
 5 .__add__
method-wrapper '__add__' of int object at 0x8ce3d60





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


Re: scope of function parameters

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 09:12:50 +0200, Laurent Claessens wrote:

 Could you give an example of an object that has no name ? I've missed
 something ...


 mylist = [None, 42, something]


The list object has a name, mylist.

The three objects inside the list have no names.


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


Re: scope of function parameters

2011-05-30 Thread Ben Finney
Laurent Claessens moky.m...@gmail.com writes:

 Le 30/05/2011 11:02, Terry Reedy a écrit :
  Try 5 .__add__(6)

 What is the rationale behind the fact to add a space between 5 and
 .__add__ ?
 Why does it work ?

Try asking it the other way around. Why doesn't ‘5.__add__(6)’, without
the space, work?

-- 
 \“Telling pious lies to trusting children is a form of abuse, |
  `\plain and simple.” —Daniel Dennett, 2010-01-12 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's super() considered super!

2011-05-30 Thread Duncan Booth
Ethan Furman et...@stoneleaf.us wrote:

 foo(x=1, y=2, z=3)
 Traceback (most recent call last):
   File pyshell#8, line 1, in module
 foo(x=1, y=2, z=3)
   File pyshell#4, line 2, in foo
 bar(y=2, **kwargs)
 TypeError: bar() got multiple values for keyword argument 'y'
 
 And the above error is exactly why you don't want to use named arguments 
 in MI -- because you don't know in what order the methods will be 
 called, you cannot know which named arguments to supply to the method 
 that super() will call next.
 

No, it just means you have to be careful how you do it: if you want to pass 
'y' to a super call then you must pop it out of the arguments. This can be 
done as easily with a named argument as with an explicit 'pop()' on kwargs.

What using a named argument does it to change the default action from 
silently overwriting any argumement passing up the chain to raising an 
error if you attempt to overwrite it without first checking whether it 
exists.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: portable way of sending notifying a process

2011-05-30 Thread News123
Thanks for all your feedback.


Well, I'll play a little and go either for a wrapper around
ways to detecth a file change or for a tiny socket solution.

Thanks again.


On 05/30/2011 04:03 AM, Chris Angelico wrote:
 On Mon, May 30, 2011 at 11:44 AM, Chris Torek nos...@torek.net wrote:
 What would be a light weight portable way, that one process can tell
 another to do something?

 The main requirement would be to have no CPU impact while waiting (thus
 no polling)

 Your best bet here is probably to use sockets.  Both systems have
 ways to create service sockets and to connect to a socket as a
 client.
 
 Further to this: If your two processes are going to start up, then run
 concurrently for some time, and during that time alert each other (or
 one alerts the other) frequently, a socket is an excellent choice. Use
 a TCP socket on Windows, and either a TCP socket or a Unix socket on
 Linux (I'd just use TCP on both for simplicity, but Unix sockets are
 faster), and simply write a byte to it whenever you want to alert the
 other side. You can largely guarantee that no other process can
 accidentally or maliciously wake you, as long as you have some kind of
 one-off handshake on connection - even something really simple like
 sending a random nonce, having the other end send hash(nonce +
 password), and compare.
 
 Chris Angelico
 Huge fan of TCP sockets (hello MUDs!)

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


Re: Best way to compute length of arbitrary dimension vector?

2011-05-30 Thread Chris Rebert
On Mon, May 30, 2011 at 2:11 AM, Gabriel snoopy.6...@googlemail.com wrote:
 Well, the subject says it almost all: I'd like to write a small Vector
 class for arbitrary-dimensional vectors.

 I am wondering what would be the most efficient and/or most elegant
 way to compute the length of such a Vector?

 Right now, I've got

  def length(self):                                                            
                          # x.length() = || x ||
    total = 0.0
    for k in range(len(self._coords)):
      d = self._coords[k]
      total += d*d
    return sqrt(total)

 However, that seems a bit awkward to me (at least in Python ;-) ).

 I know there is the reduce() function, but I can't seem to find a way
 to apply that to the case here (at least, not without jumping through
 too many hoops).

 I have also googled a bit, but found nothing really elegant.

 Any ideas?

def length(self):
return sqrt(sum(coord*coord for coord in self._coords))

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


Re: scope of function parameters

2011-05-30 Thread Peter Otten
Laurent Claessens wrote:

 Le 30/05/2011 11:02, Terry Reedy a écrit :
 On 5/30/2011 3:38 AM, Laurent wrote:

  Cool. I was thinking that 5 was the name, but
 5.__add__(6)
  File stdin, line 1
  5.__add__(6)


 Try 5 .__add__(6)
 
 What is the rationale behind the fact to add a space between 5 and
 .__add__ ?
 Why does it work ?

It's a hint for the tokenizer.

$ cat show_tokens.py
import sys

from tokenize import generate_tokens
from cStringIO import StringIO
from token import tok_name

_name_width = max(len(name) for name in tok_name.itervalues())

def show_tokens(s):
for token in generate_tokens(StringIO(s).readline):
name = tok_name[token[0]]
value = token[1]
print %-*s %r % (_name_width, name, value)

if __name__ == __main__:
show_tokens( .join(sys.argv[1:]))

$ python show_tokens.py 5.__add__
NUMBER   '5.'
NAME '__add__'
ENDMARKER''

$ python show_tokens.py 5 .__add__
NUMBER   '5'
OP   '.'
NAME '__add__'
ENDMARKER''



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


Re: Best way to compute length of arbitrary dimension vector?

2011-05-30 Thread Peter Otten
Gabriel wrote:

 Well, the subject says it almost all: I'd like to write a small Vector
 class for arbitrary-dimensional vectors.
 
 I am wondering what would be the most efficient and/or most elegant
 way to compute the length of such a Vector?
 
 Right now, I've got
 
   def length(self):   
 # x.length() = || x ||
 total = 0.0
 for k in range(len(self._coords)):
   d = self._coords[k]
   total += d*d
 return sqrt(total)
 
 However, that seems a bit awkward to me (at least in Python ;-) ).
 
 I know there is the reduce() function, but I can't seem to find a way
 to apply that to the case here (at least, not without jumping through
 too many hoops).
 
 I have also googled a bit, but found nothing really elegant.

 class Vector(object):
... def __init__(self, *coords):
... self._coords = coords
... def __abs__(self):
... return math.sqrt(sum(x*x for x in self._coords))
...
 import math
 abs(Vector(1,1))
1.4142135623730951
 abs(Vector(3,4))
5.0


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


Re: scope of function parameters

2011-05-30 Thread Laurent Claessens



 What is the rationale behind the fact to add a space between 5 and
 .__add__ ?
 Why does it work ?


It's a hint for the tokenizer.


I didn't know the tokenizer. Now I understand.
Thanks

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


Re: scope of function parameters

2011-05-30 Thread Laurent Claessens



 What is the rationale behind the fact to add a space between 5 and
 .__add__ ?
 Why does it work ?


It's a hint for the tokenizer.


I didn't know the tokenizer. Now I understand.
Thanks

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


python in school notebooks/laptops

2011-05-30 Thread John Thornton
Hello
Is it a waste of time to try to get school admins to put python in
their school laptops?

   OK. Here's the crib for the rest[!] of the world. Here in Australia
most secondary schools [that is kids from age approx 12-18] have some sort
of netbook/laptop program. I have looked at a few schools and they put
visual basic in  but not python. [unless of course it's a mac where python
may already be in it] . This is a curious omission when Blender needs python
to run.

  So, I emailed a school admin and told him about python, gimp, inkscape
and blender.

  Have I wasted my time?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-30 Thread Jussi Piitulainen
Laurent Claessens writes:
 Le 30/05/2011 11:02, Terry Reedy a écrit :
  On 5/30/2011 3:38 AM, Laurent wrote:
 
   Cool. I was thinking that 5 was the name, but
  5.__add__(6)
   File stdin, line 1
   5.__add__(6)
 
 
  Try 5 .__add__(6)
 
 What is the rationale behind the fact to add a space between 5 and
 .__add__ ?
 Why does it work ?

Oh joy.

   [5][0].__add__([6][-1])
  11

The parser just needs the help to detect the intended token boundary
instead of another, unintened one. As the others already say.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-30 Thread Piotr Kamiński

I'm sorry, I wanted to send the message below to the list and instead I sent it 
to just one user.

Piotr


Dnia 23-05-2011 o 10:29:24 Piotr Kamiński piotr.kamin...@poczta.onet.eu 
napisał(a):


Dnia 23-05-2011 o 00:58:55 Brendan Simon (eTRIX) brendan.si...@etrix.com.au 
napisał(a):

...

Take a look at Cobra.

http://cobra-language.com/docs/python/

http://cobra-language.com/

It is similar to Python, but with a quite a few nice extras and few improved things (eg. no 
self, no :, ...)

Possible negatives are:
* Requires either .NET or Mono frameworks.
* lack of 3rd party libraries ??


Cheers, Brendan.




One more piece of information and a link: ...It supports both static and dynamic 
typing... 
http://en.wikipedia.org/wiki/Cobra_(programming_language_from_Cobra_Language_LLC)

HTH,

Piotr

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


Re: python in school notebooks/laptops

2011-05-30 Thread hackingKK


On 30/05/11 15:45, John Thornton wrote:

Hello
Is it a waste of time to try to get school admins to put 
python in their school laptops?


   OK. Here's the crib for the rest[!] of the world. Here in 
Australia most secondary schools [that is kids from age approx 12-18] 
have some sort of netbook/laptop program. I have looked at a few 
schools and they put visual basic in  but not python. [unless of 
course it's a mac where python may already be in it] . This is a 
curious omission when Blender needs python to run.


Even better, try convincing them to use Ubuntu instead of  a virus 
called Where I Never Do Operations With Safety, or WINDOWS for short.

That way Python will come by default  and VB will be out of question
Happy hacking.
Krishnakant.

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


Re: python in school notebooks/laptops

2011-05-30 Thread John Thornton
I agree fully. Linux  is better and safer. But they seem hellbent on getting
their students to use Windows. For laughs the kids in year 7 start off with
this on their school netbook:

   Individual software packages
MS Office Professional 2010 $80.30
(Word, Excel, PowerPoint, Access, Outlook, Publisher, OneNote)
(EULA needs to be signed)
DyKnow $47.00
Microworlds EX Robotics (PC/Mac) $27.50
Inspiration V8 (PC/Mac) $50.60
Graphmatica $4.40
Sophos Anti-virus $30.00
Network Cable $6.00
Labels for laptop and bag $1.00
Additional Software
Home Studio (Yr 7 and 8 Music) $50.00
Upgrade from Vista Business to Windows 7 Professional $103.40
Software packages also installed (either free of charge or cost covered by
School) are ArtRage, Acrobat
Reader, Cite Ace, Mavis Beacon Typing, Scratch, Wordweb, Kahootz, Comic
Life, Ni Hao, French
Gamemaker, NewsMaker, Yenka Science, Autodesk Inventor.

***
Gimp? Python? Linux? Inkscape? Blender?
That software may as well be on the moon. [sobs into beer...oh well, at
least they get to buy anti-virus gear...:)]

John



On Mon, May 30, 2011 at 9:09 PM, hackingKK hackin...@gmail.com wrote:


 On 30/05/11 15:45, John Thornton wrote:

 Hello
Is it a waste of time to try to get school admins to put python in
 their school laptops?

   OK. Here's the crib for the rest[!] of the world. Here in Australia
 most secondary schools [that is kids from age approx 12-18] have some sort
 of netbook/laptop program. I have looked at a few schools and they put
 visual basic in  but not python. [unless of course it's a mac where python
 may already be in it] . This is a curious omission when Blender needs python
 to run.


 Even better, try convincing them to use Ubuntu instead of  a virus called
 Where I Never Do Operations With Safety, or WINDOWS for short.
 That way Python will come by default  and VB will be out of question
 Happy hacking.
 Krishnakant.


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


SQLObject 1.0.1

2011-05-30 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.0.1, a bugfix release of branch 1.0
of SQLObject.



What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/1.0.1

News and changes:
http://sqlobject.org/News.html


What's New
==

* A syntax incompatibility was fixed in SQLiteConnection that prevented
  SQLObject to be used with Python 2.4.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-30 Thread Peter Moylan
rantingrick wrote:
 On May 18, 7:19 am, Peter Moylan inva...@peter.pmoylan.org.invalid
 wrote:
 
 It's interesting to note that the definitions of 'recursive' to be found
 in Wikipedia and Wiktionary have very little in common with the
 definitions to be found in the dictionaries covered by Onelook.  No
 wonder experts in different areas have trouble communicating with one
 another.
 
 Yes, and when you extrapolate that conclusion into the current hodge
 podge of natural languages you begin to understand the genesis of
 human beings selfish nature.

I do?

-- 
Peter Moylan, Newcastle, NSW, Australia.  http://www.pmoylan.org
For an e-mail address, see my web page.
-- 
http://mail.python.org/mailman/listinfo/python-list


searching in list

2011-05-30 Thread vino19
I want to make a function that is called only once per one argument. I mean I 
want to store data of function calling to prevent calling it again if there is 
no need.
How to make it? For example I can make a global list that just consist of 
tuples 
[(arg1, res1), (arg2, res2), ...]. Ok, how to search if an arg135 in that list?

Thanks for answering
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-30 Thread Peter Moylan
rantingrick wrote:
 On May 18, 12:59 pm, s...@sig.for.address (Victor Eijkhout) wrote:
 Harrison Hill harrish...@gmx.com wrote:
 No need - I have the Dictionary definition of recursion here:
 Recursion: (N). See recursion.
 If you tell a joke, you have to tell it right.
 
 Jeez, speaking of bad colloquialisms...
 
  if you're going to share a joke you should at least recite it
 CORRECTLY.

He was her man
But he was doing her incorrectly.

I'm not convinced that this new meaning of share has contributed
anything of value to the language.  Which is possibly why people stopped
using it in about the 1980s.

-- 
Peter Moylan, Newcastle, NSW, Australia.  http://www.pmoylan.org
For an e-mail address, see my web page.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching in list

2011-05-30 Thread Dave Angel

On 01/-10/-28163 02:59 PM, vino19 wrote:

I want to make a function that is called only once per one argument. I mean I 
want to store data of function calling to prevent calling it again if there is 
no need.
How to make it? For example I can make a global list that just consist of tuples
[(arg1, res1), (arg2, res2), ...]. Ok, how to search if an arg135 in that list?

Thanks for answering



Usual answer is to use a dict.  You can convert a list of tuples to a 
dict bydict(mylist)


Second choice is to keep the list sorted, and use the bisect module. 
But usually a dictionary is better.


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


Re: python in school notebooks/laptops

2011-05-30 Thread Chris Angelico
On Mon, May 30, 2011 at 8:15 PM, John Thornton secretel...@gmail.com wrote:
 Hello
     Is it a waste of time to try to get school admins to put python in
 their school laptops?

Two halves to this question.

1) Would it be of value if the school admins were to put Python on the
school laptops?
2) If you ask them to, would they?

The answer to #1 is Undoubtedly. Cost? A tiny bit of disk space.
Benefit? Even if only one student in a thousand picked it up and
learned it, that's a huge number of people who've been exposed to a
better language than VB.

But the answer to #2, based on my cynical view of these things, is
Unlikely. You could ask the school admins, but they'll point to some
policy from upstairs that says what they need to provide. And I don't
know who formulates that policy, but more than likely it's a
committee.

Who pays for all that software? I'm guessing it's part of one of those
perversities where something is valued more if it costs more (We
spend $X million teaching our students modern computing). Replacing
the netbook packageset with Ubuntu and a whole swathe of free software
(the significant part here being free-as-in-beer, but it would be
free-as-in-speech software too) would cut $400 per student off their
boast according to the figures you posted - but that doesn't seem to
include the OS itself, so possibly even more.

The other part of the problem is a huge lock-in involving grade
schools, tertiary education, and company employment agencies, all of
whom think that computer skill means knows how to change cell color
in Excel. And that is not an exaggeration - my brother says that when
he was applying for jobs that required computing skills, the
recruitment agency wanted to know his ability level with Word 2003 and
Excel 2003. Getting past that is not going to be easy.

But if you can just get a smidge of extra software put on the laptops
(some nice easy tiny stuff - Python, 7-Zip, InfraRecorder - skip OO
because it's too heavy), nobody would notice the extra disk space
usage (even a cheap netbook will have storage measured in hundreds of
gig), and it gives them a chance to learn something decent. Bored
student browsing the Start menu... might not happen very often, but if
even one person learns Python, that'd be worth it!

Possibly the best way to encourage Python deployment would be to
require it to run some internal script. Then the interpreter will be
put on the laptops (it's so tiny, won't cost anything to put it
there), and IDLE will be available for anyone who wants it. Now the
question is, how can you get into a position where you can have a
script that's needed for every student...

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


Re: Best way to compute length of arbitrary dimension vector?

2011-05-30 Thread Gabriel
Thanks a lot to both of you, Chris  Peter!

(I knew the solution would be simple ... ;-) )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching in list

2011-05-30 Thread Chris Angelico
On Mon, May 30, 2011 at 10:58 PM, vino19 vinogra...@gmail.com wrote:
 I want to make a function that is called only once per one argument. I mean I 
 want to store data of function calling to prevent calling it again if there 
 is no need.
 How to make it? For example I can make a global list that just consist of 
 tuples
 [(arg1, res1), (arg2, res2), ...]. Ok, how to search if an arg135 in that 
 list?

 Thanks for answering

If you're always going to look them up by the argument, the best way
would be to use a dictionary:
cache={arg1: res1, arg2: res2, ...}

Then you can search with a simple: cache[arg135]

You can add things with: cache[arg135]=res135

This works best if the argument is an immutable and fairly simple
type. For instance, you could calculate Fibonacci numbers in a naive
and straightforward way:

def fib(n,cache={}):
  if n in cache: return cache[n]
  ret=n if n2 else fib(n-1)+fib(n-2) # This bit actually calculates fib(n)
  cache[n]=ret
  return ret

Of course, this is a poor algorithm for calculating Fibonacci numbers,
but it does demonstrate the cache. It's recursive, meaning that if it
has fib(50) in its cache and it is asked for fib(60), it will find and
make use of the cached element.

(Note the sneaky way of storing a cache dictionary. A function's
default arguments are evaluated once, so this will use the same
dictionary for every call.)

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


Re: searching in list

2011-05-30 Thread vino19
Thanks.

It seems that dictionary is a sorted list of tuples, so the procedure of 
searching an element is quite quick.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python in school notebooks/laptops

2011-05-30 Thread jmfauth
On 30 mai, 13:09, hackingKK hackin...@gmail.com wrote:

[...]


 Even better, try convincing them to use Ubuntu instead of  a virus
 called Where I Never Do Operations With Safety, or WINDOWS for short.
 That way Python will come by default  and VB will be out of question
 Happy hacking.
 Krishnakant.

Do you mean one of these os's, where Python (2) is not
working properly because the *defaultencoding* is set
to utf-8?

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


Re: searching in list

2011-05-30 Thread Chris Angelico
On Mon, May 30, 2011 at 11:50 PM, vino19 vinogra...@gmail.com wrote:
 Thanks.

 It seems that dictionary is a sorted list of tuples, so the procedure of 
 searching an element is quite quick.

Not sorted - it's hashed, so it's even faster. Yep, sounds like a
dictionary is everything you want!

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


Re: How to catch a line with Popen

2011-05-30 Thread TheSaint
Chris Torek wrote:

 In at least some versions of Python 2

I'm with P3k :P. However thank you for your guidelines.
Last my attempt was to use a *for* p.wait() , as mentioned earlier

That looks good enough. I noted some little delay for the first lines, 
mostly sure Popen assign some buffer even it is not set.

Haven't you try a perpetual ping, how would be the line_at_a_time ?

-- 
goto /dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching in list

2011-05-30 Thread Ian Kelly
On Mon, May 30, 2011 at 7:41 AM, Chris Angelico ros...@gmail.com wrote:
 If you're always going to look them up by the argument, the best way
 would be to use a dictionary:
 cache={arg1: res1, arg2: res2, ...}

 Then you can search with a simple: cache[arg135]

 You can add things with: cache[arg135]=res135

 This works best if the argument is an immutable and fairly simple
 type. For instance, you could calculate Fibonacci numbers in a naive
 and straightforward way:

 def fib(n,cache={}):
  if n in cache: return cache[n]
  ret=n if n2 else fib(n-1)+fib(n-2) # This bit actually calculates fib(n)
  cache[n]=ret
  return ret

 Of course, this is a poor algorithm for calculating Fibonacci numbers,
 but it does demonstrate the cache. It's recursive, meaning that if it
 has fib(50) in its cache and it is asked for fib(60), it will find and
 make use of the cached element.

 (Note the sneaky way of storing a cache dictionary. A function's
 default arguments are evaluated once, so this will use the same
 dictionary for every call.)

If you're using Python 3.2, the functools.lru_cache decorator will do
the caching for you, and without modifying the function arguments.  By
default it stores only the 100 most recent results, but you can make
the storage unbounded by passing in the argument maxsize=None.  Then
the Fibonacci example becomes:

@functools.lru_cache(maxsize=None)
def fib(n):
if n  2:
return n
return fib(n-2) + fib(n-1)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-30 Thread Terry Reedy

On 5/30/2011 5:08 AM, Laurent Claessens wrote:

Le 30/05/2011 11:02, Terry Reedy a écrit :

On 5/30/2011 3:38 AM, Laurent wrote:


Cool. I was thinking that 5 was the name, but
 5.__add__(6)
File stdin, line 1
5.__add__(6)



Try 5 .__add__(6)


What is the rationale behind the fact to add a space between 5 and
.__add__ ?
Why does it work ?


Others have given you specific answers, here is the bigger picture.

For decades, text interpreter/compilers have generally run in two phases:
1. a lexer/tokenizer that breaks the stream of characters into tokens;
2. a parser that recognizes higher-level syntax and takes appropriate 
action.


Lexers are typically based on regular grammars and implemented as very 
simple and fast deterministic finite-state automata. In outline (leaving 
out error handling and end-of-stream handling), something like:


def lexer(stream, lookup, initial_state):
  state = initial_state
  buffer = []
  for char in stream:
state,out = lookup[state,char]
if out:
  yield output(buffer)
  # convert list of chars to token expected by parser, clear buffer
buffer += char

There is no backup and no lookahead (except for the fact that output 
excludes the current char). For python, lookup[start,'5'] == 
in_number,False, and lookup[in_number,'.'] == in_float,False.


 5..__add__(6)
11.0

works because lookup[in_float,'.'] == start,True, because buffer now 
contains a completed float ready to output and '.' signals the start of 
a new token.


I believe we read natural language text similarly, breaking it into 
words and punctuation. I believe the ability to read programs depends on 
being able to adjust the internal lexer a bit. Python is easier to read 
than some other algorithm languages because it tends to have at most one 
punctuation-like symbol unit between words, as is the case in the code 
above.


--
Terry Jan Reedy


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


3rd party tree/outline data structure module?

2011-05-30 Thread python
Before I reinvent the wheel, I'm wondering if anyone can
recommend a 3rd party tree data structure module? (I do not need
a GUI component)

I've looked at ElementTree but I think(?) need something more
flexible.

I have a parser that reads a proprietary file format which
defines an outline-like structure. (The file format is based on a
legacy product).

I need to create a tree data structure that supports the ability
to dynamically, add, delete, and move nodes/branches. I would
like the nodes to be based on my own node class.

I also need to to walk the tree structure in various ways
including given a node, find its previous and next nodes
including moving up and down branches to find the next logical
node and the ability to quickly find an element by its unique id.

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


Re: GIL in alternative implementations

2011-05-30 Thread Pascal Chambon

Thanks for the details on IronPython's implementation B-)

Hopefully Pypy will eventually get rid of its own Gil, since it doesn't 
do refcounting either.


Regards,
Pascal

Le 28/05/2011 00:52, Dino Viehland a écrit :


In IronPython we have fine grained locking on our mutable data 
structures.  In particular we have a custom dictionary type which is 
designed to allow lock-free readers on common operations while writers 
take a lock.  Our list implementation is similar but in some ways 
that's trickier to pull off due to features like slicing so if I 
recall correctly we only have lock-free reads when accessing a single 
element.


For .NET data structures they follow the .NET convention which is up 
to the data structure.  So if you wanted to get every last bit of 
performance out of your app you could handle thread safety yourself 
and switch to using the .NET dictionary or list types (although 
they're a lot less friendly to Python developers).


Because of these locks on micro-benchmarks that involve simple 
list/dict manipulations you do see noticeably worse performance in 
IronPython vs. CPython. 
http://ironpython.codeplex.com/wikipage?title=IP27A1VsCPy27PerfreferringTitle=IronPython%20Performance 
http://ironpython.codeplex.com/wikipage?title=IP27A1VsCPy27PerfreferringTitle=IronPython%20Performance 
 - See the SimpleListManipulation and SimpleDictManipulation as the 
core examples here.  Also CPython's dictionary is so heavily tuned 
it's hard to beat anyway, but this is a big factor.


Finally one of the big differences with both Jython and IronPython is 
that we have good garbage collectors which don't rely upon reference 
counting.  So one area where CPython gains from having a GIL is a 
non-issue for us as we don't need to protect ref counts or use 
interlocked operations for ref counting.


*From:* python-list-bounces+dinov=exchange.microsoft@python.org 
[mailto:python-list-bounces+dinov=exchange.microsoft@python.org] 
*On Behalf Of *Pascal Chambon

*Sent:* Friday, May 27, 2011 2:22 PM
*To:* python-list@python.org  Python List
*Subject:* GIL in alternative implementations

Hello everyone,

I've already read quite a bit about the reasons for the GIL in 
CPython, i.e to summarize, that a more-fine graine locking, allowing 
real concurrency in multithreaded applications, would bring too much 
overhead for single-threaded python applications.


However, I've also heard that other python implementations 
(ironpython, jython...) have no GIL, and yet nobody blames them for 
performance penalties that would be caused by that lack (I especially 
think about IronPython, whose performances compare quite well to CPython).


So I'd like to know: how do these other implementations handle 
concurrency matters for their primitive types, and prevent them from 
getting corrupted in multithreaded programs (if they do) ? I'm not 
only thinking about python types, but also primitive containers and 
types used in .Net and Java VMs, which aren't atomic elements either 
at an assembly-level point of view.


Do these VMs have some GIL-like limitations, that aren't spoken about 
? Are there functionings completely different from the CPython VM, so 
that the question is not relevant ? Do people consider that they 
always concern multithreaded applications, and so accept performance 
penalties that they wouldn't allow in their CPython scripts ?


I think you in advance for your lights on these questions.

Regards,

Pkl

[[ Important Note: this is a serious question, trolls and emotionally 
disturbed persons had better go on their way. ]]




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


Re: How to Use Setuptools, Alternatives?

2011-05-30 Thread dough
On May 29, 10:41 pm, ray r...@aarden.us wrote:
 I have Python 2.7 on Win7 Pro on a tightly locked down desktop.  I
 would like to install Networkx from an egg.  From what I have read,
 Setuptools can be used for this.

 I don't know how to install Setuptools.  The exe will not work.  On
 execution, it reports that the Python version is not included in the
 registry.  Further, I can not input the version and location on the
 subsequent installation screen, the fields will not accept focus so I
 can not input the values.

 Since the exe will not install, I considered using the Setuptools
 egg.  But it requires Setuptools.  It appears to be a circle.


You're right. Since Setuptools is distributed as an egg, and Python
doesn't natively support eggs,
there can be a chicken-and-egg situation.

 What are some suggestions for installing this?

 Thanks,
 ray

You can try downloading ezsetup.py and running it as a python script
(i.e. python ezsetup.py).
It will locate and download the latest version of Setuptools for your
platform and install it.
If HTTP access is blocked, just place the desired egg in the same
folder as ezsetup.py and run
the script again.

Assuming you can get Setuptools installed correctly, it puts a program
called easy_install.exe
in your python\Scripts folder. You can then just run (from the
command line):

easy_install package name

It will hunt, download and install the latest version of the package
for your platform.
You may want to add the path to the Scripts folder to your PATH
environment variable so
you can just run easy_install from any current working directory.

Hope that helps,

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


Re: Best way to compute length of arbitrary dimension vector?

2011-05-30 Thread Gabriel Genellina

En Mon, 30 May 2011 06:46:01 -0300, Peter Otten __pete...@web.de
escribió:


Gabriel wrote:


Well, the subject says it almost all: I'd like to write a small Vector
class for arbitrary-dimensional vectors.




class Vector(object):

... def __init__(self, *coords):
... self._coords = coords
... def __abs__(self):
... return math.sqrt(sum(x*x for x in self._coords))
...

import math
abs(Vector(1,1))

1.4142135623730951

abs(Vector(3,4))

5.0


Using math.fsum instead of sum may improve accuracy, specially when  
len(coords)≫2


py import math
py
py def f1(*args):
...   return math.sqrt(sum(x*x for x in args))
...
py def f2(*args):
...   return math.sqrt(math.fsum(x*x for x in args))
...
py pi=math.pi
py args=[pi]*16
py abs(f1(*args)/4 - pi)
4.4408920985006262e-16
py abs(f2(*args)/4 - pi)
0.0


--
Gabriel Genellina

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


Re: float(nan) in set or as key

2011-05-30 Thread Chris Torek
In article 4de3358b$0$29990$c3e8da3$54964...@news.astraweb.com
Steven D'Aprano  steve+comp.lang.pyt...@pearwood.info wrote:
Better than a float method is a function which takes any number as 
argument:

 import math, fractions, decimal
 math.isnan(fractions.Fraction(2, 3))
False
 math.isnan(decimal.Decimal('nan'))
True

Ah, apparently someone's been using Larry Wall's time machine. :-)

I should have looked at documentation.  In my case, though:

$ python
Python 2.5.1 (r251:54863, Dec 16 2010, 14:12:43) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type help, copyright, credits or license for more information.
 import math
 math.isnan
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'module' object has no attribute 'isnan'

You can even handle complex NANs with the cmath module:

 import cmath
 cmath.isnan(complex(1, float('nan')))
True

Would it be appropriate to have isnan() methods for Fraction,
Decimal, and complex, so that you do not need to worry about whether
to use math.isnan() vs cmath.isnan()?  (I almost never work with
complex numbers so am not sure if the or behavior -- cmath.isinf
and cmath.isnan return true if either real or complex part are
Infinity or NaN respectively -- is appropriate in algorithms that
might be working on any of these types of numbers.)

It might also be appropriate to have trivial always-False isinf and
isnan methods for integers.
-- 
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W)  +1 801 277 2603
email: gmail (figure it out)  http://web.torek.net/torek/index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-30 Thread Rikishi42
On 2011-05-28, Chris Angelico ros...@gmail.com wrote:
 I think it's geographic. This list covers a lot of geography; I'm in
 Australia, there are quite a few Brits, and probably the bulk of posts
 come from either the US or Europe. (And yes, I did deliberately fold
 all of Europe down to one entity, and I did also deliberately leave
 Great Britain out of that entity.)

I allways found that odd. Especially if you're talking geography, not
politics. I can understand they want to be seen as independant, even they
are in it enough to allways opose anything someone else suggests.  :-)

To me, saying the UK isn't part of Europe, is like saying Japan isn't part
of Asia. Oh by the way, I'm Belgian.


 Most things work out that way. A thing gets a name based either on its
 implementation or on the brand name of the first/most popular one. If
 the only microwave oven ever produced had been made by Foobar Corp,
 and that company were not known for anything else, then quite possibly
 everyone would call them foobar ovens.

Yeah, when I was a kid a photo camera was called a Kodak.



-- 
When in doubt, use brute force.
-- Ken Thompson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-30 Thread Rikishi42
On 2011-05-28, Chris Angelico ros...@gmail.com wrote:
 Chris Angelico
 yes, bit of a Bible geek as well as a programming geek

So you don't believe in genetic algorithms, then ?


(ducking for cover)



-- 
When in doubt, use brute force.
-- Ken Thompson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to catch a line with Popen

2011-05-30 Thread Chris Torek
Chris Torek wrote:
 In at least some versions of Python 2
[the file-type object iterators behave badly with pipes]

(This may still be true in Python 3, I just have no experience with
Py3k.  At least some version of Python 2 means the ones I have
access to, and have tried. :-) )

In article is0d44$d7m$1...@speranza.aioe.org
TheSaint  nob...@nowhere.net.no wrote:
I'm with P3k :P. However thank you for your guidelines.
Last my attempt was to use a *for* p.wait() , as mentioned earlier

If you have a process that has not yet terminated and that you
must stop from your own python program, calling the wait() method
will wait forever (because you are now waiting for yourself, in
effect -- waiting for yourself to terminate the other process).

The only time to call p.wait() (or p.communicate(), which itself
calls the wait() method) is when you believe the subprocess is
on its wao to terminating -- in this case, after you force it
to do so.

That looks good enough. I noted some little delay for the first lines, 
mostly sure Popen assign some buffer even it is not set.

According to the documentation, the default buffer size of Python 2
is 0, which is passed to fdopen() and makes the resulting files
unbuffered.  I recall some sort of changes discussed for Py3k though.

Haven't you try a perpetual ping, how would be the line_at_a_time ?

Since it is a generator that only requests another line when called,
it should be fine.  (Compare to the itertools cycle and repeat
generators, for instance, which return an infinite sequence.)
-- 
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W)  +1 801 277 2603
email: gmail (figure it out)  http://web.torek.net/torek/index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


sqlalchemy and Unicode strings: errormessage

2011-05-30 Thread Wolfgang Meiners
Hi,

I am trying to build an application using sqlalchemy.

in principle i have the structure

#==

from sqlalchemy import *
from sqlalchemy.orm import *

metadata = MetaData('sqlite://')
a_table = Table('tf_lehrer', metadata,
Column('id', Integer, primary_key=True),
Column('Kuerzel', Text),
Column('Name', Text))

A_class = Class(object):
def __init__(self, Kuerzel, Name)
self.Kuerzel=Kuerzel
self.Name=Name

mapper(A_class, a_table)

A_record = A_class('BUM', 'Bäumer')

Session = sessionmaker()
session = Session()

session.add(A_record)

session.flush()

#

At this time it runs to the line

session.flush()

where i get the following errormessage:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) You must not use
8-bit bytestrings unless you use a text_factory that can interpret 8-bit
bytestrings (like text_factory = str). It is highly recommended that you
instead just switch your application to Unicode strings. u'INSERT INTO
tf_lehrer (Kuerzel, Name) VALUES (?, ?)' ('BUM', 'B\xc3\xa4umer')

but where can i switch my  application to Unicode strings?

Thank you for all hints
Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python in school notebooks/laptops

2011-05-30 Thread Irmen de Jong
On 30-5-2011 16:30, jmfauth wrote:
 On 30 mai, 13:09, hackingKK hackin...@gmail.com wrote:
 
 [...]
 

 Even better, try convincing them to use Ubuntu instead of  a virus
 called Where I Never Do Operations With Safety, or WINDOWS for short.
 That way Python will come by default  and VB will be out of question
 Happy hacking.
 Krishnakant.
 
 Do you mean one of these os's, where Python (2) is not
 working properly because the *defaultencoding* is set
 to utf-8?
 
 jmf

Huh? On all of my machines, including windows and Ubuntu 11.04, 
sys.getdefaultencoding()
returns 'ascii'.

Irmen



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


Pydev 2.1.0 Released

2011-05-30 Thread Fabio Zadrozny
Hi All,

Pydev 2.1.0 has been released

Details on Pydev: http://pydev.org
Details on its development: http://pydev.blogspot.com

Release Highlights:
---


Code Analysis

By default, only the currently opened editor will be analyzed
(resulting in much shorter build times).
Added action to force the analysis on a given folder or file.
Showing error markers for PyDev elements in the tree.
New option to remove error markers when the editor is closed (default).

Editor

Override method completions (Ctrl+Space after a 'def ') .
Completions starting with '_' now have lower priority.
Fixed major issue when replacing markers which could make errors
appear when they shouldn't appear anymore
Auto-linking on close parens is now optional (and disabled by default).

Code coverage

No longer looses the selection on a refresh.
Fixed issue where coverage was not working properly when running
with multiple processes.
Added orientation options

PyUnit

Added feature to relaunch the last launch when file changes (with
option to relaunch only errors).
setUpClass was not called when running with the pydev test runner
F12 makes the editor active even if there's a tooltip active in
the PyUnit view.
The PyUnit tooltip is now properly restoring the focus of the
previous active control.
Added orientation options

And a bunch of other bug-fixes.


Note: Java 1.4 is no longer supported (at least Java 5 is required now).



What is PyDev?
---

PyDev is a plugin that enables users to use Eclipse for Python, Jython
and IronPython development -- making Eclipse a first class Python IDE
-- It comes with many goodies such as code completion, syntax
highlighting, syntax analysis, refactor, debug and many others.


Cheers,

-- 
Fabio Zadrozny
--
Software Developer

Appcelerator
http://appcelerator.com/

Aptana
http://aptana.com/

Pydev - Python Development Environment for Eclipse
http://pydev.org
http://pydev.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 23:04:41 +0200, Rikishi42 wrote:

 On 2011-05-28, Chris Angelico ros...@gmail.com wrote:
 I think it's geographic. This list covers a lot of geography; I'm in
 Australia, there are quite a few Brits, and probably the bulk of posts
 come from either the US or Europe. (And yes, I did deliberately fold
 all of Europe down to one entity, and I did also deliberately leave
 Great Britain out of that entity.)
 
 I allways found that odd. Especially if you're talking geography, not
 politics. I can understand they want to be seen as independant, even
 they are in it enough to allways opose anything someone else suggests. 
 :-)
 
 To me, saying the UK isn't part of Europe, is like saying Japan isn't
 part of Asia. Oh by the way, I'm Belgian.

In my experience, the Japanese have the same attitude towards Asia as the 
British have towards Europe: they will claim membership, or deny it, 
depending on whichever suits their mood at the time.


 Most things work out that way. A thing gets a name based either on its
 implementation or on the brand name of the first/most popular one. If
 the only microwave oven ever produced had been made by Foobar Corp, and
 that company were not known for anything else, then quite possibly
 everyone would call them foobar ovens.
 
 Yeah, when I was a kid a photo camera was called a Kodak.

Sometimes brand names do become generic. Personal Computer once was a 
specific IBM model, not just a description. Elevator and escalator were 
once brandnames. In some parts of the southern USA, coke is used as a 
word for any softdrink, not just Coca Cola.


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


Re: float(nan) in set or as key

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 19:58:35 +, Chris Torek wrote:

 In article 4de3358b$0$29990$c3e8da3$54964...@news.astraweb.com Steven
 D'Aprano  steve+comp.lang.pyt...@pearwood.info wrote:
Better than a float method is a function which takes any number as
argument:

 import math, fractions, decimal
 math.isnan(fractions.Fraction(2, 3))
False
 math.isnan(decimal.Decimal('nan'))
True
 
 Ah, apparently someone's been using Larry Wall's time machine. :-)

He has one too? Just like Guido van Rossum.

 
 I should have looked at documentation.  In my case, though:
 
 $ python
 Python 2.5.1 (r251:54863, Dec 16 2010, 14:12:43) [GCC 4.0.1 (Apple
 Inc. build 5465)] on darwin Type help, copyright, credits or
 license for more information.


Python 2.5 is two major releases behind! I feel your pain, though, 
because 2.5 is the system python on my desktop as well. (And 2.4 is the 
system python on my server, ouch!)

You should consider installing 2.7 and/or 3.2 in parallel with the system 
python.


 Would it be appropriate to have isnan() methods for Fraction, Decimal,
 and complex, so that you do not need to worry about whether to use
 math.isnan() vs cmath.isnan()?

Probably not. From a purely object-oriented, Java-esque viewpoint, yes, 
all number types should support isnan and isinf methods, but Python uses 
a more mixed style, and a function that accepts multiple types is 
appropriate.

Unless you're using complex numbers, you don't need to care about complex 
numbers. *wink* Hence for normal numeric use, stick to the math module. 
If you do need complex numbers, cmath.isnan works perfectly fine with non-
complex arguments:

 cmath.isnan(42)
False
 cmath.isnan(float('nan'))
True


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


Re: scope of function parameters (take two)

2011-05-30 Thread Henry Olders

On 2011-05-29, at 4:30 , Henry Olders wrote:

 I just spent a considerable amount of time and effort debugging a program. 
 The made-up code snippet below illustrates the problem I encountered:
 
 def main():
   a = ['a list','with','three elements']
   print a
   print fnc1(a)
   print a
   
 def fnc1(b):
   return fnc2(b)
 
 def fnc2(c):
   c[1] = 'having'
   return c
 
 This is the output:
 ['a list', 'with', 'three elements']
 ['a list', 'having', 'three elements']
 ['a list', 'having', 'three elements']
 
 I had expected the third print statement to give the same output as the 
 first, but variable a had been changed by changing variable c in fnc2.
 
 It seems that in Python, a variable inside a function is global unless it's 
 assigned. This rule has apparently been adopted in order to reduce clutter by 
 not having to have global declarations all over the place.
 
 I would have thought that a function parameter would automatically be 
 considered local to the function. It doesn't make sense to me to pass a 
 global to a function as a parameter.
 
 One workaround is to call a function with a copy of the list, eg in fnc1 I 
 would have the statement return fnc2(b[:]. But this seems ugly.
 
 Are there others who feel as I do that a function parameter should always be 
 local to the function? Or am I missing something here?
 

My thanks to all the people who responded - I've learned a lot. Sadly, I feel 
that the main issue that I was trying to address, has not been dealt with. 
Perhaps I didn't explain myself properly; if so, my apologies.

I am trying to write python programs in a more-or-less functional programming 
mode, ie functions without side effects (except for print statements, which are 
very helpful for debugging). This is easiest when all variables declared in 
functions are local in scope (it would also be nice if variables assigned 
within certain constructs such as for loops and list comprehensions were local 
to that construct, but I can live without  it). 

It appears, from my reading of the python documentation, that a deliberate 
decision was made to have variables that are referenced but not assigned in a 
function, have a global scope. I quote from the python FAQs: In Python, 
variables that are only referenced inside a function are implicitly global. If 
a variable is assigned a new value anywhere within the function’s body, it’s 
assumed to be a local. If a variable is ever assigned a new value inside the 
function, the variable is implicitly local, and you need to explicitly declare 
it as ‘global’.
Though a bit surprising at first, a moment’s consideration explains this. On 
one hand, requiring global for assigned variables provides a bar against 
unintended side-effects. On the other hand, if global was required for all 
global references, you’d be using global all the time. You’d have to declare as 
global every reference to a built-in function or to a component of an imported 
module. This clutter would defeat the usefulness of the global declaration for 
identifying side-effects. (http://docs.python.org/faq/programming.html)

This suggests that the decision to make unassigned (ie free variables) have a 
global scope, was made somewhat arbitrarily to  prevent clutter. But I don't 
believe that the feared clutter would materialize. My understanding is that 
when a variable is referenced, python first looks for it in the function's 
namespace, then the module's, and finally the built-ins. So why would it be 
necessary to declare references to built-ins as globals?

What I would like is that the variables which are included in the function 
definition's parameter list, would be always treated as local to that function 
(and of course, accessible to nested functions) but NOT global unless 
explicitly defined as global. This would prevent the sort of problems that I 
encountered as described in my original post. I may be wrong here, but it seems 
that the interpreter/compiler should be able to deal with this, whether the 
parameter passing is by value, by reference, by object reference, or something 
else. If variables are not assigned (or bound) at compile time, but are 
included in the parameter list, then the binding can be made at runtime.
And I am NOT talking about variables that are only referenced in the body of a 
function definition; I am talking about parameters (or arguments) in the 
function's parameter list. As I stated before, there is no need to include a 
global variable in a parameter list, and if you want to have an effect outside 
of the function, that's what the return statement is for.

I don't believe I'm the only person who thinks this way. Here is a quote from 
wikipedia: It is considered good programming practice to make the scope of 
variables as narrow as feasible so that different parts of a program do not 
accidentally interact with each other by modifying each other's variables. 
Doing so also prevents action at a 

Re: Beginner needs advice

2011-05-30 Thread harrismh777

Steven D'Aprano wrote:


 LOL


I invite you to consider the difference between a legally dead person
moments before being resuscitated by a paramedic,


   ( ... alive )


versus a chicken that
has just been beheaded and is still running around the yard,


   ( ... alive )


versus a
million-year-old fossilized bone that has turned to stone.


   ( ... mostly 'dead' )


Who could
possibly justify saying that all three are equally dead?


   LOL( the first two [ roflol ] are 'partly' alive... )

  (  the third is just mostly dead...  )




Beware the tyranny of the discontinuous mind.



Sic Semper Tyrannus !




Compatibility is inherently continuous, a matter
of degree.


   Compatible by degrees is incompatible. Just 'how' incompatible 
determines whether the factor(s) are utterly useless, or just difficult 
to negotiate.


(uh, oh,... me suspects another analogy fallacy coming up... )


This is especially true when it comes to languages, both natural and
programming.


( Yup...  analogy fallacy for Ænglisc speakers... )


British English and American English are perhaps 99.5%
compatible, but table a motion means completely opposite things in
British and American English. (In Britain, it means to deal with it
immediately; in the USA, it means to postpone it.) Should we conclude
from this that British and American English are different languages and
completely incompatible?


   We Americans have not spoken 'English' in well over two hundred 
years...   :)  roflol


   However, I guarantee that if I'm dumped unaided in Piccadilly I'll 
be able to hail a cab, pay my £12.00 and get myself to Liverpool Street 
Station, find the bathroom, and be on the correct train just in time for 
dinner, all without looking into the English dictionary.
   On the other hand (playing along with this analogy fallacy) if I 
dump a python newbie unaided in the middle of 2.5 and ask them to format 
a simple polytonic Greek unicode string and output it with print to 
stdout (redirected to a file) they will fail... maybe even if they have 
a dictionary !




The differences between Python 2 and 3 are less than those between
American and British English.


   absurd and unsubstantiated claim... quickly now call the bobbies, 
call the bobbies !!!


To describe them as different languages,

as if going from Python 2 to 3 was like translating English to Italian,
is absurd.


   ... no, um, its more like migrating ye old Ænglisc...  (the Ænglisc 
of say, Beowulf ) to modern English  still assuming the English 
analogy fallacy holds... which,... it doesn't...



Ever tried to read Beowulf in the original?  Ever tried to write Ænglisc ?






kind regards,
m harris


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


Re: Beginner needs advice

2011-05-30 Thread harrismh777

Ian Kelly wrote:

You have just misrepresented Steven's argument, which is rather ironic
considering that you're the one who brought up straw-men.  Steven did
not use one code snippet to demonstrate that Python 2 and Python 3 are
fully compatible.  The code snippet merely demonstrated that Python 2
and 3 are not totally incompatible as you had claimed.


   Ian gets the Christmas turkey for pinning the irony on me fair 'n 
square...  'demonstrating' the straw-man is intimately and infinitely 
more delicious than just defining it... besides, the tables must be 
turned me thinks...:)




I realize you are now asserting that compatibility is a boolean
condition, and that totally incompatible is a redundant phrase that
you tossed out as a joke.  I don't know whether you're sincere or
backpedaling, but in any case this assertion is flatly ludicrous.
Following your definition,*nothing*  is compatible with anything else.
  If you disagree, then I invite you to list one example of two
different things that are compatible.


   one man, and one woman



And finally, . . . you
seem to view all analogies as false) regardless of what that person
actually said


   ... all analogies are argumentative fallacy. Now, the analogy event 
(or ontological state of the analogy) may in fact be true... but that 
event or state can *never* be used to assert truth in 'different event' 
or fact of 'another state' as the 'same thing(s)'.


   The truth or fallacy of an argument should never be asserted by the 
use of an analogy regardless how well the analogy illustrates the point. 
Some folks believe that a good illustration of a point can be used to 
prove the point true (or false), when in fact the illustration (the 
analogy event) is often nothing more than entertaining explanation 
(Steven's are some of the best, I admit !)


-- even if that person does*sometimes*  actually commit

those fallacies -- then you yourself are employing an ad hominem.



   ... oh ho ho... lol   yes...   again... guilty as charged.



kind regards,
m harris



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


Re: Beginner needs advice

2011-05-30 Thread harrismh777

Jason Tackaberry wrote:

At least,
his arguments make more sense if I read him as arguing from the not
completely compatible position.  It's possible he is intentionally
equivocating for dramatic effect.



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


Re: scope of function parameters (take two)

2011-05-30 Thread Benjamin Kaplan
On Mon, May 30, 2011 at 5:28 PM, Henry Olders henry.old...@mcgill.ca wrote:

 On 2011-05-29, at 4:30 , Henry Olders wrote:

 I just spent a considerable amount of time and effort debugging a program. 
 The made-up code snippet below illustrates the problem I encountered:

 def main():
       a = ['a list','with','three elements']
       print a
       print fnc1(a)
       print a

 def fnc1(b):
       return fnc2(b)

 def fnc2(c):
       c[1] = 'having'
       return c

 This is the output:
 ['a list', 'with', 'three elements']
 ['a list', 'having', 'three elements']
 ['a list', 'having', 'three elements']

 I had expected the third print statement to give the same output as the 
 first, but variable a had been changed by changing variable c in fnc2.

 It seems that in Python, a variable inside a function is global unless it's 
 assigned. This rule has apparently been adopted in order to reduce clutter 
 by not having to have global declarations all over the place.

 I would have thought that a function parameter would automatically be 
 considered local to the function. It doesn't make sense to me to pass a 
 global to a function as a parameter.

 One workaround is to call a function with a copy of the list, eg in fnc1 I 
 would have the statement return fnc2(b[:]. But this seems ugly.

 Are there others who feel as I do that a function parameter should always be 
 local to the function? Or am I missing something here?


 My thanks to all the people who responded - I've learned a lot. Sadly, I feel 
 that the main issue that I was trying to address, has not been dealt with. 
 Perhaps I didn't explain myself properly; if so, my apologies.

 I am trying to write python programs in a more-or-less functional programming 
 mode, ie functions without side effects (except for print statements, which 
 are very helpful for debugging). This is easiest when all variables declared 
 in functions are local in scope (it would also be nice if variables assigned 
 within certain constructs such as for loops and list comprehensions were 
 local to that construct, but I can live without  it).

 It appears, from my reading of the python documentation, that a deliberate 
 decision was made to have variables that are referenced but not assigned in a 
 function, have a global scope. I quote from the python FAQs: In Python, 
 variables that are only referenced inside a function are implicitly global. 
 If a variable is assigned a new value anywhere within the function’s body, 
 it’s assumed to be a local. If a variable is ever assigned a new value inside 
 the function, the variable is implicitly local, and you need to explicitly 
 declare it as ‘global’.
 Though a bit surprising at first, a moment’s consideration explains this. On 
 one hand, requiring global for assigned variables provides a bar against 
 unintended side-effects. On the other hand, if global was required for all 
 global references, you’d be using global all the time. You’d have to declare 
 as global every reference to a built-in function or to a component of an 
 imported module. This clutter would defeat the usefulness of the global 
 declaration for identifying side-effects. 
 (http://docs.python.org/faq/programming.html)

 This suggests that the decision to make unassigned (ie free variables) have 
 a global scope, was made somewhat arbitrarily to  prevent clutter. But I 
 don't believe that the feared clutter would materialize. My understanding is 
 that when a variable is referenced, python first looks for it in the 
 function's namespace, then the module's, and finally the built-ins. So why 
 would it be necessary to declare references to built-ins as globals?

 What I would like is that the variables which are included in the function 
 definition's parameter list, would be always treated as local to that 
 function (and of course, accessible to nested functions) but NOT global 
 unless explicitly defined as global. This would prevent the sort of problems 
 that I encountered as described in my original post. I may be wrong here, but 
 it seems that the interpreter/compiler should be able to deal with this, 
 whether the parameter passing is by value, by reference, by object reference, 
 or something else. If variables are not assigned (or bound) at compile time, 
 but are included in the parameter list, then the binding can be made at 
 runtime.
 And I am NOT talking about variables that are only referenced in the body of 
 a function definition; I am talking about parameters (or arguments) in the 
 function's parameter list. As I stated before, there is no need to include a 
 global variable in a parameter list, and if you want to have an effect 
 outside of the function, that's what the return statement is for.

 I don't believe I'm the only person who thinks this way. Here is a quote from 
 wikipedia: It is considered good programming practice to make the scope of 
 variables as narrow as feasible so that different parts of a program do not 
 

Re: python in school notebooks/laptops

2011-05-30 Thread harrismh777

Chris Angelico wrote:

 Is it a waste of time to try to get school admins to put python in
  their school laptops?


   No, absolutely no...  Python advocacy is necessary in this venue !


Possibly the best way to encourage Python deployment would be to
require it to run some internal script.


   Chris has a great idea here... but I think more along the lines of 
an app that benefits school admins in terms of networking registration, 
accountability, or messaging. In other words, if I understand Chris 
correctly, make the script / app  necessarily useful to the admins you 
are trying to advocate to, so that the students reap the benefits of 
having the interpretor installed and ready...?!?


   Great idea...





kind regards,
m harris
--
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner needs advice

2011-05-30 Thread Rhodri James
On Tue, 31 May 2011 01:32:01 +0100, harrismh777 harrismh...@charter.net  
wrote:



Steven D'Aprano wrote:

Compatibility is inherently continuous, a matter
of degree.


Compatible by degrees is incompatible. Just 'how' incompatible  
determines whether the factor(s) are utterly useless, or just difficult  
to negotiate.


(uh, oh,... me suspects another analogy fallacy coming up... )


This is especially true when it comes to languages, both natural and
programming.


 ( Yup...  analogy fallacy for Ænglisc speakers... )


I don't know about you, but I speak English not Anglish.  This is how an  
aesc is pronounced, after all.



British English and American English are perhaps 99.5%
compatible, but table a motion means completely opposite things in
British and American English. (In Britain, it means to deal with it
immediately; in the USA, it means to postpone it.) Should we conclude
from this that British and American English are different languages  
and

completely incompatible?


We Americans have not spoken 'English' in well over two hundred  
years...   :)  roflol


Quite the contrary, in fact.  Much American usage of English actually  
better preserves the styles of eighteenth century English usage, having  
managed to avoid some of the corrections of Victorian grammarians.


However, I guarantee that if I'm dumped unaided in Piccadilly I'll  
be able to hail a cab, pay my £12.00 and get myself to Liverpool Street  
Station, find the bathroom, and be on the correct train just in time for  
dinner, all without looking into the English dictionary.


And I guarantee that you'd get odd looks for at least one of those.  You  
may not notice; we Brits are used to translating the large amount of US TV  
we get back into British English.


On the other hand (playing along with this analogy fallacy) if I  
dump a python newbie unaided in the middle of 2.5 and ask them to format  
a simple polytonic Greek unicode string and output it with print to  
stdout (redirected to a file) they will fail... maybe even if they have  
a dictionary !


Now this is an analogy fallacy, and an obvious one at that.

--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters (take two)

2011-05-30 Thread Daniel Kluev
On Tue, May 31, 2011 at 11:28 AM, Henry Olders henry.old...@mcgill.ca wrote:
 What I would like is that the variables which are included in the function 
 definition's parameter list, would be always treated as local to that function

You still mis-reading docs and explanations you received from the list.
Let me try again.

First, there are objects and names. Calling either of them as
'variables' is leading to this mis-understanding. Name refers to some
object. Object may be referenced by several names or none.

Second, when you declare function `def somefunc(a, b='c')` a and b are
both local to this function. Even if there are some global a and b,
they are 'masked' in somefunc scope.
Docs portion you cited refer to other situation, when there is no
clear indicator of 'locality', like this:

def somefunc():
 print a

In this - and only in this - case a is considered global.

Third, when you do function call like somefunc(obj1, obj2) it uses
call-by-sharing model. It means that it assigns exactly same object,
that was referenced by obj1, to name a. So both obj1 and _local_ a
reference same object. Therefore when you modify this object, you can
see that obj1 and a both changed (because, in fact, obj1 and a are
just PyObject*, and point to exactly same thing, which changed).

However, if you re-assign local a or global obj1 to other object,
other name will keep referencing old object:

obj1 = []

def somefunc(a):
 a.append(1) # 'a' references to the list, which is referenced by
obj1, and calls append method of this list, which modifies itself in
place
 global obj1
 obj1 = [] # 'a' still references to original list, which is [1]
now, it have no relation to obj1 at all

somefunc(obj1)

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python in school notebooks/laptops

2011-05-30 Thread Terry Reedy

On 5/30/2011 6:15 PM, Irmen de Jong wrote:


Do you mean one of these os's, where Python (2) is not
working properly because the *defaultencoding* is set
to utf-8?



Huh? On all of my machines, including windows and Ubuntu 11.04, 
sys.getdefaultencoding()
returns 'ascii'.


For me, WINXP, 2.7
 sys.getdefaultencoding()
'ascii'

winxp, 3.2:
 sys.getdefaultencoding()
'utf-8'

Both are what one would want.

--
Terry Jan Reedy

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


Re: Beginner needs advice

2011-05-30 Thread Ian Kelly
On Mon, May 30, 2011 at 6:43 PM, harrismh777 harrismh...@charter.net wrote:
 I realize you are now asserting that compatibility is a boolean
 condition, and that totally incompatible is a redundant phrase that
 you tossed out as a joke.  I don't know whether you're sincere or
 backpedaling, but in any case this assertion is flatly ludicrous.
 Following your definition,*nothing*  is compatible with anything else.
  If you disagree, then I invite you to list one example of two
 different things that are compatible.

   one man, and one woman

Now you're equivocating.  The discussion has been about whether Python
2 and Python 3 are compatible in the interchangeable sense, not in
the capable of functioning together sense.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters (take two)

2011-05-30 Thread Terry Reedy

On 5/30/2011 8:28 PM, Henry Olders wrote:



Sadly, I feel that the main issue that I was trying to address, has
not been dealt with.


False. Please go back and read what I and others wrote before.

...

What I would like is that the variables which are included in the
function definition's parameter list, would be always treated as
local to that function (and of course, accessible to nested
functions)


You would like Python to be the way it is. Fine. For the Nth time,
PARAMATER NAMES ARE LOCAL NAMES. Period.


but NOT global unless explicitly defined as global.


PARAMETER NAMES **CANNOT** BE DEFINED AS GLOBAL.

 def f(a):
global a

SyntaxError: name 'a' is parameter and global

Again, go back and reread what I and other wrote. I believe that you 
are, in part, hypnotized by the work 'variable'. Can you define the 
word? There are 10 to 20 possible variations, and yours is probably 
wrong for Python.



quote from wikipedia: It is considered good programming practice to
make the scope of variables as narrow as feasible so that different
parts of a program do not accidentally interact with each other by
modifying each other's variables.


From 'import this':
Namespaces are one honking great idea -- let's do more of those!
Python is loaded with namespaces.

 Doing so also prevents action at a

distance. Common techniques for doing so are to have different
sections of a program use different namespaces, or to make individual
variables private through either dynamic variable scoping or
lexical variable scoping.
(http://en.wikipedia.org/wiki/Variable_(programming)#Scope_and_extent).


Python is lexically scoped.


another quote from the wikipedia entry for Common Lisp: the use of
lexical scope isolates program modules from unwanted interactions.


Python is lexically scoped.


If making python behave this way is impossible,


How do you expect us to respond when you say Please make Python the way 
it is.? Or is you say If making Python the way it is is impossible...?


Now, if you actually want Python to drastically change its mode of 
operation and break most existing programs, do not bother asking.


 Are there others who feel as I do that a

function parameter should always be local to the function?


Yes, we all do, and they are.

--
Terry Jan Reedy

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


Re: Beginner needs advice

2011-05-30 Thread Terry Reedy

On 5/30/2011 8:32 PM, harrismh777 wrote:


Ever tried to read Beowulf in the original? Ever tried to write Ænglisc ?


I have, and it is a lot further from modern American than Python 2 and 3 
are from each other.


--
Terry Jan Reedy


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


Re: Beginner needs advice

2011-05-30 Thread Terry Reedy

On 5/30/2011 8:32 PM, harrismh777 wrote:



However, I guarantee that if I'm dumped unaided in Piccadilly I'll be
able to hail a cab, pay my £12.00 and get myself to Liverpool Street
Station, find the bathroom, and be on the correct train just in time for
dinner, all without looking into the English dictionary.


Because natural language is redundant and most speakers are forgiving, 
while computer language are stripped on much redundancy and their 
interpreters tend to be unforgiving, so a single missing comma or space 
can raise a SyntaxError. Python is designed to do so, and allow/require 
correction, rather than guess and go on.


This is not so bad; what if the cabbie does not understand you but say 
OK, guesses the destination, ignores any protestations, and asks for £30 
at the wrong destination. Following people who deafly say OK and take 
you whereever is a real hazard in some countries. Some tourist guides 
even warn about the practice.


Anyway, 'L i v e r p o o l   S t r e e t   S t a t i o n' is such a 
trivial utterance as to not be comparable to anything as complicated as 
a typical 5-line function.


--
Terry Jan Reedy


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


Re: scope of function parameters (take two)

2011-05-30 Thread Daniel Kluev
On Tue, May 31, 2011 at 12:30 PM, Terry Reedy tjre...@udel.edu wrote:
 Again, go back and reread what I and other wrote. I believe that you are, in
 part, hypnotized by the work 'variable'. Can you define the word? There are
 10 to 20 possible variations, and yours is probably wrong for Python.

On a sidenote, I wonder what is the reason to keep word 'variable' in
python documentation at all. I believe word 'name' represents concept
better, and those, who come from other languages, would be less likely
to associate wrong definitions with it.

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner needs advice

2011-05-30 Thread Chris Angelico
On Tue, May 31, 2011 at 11:16 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Mon, May 30, 2011 at 6:43 PM, harrismh777 harrismh...@charter.net wrote:
  If you disagree, then I invite you to list one example of two
 different things that are compatible.

   one man, and one woman

 Now you're equivocating.  The discussion has been about whether Python
 2 and Python 3 are compatible in the interchangeable sense, not in
 the capable of functioning together sense.

Indeed. If a man has a scripting language, and a woman has a scripting
language, the two would differ because there are things each can do
that the other cannot. But there's a lot of things that both can do,
so the two languages would be highly similar in purpose and
functionality.

Hmm. If you did write those two scripting languages, we would finally
be able to type man woman to get docs on how to talk to women...

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


Re: python in school notebooks/laptops

2011-05-30 Thread Chris Angelico
On Tue, May 31, 2011 at 10:57 AM, harrismh777 harrismh...@charter.net wrote:
 Chris Angelico wrote:
 Possibly the best way to encourage Python deployment would be to
 require it to run some internal script.

   Chris has a great idea here... but I think more along the lines of an app
 that benefits school admins in terms of networking registration,
 accountability, or messaging. In other words, if I understand Chris
 correctly, make the script / app  necessarily useful to the admins you are
 trying to advocate to, so that the students reap the benefits of having the
 interpretor installed and ready...?!?

Precisely. If there is some kind of need for a script to be deployed
on all students' laptops (even if it's just part of some installer,
and not necessary post-setup), then write it in Python and put the
interpreter on there. This is not shenanigans, but simply the use of a
quality tool; it's no different from the eComStation installers making
extensive use of VX-REXX, and thus mandating its installation as part
of the eCS install.

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


Re: Beginner needs advice

2011-05-30 Thread harrismh777

Chris Angelico wrote:

Hmm. If you did write those two scripting languages, we would finally
be able to type man woman to get docs on how to talk to women...


   Which just wouldn't be fair, because her use of  man man  would lead 
her no closer to understanding how men speak... (er, think, um... )



:)









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


Re: scope of function parameters (take two)

2011-05-30 Thread Chris Angelico
On Tue, May 31, 2011 at 10:28 AM, Henry Olders henry.old...@mcgill.ca wrote:
 I don't believe I'm the only person who thinks this way. Here is a quote from 
 wikipedia: It is considered good programming practice to make the scope of 
 variables as narrow as feasible so that different parts of a program do not 
 accidentally interact with each other by modifying each other's variables. 
 Doing so also prevents action at a distance. Common techniques for doing so 
 are to have different sections of a program use different namespaces, or to 
 make individual variables private through either dynamic variable scoping 
 or lexical variable scoping. 
 (http://en.wikipedia.org/wiki/Variable_(programming)#Scope_and_extent).


Side point, on variable scope.

There is a philosophical split between declaring variables and not
declaring them. Python is in the latter camp; you are not required to
put int a; char *b; float c[4]; before you use the integer, string,
and list/array variables a, b, and c. This simplifies code
significantly, but forces the language to have an unambiguous scoping
that doesn't care where you assign to a variable.

Example:

def f():
  x=1  # x is function-scope
  if cond: # cond is global
x=2 # Same function-scope x as above
  print(x) # Function-scope, will be 2 if cond is true

This is fine, and is going to be what you want. Another example:

def f():
  print(x) # global
  #  way down, big function, you've forgotten what you're doing
for x in list_of_x:
  x.frob()

By using x as a loop index, you've suddenly made it take function
scope, which stops it from referencing the global. Granted, you
shouldn't be using globals with names like 'x', but it's not hard to
have duplication of variable names. As a C programmer, I'm accustomed
to being able to declare a variable in an inner block and have that
variable cease to exist once execution leaves that block; but that
works ONLY if you declare the variables where you want them.

Infinitely-nested scoping is simply one of the casualties of a
non-declarative language.

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


Re: scope of function parameters (take two)

2011-05-30 Thread Daniel Kluev
On Tue, May 31, 2011 at 2:05 PM, Chris Angelico ros...@gmail.com wrote:
 Infinitely-nested scoping is simply one of the casualties of a
 non-declarative language.

Well, this is not accurate, as you can have 'infinitely-nested
scoping' in python, in form of nested functions. For example, you can
use map(lambda x: expressions with x, including other
map/filter/reduce/lambda's, list_of_x), and you will have your
isolated scopes. Although due to lambdas supporting only expressions,
following this style leads to awkward and complicated code (and/or
instead if, map instead for, and so on).


-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters (take two)

2011-05-30 Thread Chris Angelico
On Tue, May 31, 2011 at 1:18 PM, Daniel Kluev dan.kl...@gmail.com wrote:
 On Tue, May 31, 2011 at 2:05 PM, Chris Angelico ros...@gmail.com wrote:
 Infinitely-nested scoping is simply one of the casualties of a
 non-declarative language.

 Well, this is not accurate, as you can have 'infinitely-nested
 scoping' in python, in form of nested functions. For example, you can
 use map(lambda x: expressions with x, including other
 map/filter/reduce/lambda's, list_of_x), and you will have your
 isolated scopes. Although due to lambdas supporting only expressions,
 following this style leads to awkward and complicated code (and/or
 instead if, map instead for, and so on).

That's an incredibly messy workaround, and would get ridiculous if you
tried going many levels in. It's like saying that a C-style 'switch'
statement can be implemented in Python using a dictionary of
lambdas... and then trying to implement fall-through. But you're
right; a lambda does technically create something of a nested scope -
albeit one in which the only internal variables are its parameters.

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


pydev ant build

2011-05-30 Thread prakash jp
Hi all,

Could any one provide relevant url/s on the usage of *pyant* scripts and its
setup as well

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


Re: scope of function parameters (take two)

2011-05-30 Thread Dan Stromberg
On Mon, May 30, 2011 at 5:28 PM, Henry Olders henry.old...@mcgill.cawrote:

 What I would like is that the variables which are included in the function
 definition's parameter list, would be always treated as local to that
 function (and of course, accessible to nested functions) but NOT global
 unless explicitly defined as global.


If you don't want any globals other than callables and modules and builtins,
then don't define any.  I normally code that way, other than an infrequent
(EG) HAVE_CSTRINGIO global or similar (which is module-global, not
program-global) - that is, for variables describing what sorts of optional
modules are available.

Be careful not to conflate global scoping or global lifetime, with
mutability or pure, side-effect-free functions (callables).  It sounds like
what you want is immutability and/or freedom from side effects, which is
found most often in (pure) functional languages - which is not what Python
is, nor does it attempt to be so.

In Python, and in many other languages, if you pass a scalar (or more
generally, an object of an immutable type) to a function, and then change
the scalar in that function, you only change the scalar within that
function, not within the caller.

However, if you pass an aggregate type like a list (array) or dictionary
(hash table), then the formal argument itself that you've passed is still
only changeable within that function, however what it points off at _is_
changeable via that formal argument.  This is of course because otherwise
passing a 1 gigabyte dictionary to a function would either have to copy the
whole dictionary, or implement some sort of Copy-on-Write semantics, or make
it somehow readonly.

If you need side effect-free functions in Python, you'd probably best copy
your aggregates, EG:

import copy

def main():
  a = ['a list','with','three elements']
  print a
  print fnc1(a)
  print a

def fnc1(b):
  b = copy.deepcopy(b)
  return fnc2(b)

def fnc2(c):
  c = copy.deepcopy(c)
  c[1] = 'having'
  return c

main()

Or use Haskell.  Please don't try to turn Python into Haskell.  Each has its
own interesting tradeoffs, and we don't really need two Pythons, and we
don't really need two Haskells.

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


Re: scope of function parameters (take two)

2011-05-30 Thread Steven D'Aprano
On Mon, 30 May 2011 20:28:34 -0400, Henry Olders wrote:

 I am trying to write python programs in a more-or-less functional
 programming mode, ie functions without side effects (except for print
 statements, which are very helpful for debugging). This is easiest when
 all variables declared in functions are local in scope 

They are.


 (it would also be
 nice if variables assigned within certain constructs such as for loops
 and list comprehensions were local to that construct, but I can live
 without  it).

for loop variables are local to the function, by design.

List comprehension variables leak outside the comprehension. That is an 
accident that is fixed in Python 3. Generator expression variables never 
leaked.


 It appears, from my reading of the python documentation, that a
 deliberate decision was made to have variables that are referenced but
 not assigned in a function, have a global scope.
[...]
 This suggests that the decision to make unassigned (ie free variables)
 have a global scope, was made somewhat arbitrarily to  prevent clutter.
 But I don't believe that the feared clutter would materialize.

Then you haven't understood the problem at all.


 My
 understanding is that when a variable is referenced, python first looks
 for it in the function's namespace, then the module's, and finally the
 built-ins. So why would it be necessary to declare references to
 built-ins as globals?

How else would the functions be found if they were ONLY treated as local?

Consider this code:

def spam():
print a_name
print len(a_name)

This includes two names: a_name and len. They both follow the same 
lookup rules. Functions in Python are first-class values, just like ints, 
strings, or any other type.

You don't want spam() to see any global a_name without it being 
declared. But how then can it see len?

Don't think that Python could change the rules depending on whether 
you're calling a name or not. Consider this:

def spam():
print a_name
print a_name(len)


Do you expect the first lookup to fail, and the second to succeed?



 What I would like is that the variables which are included in the
 function definition's parameter list, would be always treated as local
 to that function (and of course, accessible to nested functions) but NOT
 global unless explicitly defined as global.

They are. Always have been, always will be.


 This would prevent the sort
 of problems that I encountered as described in my original post.

No it wouldn't. You are confused by what you are seeing, and interpreting 
it wrongly.

I believe that what you want is pass-by-value semantics, in the old-
school Pascal sense, where passing a variable to a function makes a copy 
of it. This is not possible in Python. As a design principle, Python 
never copies objects unless you as it to.


 I may
 be wrong here, but it seems that the interpreter/compiler should be able
 to deal with this, whether the parameter passing is by value, by
 reference, by object reference, or something else. 

Of course. You could create a language that supports any passing models 
you want. Pascal and VB support pass-by-value (copy on pass) and pass-
by-reference. Algol supports pass-by-value and (I think) pass-by-name. 
There's no reason why you couldn't create a language to support pass-by-
value and pass-by-object. Whether this is a good idea is another story.

However, that language is not Python.


 If variables are not
 assigned (or bound) at compile time, but are included in the parameter
 list, then the binding can be made at runtime. 

Er, yes? That already happens.


 And I am NOT talking
 about variables that are only referenced in the body of a function
 definition; I am talking about parameters (or arguments) in the
 function's parameter list. 

You keep bring up the function parameter list as if that made a 
difference. It doesn't.

Perhaps this will enlighten you:

 alist = [1, 2, 3, 4]
 blist = alist
 blist[0] = -999
 alist
[-999, 2, 3, 4]


Passing alist to a function is no different to any other name binding. It 
doesn't make a copy of the list, it doesn't pass a reference to the name 
alist, it passes the same object to a new scope.



 As I stated before, there is no need to
 include a global variable in a parameter list, and if you want to have
 an effect outside of the function, that's what the return statement is
 for.

Function parameters are never global. You are misinterpreting what you 
see if you think they are.


[...]
 If making python behave this way is impossible, then I will just have to
 live with it. But if it's a question of we've always done it this way,
 or,  why change? I'm not bothered by it, then I will repeat my
 original question: Are there others who feel as I do that a function
 parameter should always be local to the function?

They are. You are misinterpreting what you see.




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


Re: scope of function parameters (take two)

2011-05-30 Thread Wolfgang Rohdewald
On Dienstag 31 Mai 2011, Henry Olders wrote:
 What I would like is that the variables which are included in
 the function definition's parameter list, would be always
 treated as local to that function (and of course, accessible
 to nested functions) but NOT global unless explicitly defined
 as global. This would prevent the sort of problems that I
 encountered as described in my original post.

the parameter is local but it points to an object from an outer
scope - that could be the scope of the calling function or maybe
the global scope. So if you change the value of this parameter, 
you change that object from outer scope. But the parameter 
itself is still local. If you do 

def fnc2(c):
   c = 5

the passed object will not be changed, c now points to another
object. This is different from other languages where the global
c would change (when passing c by reference)

what you really seem to want is that a function by default
cannot have any side effects (you have a side effect if a
function changes things outside of its local scope). But
that would be a very different language than python

did you read the link Steven gave you?
http://mail.python.org/pipermail/tutor/2010-December/080505.html

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


Re: scope of function parameters (take two)

2011-05-30 Thread Thomas Rachel

Am 31.05.2011 02:28 schrieb Henry Olders:


This suggests that the decision to make unassigned (ie free
variables) have a global scope, was made somewhat arbitrarily to
prevent clutter. But I don't believe that the feared clutter would
materialize. My understanding is that when a variable is referenced,
python first looks for it in the function's namespace, then the
module's, and finally the built-ins. So why would it be necessary to
declare references to built-ins as globals?


Not for the builtins, but for the global ones.

Suppose you have a module

def f(x):
   return 42

def g(x, y):
   return f(x) + f(y)

Would you really want to need a global f inside g?


Besides, this doesn't have to do with your original problem at all. Even 
then, a


def h(x):
   x.append(5)
   return x

would clobber the given object, because x is just a name for the same 
object which the caller has.



What I would like is that the variables which are included in the
function definition's parameter list, would be always treated as
local to that function (and of course, accessible to nested
functions)


They are - in terms of name binding. In Python, you always have objects 
which can be referred to from a variety of places under different names.


Maybe what you want are immutable objects (tuples) instead of mutable 
ones (lists)...




I don't believe I'm the only person who thinks this way. Here is a
quote from wikipedia: It is considered good programming practice to
make the scope of variables as narrow as feasible


Again: It is the way here.

Think of C: there you can have a

int f(int * x) {
*x = 42;
return x;
}

The scope of the variable x is local here. Same in Python.
The object referred to by *x is somewhere else, by design. Same in Python.



If making python behave this way is impossible, then I will just have
to live with it.


Even if I still think that you are confusing scope of a name binding 
and scope of an object, it is a conceptual thing.


Surely it would have been possible to do otherwise, but then it would be 
a different language. Objects can be mutable, period.


In MATLAB, e.g., you have what you desire here: you always have to pass 
your object around and get another ne back, even if you just add or 
remove a field of a struct or change the value of a field.


HTH,

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


Re: scope of function parameters (take two)

2011-05-30 Thread Ben Finney
Daniel Kluev dan.kl...@gmail.com writes:

 On a sidenote, I wonder what is the reason to keep word 'variable' in
 python documentation at all. I believe word 'name' represents concept
 better, and those, who come from other languages, would be less likely
 to associate wrong definitions with it.

I agree, but the term “variable” is used freely within the Python
development team to refer to Python's name-to-object bindings, and that
usage isn't likely to stop through our efforts.

So the burden is unfortunately on us to teach each newbie that this
often-used term means something other than what they might expect.

-- 
 \   “In case you haven't noticed, [the USA] are now almost as |
  `\ feared and hated all over the world as the Nazis were.” —Kurt |
_o__)   Vonnegut, 2004 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner needs advice

2011-05-30 Thread Benjamin Kaplan
On Mon, May 30, 2011 at 10:20 PM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 On Mon, 30 May 2011 21:34:09 -0400, Terry Reedy tjre...@udel.edu
 declaimed the following in gmane.comp.python.general:

 On 5/30/2011 8:32 PM, harrismh777 wrote:

  Ever tried to read Beowulf in the original? Ever tried to write Ænglisc ?

 I have, and it is a lot further from modern American than Python 2 and 3
 are from each other.

        Heck... Python 2 and 3 are modern vs Shakespearian English...
 Chaucer is closer to Python vs Ruby... Beowulf? Might as well be APL...
 --


No, Python 2 vs 3 is more of American English vs British English.
People who speak one of them work under the philosophy that if y'all
would just speak English we wouldn't have these problems
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters (take two)

2011-05-30 Thread Daniel Kluev
On Tue, May 31, 2011 at 4:13 PM, Wolfgang Rohdewald
wolfg...@rohdewald.de wrote:
 what you really seem to want is that a function by default
 cannot have any side effects (you have a side effect if a
 function changes things outside of its local scope). But
 that would be a very different language than python

This can be done in Python (to some degree), like this

@copy_args
def somefunc(a, b, c):
 ...

where copy_args would explicitly call deepcopy() on all args passed to
the function.
Or, to save some performance, wrap them in some CopyOnEdit proxy
(although this is tricky, as getattr/getitem can modify object too if
class overrides them).

Obviously it would not save you from functions which use
global/globals() or some other ways to change state outside their
scope.

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner needs advice

2011-05-30 Thread Ben Finney
Dennis Lee Bieber wlfr...@ix.netcom.com writes:

   Well... He did say find the bathroom, not ask for directions to
 whatever euphemism is in current usage (water closet, W/C, loo ?)

The room which contains the bath is the bathroom.

Assuming that the toilet is in the same room as the bath is parochial.

If he wants the toilet, “bathroom” is a euphemism, and he should instead
ask for directions to the toilet.

-- 
 \  “When we talk to God, we're praying. When God talks to us, |
  `\ we're schizophrenic.” —Jane Wagner, via Lily Tomlin, 1985 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue11623] Distutils is reporting OSX 10.6 w/ XCode 4 as universal

2011-05-30 Thread sorin

sorin sorin.sbar...@gmail.com added the comment:

FYI, I got the above output from 10.7 from a friend, I do not have access to 
the seed, so the information could be wrong.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11623
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12206] Documentation Std. Library 15.7.5 LogRecord objects: Parameters: level(currently wrong) - levelno (correct)

2011-05-30 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The name of the level parameter to LogRecord constructor is correct in the 
documentation (I checked the code). The only inconsitency that I see is that 
the corresponding attribute name of LogRecord is levelno.

--
nosy: +petri.lehtinen

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12206
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12206] Documentation Std. Library 15.7.5 LogRecord objects: Parameters: level(currently wrong) - levelno (correct)

2011-05-30 Thread Martin Ponweiser

Martin Ponweiser m.ponwei...@gmail.com added the comment:

You are right, I should have looked closer -- sorry to all involved.
Nevertheless this caused some confusion here. I guess mentioning the
inconsistency in the documentation is out of the question.

On Mon, May 30, 2011 at 10:10 AM, Petri Lehtinen rep...@bugs.python.orgwrote:


 Petri Lehtinen pe...@digip.org added the comment:

 The name of the level parameter to LogRecord constructor is correct in
 the documentation (I checked the code). The only inconsitency that I see is
 that the corresponding attribute name of LogRecord is levelno.

 --
 nosy: +petri.lehtinen

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue12206
 ___


--
Added file: http://bugs.python.org/file22187/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12206
___You are right, I should have looked closer -- sorry to all involved. 
Nevertheless this caused some confusion here. I guess mentioning the 
inconsistency in the documentation is out of the question.brbrdiv 
class=gmail_quote
On Mon, May 30, 2011 at 10:10 AM, Petri Lehtinen span dir=ltrlt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span 
wrote:brblockquote class=gmail_quote style=margin:0 0 0 
.8ex;border-left:1px #ccc solid;padding-left:1ex;
br
Petri Lehtinen lt;a href=mailto:pe...@digip.org;pe...@digip.org/agt; 
added the comment:br
br
The name of the quot;levelquot; parameter to LogRecord constructor is correct 
in the documentation (I checked the code). The only inconsitency that I see is 
that the corresponding attribute name of LogRecord is quot;levelnoquot;.br

br
--br
nosy: +petri.lehtinenbr
divdiv/divdiv class=h5br
___br
Python tracker lt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br
lt;a href=http://bugs.python.org/issue12206; 
target=_blankhttp://bugs.python.org/issue12206/agt;br
___br
/div/div/blockquote/divbrbr clear=allbr-- brMartin 
PonweiserbrFrauengasse 4/8, 2700 Wr. Neustadt, Austriabrcell phone: 0043 
650-68 27 949 (no SMS inbox)br
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12206] Documentation Std. Library 15.7.5 LogRecord objects: Parameters: level(currently wrong) - levelno (correct)

2011-05-30 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Martin Ponweiser wrote:
 I guess mentioning the inconsistency in the documentation is out of
 the question.

No, not at all. If you have a good wording in your mind, please share
it :) Or even better, write a patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12206
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1195] Problems on Linux with Ctrl-D and Ctrl-C during raw_input

2011-05-30 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
resolution: fixed - 
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12198] zipfile.py:1047: DeprecationWarning: 'H' format requires 0 = number = 65535

2011-05-30 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

On 2.7, your example raises an error:

Traceback (most recent call last):
  File a.py, line 7, in module
z.write(a, a)
  File /home/petri/tmp/cpython/cpython/Lib/zipfile.py, line 1071, in write
self.fp.write(zinfo.FileHeader())
  File /home/petri/tmp/cpython/cpython/Lib/zipfile.py, line 348, in FileHeader
len(filename), len(extra))
struct.error: ushort format requires 0 = number = USHRT_MAX

I doubt this can be fixed in 2.6 anymore, as it's in security fix only -mode.

What comes to the error on 2.7, it could be better. If zip files simply don't 
support dates before 1980, an error describing this could be raised. Another 
possibility would be to clamp too old dates to 1980.

--
nosy: +petri.lehtinen

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12198
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12014] str.format parses replacement field incorrectly

2011-05-30 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12014
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12151] test_logging fails sometimes

2011-05-30 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

The last change appears to have fixed the problem; AFAIK there have been no 
test_logging failures on the buildbots for several days.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12151
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12068] test_logging failure in test_rollover

2011-05-30 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

There appear to have been no test_logging failures on the buildbots for around 
a week, so closing this issue. A change to ignore socket errors when the server 
was closed appears to have done the trick.

--
resolution:  - fixed
status: pending - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12068
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12151] test_logging fails sometimes

2011-05-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 The last change appears to have fixed the problem; 
 AFAIK there have been no test_logging failures on the buildbots 
 for several days.

Great job, thanks!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12151
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11254] distutils doesn't byte-compile .py files to __pycache__ during installation

2011-05-30 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

to be backported in packaging -- in a way that will make it work with previous 
python versions for the incoming 2.x backport

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11254
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11975] Fix referencing of built-in types (list, int, ...)

2011-05-30 Thread Jonas H.

Jonas H. jo...@lophus.org added the comment:

I'm not.

My patch doesn't address the problem of unlinkable methods but wrong type 
declarations (read, wrong usage of .. function:: directives) for builtins 
like int, float, bool, list etc. Because the directives change, the roles used 
to link to them (:func:`list`) have to be changed accordingly.  That's what 
this patch does.

I want to address `list` method documentation in the next step.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6490] os.popen documentation in 2.6 is probably wrong

2011-05-30 Thread Chris Rebert

Chris Rebert pyb...@rebertia.com added the comment:

Per msg129958, attached is my stab at a patch to replace most uses of 
os.popen() with the subprocess module. The test suite passes on my Mac, but the 
patch does touch some specific-to-other-platform code, so further testing is 
obviously needed.
This is my first non-docs patch, please be gentle. :) [Those patches were to 
subprocess' docs though!]

Stuff still using os.popen() that the patch doesn't fix:
- multiprocessing
- platform.popen() [which is itself deprecated]
- subprocess.check_output()
- Lib/test/test_poll.py
- Lib/test/test_select.py
- Lib/distutils/tests/test_cygwinccompiler.py

Also, I suppose Issue 9382 should be marked as a dupe of this one?

--
nosy: +cvrebert
Added file: http://bugs.python.org/file22188/mostly_replace_os_popen.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6490
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6490] os.popen documentation in 2.6 is probably wrong

2011-05-30 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Chris Rebert wrote:
 
 Chris Rebert pyb...@rebertia.com added the comment:
 
 Per msg129958, attached is my stab at a patch to replace most uses of 
 os.popen() with the subprocess module. The test suite passes on my Mac, but 
 the patch does touch some specific-to-other-platform code, so further testing 
 is obviously needed.
 This is my first non-docs patch, please be gentle. :) [Those patches were to 
 subprocess' docs though!]
 
 Stuff still using os.popen() that the patch doesn't fix:
 - multiprocessing
 - platform.popen() [which is itself deprecated]
 - subprocess.check_output()
 - Lib/test/test_poll.py
 - Lib/test/test_select.py
 - Lib/distutils/tests/test_cygwinccompiler.py
 
 Also, I suppose Issue 9382 should be marked as a dupe of this one?

Thanks, but I still don't understand why os.popen() wasn't removed
from the list of deprecated APIs as per Guido's message further up
on the ticket.

If you look at the amount of code you need to add in order
to support the os.popen() functionality directly using
subprocess instead of going the indirect way via the existing
os.popen() wrapper around the subprocess functionality, I think
this shows that the wrapper is indeed a good thing to have
and something you'd otherwise implement anyway as part of
standard code refactoring.

So instead of applying such a patch, I think we should add back
the documentation for os.popen() and remove the deprecation
notices.

The deprecations for os.popenN() are still fine, since those
APIs are not used all that much, and I'm sure that no one can
really remember what all the different versions do anyway :-)

os.popen() OTOH is often used and implements a very common
use: running an external command and getting the stdout
results back for further processing.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6490
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12213] BufferedRandom, BufferedRWPair: issues with interlaced read-write

2011-05-30 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
title: BufferedRandom: write(); read() gives different result using io and 
_pyio - BufferedRandom, BufferedRWPair: issues with interlaced read-write

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12213
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12125] test_sysconfig fails on OpenIndiana because of test_packaging

2011-05-30 Thread Jesús Cea Avión

Jesús Cea Avión j...@jcea.es added the comment:

Tarek, can you confirm that the bug is closed?. It is reported as open in the 
tracker.

Could you possibly close it, if appropiate?.

--
assignee: tarek - 

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12125
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >