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

2009-08-31 Thread Kirill Simonov


 Announcing PyYAML-3.09


A new bug fix release of PyYAML is now available:

http://pyyaml.org/wiki/PyYAML

Note that PyYAML supports both Python 2 and Python 3.  For
compatibility notes, please see

http://pyyaml.org/wiki/PyYAMLDocumentation#Python3support


Changes
===

* Fixed compatibility issues with Python 3.1.
* Fixed use of uninitialized memory when emitting anchors with
  LibYAML bindings (Thank to cegner(at)yahoo-inc(dot)com).
* Fixed emitting incorrect BOM characters for UTF-16 (Thank to
  Valentin Nechayev)
* Fixed the emitter for folded scalars not respecting the preferred
  line width (Thank to Ingy).
* Fixed a subtle ordering issue with emitting '%TAG' directives
  (Thank to Andrey Somov).
* Fixed performance regression with LibYAML bindings.


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.09.tar.gz
ZIP package: http://pyyaml.org/download/pyyaml/PyYAML-3.09.zip
Windows installers:
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.3.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.4.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.5.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.6.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py3.0.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py3.1.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/


IMDbPY 4.2

2009-08-31 Thread Davide Alberani
MDbPY 4.2 is available (tgz, rpm, exe) from:
  http://imdbpy.sourceforge.net/

IMDbPY is a Python package useful to retrieve and manage the data of
the IMDb movie database about movies, people, characters and companies.

With this release, a lot of bugs were fixed, and some minor new features
introduced.

Platform-independent and written in pure Python (and few C lines),
IMDbPY can retrieve data from both the IMDb's web server and a local
copy of the whole database.

IMDbPY package can be very easily used by programmers and developers
to provide access to the IMDb's data to their programs.
Some simple example scripts are included in the package; other
IMDbPY-based programs are available from the home page.


-- 
Davide Alberani albera...@libero.it [GPG KeyID: 0x465BFD47]
http://erlug.linux.it/~da/

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

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


Re: why python got less developers ?

2009-08-31 Thread Erik Reppen
It seems to be a language embraced by people who enjoy coding. Not so
much by the time-spent-seeking-degree to paycheck ratio balancing
crowd. Or maybe I just hate bloated IDEs and I've heard too many Java
dev jokes to be impartial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Overriding iadd for dictionary like objects

2009-08-31 Thread RunThePun
On Aug 30, 10:33 pm, a...@pythoncraft.com (Aahz) wrote:
 In article 
 e09276e8-8152-4002-8366-4c12705a8...@l35g2000vba.googlegroups.com,





 RunThePun  ubershme...@gmail.com wrote:

 I made a DictMixin where the keys are filenames and the values are the
 file contents. It was very simple and easy to do thanks to DictMixin.

 For example this code writes abc in a file named temp.txt and
 prints the contents of the file named swallow, these files are
 looked up/created/deleted in the directory spam:
  d =3D FilesDict('spam')
  d['temp.txt'] =3D 'abc'
  print(d['swallow'])

 My problem arose when I wanted to append a string to a file which
 using open(..., 'ab') would have been miles more efficient because I
 wouldn't have to read the entire file (__getitem__) and then write the
 entire file back (__setitem__). The files are expected to be as big as
 600 KB which will be appended 30 bytes at a time about 3 times a
 second. Performance-wise the system would probably work without open
 (..., 'ab') but it would be a real thrashing so the current solution
 uses a method AddTo as Robert suggested, sacrificing the neat
 getitem/setitem syntax.

 You can do mostly what you want, I think, by having __setitem__()
 convert string values into FileProxy() objects that have an appropriate
 __iadd__() method.  That brings a whole new set of problems, of course.
 --
 Aahz (a...@pythoncraft.com)           *        http://www.pythoncraft.com/

 I support family values -- Addams family values --www.nancybuttons.com

I'm guessing you meant __getitem__, which is what Jan Kaliszewski
suggested, but as you noted, would be a bit cumbersome in this case.
-- 
http://mail.python.org/mailman/listinfo/python-list


lambda functions

2009-08-31 Thread Pierre
Hello,

I would like to know if it is possible to define a loop in a lambda
function

How to manage the indents ? Example :
s_minus_1 = lambda s : for index in range(0, len(s)) : s[index] = s
[index]-1


Thanks !

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


Re: An assessment of Tkinter and IDLE

2009-08-31 Thread eb303
On Aug 28, 4:41 pm, r rt8...@gmail.com wrote:
 Thanks eb303 for the wonderful post

 I have looked over the new ttk widgets and everything looks nice. I am
 very glad to see the death of Tix as i never much liked it anyhow and
 always believed these widgets should have been in the main Tkinter
 module to start with. The tree widget has been needed for some time.

 However, i am not sure about the new style separation. Previously a
 simple command like root.option_add('*Label.Font'...) accomplished the
 same thing with less typing, but there may be a future method to this
 current madness that i am unaware of...???

The new widgets have been made mainly to make tk look better by making
it possible to use native widgets. The drawback is that it limits a
lot the possibilities of configuration you can have: on many
platforms, the looks of the widgets are decided by the user via a
system preference, not by the application programmer. This is why ttk
widgets are not configurable directly, because 'native' styles usually
don't allow it at application level anyway.

Keep in mind that the new ttk widgets are not replacements for former
widgets, but an addition to them. 'Old' widgets are still here, and
there is no plan I know of to remove them. If you want to do an
application with a very specific look, you can still use these.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda functions

2009-08-31 Thread Javier Collado
Hello,

This page has some advice about how to avoid some of the lambda
functions limitations:
http://p-nand-q.com/python/stupid_lambda_tricks.html

In particular, it suggests to use map function instead of for loops.

Best regards,
Javier

2009/8/31 Pierre pierre.gaill...@gmail.com:
 Hello,

 I would like to know if it is possible to define a loop in a lambda
 function

 How to manage the indents ? Example :
 s_minus_1 = lambda s : for index in range(0, len(s)) : s[index] = s
 [index]-1


 Thanks !

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

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


Re: initilize a memory zone in python

2009-08-31 Thread Diez B. Roggisch

Mug schrieb:

On Aug 30, 8:58 pm, Diez B. Roggisch de...@nospam.web.de wrote:

Mug schrieb:


hello, i'm new in python, i used to program in C,
i have a small problem, i tryed to do some serial port things
manipulation
with python.
i have something like:
import sys,termios
fd = sys.stdin.fileno()
term_conf=termios.tcgetattr(fd);
now i want to modify the actuall values in term_conf  zone to zero
i don't see how to do it,
in C we can do : bzero(term_conf,sizeof(struct termios));
i want to know if it exist a similar function in python, thanks

In python you don't modify memory like that.

For the above function, you pass a value as the one you got to
tcgetattr, with values modified as you desire them.

i tryed
print term_conf
and i saw that the term_conf is actually represent with an array in
python:

zsh/3 4201 [1] % python test.py
[27906, 5, 1215, 35387, 15, 15, ['\x03', '\x1c', '\x7f', '\x15',
'\x04', '\x00', '\x01', '\xff', '\x11', '\x13', '\x1a', '\xff',
'\x12', '\x0f', '\x17', '\x16', '\xff', '\x00', '\x00', '\x00',
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
'\x00', '\x00', '\x00', '\x00']]

it's a array of 7 elements, with the seventh element it self a array,
so in order to initialize them to zero, there's no other way than
modify them
one by one in a loop? is there a fonction like memset or bzero in
python?


Again: no, there is no such function. But for the above, you'd easily write:

foo = [0] * 7 # only do this with immutables
foo[-1] = ['\x00'] * 16

alternatively, you modify the result you got from tcgetattr in the 
places you want.




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


Re: lambda functions

2009-08-31 Thread Chris Rebert
On Mon, Aug 31, 2009 at 12:41 AM, Pierrepierre.gaill...@gmail.com wrote:
 Hello,

 I would like to know if it is possible to define a loop in a lambda
 function

Not possible. Lambdas can only contain a single expression. A loop is
a block statement.
Just use a named function instead. There's nothing that can be done
with a lambda that can't be done with a named function instead.

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


Re: lambda functions

2009-08-31 Thread Gabriel Genellina
En Mon, 31 Aug 2009 04:41:57 -0300, Pierre pierre.gaill...@gmail.com  
escribió:



I would like to know if it is possible to define a loop in a lambda
function

How to manage the indents ? Example :
s_minus_1 = lambda s : for index in range(0, len(s)) : s[index] = s
[index]-1


You can't. lambda is just a way to define a short, inline, anonymous  
function, and its body can only contain expressions, not statements.


Even if what you want were legal, giving a name to the resulting  
expression kind of defeats the purpose of lambda - use a normal function  
instead:


def s_minus_1(s):
  document usage here
  for index,item in enumerate(s):
s[index] -= 1

--
Gabriel Genellina

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


Re: An assessment of the Unicode standard

2009-08-31 Thread Hendrik van Rooyen
On Sunday 30 August 2009 22:46:49 Dennis Lee Bieber wrote:

   Rather elitist viewpoint... Why don't we just drop nukes on some 60%
 of populated landmasses that don't have a western culture and avoid
 the whole problem?

Now yer talking, boyo!  It will surely help with the basic problem which is 
the heavy infestation of people on the planet!
:-)

- Hendrik

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


Re: map

2009-08-31 Thread Hendrik van Rooyen
On Monday 31 August 2009 06:55:52 elsa wrote:

8 - map question 


 (Ultimately, I want to call myFunc(myList[0], 'booHoo'), myFunc(myList
 [1], 'booHoo'), myFunc(myList[2], 'booHoo') etc. However, I might want
 to call myFunc(myList[0], 'woo'), myFunc(myList[1], 'woo'), myFunc
 (myList[2], 'woo') some other time).

Here is some heretical advice:

Do not use stuff like map and reduce unless they fit what you want to do 
perfectly, and JustWorks the first time.

You have a very clear idea of what you want to do, so why do you not just 
simply write something to do it?

something like this (untested):

def woofer(thefunc,thelist,thething):
theanswers = []
for x in thelist:
theanswers.append(thefunc(x,thething))
return theanswers

And the advantage is that you do not have to remember what map does...

*ducks away from the inevitable flames*

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


rcond in numpy :

2009-08-31 Thread Pierre

Hello,

Anyone knows the numpy equivalent of the matlab function : rcond
(Matrix reciprocal condition number estimate) ?

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


Re: map

2009-08-31 Thread Gabriel Genellina
En Mon, 31 Aug 2009 05:43:07 -0300, Hendrik van Rooyen  
hend...@microcorp.co.za escribió:

On Monday 31 August 2009 06:55:52 elsa wrote:


(Ultimately, I want to call myFunc(myList[0], 'booHoo'), myFunc(myList
[1], 'booHoo'), myFunc(myList[2], 'booHoo') etc. However, I might want
to call myFunc(myList[0], 'woo'), myFunc(myList[1], 'woo'), myFunc
(myList[2], 'woo') some other time).


Here is some heretical advice:

Do not use stuff like map and reduce unless they fit what you want to do
perfectly, and JustWorks the first time.


I think of that advice as orthodox, not heretical! (functional guys  
are minority here...)



You have a very clear idea of what you want to do, so why do you not just
simply write something to do it?

something like this (untested):

def woofer(thefunc,thelist,thething):
theanswers = []
for x in thelist:
theanswers.append(thefunc(x,thething))
return theanswers

And the advantage is that you do not have to remember what map does...


This block:

theanswers = []
for x in thelist:
theanswers.append(thefunc(x,thething))

is formally the same as this one:

theanswers = [thefunc(x,thething) for x in thelist]

but the list comprehension is faster. So the function becomes:

def woofer(thefunc,thelist,thething):
return [thefunc(x,thething) for x in thelist]

and may be inlined (it's usually easier to read).


*ducks away from the inevitable flames*


*fights back to back with you against heretics*

--
Gabriel Genellina

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


Re: map

2009-08-31 Thread Piet van Oostrum
 Hendrik van Rooyen hend...@microcorp.co.za (HvR) wrote:

HvR On Monday 31 August 2009 06:55:52 elsa wrote:
HvR 8 - map question 

 
 (Ultimately, I want to call myFunc(myList[0], 'booHoo'), myFunc(myList
 [1], 'booHoo'), myFunc(myList[2], 'booHoo') etc. However, I might want
 to call myFunc(myList[0], 'woo'), myFunc(myList[1], 'woo'), myFunc
 (myList[2], 'woo') some other time).

HvR Here is some heretical advice:

HvR Do not use stuff like map and reduce unless they fit what you want to do 
HvR perfectly, and JustWorks the first time.

HvR You have a very clear idea of what you want to do, so why do you not just 
HvR simply write something to do it?

HvR something like this (untested):

HvR def woofer(thefunc,thelist,thething):
HvR   theanswers = []
HvR   for x in thelist:
HvR   theanswers.append(thefunc(x,thething))
HvR   return theanswers

HvR And the advantage is that you do not have to remember what map does...

Map should be in every good programmer's toolbox. So (s)he presumably
knows already what map does. In order to follow your advise (s)he must
first forget what map does :=)

Agreed on the part that map shouldn't be used indiscriminately. Neither
should loops. Your woofer is much harder to follow than map, I think.

[myFunc(elt, 'booHoo') for elt in myList] is also a good candidate and
in this case I think it is preferable to both the loop and the map with
a partial or lambda in terms of clarity.

On the other hand when you just want to call a function on each element
of a list and you don't need to collect the result a simple loop is
often preferable.

But ultimately it is also very much a matter of taste, preference and habit.
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


starting a client remotely

2009-08-31 Thread jacopo
I am playing with multiprocessing and I would like to have a python
script on one machine which initialize my whole system, in other
words, this script should start the server (a python script) on my
local machine and the clients (python scripts) on the other machines
in my local network.

Would you have any suggestion?

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


Re: starting a client remotely

2009-08-31 Thread Diez B. Roggisch
jacopo wrote:

 I am playing with multiprocessing and I would like to have a python
 script on one machine which initialize my whole system, in other
 words, this script should start the server (a python script) on my
 local machine and the clients (python scripts) on the other machines
 in my local network.
 
 Would you have any suggestion?

This isn't possible witout some kind of service running on the remote
machine. You don't write what OS you are using, on unix'ish machines this
can be easily accomplished using SSH to invoke a remote-command that starts
your server. I've used that + Pyro in the past to create distributed
systems.

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


Re: Return value of multiprocessing manager registerred function

2009-08-31 Thread jacopo
Hi Terry,
I have just started working on similar things and I am strugling to
find examples or documentations. So far I have found only the official
documentation of the multiprocessing package. Would you be able to
recommend me some good reference or a book. I dont want to overwhelm
this newsgroup with questions... yet :)
Regards, Jacopo

On Aug 26, 4:22 am, Terry terry.yin...@gmail.com wrote:
 Hi,

 I'm using the multiprocessing.manager to run proceduresremotely. It
 all worked fine except I hope to have a different return value type.

 The remote function calls always return a proxy, which when I need to
 get the value it need to connect to the manager again to fetch it. But
 I just need the value, not the proxy.

 Can I just return the value instead of a proxy from a manager?

 br, Terry

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


Re: Is behavior of += intentional for int?

2009-08-31 Thread Piet van Oostrum
 Derek Martin c...@pizzashack.org (DM) wrote:

DM On Sun, Aug 30, 2009 at 03:42:06AM -0700, Paul McGuire wrote:

 Is it any odder that 3 is an object than that the string literal
 Hello, World! is an object?  

DM Yes.  Because 3 is a fundamental bit of data that the hardware knows
DM how to deal with, requiring no higher level abstractions for the
DM programmer to use it (though certainly, a programming language can
DM provide them, if it is convenient).  Hello, World! is not.  They are
DM fundamentally different in that way.

How the semantics of Python is defined is not dependent of the hardware.
You could imagine a computer where strings are as much built into the
hardware as ints are. On the other hand you could also imagine a
computer that only knows about bits and where int arithmetic has to be
done in software. In fact early microprocessors only could operate
directly on bytes and arithmetic of larger ints was in software. And
even nowadays there are processors in use that don't have built-in
floating point hardware. Would you say that considering whether 3.14 is
an object in Python or whether that is to be considered strange should
depend on the availability of a floating point unit in the hardware
where the program runs? Would that make floating point numbers
fundamentally different from ints in the sense described above?
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: starting a client remotely

2009-08-31 Thread jacopo
thank you Diez,
unfortunatelly I am on Windows NT.
Did you use SSH in a python script?
Isn't multiprocessing.managers already doing something like Pyro?


thanks
Jacopo


On Aug 31, 12:47 pm, Diez B. Roggisch de...@nospam.web.de wrote:
 jacopo wrote:
  I am playing with multiprocessing and I would like to have a python
  script on one machine which initialize my whole system, in other
  words, this script should start the server (a python script) on my
  local machine and the clients (python scripts) on the other machines
  in my local network.

  Would you have any suggestion?

 This isn't possible witout some kind of service running on the remote
 machine. You don't write what OS you are using, on unix'ish machines this
 can be easily accomplished using SSH to invoke a remote-command that starts
 your server. I've used that + Pyro in the past to create distributed
 systems.

 Diez

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


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

2009-08-31 Thread Kirill Simonov


 Announcing PyYAML-3.09


A new bug fix release of PyYAML is now available:

http://pyyaml.org/wiki/PyYAML

Note that PyYAML supports both Python 2 and Python 3.  For
compatibility notes, please see

http://pyyaml.org/wiki/PyYAMLDocumentation#Python3support


Changes
===

* Fixed compatibility issues with Python 3.1.
* Fixed use of uninitialized memory when emitting anchors with
  LibYAML bindings (Thank to cegner(at)yahoo-inc(dot)com).
* Fixed emitting incorrect BOM characters for UTF-16 (Thank to
  Valentin Nechayev)
* Fixed the emitter for folded scalars not respecting the preferred
  line width (Thank to Ingy).
* Fixed a subtle ordering issue with emitting '%TAG' directives
  (Thank to Andrey Somov).
* Fixed performance regression with LibYAML bindings.


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.09.tar.gz
ZIP package: http://pyyaml.org/download/pyyaml/PyYAML-3.09.zip
Windows installers:
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.3.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.4.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.5.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py2.6.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py3.0.exe
http://pyyaml.org/download/pyyaml/PyYAML-3.09.win32-py3.1.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-list


Re: starting a client remotely

2009-08-31 Thread Diez B. Roggisch
jacopo wrote:

 thank you Diez,
 unfortunatelly I am on Windows NT.
 Did you use SSH in a python script?

Via subprocess, yes. Paramiko would be a way, too.

 Isn't multiprocessing.managers already doing something like Pyro?

I never used it, so I don't know - but it appears to be, yes. Doesn't change
the overall problem though - without an inroad to another server, you can't
spawn processes on remote machines.

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


Re: starting a client remotely

2009-08-31 Thread Gabriel Genellina

On Aug 31, 12:47 pm, Diez B. Roggisch de...@nospam.web.de wrote:

jacopo wrote:
 I am playing with multiprocessing and I would like to have a python
 script on one machine which initialize my whole system, in other
 words, this script should start the server (a python script) on my
 local machine and the clients (python scripts) on the other machines
 in my local network.


En Mon, 31 Aug 2009 07:08:04 -0300, jacopo jacopo.pe...@gmail.com  
escribió:



thank you Diez,
unfortunatelly I am on Windows NT.


NT 4.0???
I was going to say use the rexec command but I think it's posterior to  
the Triasic-Jurasic extinction event :)


--
Gabriel Genellina

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


Re: Object's nesting scope

2009-08-31 Thread Bruno Desthuilliers

zaur a écrit :

On 28 авг, 16:07, Bruno Desthuilliers bruno.
42.desthuilli...@websiteburo.invalid wrote:

zaur a écrit :




On 26 авг, 17:13, Diez B. Roggisch de...@nospam.web.de wrote:

Whom am we to judge? Sure if you propose this, you have some usecases in
mind - how about you present these

Ok. Here is a use case: object initialization.
For example,
person = Person():
  name = john
  age = 30
  address = Address():
 street = Green Street
 no = 12
vs.
person = Person()
person.name = john
person.age = 30
address = person.address = Address()
address.street = Green Street
address.no = 12



Err... Looks like you really should read the FineManual(tm) -
specifically, the parts on the __init__ method.

class Person(object):
def __init__(self, name, age, address):
self.name = name
self.age = age
self.address = address

class Address(object):
def __init__(self, street, no):
self.no = no
self.street = street

person = Person(
name=john,
age=30,
address = Address(
street=Green Street,
no=12
)
)


What are you doing if 1) classes Person and Address imported from
foreign module 2) __init__ method is not defined as you want?


Either 1/write an alternate initializer and bind it to the appropriate 
classes or 2/write factory functions:


1/

from foreign_module import Person, Address

def my_init(self, **kw):
for k, v in kw.items():
setattr(self, k, v)
return self

Person.init = my_init
Address.init = my_init

person = Person().init(
 name=john,
 age=30,
 address = Address().init(
 street=Green Street,
 no=12
 )
 )


2/

from functools import partial
import foreign_module

def my_factory(cls, **kw):
obj = cls()
for k, v in kw.items():
setattr(obj, k, v)
return obj

Person = partial(my_factory, foreign_module.Person)
Address = partial(my_factory, foreign_module.Address)

person = Person(
 name=john,
 age=30,
 address = Address(
 street=Green Street,
 no=12
 )
 )

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


Re: map

2009-08-31 Thread Steven D'Aprano
On Mon, 31 Aug 2009 10:43:07 +0200, Hendrik van Rooyen wrote:

 Here is some heretical advice:
 
 Do not use stuff like map and reduce unless they fit what you want to do
 perfectly, and JustWorks the first time.
 
 You have a very clear idea of what you want to do, so why do you not
 just simply write something to do it?

That's not heretical advice -- that's pretty standard, vanilla, boring 
advice. It's probably good advice, if you care more about Getting the Job 
Done than about learning the language.


 And the advantage is that you do not have to remember what map does...

map() is probably the simplest, most straightforward of the functional 
tools in Python. It's harder for me to remember it's name than to 
remember what it does: it applies a function to each element of a list, 
instead of two the entire list as a single argument. Easy-peasy.

 *ducks away from the inevitable flames*

You'll have to try harder than that to get flamed :)



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


Re: map

2009-08-31 Thread Hendrik van Rooyen
On Monday 31 August 2009 11:31:34 Piet van Oostrum wrote:

 But ultimately it is also very much a matter of taste, preference and
 habit.

This is true, but there is another reason that I posted - I have noticed that 
there seems to be a tendency amongst newcomers to the group to go to great 
lengths to find something that will do exactly what they want, irrespective 
of the inherent complexity or lack thereof of that which they are trying to 
do.

Now I cannot understand why this is - one could say that it is caused by an 
eagerness to understand all the corners of the tool that is python, but 
somehow it does not feel like that to me - I see it almost as a crisis of 
confidence - as if the newbie lacks the self confidence to believe that he or 
she is capable of doing anything independently.  

So whenever I can, I try to encourage people to just do it their way, and to 
see what happens, and to hack using the interactive interpreter, to build 
confidence by experimenting and making mistakes, and realizing that when you 
have made a mistake, it is not the end of the world,  - you can fix it and 
move on.

Don't know if this rant makes any sense...

- Hendrik

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


Re: An assessment of Tkinter and IDLE

2009-08-31 Thread Kevin Walzer

On 8/28/09 8:11 PM, r wrote:

On Aug 28, 5:48 pm, Mark Rosemanm...@markroseman.com  wrote:
(snip)

Thewww.tkdocs.comsite is 'language neutral' - currently the tutorial
covers Tcl, Perl, Ruby and yes Python, and allows you to switch between
any of those languages (or show all of them).


True, however the coverage is incomplete. I would back this site if we
can get a complete coverage of all widgets in the Python language.

+0.1


Are you certain the site is incomplete? Its coverage of the basic Tk and 
Ttk  widgets is spectacular. . Its coverage of layout techinques and 
best practices for organizing complex interfaces with Tk is also 
extremely valuable. I wish this site had been around when I was learning 
Tk five years ago. I've looked at just about every Tk and Tkinter 
tutorial site out there, and this one surpasses them all. Mark 
Roseman--a professional, independent software developer whose commercial 
products almost all incorporate Tk into their GUI's--has spent a couple 
of years putting together this site with input from various users and 
developers (myself included). It's now an absolutely indispensible 
resource for beginners and more experienced developers.


The reason the site does not cover 'all widgets in the Python language' 
is threefold:


1. It's a site about Tk, a tookit that has Python bindings and bindings 
to other languages also (Ruby, Perl, Tcl, etc.).
2. It omits additional Python-specific, Tkinter-based widget sets such 
as PMW, Tix, etc. because once you understand the basics of Tk, then 
grokking these other megawidget sets (which all build on top of Tk) 
should be pretty straightforward.
3. Finally, 'all widgets in the Python language' gets into other tookits 
as well, which is obviously unfeasible for a website.


If the site by itself isn't enough for you, or is a bit too basic in its 
coverage of Python techniques, then there are other options. Couple the 
TkDocs site with effbot's more advanced walk through the various Tkinter 
classes, and perhaps one or two of the other Tkinter-specific tutorials, 
and you'll have learned a lot. But I think the TkDocs site is essential, 
especially in its more advanced discussion of how to put together an 
attractive, polished user interface with Tk. Tk has a long-standing 
reputation of being the toolkit of choice for quick, simple, ugly 
interfaces, and the other resources I've mentioned do nothing to to 
change this. The practices that Mark Roseman discusses will allow one to 
eventually put together a UI that matches anything that the other big 
toolkits (wxPython, PyQt, PyObjC, PyGtk, etc.) can do.


Hope this helps,
Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Math Notations, Computer Languages, and the “Form ” in Formalism

2009-08-31 Thread Xah Lee
• Math Notations, Computer Languages, and the “Form” in Formalism
  http://xahlee.org/cmaci/notation/index.html

plain text version follows. (lacks links)

-
Math Notations, Computer Languages, and the “Form” in Formalism

Xah Lee, 2009-08-31

This page is a collection of essays and expositions on the subjects of
nomenclature and notations in math and computer languages, in the
context of facilitating human communication and theorem proving
systems.

Most of these essays here are originally from email, blogs, or rants.
They are not of publication quality, and they are not a coherent
exposition the subject. Here's a very brief summary of of these
essays's central thesis:

• Traditional math notations are very inconsistent. Edsger Dijkstra is
a leader in a movement of what's called Calculational Proofs. That is,
using a notation that is consistent and facilitates the calculation
aspects when doing math by humans.

• Today, especially since 1990s, tremendous advances are made in
computer algebra systems and theorem proving systems. In these
languages, a coherent syntax, grammar, are needed for math
expressions.

• In computer algebra or theorem proving systems, they are intimately
tied to the math philosophies of formalism and logicism. In a sense,
formalism and logicism today are tied together as a single subject,
and using computer languages as foundation.

• Math expressions/syntax in computer languages are intimately tied to
math notations for human reading. (e.g. Mathematical, MathML are
technologies that combine the two.)

• The syntax and grammar of today's computer languages, such as Java,
C, Python, SQL, Lisp, are ad-hoc and their communities have little
understanding of the knowledge gained in math related fields such as
computer algebra or theorem proving languages. (This applies to
functional langs such as Haskell as well, but to a lesser degree.) On
the other hand, mathematicians in general are illiterate about
programing or using computer languages.

All of the above considered together, computer language designers and
mathematicians, should be made aware of these issues, so that when
they design or use computer languages, may it be math oriented or not,
the language's syntax and grammar can move towards a consistent syntax
system with solid foundation (as opposed to ad-hoc), and such language
should have build-in markup or simple mapping to 2-dimensional
notations for human reading (such as done with Mathematica or Semantic
MathML), and this computer language should be in fact as a basis of
theorem prover or computer algebra system (as in OCaml, Haskell,
Mathematica). The languages of computer algebra and theorem prover
would in fact merge together into one single subject if it is not
already slowly happening today.

Progress in the above issues are made in different fields but there
are little unification going on.

For example, there's Edsger Dijkstra's Calculational Proofs movement.
It improves math notations towards consistency and formalism. However,
people in Calculational Proofs movement are mostly math pedagogy
community i think. They are not programers interested in computer
languages, nor logicians interested in math formalism, or industrial
and commercial organizations interested in math notation
representation systems.

There's the computer algebra community, such as Mathematica, Maple,
Matlab, which requires a syntax and grammar for mathematical concepts.
There's the theorem proving community, such as OCaml, Coq, HOL, which
not only requires a syntax for math concepts, but also made major
understanding about math as a system of forms, i.e. formal systems.
Both computer algebra and theorem proving systems require math
notations and computer language syntax that are consistent and can
represent math concepts. However, the 2 camps are largely separate
communities. For example, there is as far as i know no tool that is
both a practical computer algebra system as well as a theorem proving
language.

Common computer languages, such as C, Java, Python, requires a good
syntax, parsers, and compilers, but their community, including
computer scientists and programers, are usually illiterate in typical
topics of of mathematics proper. Functional languages, such as Scheme
Lisp, APL, OCaml, Haskell, are more based on logic foundations (lambda
calculus) but their syntax and grammar has little to do with the math
notations as a logic or formal system. (these languages do not have a
formal spec in the sense of Formlism, i.e. transformation of forms. In
fact, almost no languages has a formal spec, formalism or not.)

There's math notation representation needs, such as TeX, MathCAD,
MathML, Mathematica. These are typically commercial organizations in
the computing industry. They can render math notations. In the case of
MathML and Mathematica, the language also represent the semantic
content of math notations. These two made major understanding about
the relation of math 

Re: Suggestion

2009-08-31 Thread Nitebirdz
On Sat, Aug 29, 2009 at 02:42:36PM +0530, Thangappan.M wrote:
 Dear all,
 
  I am in the process of learning Python programming language. I know
 Perl,PHP. Compare to both the language Python impressed me because here
 there is no lexical variables and all.Now I need suggestion saying that ,
 What online book can I follow?
 
  I have not yet learnt any advanced programming stuffs in Python.
 Please suggest some book? or tutorial. net net my goal is that I will be
 able to do the project in any languages(Python,Perl,PHP).So I need to learn
 more depth knowledge of Python.
 
 So Please help me?
 

Thangappan,


I'm no expert, but perhaps the following book will be of some help:

http://diveintopython.org/


There are plenty of tutorials on the web too.  Just do a quick search
for something like python tutorial.  


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


Re: An assessment of the Unicode standard

2009-08-31 Thread Nigel Rantor

Hendrik van Rooyen wrote:

On Sunday 30 August 2009 22:46:49 Dennis Lee Bieber wrote:


Rather elitist viewpoint... Why don't we just drop nukes on some 60%
of populated landmasses that don't have a western culture and avoid
the whole problem?


Now yer talking, boyo!  It will surely help with the basic problem which is 
the heavy infestation of people on the planet!

:-)


bait
On two conditions:

1) We drop some test bombs on Slough to satisfy Betjeman.

2) We strap both Xah and r to aforementioned bombs.
/bait

switch
Also, I'm surprised no-one has mentioned Esperanto yet. Sounds like 
something r and Xah would *love*.


Slightly off-topic - does anyone have a good recipe for getting 
thunderbird to kill whole threads for good? Either based on a rule or 
just some extension I can use?


The Xah/r threads are like car crashes, I can't help but watch but my 
time could be better spent and I don't want to unsub the whole list.

/switch

Cheers,

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


Re: a popen command line question

2009-08-31 Thread Nitebirdz
On Sat, Aug 29, 2009 at 01:13:12PM -0700, Joni Lee wrote:
 Hi all,
 
 I write a small script
 
 status = os.popen('top').readlines()
 print status
 
 It calls the command line top and will print out the status.
 But I have to press the keyboard q to quit top, then the status
 will be printed, otherwise it just stands by with blank.
 
 Question is. Do you know how to give q into my python script so that
 top is automatically quit immediately or maybe after 1s (for
 gathering information)
 

Why not run the actual 'top' command in batch mode with only one
iteration?  It's in the man page.  I'm referring to this:

  status = os.popen('top -b -n 1').readlines()


Also, the following approach seems to display a nicer output:

-
#!/usr/bin/env python

import os

status=os.popen('top -b -n 1')
for i in status.readlines():
  print i
-


Or how about the following?

-
#!/usr/bin/env python

import commands

status=commands.getoutput('top -b -n 1')
print status
-


Mind you, I'm just suggesting different approaches.  I'm new to Python
and don't necessarily know what I'm doing.  Other more experienced
people may be able to suggest something better.


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


Re: IDE for Python

2009-08-31 Thread Mike Driscoll
On Aug 29, 1:08 pm, ivanko@gmail.com wrote:
 29.08.2009 4:14 пользователь Thangappan.M thangappan...@gmail.com  
 написал:

  Dear all,
  Please suggest some good IDE for python.I am working in linux platform.
  --
  Regards,
  Thangappan.M

 You can use Eclipse + PyDev or Emacs+PythonMode . Also there are Anjuta and  
 Code:Blocks, but they are designed mainly for C++ (but still can be used).

Don't forget Wingware IDE. Admittedly, it's not free (except for a
limited version), but it's pretty good. There's also SPE (Stani's
Python Editor). If you want a nigh-complete list, check the Python
wiki:

http://wiki.python.org/moin/PythonEditors

---
Mike Driscoll

Blog:   http://blog.pythonlibrary.org

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


Re: IDE for Python

2009-08-31 Thread Che M
On Aug 31, 10:53 am, Mike Driscoll kyoso...@gmail.com wrote:
 On Aug 29, 1:08špm, ivanko@gmail.com wrote:

  29.08.2009 4:14 ÐÏÌØÚÏ×ÁÔÅÌØ Thangappan.M thangappan...@gmail.com š
  ÎÁÐÉÓÁÌ:

   Dear all,
   Please suggest some good IDE for python.I am working in linux platform.
   --
   Regards,
   Thangappan.M

  You can use Eclipse + PyDev or Emacs+PythonMode . Also there are Anjuta and 
  š
  Code:Blocks, but they are designed mainly for C++ (but still can be used).

 Don't forget Wingware IDE. Admittedly, it's not free (except for a
 limited version), but it's pretty good. There's also SPE (Stani's
 Python Editor). If you want a nigh-complete list, check the Python
 wiki:

 http://wiki.python.org/moin/PythonEditors

Not sure when an editor gets to be called an IDE, but while on the
site
that OP should check out this related page:

http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

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


Re: An assessment of Tkinter and IDLE

2009-08-31 Thread Terry Reedy

Kevin Walzer wrote:
www.tkdocs.com

[snip]

and you'll have learned a lot. But I think the TkDocs site is essential, 
especially in its more advanced discussion of how to put together an 
attractive, polished user interface with Tk. Tk has a long-standing 
reputation of being the toolkit of choice for quick, simple, ugly 
interfaces, and the other resources I've mentioned do nothing to to 
change this. The practices that Mark Roseman discusses will allow one to 
eventually put together a UI that matches anything that the other big 
toolkits (wxPython, PyQt, PyObjC, PyGtk, etc.) can do.


Hope this helps,


It persuaded me to go and start reading. A couple of things of interest.

It would be a great help if you could have a look around, provide any 
comments, corrections or suggestions, or even help fill in some of the 
missing pieces. 


so no pretense of completeness yet.

In the near future, the plan is to continue refining the tutorial, 
mainly finishing up the rest of the Perl and Python examples.


And from the linked blog

July 09, 2009
Python material in progress.

While not yet complete, I've managed to add a very hefty chunk of Python 
material to the tutorial. I should be able to complete the rest over the 
next week or so. Would definitely appreciate feedback from any 
Pythonistas on the existing material.


While I hadn't used it before, I think Tkinter may very well be the 
nicest interface to Tk next to Tcl's (for which Tk was originally 
designed of course, so you'd expect a bit of an advantage). For people 
unfamiliar with either language, I think Python's more conventional use 
of parentheses for functions, the option=value syntax, plus other 
language features it takes advantage of are very attractive and win out 
over Tcl. The two main parts that I think Tcl does in a nicer way are 
event bindings and the fact you can create and geometry manage a widget 
in one statement, while still keeping a handle to a widget around.


UPDATE July 17/2009: Most of the rest of the Python examples and code 
snippets have been added.



tjr

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


Re: map

2009-08-31 Thread Paul Rubin
elsa kerensael...@hotmail.com writes:
 map(myFunc(b='booHoo'), myList)
 
 Why doesn't this work? is there a way to make it work?

You can use functools.partial but a listcomp might be simpler:

   list(myfunc(a, b='booHoo') for a in myList)

There is another listcomp syntax with square brackets, but I try to
avoid it because it has broken behavior (leaks the index variable) in
Python 2.x.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda functions

2009-08-31 Thread Paul Rubin
Pierre pierre.gaill...@gmail.com writes:
 s_minus_1 = lambda s : for index in range(0, len(s)) : s[index] = s
 [index]-1

What are you trying to do here anyway?  That looks broken. 
Maybe you want the list.insert method.
-- 
http://mail.python.org/mailman/listinfo/python-list


executable path finding

2009-08-31 Thread koranthala
Hi,
I am creating a python application using py2exe. I am facing a
problem which I am not sure how to solve.
The application contains many other files associated with it -
like icons, config files etc. The executable can be in any directory.
If the user creates a shortcut to the executable to run in desktop,
the program fails - saying that the icon image cannot be found. But I
can run the application properly, if I run it from application
directory - where all the other icons, config files etc are kept.
How is such issues usually solved? I do not want to hardcode the
paths of icons and store the icons in those paths. I guess, we can
change the directory to the application directory before running the
application. (in __init__.py ???) But how do we find the current
directory in that case? I am completely at sea in solving this.
This looks to be a very common issue. How is this usually solved?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: executable path finding

2009-08-31 Thread Diez B. Roggisch
koranthala wrote:

 Hi,
 I am creating a python application using py2exe. I am facing a
 problem which I am not sure how to solve.
 The application contains many other files associated with it -
 like icons, config files etc. The executable can be in any directory.
 If the user creates a shortcut to the executable to run in desktop,
 the program fails - saying that the icon image cannot be found. But I
 can run the application properly, if I run it from application
 directory - where all the other icons, config files etc are kept.
 How is such issues usually solved? I do not want to hardcode the
 paths of icons and store the icons in those paths. I guess, we can
 change the directory to the application directory before running the
 application. (in __init__.py ???) But how do we find the current
 directory in that case? I am completely at sea in solving this.
 This looks to be a very common issue. How is this usually solved?

You can get the location of a module via

 module.__file__

This can be used to find a file relative to e.g. the toplevel module/package
of your application.

The pkg_resources-module of setuptools encapsulates that even into a stream
and file-name api.

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


find free hard disk space remote windows host

2009-08-31 Thread Daniel
Hello,

I'm trying to determine the amount of free hard disk space on a remote
windows host.  Seems like this should be simple, but it's giving me
grief.  Here's what I've tried:

 mystat = os.stat('//remotehost/share/')
 mystat
(16895, 0L, 0, 0, 0, 0, 0L, 1251731920, 1251731289, 1249399952)

For some reason it doesn't show the details about space on the remote
path.

Next I tried this:

subprocess.call('dir //remotehost/share/ | find bytes free',
shell=True)

But this only returns the status, not the output, which is what I
need.

How can I determine the amount of free hard drive space on a remote
windows host using python?

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


Efficient way to sum a product of numbers...

2009-08-31 Thread vsoler
Hi,

After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:

Say
 m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
 r={'a':4, 'b':5, 'c':6}

What I need is the calculation

 1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26

That is, for each row list in variable 'm' look for its first element
in variable 'r' and multiply the value found by the second element in
row 'm'. After that, sum all the products.

What's an efficient way to do it? I have thousands of these
calculations to make on a big data file.

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


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Tim Chase

After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:

Say
 m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]

assuming you meant ['c', 3] here...^

 r={'a':4, 'b':5, 'c':6}

What I need is the calculation

 1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26
and you mean 3*6 here instead of 3*4, which is 18 instead of 
12, making the whole sum 4+10+18=32



Then it sounds like you could do something like

 result = sum(v * r[k] for k,v in m)

where m is any arbitrary iterable of tuples.  If the keys (the 
letters) aren't guaranteed to be in r, then you can use 
defaults (in this case 0, but could just as likely be 1 
depending on your intent):


 result = sum(v * r.get(k,0) for k,v in m)


If the conditions above don't hold, you'll have to introduce me 
to your new math. ;-)


-tkc



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


Re: An assessment of the Unicode standard

2009-08-31 Thread Rami Chowdhury
No need to feed the troll by actually trying to engage in the discussion,  
but just FYI:



   Sanskrit is mostly written in Devanagari these days which is also
useful for selling things to people who speak Hindi and other Indian
languages.


Devanagari is what's used for Hindi and a handful of other languages, yes,  
but most Indian languages (Gujarati, Punjabi, Bengali, and Tamil just to  
name a few) use different scripts.


On Sat, 29 Aug 2009 20:07:17 -0700, Neil Hodgson  
nyamatongwe+thun...@gmail.com wrote:



Benjamin Peterson:


Like Sanskrit or Snowman language?


   Sanskrit is mostly written in Devanagari these days which is also
useful for selling things to people who speak Hindi and other Indian
languages.

   Not sure if you are referring to the ☃ snowman character or Arctic
region languages like Canadian Aboriginal syllabic writing like ᐲᐦᒑᔨᕽ
which were added to Unicode 8 years after the initial version. I'd guess
that was added from political rather than marketing motives. ☃ was
required since it was present in Japanese character sets.

   Neil




--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: executable path finding

2009-08-31 Thread koranthala
On Aug 31, 9:07 pm, Diez B. Roggisch de...@nospam.web.de wrote:
 koranthala wrote:
  Hi,
      I am creating a python application using py2exe. I am facing a
  problem which I am not sure how to solve.
      The application contains many other files associated with it -
  like icons, config files etc. The executable can be in any directory.
  If the user creates a shortcut to the executable to run in desktop,
  the program fails - saying that the icon image cannot be found. But I
  can run the application properly, if I run it from application
  directory - where all the other icons, config files etc are kept.
      How is such issues usually solved? I do not want to hardcode the
  paths of icons and store the icons in those paths. I guess, we can
  change the directory to the application directory before running the
  application. (in __init__.py ???) But how do we find the current
  directory in that case? I am completely at sea in solving this.
      This looks to be a very common issue. How is this usually solved?

 You can get the location of a module via

  module.__file__

 This can be used to find a file relative to e.g. the toplevel module/package
 of your application.

 The pkg_resources-module of setuptools encapsulates that even into a stream
 and file-name api.

 Diez

Thank you Diez. It was what I was looking for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rcond in numpy :

2009-08-31 Thread Robert Kern

On 2009-08-31 04:02 AM, Pierre wrote:


Hello,

Anyone knows the numpy equivalent of the matlab function : rcond
(Matrix reciprocal condition number estimate) ?


You will want to ask numpy questions on the numpy mailing list:

  http://www.scipy.org/Mailing_Lists

numpy.linalg.cond() will give you the condition number of the matrix. Invert it 
to get the reciprocal.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread vsoler
On Aug 31, 6:30 pm, Tim Chase python.l...@tim.thechases.com wrote:
  After simplifying my problem, I can say that I want to get the sum of
  the product of two culumns:

  Say
           m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]

 assuming you meant ['c', 3] here...    ^          r={'a':4, 'b':5, 'c':6}

  What I need is the calculation

           1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26

 and you mean 3*6 here instead of 3*4, which is 18 instead of
 12, making the whole sum 4+10+18=32

 Then it sounds like you could do something like

   result = sum(v * r[k] for k,v in m)

 where m is any arbitrary iterable of tuples.  If the keys (the
 letters) aren't guaranteed to be in r, then you can use
 defaults (in this case 0, but could just as likely be 1
 depending on your intent):

   result = sum(v * r.get(k,0) for k,v in m)

 If the conditions above don't hold, you'll have to introduce me
 to your new math. ;-)

 -tkc

Hello Tim,

There is no mistake in my original post, so I really meant [ 'a', 3]

Imagine that m contains time sheets of suppliers

   supplier 'a' has worked for you 1 hour
   supplier 'b' has worked for you 2 hour
   supplier 'a' has worked for you 3 hour

Now

   supplier 'a' charges $4 per hour
   supplier 'b' charges $5 per hour
   supplier 'c' charges $6 per hour

I want to know how much I will be charged this month by my pannel of
suppliers.

   1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26

This is what I am after.
I expect all my suppliers to have handed me in advance the per hour
fee. If at least one hasn't, I must know that the result is undefined.

Hope this helps


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


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Tim Chase

vsoler wrote:

On Aug 31, 6:30 pm, Tim Chase python.l...@tim.thechases.com wrote:

After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:
Say
 m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]

assuming you meant ['c', 3] here...^  r={'a':4, 'b':5, 'c':6}


What I need is the calculation
 1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26

and you mean 3*6 here instead of 3*4, which is 18 instead of
12, making the whole sum 4+10+18=32

Then it sounds like you could do something like

  result = sum(v * r[k] for k,v in m)

where m is any arbitrary iterable of tuples.  If the keys (the
letters) aren't guaranteed to be in r, then you can use
defaults (in this case 0, but could just as likely be 1
depending on your intent):

  result = sum(v * r.get(k,0) for k,v in m)

If the conditions above don't hold, you'll have to introduce me
to your new math. ;-)



There is no mistake in my original post, so I really meant [ 'a', 3]


Ah...that makes more sense of the data.  My answer still holds 
then.  Use the r[k] version instead of the r.get(...) version, 
and it will throw an exception if the rate doesn't exist in your 
mapping.  (a KeyError if you want to catch it)


-tkc


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


Re: An assessment of Tkinter and IDLE

2009-08-31 Thread r
Kevin and Terry,


Kevin.
I respectfully disagree that the site is ready for prime time
*However* i do not wish to undermine the great work that Mark Roseman
has done here and i thank him for his contribution. He has put much
work into covering all the major languages and i think this site
*could* turn out to be the best one-stop-shop for Tk coding no matter
what language you come use. And Actually of all the sites that i know
of, his is by far the most professional/modern looking of all!

My only beef with Mark's site is lack of detailed information OR a
reference manual of sorts in the Python language. We have too many
places around the net one must go to get this information when
starting the road to Tkinter.

The Effbot site is great with much detail but is not a good reference.
John's NMT site is a great reference but lacks the extensive tutorial
style details of effbot. Mark's site is the shiny new corvette,
however the engine is on back order?

We need to compile this info into one beautiful orgy of Tkinter
learning material. Here are the three sites that i mentioned above,
they would compress well into one...

http://effbot.org/tkinterbook/
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
http://www.tkdocs.com/


[TERRY SAID..]
While I hadn't used it before, I think Tkinter may very well be the
nicest interface to Tk next to Tcl's (for which Tk was originally
designed of course, so you'd expect a bit of an advantage). For people
unfamiliar with either language, I think Python's more conventional
use of parentheses for functions, the option=value syntax, plus
other
language features it takes advantage of are very attractive and win
out over Tcl.
[/TERRY]

Well put Terry! I could not agree more with this assessment! Pythons
wrapping of Tk is so beautiful next to the other languages i can bet a
lot of Ruby, Tcl, and Perl guys are going to feel like ugly ducklings
at a Ms america pageant! (but i may be partial to Python code... just
a little)  ;-)

When it comes to using Tkinter I think a lot of people let ego get in
the way. Yes the name may sound synonymous with Tinker Toys however,
TEE-KAY-ENTER is a great (albeit simple) GUI toolkit. I use it quite
often and reach for the power of wx only when i need the extra
functionality -- which the gap is starting to close. Anyhow, welcome
to Tkinter Terry, i only wished you would had dropped by
sooner...??? :)

psst: maybe you can use your influence and convince others that Tk is
not so bad?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is behavior of += intentional for int?

2009-08-31 Thread Carl Banks
On Aug 31, 10:21 am, zaur szp...@gmail.com wrote:
 On 29 авг, 16:45, zaur szp...@gmail.com wrote:





  Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
  [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
  Type copyright, credits or license() for more information. a=1
   x=[a]
   id(a)==id(x[0])
  True
   a+=1
   a
  2
   x[0]

  1

  I thought that += should only change the value of the int object. But
  += create new.
  Is this intentional?

 As a result of this debate is not whether we should conclude that
 there should be two types of integers in python: 1) immutable numbers,
 which behave as constant value; 2) mutable numbers, which behave as
 variable value?

You are free to use third-party modules (such as numpy) which provide
mutable numbers.

I see no reason to include any mutable number type standard library,
as not many people will require the performance benefits and/or
indirection of mutable numbers, and those who do are free to use third-
party modules that provide them.


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


Re: IDE for Python

2009-08-31 Thread Chris Colbert
I'm a big fan of wing. Pay for the non-free version and you get all
the goodies, plus PHENOMENAL support. Really. They answer support
emails within a few minutes.

Its has the best code completion i've seen in any python editor/ide
and is also the most stable, fastest (for ide's), and customizable.

I am not affiliated with Wingware or their parent company in any way.


On Mon, Aug 31, 2009 at 11:32 AM, Che Mcmpyt...@gmail.com wrote:
 On Aug 31, 10:53 am, Mike Driscoll kyoso...@gmail.com wrote:
 On Aug 29, 1:08špm, ivanko@gmail.com wrote:

  29.08.2009 4:14 ÐÏÌØÚÏ×ÁÔÅÌØ Thangappan.M thangappan...@gmail.com š
  ÎÁÐÉÓÁÌ:

   Dear all,
   Please suggest some good IDE for python.I am working in linux platform.
   --
   Regards,
   Thangappan.M

  You can use Eclipse + PyDev or Emacs+PythonMode . Also there are Anjuta 
  and š
  Code:Blocks, but they are designed mainly for C++ (but still can be used).

 Don't forget Wingware IDE. Admittedly, it's not free (except for a
 limited version), but it's pretty good. There's also SPE (Stani's
 Python Editor). If you want a nigh-complete list, check the Python
 wiki:

 http://wiki.python.org/moin/PythonEditors

 Not sure when an editor gets to be called an IDE, but while on the
 site
 that OP should check out this related page:

 http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

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

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


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Paul Rubin
vsoler vicente.so...@gmail.com writes:
  m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
  r={'a':4, 'b':5, 'c':6}
 
 What I need is the calculation
 
  1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26

sum(r[k]*w for k,w in m)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread vsoler
On Aug 31, 6:59 pm, Tim Chase python.l...@tim.thechases.com wrote:
 vsoler wrote:
  On Aug 31, 6:30 pm, Tim Chase python.l...@tim.thechases.com wrote:
  After simplifying my problem, I can say that I want to get the sum of
  the product of two culumns:
  Say
           m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
  assuming you meant ['c', 3] here...    ^          r={'a':4, 'b':5, 'c':6}

  What I need is the calculation
           1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26
  and you mean 3*6 here instead of 3*4, which is 18 instead of
  12, making the whole sum 4+10+18=32

  Then it sounds like you could do something like

    result = sum(v * r[k] for k,v in m)

  where m is any arbitrary iterable of tuples.  If the keys (the
  letters) aren't guaranteed to be in r, then you can use
  defaults (in this case 0, but could just as likely be 1
  depending on your intent):

    result = sum(v * r.get(k,0) for k,v in m)

  If the conditions above don't hold, you'll have to introduce me
  to your new math. ;-)
  There is no mistake in my original post, so I really meant [ 'a', 3]

 Ah...that makes more sense of the data.  My answer still holds
 then.  Use the r[k] version instead of the r.get(...) version,
 and it will throw an exception if the rate doesn't exist in your
 mapping.  (a KeyError if you want to catch it)

 -tkc

It works!!!

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


Re: Is behavior of += intentional for int?

2009-08-31 Thread zaur
On 29 авг, 16:45, zaur szp...@gmail.com wrote:
 Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
 [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
 Type copyright, credits or license() for more information. a=1
  x=[a]
  id(a)==id(x[0])
 True
  a+=1
  a
 2
  x[0]

 1

 I thought that += should only change the value of the int object. But
 += create new.
 Is this intentional?

As a result of this debate is not whether we should conclude that
there should be two types of integers in python: 1) immutable numbers,
which behave as constant value; 2) mutable numbers, which behave as
variable value?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging contents of IRC channel

2009-08-31 Thread Paul Rubin
devaru ajoys...@gmail.com writes:
 I am new to Python. I want to log the activities in an IRC channel.
 Any pointers regarding this would be of great help.

http://science.slashdot.org/science/04/04/13/1356216.shtml
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of Tkinter and IDLE

2009-08-31 Thread r
On Aug 28, 11:12 am, Mark Roseman m...@markroseman.com wrote:
 Would it be useful to link to this from the main Python Tkinter
 documentation?

 Mark

Sorry Mark,
i did not realize when i replied to you that YOU are the Mark of
tkdoc.com. For some reason i only saw Tcl code when i visted the site,
and that prompted my slightly grumpy rant. After looking a second time
(and actually reading more) i see this site has much promise. I hope
my post did not seem condescending of your efforts. I think your site
is beautiful and just wish we could add MORE Python specific info to
it like i covered in my last post. And also I would like to see a
complete coverage of all the widgets.

We more experienced guys already know how and where to find the
thousand or so sites for this or that Python info, but the new users
are going to be lost in the wilderness. I love that Python has so much
info out there, i just hate that is so spread out! We must do
something about this in a way that all doc/tut creators can be happy.

PS: and i would like to contribute to your site.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: find free hard disk space remote windows host

2009-08-31 Thread Tim Golden

Daniel wrote:

Hello,

I'm trying to determine the amount of free hard disk space on a remote
windows host.  Seems like this should be simple, but it's giving me
grief.  Here's what I've tried:


mystat = os.stat('//remotehost/share/')
mystat

(16895, 0L, 0, 0, 0, 0, 0L, 1251731920, 1251731289, 1249399952)


Assuming you have the necessary security levels,
WMI's quite good at this kind of thing. See this
example:

 http://timgolden.me.uk/python/wmi_cookbook.html#percentage_free

and just add remotehost as the first parameter to the
wmi.WMI () call. (And I recommend find_classes=False) for
speed.

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


Re: Logging contents of IRC channel

2009-08-31 Thread Jonathan Gardner
On Aug 31, 10:23 am, devaru ajoys...@gmail.com wrote:
 I am new to Python. I want to log the activities in an IRC channel.
 Any pointers regarding this would be of great help.

How are you going to plug into the chat server to obtain the data?

How will you store the data?

The in between parts are really easy.
-- 
http://mail.python.org/mailman/listinfo/python-list


win32ui DLL Load Failed

2009-08-31 Thread MikeC
I have a python executable that's failing to load on a user's machine
running Windows XP. My developer machine is also running Windows XP. I
have determined that it is failing when it attempts to load win32ui.

I have Python 2.6 on my developer machine and am using the pywin
support (Mark Hammonds???) for Python 2.6.

In order to make the problem smaller and more managable I created an
executable (with pytoexe) of a 1 one-line python script which does the
following:

import win32ui

Running the one-line script on my machine from python source as well
as from the executable created from the one-line source works fine on
my machine. But when I attempt to run the executable on a target
Windows/XP user machine (without Python) it fails with the following
traceback

Traceback (most recent call last):
  File CheckScan.py, line 7, in module
  File PrintImage.pyc, line 1, in module
  File win32ui.pyc, line 12, in module
  File win32ui.pyc, line 10, in __load
ImportError: DLL load failed: This application has failed to start
because the application configuration is incorrect. Reinstalling the
application may fix this problem.

The only thing I can think of regarding the difference between my
machine and the target machine is that I have the .NET framework on my
machine. Is it possible that that is the problem? Running Depends
didn't get me anywhere. I would appreciate any help you can offer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Unexpected 411 error response using httplib

2009-08-31 Thread John Gordon
I'm writing some code that queries a Microsoft Exchange Web Services server.
The server is responding with a 411 Length Required error, which is strange
because I am definitely sending a Content-Length header.

Here's the code:

-
import httplib
import base64

SoapMessage = \
?xml version=1.0 encoding=utf-8?
soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/;
   
xmlns:t=http://schemas.microsoft.com/exchange/services/2006/types;
  soap:Body
FindItem 
xmlns=http://schemas.microsoft.com/exchange/services/2006/messages;
  
xmlns:t=http://schemas.microsoft.com/exchange/services/2006/types;
  Traversal=Shallow
  ItemShape
t:BaseShapeDefault/t:BaseShape
t:AdditionalProperties
  t:FieldURI FieldURI=calendar:Start /
  t:FieldURI FieldURI=calendar:End /
  t:FieldURI FieldURI=calendar:LegacyFreeBusyStatus /
/t:AdditionalProperties
  /ItemShape
  ParentFolderIds
t:DistinguishedFolderId Id=calendar /
  /ParentFolderIds
/FindItem
  /soap:Body
/soap:Envelope\


host = some.host.com

username = myUsername
password = myPassword
auth = base64.encodestring(username + : + password)

conn = httplib.HTTPSConnection(host)
conn.set_debuglevel(5)
conn.putrequest(POST, /EWS/Exchange.asmx)
conn.putheader(Content-type, text/xml; charset=\UTF-8\)
conn.putheader(Proxy-Authorization, Basic %s % auth)
conn.putheader(Content-Length, %d % len(SoapMessage))
conn.putheader(User-Agent, Python post)
conn.endheaders()
conn.send(SoapMessage)

resp = conn.getresponse()

body= resp.read()
headers = resp.msg
version = resp.version
status  = resp.status
reason  = resp.reason

conn.close()

print Response: , status, reason
print Headers: , headers
print body
-

As you can see, I am including the call to putheader() for Content-Length,
and the debugging output confirms that the header is present in the outgoing
message.

So why am I getting a 411 Length Required error?

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: An assessment of the Unicode standard

2009-08-31 Thread Emile van Sebille

On 8/31/2009 10:41 AM Dennis Lee Bieber said...

On Mon, 31 Aug 2009 15:36:46 +0100, Nigel Rantor wig...@wiggly.org

snip
Also, I'm surprised no-one has mentioned Esperanto yet. Sounds like 
something r and Xah would *love*.



Hmmm, thought I had mentioned Esperanto (and Klingon)


Just curious -- has anyone mentioned autocoding?  :)

Emile

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


pyjamas in action?

2009-08-31 Thread kj



At work we want to implement a webapp using Google's GWT, and we're
debating whether to use the standard GWT approach with Java, or to
try Pyjamas.  There's no great love here for Java, but there's the
concern that Pyjamas will not be able to deliver the full power
and/or convenience of standard Java-based GWT.  (Why-oh-why did
Google pick Java for this?  Couldn't Guido twist some arms?  Just
kidding.)

Are there any examples of real production websites implemented with
Pyjamas?

TIA!

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


Re: win32ui DLL Load Failed

2009-08-31 Thread Mike Driscoll
On Aug 31, 2:43 pm, MikeC mcrav...@att.net wrote:
 I have a python executable that's failing to load on a user's machine
 running Windows XP. My developer machine is also running Windows XP. I
 have determined that it is failing when it attempts to load win32ui.

 I have Python 2.6 on my developer machine and am using the pywin
 support (Mark Hammonds???) for Python 2.6.

 In order to make the problem smaller and more managable I created an
 executable (with pytoexe) of a 1 one-line python script which does the
 following:

 import win32ui

 Running the one-line script on my machine from python source as well
 as from the executable created from the one-line source works fine on
 my machine. But when I attempt to run the executable on a target
 Windows/XP user machine (without Python) it fails with the following
 traceback

 Traceback (most recent call last):
   File CheckScan.py, line 7, in module
   File PrintImage.pyc, line 1, in module
   File win32ui.pyc, line 12, in module
   File win32ui.pyc, line 10, in __load
 ImportError: DLL load failed: This application has failed to start
 because the application configuration is incorrect. Reinstalling the
 application may fix this problem.

 The only thing I can think of regarding the difference between my
 machine and the target machine is that I have the .NET framework on my
 machine. Is it possible that that is the problem? Running Depends
 didn't get me anywhere. I would appreciate any help you can offer.

Did you install PyWin32? If so, which version? Here's a link:

http://sourceforge.net/projects/pywin32/

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


Re: win32ui DLL Load Failed

2009-08-31 Thread Chris Kaynor
You likely need to install the Microsoft Visual C++ 2008 SP1 Redistributable
Package on the target machine. If you search Google for this, you should
find it (make sure to grab the correct version of x86 or x64 depending upon
the Python version).


Chris


On Mon, Aug 31, 2009 at 12:43 PM, MikeC mcrav...@att.net wrote:

 I have a python executable that's failing to load on a user's machine
 running Windows XP. My developer machine is also running Windows XP. I
 have determined that it is failing when it attempts to load win32ui.

 I have Python 2.6 on my developer machine and am using the pywin
 support (Mark Hammonds???) for Python 2.6.

 In order to make the problem smaller and more managable I created an
 executable (with pytoexe) of a 1 one-line python script which does the
 following:

 import win32ui

 Running the one-line script on my machine from python source as well
 as from the executable created from the one-line source works fine on
 my machine. But when I attempt to run the executable on a target
 Windows/XP user machine (without Python) it fails with the following
 traceback

 Traceback (most recent call last):
  File CheckScan.py, line 7, in module
  File PrintImage.pyc, line 1, in module
  File win32ui.pyc, line 12, in module
  File win32ui.pyc, line 10, in __load
 ImportError: DLL load failed: This application has failed to start
 because the application configuration is incorrect. Reinstalling the
 application may fix this problem.

 The only thing I can think of regarding the difference between my
 machine and the target machine is that I have the .NET framework on my
 machine. Is it possible that that is the problem? Running Depends
 didn't get me anywhere. I would appreciate any help you can offer.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: map

2009-08-31 Thread Nobody
On Sun, 30 Aug 2009 21:55:52 -0700, elsa wrote:

 say I have a list, myList. Now say I have a function with more than
 one argument:
 
 myFunc(a, b='None')
 
 now, say I want to map myFunc onto myList, with always the same
 argument for b, but iterating over a:
 
 map(myFunc(b='booHoo'), myList)
 
 Why doesn't this work?

You're passing the result of (incorrectly) calling myFunc to map(), but
you need to pass a function.

 is there a way to make it work?

If you need to construct a simple function on-the-fly, you can use a
lambda form:

map(lambda x: myFunc(x, b='booHoo'), myList)

Or you could use a list comprehension:

[myFunc(x, b='booHoo') for x in myList]

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


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Jan Kaliszewski

31-08-2009 o 18:19:28 vsoler vicente.so...@gmail.com wrote:


Say
 m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
 r={'a':4, 'b':5, 'c':6}

What I need is the calculation

 1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26

That is, for each row list in variable 'm' look for its first element
in variable 'r' and multiply the value found by the second element in
row 'm'. After that, sum all the products.

What's an efficient way to do it? I have thousands of these
calculations to make on a big data file.



31-08-2009 o 18:30:27 Tim Chase python.l...@tim.thechases.com wrote:


  result = sum(v * r[k] for k,v in m)



You can also check if this isn't more efficient:

  from itertools import starmap
  from operator import mul

  result = sum(starmap(mul, ((r[name], hour) for name, hour in m)))


Or, if you had m in form of two lists:

  names = ['a', 'b', 'a']
  hours = [1, 2, 3]

...then you could do:

  from itertools import imap as map  # - remove if you use Py3.x
  from operator import mul

  result = sum(map(mul, map(r.__getitem__, names), hours))


Cheers,
*j

PS. I've done a quick test on my computer (Pentium 4, 2.4Ghz, Linux):

setup = from itertools import starmap, imap ; from operator import  
mul; import random, string; names =  
[rndom.choice(string.ascii_letters) for x in xrange(1)]; hours =  
[random.randint(1, 12) for x in xrange(1000)]; m = zip(names, hours);  
workers = set(names); r = dict(zip(workers, (random.randint(1, 10) for  
x in xrange(en(workers)

tests = (

... 'sum(v * r[k] for k,v in m)',
... 'sum(starmap(mul, ((r[name], hour) for name, hour in m)))',
... 'sum(imap(mul, imap(r.__getitem__, names), hours))',
... )

for t in tests:

... print t
... timeit.repeat(t, setup, number=1000)
... print
...
sum(v * r[k] for k,v in m)
[6.2493009567260742, 6.1892399787902832, 6.2634339332580566]

sum(starmap(mul, ((r[name], hour) for name, hour in m)))
[9.3293819427490234, 10.280816078186035, 9.2766909599304199]

sum(imap(mul, imap(r.__getitem__, names), hours))
[5.7341709136962891, 5.5898380279541016, 5.7318859100341797]


--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list


Re: pyjamas in action?

2009-08-31 Thread André
On Aug 31, 4:46 pm, kj no.em...@please.post wrote:
 At work we want to implement a webapp using Google's GWT, and we're
 debating whether to use the standard GWT approach with Java, or to
 try Pyjamas.  There's no great love here for Java, but there's the
 concern that Pyjamas will not be able to deliver the full power
 and/or convenience of standard Java-based GWT.  (Why-oh-why did
 Google pick Java for this?  Couldn't Guido twist some arms?  Just
 kidding.)

 Are there any examples of real production websites implemented with
 Pyjamas?

 TIA!

 kynn

Perhaps you might get answers faster if you posted to the pyjamas
group: http://groups.google.com/group/pyjamas-dev

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


Re: win32ui DLL Load Failed

2009-08-31 Thread MikeC
On Aug 31, 12:43 pm, MikeC mcrav...@att.net wrote:
 I have a python executable that's failing to load on a user's machine
 running Windows XP. My developer machine is also running Windows XP. I
 have determined that it is failing when it attempts to load win32ui.

 I have Python 2.6 on my developer machine and am using the pywin
 support (Mark Hammonds???) for Python 2.6.

 In order to make the problem smaller and more managable I created an
 executable (with pytoexe) of a 1 one-line python script which does the
 following:

 import win32ui

 Running the one-line script on my machine from python source as well
 as from the executable created from the one-line source works fine on
 my machine. But when I attempt to run the executable on a target
 Windows/XP user machine (without Python) it fails with the following
 traceback

 Traceback (most recent call last):
   File CheckScan.py, line 7, in module
   File PrintImage.pyc, line 1, in module
   File win32ui.pyc, line 12, in module
   File win32ui.pyc, line 10, in __load
 ImportError: DLL load failed: This application has failed to start
 because the application configuration is incorrect. Reinstalling the
 application may fix this problem.

 The only thing I can think of regarding the difference between my
 machine and the target machine is that I have the .NET framework on my
 machine. Is it possible that that is the problem? Running Depends
 didn't get me anywhere. I would appreciate any help you can offer.

I assume you're asking about my development machine. Yes I have it
installed. When I bring up PythonWin.exe, here is what is displayed at
the top of the main dialog.

PythonWin 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin'
for further copyright information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Efficient way to sum a product of numbers...

2009-08-31 Thread Jan Kaliszewski

31-08-2009 o 22:28:56 Jan Kaliszewski z...@chopin.edu.pl wrote:


 setup = from itertools import starmap, imap ; from operator
import mul; import random, string; names = [rndom.choice(string.
ascii_letters) for x in xrange(1)]; hours = [random.randint(
1, 12) for x in xrange(1000)]; m = zip(names, hours); workers = 
set(names); r = dict(zip(workers, (random.randint(1, 10) for x i

n xrange(en(workers)


Erratum -- should be:

   setup = (
  ... 'from itertools import starmap, imap;'
  ... 'from operator import mul;'
  ... 'import random, string; names'
  ... ' = [random.choice(string.ascii_letters)'
  ... 'for x in xrange(1)];'
  ... 'hours = [random.randint(1, 12)'
  ...   for x in xrange(1)];'
  ... 'm = zip(names, hours);'
  ... 'workers = set(names);'
  ... 'r = dict(zip(workers, (random.randint(1, 10)'
  ... '   for x in xrange(len(workers)'
  ... )

--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list


Re: Object Reference question

2009-08-31 Thread Ethan Furman

josef wrote:

On Aug 27, 1:35 pm, Ethan Furman et...@stoneleaf.us wrote:


josef wrote:


Thanks to everyone who responded.



I will be going with some sort of a = MyClass(name = 'a') format. It's
the Python way.



For me, it was very hard to accept that EVERYTHING is an object
reference. And that there are no object reference names, just string
entries in dictionaries. But I think it all makes sense now.



Thanks again,



Josef


My apologies if I missed it, but what *exactly* are you planning on
doing with your 'name' attribute?  From the posts I've seen so far, I
think you are only setting yourself up for failure.

~Ethan~



I'm going to use it for printing purposes. dk = MyClass(name='dk')
When I need a name dk.name. There will only ever be one dk defined.

Does that read like I'm setting myself up for failure?


I was hoping someone with more expertise than myself would answer that. 
 :)  Oh well.


The best answer I can give is that you do not want to use 'name' to 
reference the object itself, but only for printing/debugging purposes. 
'name' is just a label for your object, and not necessarily the only 
label;  that particular label may also be lost... Consider:


In [5]: class MyClass(object):
   ...: def __init__(self, name):
   ...: self.name = name
   ...: def __repr__(self):
   ...: return MyClass(name='%s') % self.name
   ...:

In [6]: dk = MyClass(name='dk')

In [7]: dk
Out[7]: MyClass(name='dk')

In [8]: se = dk

In [9]: del dk

In [10]: se
Out[10]: MyClass(name='dk')

In [11]: dk
---
NameError Traceback (most recent call last)

C:\pythonlib\ipython console in module()

NameError: name 'dk' is not defined

As you can see, just because you have saved the original name does not 
gaurantee that same name will always reference that same object, or any 
object.


Hope this helps!

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


Re: lambda functions

2009-08-31 Thread Rhodri James
On Mon, 31 Aug 2009 08:41:57 +0100, Pierre pierre.gaill...@gmail.com  
wrote:



Hello,

I would like to know if it is possible to define a loop in a lambda
function

How to manage the indents ? Example :
s_minus_1 = lambda s : for index in range(0, len(s)) : s[index] = s
[index]-1


You can't use commands in a lambda function, only expressions.  The nearest
thing I can think of to what you want here is to use a list comprehension:

  s_minus_1 = lambda s : [i-1 for i in s]
  my_list = s_minus_1(my_list)

On the other hand, giving a name to an anonymous function rather defeats
the point of it being an *anonymous* function!  What are you actually
trying to do here?  There's almost certainly a better way to do it than
this.

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


Python installation

2009-08-31 Thread Vo, Trinh (388C)
Hello Python Users,

I am new to Python.  I have errors message when I installed Python.  I 
appreciate if you can help.

I download Python-2.6-2.  I then did the following steps:
./configure
make

In the second step make, I had the following message:


Failed to find the necessary bits to build these modules:
_bsddb _curses_curses_panel
_hashlib   _sqlite3   _ssl
_tkinter   bsddb185   bz2
dbmdl gdbm
imageopreadline   sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the 
module's name.
I however still saw the binary python was installed in /usr/local/Python-2.6.2. 
 I tested, and it till run OK.  However, I am worried if the above message can 
cause any problem in  the future.  I have on my cluster:
X86_64
GCC version 4.1.2  (Red Hat 4.1.2-42)

Thank you,

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


Re: Python installation

2009-08-31 Thread Benjamin Kaplan
On Mon, Aug 31, 2009 at 9:32 PM, Vo, Trinh (388C)trinh...@jpl.nasa.gov wrote:
 Hello Python Users,



 I am new to Python.  I have errors message when I installed Python.  I
 appreciate if you can help.



 I download Python-2.6-2.  I then did the following steps:

 ./configure

 make



 In the second step “make”, I had the following message:





 Failed to find the necessary bits to build these modules:

 _bsddb _curses    _curses_panel

 _hashlib   _sqlite3   _ssl

 _tkinter   bsddb185   bz2

 dbm    dl gdbm

 imageop    readline   sunaudiodev

 To find the necessary bits, look in setup.py in detect_modules() for the
 module's name.

 I however still saw the binary python was installed in
 /usr/local/Python-2.6.2.  I tested, and it till run OK.  However, I am
 worried if the above message can cause any problem in  the future.  I have
 on my cluster:

 X86_64

 GCC version 4.1.2  (Red Hat 4.1.2-42)

It's only a problem if you want to use those modules. Personally, I
would rebuild it with some more of those (just install those libraries
and the dev versions if red hat keeps them separate) but Python can
run fine without them.



 Thank you,



 Trinh Vo

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


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


[issue5639] Support TLS SNI extension in ssl module

2009-08-31 Thread Daniel Black

Daniel Black dan...@cacert.org added the comment:

The small deficiency with these patches is that the specified
server_hostname is almost always the hostname that is used in the socket
pair of connect. Is it appropriate to grab the hostname value and use it
in the SNI extension header?

--

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



[issue6788] codecs.open on Win32 does not force binary mode

2009-08-31 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

I think your test is invalid: it creates the file in w mode, so \n are 
written as two bytes \r\n on the disk.
codecs.open just reads them back.

--
nosy: +amaury.forgeotdarc
resolution:  - invalid
status: open - pending

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



[issue6809] Python string.lstrip bug?

2009-08-31 Thread Andrew Liu

New submission from Andrew Liu mushywu...@gmail.com:

A simple lstrip on the following causes an extra character to be
stripped, as per the below. Tried on 2.6.1 and on 2.4.3, as below.

Python 2.6.1 (r261:67515, Feb 27 2009, 02:54:13)
[GCC 4.3.2 20081105 (Red Hat 4.3.2-7)] on linux2
Type help, copyright, credits or license for more information.
 a = contact_work_phone_no
 a.lstrip(contact)
'_work_phone_no'
 a.lstrip(contact_)
'work_phone_no'
 a = contact_city
 a.lstrip(contact_)
'ity'
 a.lstrip(con)
'tact_city'
 a.lstrip(contact)
'_city'
 a.lstrip(contact_)
'ity'



Python 2.4.3 (#1, Mar 14 2007, 19:01:42)
[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2
Type help, copyright, credits or license for more information.
 a = contact_city
 a.lstrip(contact_)
'ity'


--
components: Build
messages: 92102
nosy: mushywushy
severity: normal
status: open
title: Python string.lstrip bug?
type: behavior
versions: Python 2.6

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



[issue6801] symmetric_difference_update documentation fix

2009-08-31 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

 Well, in that case I don't understand how it is different from
 difference_update() ?

It's different from difference_update because that takes multiple
arguments. The operator form shows an equivalent and therefore shows how
to write an equivalent of the method with multiple arguments.

 suggesting that you can pipe several sets with -=,
 exactly like what you can do with ^=.

Of course you can put multiple or'ed sets on the right of ^=, but then
you can put every expression there.

 In other words, this whole section is unclear in 
 what other is, and why we have others sometimes.
 (eg a set or a several sets piped together for example)

I've fixed two other descriptions in r74603, it should be consistent now.

--

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



[issue6809] Python string.lstrip bug?

2009-08-31 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

This is not a bug:  the argument to lstrip effectively specifies a set 
of characters to be removed;  in your example, 'c' is in that set, so 
the 'c' at the beginning of city gets removed.  'i' is not in that set, 
so it stays. 

lstrip(...)
S.lstrip([chars]) - string or unicode

Return a copy of the string S with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.

--
nosy: +marketdickinson
resolution:  - invalid
status: open - closed

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



[issue2973] _ssl compiler warnings

2009-08-31 Thread Daniel Black

Daniel Black dan...@cacert.org added the comment:

The changeset that changed the definitions is here:
http://cvs.openssl.org/chngview?cn=12024 (2004-Mar-14 23:15:13 (UTC))

As you can see there is no easy identifier in the changeset (i'm not
sure how portable an ifdef on a typedef is (possible
asn1_const_ctx_st/ASN1_const_CTX)).

The patch i've done goes of then next OPENSSL_VERSION_NUMBER change
which occurred here
http://cvs.openssl.org/filediff?f=openssl/crypto/opensslv.hv1=1.36.2.35v2=1.36.2.36
(2004/03/17 11:40:44) ~3 days later.

Same patch applies to p3k

--
keywords: +patch
nosy: +grooverdan
versions: +Python 2.7, Python 3.0, Python 3.1, Python 3.2
Added file: 
http://bugs.python.org/file14811/issue2973-D2I_PARAMETER_2_TYPE.patch

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



[issue6810] add link to the documentation of signal.signal

2009-08-31 Thread Yinon Ehrlich

New submission from Yinon Ehrlich yino...@users.sourceforge.net:

in http://docs.python.org/library/signal.html#signal.signal the reader
is referred to see the reference manual section on the standard type
hierarchy. It would be generous if we will supply a link like
http://docs.python.org/reference/datamodel.html;

BTW: it would be even more generous if the page
http://docs.python.org/reference/datamodel.html will include anchors to
specific paragraphs/items, so we could even refer to 
http://docs.python.org/reference/datamodel.html#frame, for example (the
#frame anchor doesn't exist now)

Thanks in advance !

--
assignee: georg.brandl
components: Documentation
messages: 92106
nosy: Yinon, georg.brandl
severity: normal
status: open
title: add link to the documentation of signal.signal

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



[issue3212] ssl module - should test for a wrong cert

2009-08-31 Thread Daniel Black

Daniel Black dan...@cacert.org added the comment:

Is fixed in p3k Mon Sep 8 16:45:19 2008 UTC
http://svn.python.org/view/python/branches/py3k/Lib/test/test_ssl.py?r1=65837r2=66311

--
nosy: +grooverdan
versions: +Python 3.1, Python 3.2

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



[issue6802] build fails on Snow Leopard

2009-08-31 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

The patch works for me.  Thanks.

--

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



[issue6297] Added Misc/python.pc to 'distclean' Rule

2009-08-31 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks for the patch.

Applied in r74604 (trunk), r74605 (py3k), r74606 (release31-maint).

--
assignee: georg.brandl - marketdickinson
components: +Build -Documentation
nosy: +marketdickinson
resolution:  - accepted
stage:  - committed/rejected
status: open - closed
versions: +Python 2.7, Python 3.2

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



[issue2637] urllib.quote() escapes characters unnecessarily and contrary to docs

2009-08-31 Thread Senthil

Senthil orsent...@gmail.com added the comment:

Fixed and 
Committed revision 74608 - trunk
Committed revision 74609 - py3k

--
resolution:  - fixed

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



[issue6802] build fails on Snow Leopard

2009-08-31 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

With the patch installed, no regressions were seen running my standard set 
of OSX installer builds/installs/regtests on 10.4 and 10.5.

--

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



[issue6811] add a filename argument to marshal.load*

2009-08-31 Thread Brett Cannon

New submission from Brett Cannon br...@python.org:

For compatibility w/ import, importlib needs the ability to set 
code.co_filename to the actual location of the bytecode used to create a 
module and not the path embedded in the marshal data. But since 
co_filename is read-only it can't be done at the moment.

The idea is to add an optional argument to marshal.load* that takes a 
string representing the file path that co_filename should be set to, 
overriding what is in the marshal data.

A long-term perk of this is that eventually this argument can become 
required for marshal.loads() and the file path embedded in the marshal 
data can be removed entirely. marshal.load() would infer its path from 
file.name.

This was all discussed on python-dev; 
http://mail.python.org/pipermail/python-dev/2009-August/091460.html

--
assignee: brett.cannon
components: Extension Modules
messages: 92113
nosy: brett.cannon
priority: low
severity: normal
stage: test needed
status: open
title: add a filename argument to marshal.load*
type: feature request
versions: Python 3.2

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



[issue6811] add a filename argument to marshal.load*

2009-08-31 Thread Fred L. Drake, Jr.

Changes by Fred L. Drake, Jr. fdr...@acm.org:


--
nosy: +fdrake

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



[issue6802] build fails on Snow Leopard

2009-08-31 Thread Jason Montleon

Changes by Jason Montleon mont...@hotmail.com:


--
nosy: +xaoslaad

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



[issue992389] attribute error after non-from import

2009-08-31 Thread Adam Olsen

Adam Olsen rha...@gmail.com added the comment:

The key distinction between this and a bad circular import is that
this is lazy.  You may list the import at the top of your module, but
you never touch it until after you've finished importing yourself (and
they feel the same about you.)

An ugly fix could be done today for module imports by creating a proxy
that triggers the import upon the first attribute access.  A more
general solution could be done with a lazyimport statement, triggered
when the target module finishes importing; only problem there is the
confusing error messages and other oddities if you reassign that name.

--
nosy: +Rhamphoryncus

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



[issue992389] attribute error after non-from import

2009-08-31 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

I have done a lazy importer like you describe, Adam, and it does help 
solve this issue. And it does have the problem of import errors being 
triggered rather late and in an odd spot.

--

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



[issue992389] attribute error after non-from import

2009-08-31 Thread Adam Olsen

Adam Olsen rha...@gmail.com added the comment:

It'd probably be sufficient if we raised NameError: lazy import 'foo'
not yet complete.  That should require a set of what names this module
is lazy importing, which is checked in the failure paths of module
attribute lookup and global/builtin lookup.

--

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



[issue6812] Snow Leopard python program fails because _PyType_Modified is missing from python framework

2009-08-31 Thread Seamus O'Shea

New submission from Seamus O'Shea os...@uleth.ca:

Attempts to compile a simple example using XCode 3.2 (Xcode IDE: 1610.0, 
Xcode Core: 1608.0, ToolSupport: 1591.0)under Snow Leopard fail with 
error message 
Traceback (most recent call last):
  File /Users/seamus/Science/xcode exploration/Objc-
programs/First_PyObjC/build/Debug/First_PyObjC.app/Contents/Resources/ma
in.py, line 10, in module
import objc
  File 
/System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib
/python/PyObjC/objc/__init__.py, line 22, in module
_update()
  File 
/System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib
/python/PyObjC/objc/__init__.py, line 19, in _update
import _objc
ImportError: 
dlopen(/System/Library/Frameworks/Python.framework/Versions/Current/Extr
as/lib/python/PyObjC/objc/_objc.so, 2): Symbol not found: 
_PyType_Modified
  Referenced from: 
/System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib/
python/PyObjC/objc/_objc.so
  Expected in: flat namespace
 in 
/System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib/
python/PyObjC/objc/_objc.so
2009-08-31 08:31:23.534 First_PyObjC[4072:a0f] *** Terminating app due 
to uncaught exception 'NSInternalInconsistencyException', reason: 
'/Users/seamus/Science/xcode exploration/Objc-
programs/First_PyObjC/main.m:46 main() PyRun_SimpleFile failed with file 
'/Users/seamus/Science/xcode exploration/Objc-
programs/First_PyObjC/build/Debug/First_PyObjC.app/Contents/Resources/ma
in.py'.  See console for errors.'
*** Call stack at first throw:
(
0   CoreFoundation  0x90a1858a __raiseError 
+ 410
1   libobjc.A.dylib 0x9309cf49 
objc_exception_throw + 56
2   CoreFoundation  0x90a182b8 +[NSException 
raise:format:arguments:] + 136
3   CoreFoundation  0x90a1822a +[NSException 
raise:format:] + 58
4   First_PyObjC0x2bc2 main + 1084
5   First_PyObjC0x275a start + 54
)
sharedlibrary apply-load-rules all

The Current Version in the system library is 2.6.

Any suggestions?

--
assignee: ronaldoussoren
components: Macintosh
messages: 92117
nosy: ronaldoussoren, soshea
severity: normal
status: open
title: Snow Leopard python program fails because _PyType_Modified is missing 
from python framework
type: compile error
versions: Python 2.6

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



[issue5639] Support TLS SNI extension in ssl module

2009-08-31 Thread Phil Pennock

Phil Pennock python-...@spodhuis.org added the comment:

(Sorry for dropping this, lost available time)

I see your point.  OTOH, use of SNI needs to be something that can be 
disabled and people need to be able to connect to host A while supplying 
host B, not necessarily using IP addresses for the specificity.  Use-
case example: someone has a service www hosted on [www-1, www-2, 
www-3].  They have an SSL certificate for www and they want to have 
a health-checker which probes for working service, all certs valid and 
not about to expire.

Unless s.connect() gains a keep_original_hostname=False option (?), this 
is hard to do.

Then there's the principle of least surprise -- while it would be nice 
to get SNI working automatically for everyone, it's still plausible that 
amongst the various TLS servers out there are some which break horribly 
for SNI and upgrading Python shouldn't break the tools in use.

So I tend towards favouring make use of the newer, less well tested, 
protocol feature something that has to be explicitly enabled, even if 
it adds a line to boilerplate -- if SNI ever takes over the world (as 
Host: headers in HTTP have) then it can be defaulted on in future 
perhaps?

In which case, if the default is to change, the API should be sorted 
now, so perhaps connect() should take an override_server_hostname=False 
flag, which will make it pass the connect() hostname parameter instead 
of self.server_hostname in the call to _ssl.sslwrap()?  With checking 
for an IP address?

--

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



[issue5468] urlencode does not handle bytes, and could easily handle alternate encodings

2009-08-31 Thread Miles Kaufmann

Changes by Miles Kaufmann mile...@umich.edu:


Removed file: http://bugs.python.org/file14796/urllib_parse.py3k.patch

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



[issue6813] update format() documentation and tutorial

2009-08-31 Thread Daniel Black

New submission from Daniel Black dan...@cacert.org:

Release notes show the use of '{}'.format('this') and the attached patch
updates this to be the default example in the tutorial. Library
references are updated to show field_name as optional and a few examples
are added.

Relates to the improvements from issue 5237.

--
assignee: georg.brandl
components: Documentation
files: documentation-str-format.patch
keywords: patch
messages: 92119
nosy: georg.brandl, grooverdan
severity: normal
status: open
title: update format() documentation and tutorial
versions: Python 3.1, Python 3.2
Added file: http://bugs.python.org/file14812/documentation-str-format.patch

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