Next meeting of the Hamburg Python User Group

2007-11-07 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

if you happen to be in Hamburg, Germany at November, 14th, and you'd like
to meet fellow Pythonistas, you should come to Jarrestraße 46 at DDD
design, who are generously hosting us again.

We will start at 19:30 and this time we will have a presentation again. It
will be about SQLAlchemy and I will do it.

Hamburg's Pythonistas can be found online in the Google Group
http://groups.google.com/group/hamburg-pythoneers

Cheers,

Gerhard
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHMPLSdIO4ozGCH14RAnpIAJ9aWSDLKL5RyU1GSZT/KItWEvDr3gCffHYg
lF3y9LUmu+FLnCooBX7RrY4=
=OSsp
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


New book: Object-Oriented Programming in Python

2007-11-07 Thread Michael H. Goldwasser

We are pleased to announce the release of a new Python book.

   Object-Oriented Programming in Python
   by Michael H. Goldwasser and David Letscher
   Prentice Hall, 2008   (available as of 10/29/2007)

This book is based on materials developed after switching our
curriculum to the use of Python for an object-oriented CS1 course.
Since the primary market is an introductory course, we do not
assume any previous programming experience for our readers.  This
should make it a very good match for those who wish to self-study.

The book differs greatly from existing introductory Python books as
it warmly embraces the object-oriented nature of Python from the
onset.  It is also extremely comprehensive with solid fundamentals
as well as several advanced topics that can be covered as
desired.

More information can be found at http://www.prenhall.com/goldwasser

With regard,
Michael Goldwasser

   +---+
   | Michael Goldwasser|
   | Associate Professor   |
   | Dept. Mathematics and Computer Science|
   | Saint Louis University|
   | 220 North Grand Blvd. |
   | St. Louis, MO 63103-2007  |
   |   |
   | Office: Ritter Hall 6 |
   | Email:  [EMAIL PROTECTED]  |
   | URL:euler.slu.edu/~goldwasser |
   | Phone:  (314) 977-7039|
   | Fax:(314) 977-1452|
   +---+

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

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


[ANN] Release 0.66.1 of Task Coach

2007-11-07 Thread Frank Niessink
Hi,

I'm happy to announce release 0.66.1 of Task Coach. This bug fix
release addresses four bugs:

* When changing the sort order in a tree viewer, keep collapsed items
collapsed and expanded items expanded.
* Sort categories alphabetically in task editor.
* Double clicking a task in the tree view did not open the task edit dialog.
* When filtering on a specific category, a newly added task belonging
to that category was not shown in the task viewers.


What is Task Coach?

Task Coach is a simple task manager that allows for hierarchical
tasks, i.e. tasks in tasks. Task Coach is open source (GPL) and is
developed using Python and wxPython. You can download Task Coach from:

http://www.taskcoach.org

In addition to the source distribution, packaged distributions are
available for Windows XP/Vista, Mac OSX, and Linux (Debian and RPM format).

Note that Task Coach is alpha software, meaning that it is wise to back
up your task file regularly, and especially when upgrading to a new release.

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

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


ANN: NumPy 1.0.4

2007-11-07 Thread Jarrod Millman
I'm pleased to announce the release of NumPy 1.0.4.

NumPy is the fundamental package needed for scientific computing with
Python.  It contains:

   * a powerful N-dimensional array object
   * sophisticated (broadcasting) functions
   * basic linear algebra functions
   * basic Fourier transforms
   * sophisticated random number capabilities
   * tools for integrating Fortran code.

Besides it's obvious scientific uses, NumPy can also be used as an
efficient multi-dimensional container of generic data. Arbitrary
data-types can be defined. This allows NumPy to seamlessly and
speedily integrate with a wide-variety of databases.

This is largely a bug fix release with one notable improvement:

   * The NumPy and SciPy developers have decided to adopt the Python
naming convention for classes. So as of this  release, TestCase
classes may now be prefixed with either 'test' or 'Test'.  This will
allow us to write TestCase classes using the CapCase words, while
still accepting the old style names.

For information, please see the release notes:
http://sourceforge.net/project/shownotes.php?release_id=552568group_id=1369

Thank you to everybody who contributed to the recent release.

Enjoy,

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Drawing charts in Qt

2007-11-07 Thread Michel Albert
On Nov 6, 5:08 pm, David Boddie [EMAIL PROTECTED] wrote:
 On Tue Nov 6 15:46:07 CET 2007, Michel Albert wrote:

 [PyQwt and matplotlib]

  PyQwt looks much more interesting, but I have trouble installing it.
  On my machine it complains that sipconfig has no attribute
  '_pkg_config'.

 Is the configuration script finding the sipconfig file for SIP 3 or SIP 4?

How can I see if it's finding it or not? It does not give me any
helpful output.


  In the end the application should also run on Windows boxes. And I
  suppose as long as I use the right versions and use the precompiled
  binaries, I should get it at least installed. But the thing with the
  version numbers looks like some major lottery game to me. If one of
  the elements in the chain (be it Qt, or Qwt) release new versions and
  the available binary distributions get out of sync, future support
  for the written application becomes foggy.

 I'm not sure what you mean. Can you explain?

Well, I suppose I can manage this. If there really are some version
problems I can always compile everything I need myself.


  Has anyone ever successfully used these graphing libraries with PyQt?
  Or are there other graphing libraries available? In fact, my needs are
  modest. A Line- and Bar-Chart would solve the majority of problems.

 I've installed PyQwt for PyQt4 and tried the examples, but only out of
 curiosity because I wasn't writing an application that needed those
 facilities at the time.

 David


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


RE: Parallel Python environments..

2007-11-07 Thread Thorsten Kampe
* bruce (Tue, 6 Nov 2007 13:43:10 -0800)
 if i have python 2.4.3 installed, it gets placed in the python2.4 dir.. if i
 don't do anything different, and install python 2.4.2, it too will get
 placed in the python2.4 tree... which is not what i want.
 
 i'm running rhel4/5...

So you're using rpm as a packet manager. I suggest you RTFM to see if 
there are options for slots or dual installations.
 
 so.. i still need to know what to do/change in order to be able to run
 multiple versions of python, and to switch back/forth between the versions.

Unpack the Python rpm to ~/bin or compile Python yourself. And be more 
specific about what you mean with switching back/forth. 

On the other hand - as Gabriel pointed out: there is almost a 100% 
certainty that the problem you want to solve by having Python 2.4.2 
*and* 2.4.3 simultaneously exists only in your head or cannot be 
solved this way.

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


Re: command-line arguments in IDLE

2007-11-07 Thread Ginger
it does have one in activepython
 
   Thanks and Regards,
Ginger
- Original Message - 
From: Russ P. [EMAIL PROTECTED]
To: python-list@python.org
Sent: Wednesday, November 07, 2007 8:56 AM
Subject: command-line arguments in IDLE


 Is it possible to pass command-line arguments when running a program
 in IDLE? The Run menu does not seem to provide that option. Thanks.
 
 

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


Strange behavior of __get__ in a descriptor in IPython

2007-11-07 Thread Jakub Hegenbart
Hi,

I'm studying the descriptor protocol and its usage from the following  
document:

http://users.rcn.com/python/download/Descriptor.htm

There is some sample code:

http://users.rcn.com/python/download/Descriptor.htm#descriptor-example

that behaves in a different way on my machine than the example suggests:

In [2]: a=MyClass()

In [3]: a.x
Retrieving var x
Retrieving var x
Out[3]: 1

On the other hand, in the 'plain' Python shell, it's invoked only once as  
expected:

 a=desc.MyClass()
 a.x
Retrieving var x
10


Should I take as granted that IPython might in some cases access an  
attribute
of an object more than once even in face of side effects, or is this a bug?

Regards,

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


Re: Retrieving all open applications ...

2007-11-07 Thread Ajay Deshpande
hi guys:

well i still havent found a solution to this ... since i am using ubuntu
7.10, i cannot use the hammond modules ...

-Ajay

On 11/4/07, Ajay Deshpande [EMAIL PROTECTED] wrote:

 applications ... i need to retrieve all currently open applications ...

 thx for your help ...

 -Ajay

 On 10/31/07, Gabriel Genellina  [EMAIL PROTECTED] wrote:
 
  En Tue, 30 Oct 2007 06:20:10 -0300, Ajay Deshpande
  [EMAIL PROTECTED] escribió:
 
   I need to retrieve all currently open applications using a python
   program.
   So my output should be a list of window handles. Is there a module
  which
   I
   can use?
 
  applications or windows? You can use the EnumWindows function, from
  the Windows API, to enumerate all  top level windows. See this article
  from the Microsoft Knowledge Base 
  http://support.microsoft.com/kb/183009
  (the example is in VB but I hope you get the idea)
 
  Install the pywin32 extensions from Mark Hammond
  http://pywin32.sourceforge.net and you'll have the EnumWindows function
  available.
 
  --
  Gabriel Genellina
 
  --
  http://mail.python.org/mailman/listinfo/python-list
 


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

Re: Strange behavior of __get__ in a descriptor in IPython

2007-11-07 Thread Diez B. Roggisch
Jakub Hegenbart wrote:

 Hi,
 
 I'm studying the descriptor protocol and its usage from the following
 document:
 
 http://users.rcn.com/python/download/Descriptor.htm
 
 There is some sample code:
 
 http://users.rcn.com/python/download/Descriptor.htm#descriptor-example
 
 that behaves in a different way on my machine than the example suggests:
 
 In [2]: a=MyClass()
 
 In [3]: a.x
 Retrieving var x
 Retrieving var x
 Out[3]: 1
 
 On the other hand, in the 'plain' Python shell, it's invoked only once as
 expected:
 
 a=desc.MyClass()
 a.x
 Retrieving var x
 10

 
 Should I take as granted that IPython might in some cases access an
 attribute
 of an object more than once even in face of side effects, or is this a
 bug?

I'm not sure, but you could try and set up a counter that counts the number
of accesses.

But to be honest: I don't think it's a bug - this is one hell of an
essential part of python, not working here would cause all kinds of
troubles.

Instead, I presume the printing/shell-part of IPython is responsible.

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


Re: Looking for a good Python environment

2007-11-07 Thread [EMAIL PROTECTED]
On Nov 7, 3:51 am, Jens [EMAIL PROTECTED] wrote:
 Just wrote a mini review of three Python code editors on my blog...

 http://pyminer.blogspot.com/2007/11/python-code-editors.html

 I use PSPad or Notepad++ for quick editing, and Komodo Edit 4.2 for
 longer sessions. Komodo Edit is the only one with code completion - a
 very nice feature. You can pay $299 and get Komodo Edit, which has a
 debugger.

 I've only used Eclipse for Java programming, but there's a Python plug-
 in called PyDev - just haven't figured out how to install it :-(

Thanks Jeff and thanks Jen. I'll take a look at these editors to see
if they're good for me.

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


Re: LaTeX tutorial updated

2007-11-07 Thread Hendrik Maryns
[EMAIL PROTECTED] schreef:
 On Nov 6, 12:30 pm, Nicola Talbot [EMAIL PROTECTED] wrote:
 Hi,

 I've updated my Using LaTeX to write a PhD thesis tutorial. Both PDF
 and HTML versions can be reached viahttp://theoval.cmp.uea.ac.uk/~nlct/latex/

 I have added/deleted sections, so if you have any links to document
 nodes (i.e. files that are of the form node*.html) you may have to
 update your links.

 Regards
 Nicola Talbot
 
 very nice.
 
 911 truckload of Explosives on the George Washington Bridge
 http://www.youtube.com/watch?v=J520P-MD9a0
 
 http://video.google.com/videoplay?docid=3552214685532803163

PLONK.

-- 
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Confused about closures and scoping rules

2007-11-07 Thread Bruno Desthuilliers
Michele Simionato a écrit :
 On Nov 6, 7:37 pm, Chris Mellon [EMAIL PROTECTED] wrote:
 On Nov 6, 2007 6:23 PM, Jean-Paul Calderone [EMAIL PROTECTED] wrote:
 Lots of people ask about this.  The behavior you observed is the expected
 (by the implementors, anyway) behavior.
 Are there languages where closures *don't* behave like this? A closure
 that used a copy of the state rather than the actual state itself
 doesn't seem as useful. For references sake, JavaScript (the only
 language that a) has closures and b) I have a handy way to test with)
 does the same thing.
 
 Closures in Haskell's list comprehensions work as Fernando (and many
 others would expect). 

IIRC, Haskell's 'variables' are constant (ie: you cannot rebind nor 
mutate them).
-- 
http://mail.python.org/mailman/listinfo/python-list


a revolutionary principle please read that

2007-11-07 Thread No1
With Agloco you can earn in future properly money, the principle is
new! earlier you beginst so much the better are your chances. the
great in it is: in every person you mediate you earn and even from
those them again your provided mediate, this about 5 levels. The
principle is easy and efficient. if you are announced you can instal a
surfbar (however, do not have to do, however, recommendable there it
so quick money gives!). the surfbar does not interfere and is very
small like a small task strip. On this always small text
advertisements are faded in this surfbar to you then for which you are
paid so long if you the surfbar actively holds. You must click no
advertisement only the task bar allow to run (surfbar). Some users
already earn gigantic sums with up to 40,000 users and more in
unterlevels. So does not wait separate start now with it. The whole
one finances itself with the advertisement Is faded in. Many companies
use this new advertisement-princip then this brings many advantages,
one can appeal exactly to the customer group which one would also
want, companies spend every year milliards on advertisement on the
Internet. Even 90% of the money which Agloco aearn of the companies
will be transmitted to the user how using the surfbar. The
registration is for free! You can only win losing nothing! Advertise
with your friends and find partners.

Announce yourselves even today and begin your career: Here Announce

xx

 www.agloco.com/r/BBHK6764

xx

What can you earn? Example:

 You become a partner and search 5 other partners these partners 3
other partners everybody win in each case surfs per month 5 hours
(what he does anyway) (Accepted every surfed hour it is calculated on
1 $)

Then you earn per month  761.25 $

(calculated more than 5 levels)

This does, e.g., with 10 partners  1,522.50 $
or, e.g., with 20 partners  3,045.00 $

Also something or a lot is possible more!!

Announce yourselves even today and begin your career: Here Announce:

 www.agloco.com/r/BBHK6764

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


Re: Looking for a good Python environment

2007-11-07 Thread Fabio Zadrozny
On 11/6/07, Jens [EMAIL PROTECTED] wrote:

 Just wrote a mini review of three Python code editors on my blog...

 http://pyminer.blogspot.com/2007/11/python-code-editors.html

 I use PSPad or Notepad++ for quick editing, and Komodo Edit 4.2 for
 longer sessions. Komodo Edit is the only one with code completion - a
 very nice feature. You can pay $299 and get Komodo Edit, which has a
 debugger.

 I've only used Eclipse for Java programming, but there's a Python plug-
 in called PyDev - just haven't figured out how to install it :-(


Have you checked: http://www.fabioz.com/pydev/manual_101_install.html ?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a good Python environment

2007-11-07 Thread jwelby
On Nov 6, 10:56 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 Hey, I'm looking for a good Python environment. That is, at least an
 editor and a debugger, and it should run on Windows. Does anyone have
 any idea?

I currently use Python Scripter as a lightweight editor for Windows.

For project work I use Eclipse, which can be installed with PyDev and
other useful plug-ins already included if you choose a suitable
distribution of Easy Eclipse (http://www.easyeclipse.org/). There is a
distribution specifically for Python development, and also one for
LAMP, which includes a number of other components which will be of use
if you are developing for the web.

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


Re: Looking for a good Python environment

2007-11-07 Thread [EMAIL PROTECTED]
On Nov 7, 1:15 pm, jwelby [EMAIL PROTECTED] wrote:
 On Nov 6, 10:56 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:

  Hey, I'm looking for a good Python environment. That is, at least an
  editor and a debugger, and it should run on Windows. Does anyone have
  any idea?

 I currently use Python Scripter as a lightweight editor for Windows.

 For project work I use Eclipse, which can be installed with PyDev and
 other useful plug-ins already included if you choose a suitable
 distribution of Easy Eclipse (http://www.easyeclipse.org/). There is a
 distribution specifically for Python development, and also one for
 LAMP, which includes a number of other components which will be of use
 if you are developing for the web.

Thanks jewlby, I'll check it out.

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


Re: regular expressions

2007-11-07 Thread J. Cliff Dyer
Paul McGuire wrote:
 On Nov 6, 11:07 am, J. Clifford Dyer [EMAIL PROTECTED] wrote:
   
 On Tue, Nov 06, 2007 at 08:49:33AM -0800, [EMAIL PROTECTED] wrote regarding 
 regular expressions:



 
 hi i am looking for pattern in regular expreesion that replaces
 anything starting with and betweeen http:// until /
 likehttp://www.start.com/startservice/yellow/fdhttp://helo/abcdwill
 be replaced as
 p/startservice/yellow/ fdp/abcd
   
 You don't need regular expressions to do that.  Look into the methods that 
 strings have.  Look at slicing. Look at len.  Keep your code readable for 
 future generations.

 Py help(str)
 Py dir(str)
 Py help(str.startswith)

 Cheers,
 Cliff
 

 Look again at the sample input.  Some of the OP's replacement targets
 are not at the beginning of a word, so str.startswith wont be much
 help.

 Here are 2 solutions, one using re, one using pyparsing.

 -- Paul


 instr = 
 anything starting with and betweeen http://; until /
 like http://www.start.com/startservice/yellow/ fdhttp://helo/abcd
 will
 be replaced as
 

 REPLACE_STRING = p

 # an re solution
 import re
 print re.sub(http://[^/]*;, REPLACE_STRING, instr)


 # a pyparsing solution - with handling of target strings inside quotes
 from pyparsing import SkipTo, replaceWith, quotedString

 replPattern = http://; + SkipTo(/)
 replPattern.setParseAction( replaceWith(REPLACE_STRING) )
 replPattern.ignore(quotedString)

 print replPattern.transformString(instr)


 Prints:

 anything starting with and betweeen p/
 like p/startservice/yellow/ fdp/abcd will
 be replaced as


 anything starting with and betweeen http://; until /
 like p/startservice/yellow/ fdp/abcd will
 be replaced as

   
Interesting.  In my email clients, they do show up at the beginning of
words (thunderbird and mutt), but in your reply they aren't.  I wonder
if there's some funky unicode space that your computer isn't
rendering  Or something on my end.  There were definitely spaces in
his email as it appears on my computer.

But if there aren't, s.startswith() is clearly not the way to go.


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

Re: Mikhail Khodorkovsky was a Rothschild frontman and he obtained his initial capital and manipulation knowledge from there. Re: 911 operation by evil JEWS and Mossad

2007-11-07 Thread thermate
On Nov 7, 9:32 am, Matimus [EMAIL PROTECTED] wrote:
 On Nov 7, 8:35 am, [EMAIL PROTECTED] wrote:



  Google is a half russian jew company. We have had to make new accounts
  as a result of it sending us a cookie which cripples postings. The jew
  agents involved in this process are the ones that make deflecting
  replies. Their operating procedure: Deflect, when you cannot defend.
  Therefore, we ignore them.

  On Nov 7, 7:08 am, [EMAIL PROTECTED] wrote:

   911 carried out by evil jews and 
   mossadhttp://www.guba.com/watch/2000991770

   911 truckload of Explosives on the George Washington 
   Bridgehttp://www.youtube.com/watch?v=J520P-MD9a0

   Benjamin Freedman's SEMINAL TESTIMONIAL 
   SPEECHhttp://video.google.com/videoplay?docid=3552214685532803163

   Benjamin Freedman speech with Slide Show (40 Minute 
   Excerpt)http://video.google.com/videoplay?docid=3552214685532803163

   Free pdf book: THE MANUFACTURE AND SALE of Saint Einstein
   @http://jewishracism.com/SaintEinstein.htm

   Author interviews @http://jewishracism.com/interviews.htm

   Rothschilds control half the world's wealth directly and indirectly
   using zionist proxies, and loyalty based on the zionist racist cult of
   hate and paranoia based on being caught for collective financial
   crimes and crimes of other categories

   History of the Rothschilds part 
   1http://www.youtube.com/watch?v=o_u2MaNg-EQ

   History of the Rothschilds part 
   2http://www.youtube.com/watch?v=o2cw-0N_Unk

   FBI, Where are the two Israelis with TRUCKLOAD of explosives at the
   George Washington Bridge 
   ?http://www.youtube.com/watch?v=JfVumKHkcIA- Shame stooopid
   americans

   Alex Jones Interviews David Mayer de 
   Rothschildhttp://video.google.com/videoplay?docid=4891699310483983031

   The rise of the Rothschild Money 
   Mastershttp://www.youtube.com/watch?v=ZT3GyphxJv8

   Rothschilds financed APARTHEID in South Africa. They corrupted Cecil
   Rhodes, the son of an anglican minister, by TEACHING him evil
   techniques of apartheid. Apartheid was taught to him by the father
   zionists themselves.

   Rothschilds control half the world's wealth directly and indirectly
   using zionist proxies, and loyalty based on the zionist racist 
   culthttp://www.youtube.com/watch?v=fXVJzXsraX4

   Was Hitler's father a bastard son of Rothschilds? Did the Salomon
   Mayer von Rothschild perhaps rape  Maria Anna Schicklgruber in dark so
   that she could not ever claim with certainty who the real father was?
   Look at his facial features, typical central asian khazar. What was
   the cause of Hitler's fanatical hatred for the Jews 
   ?http://en.wikipedia.org/wiki/Alois_Hitlerhttp://www.youtube.com/watch...

   On Nov 6, 9:53 am, [EMAIL PROTECTED] wrote:

The world has been after Bill Gates for no reason. The richest group
was and remains the Zionist jew Rothschilds family who own HALF the
worlds total wealth through numerous frontmen zionists.
Mikhail Khodorkovsky, whom Russian President Vladimir I Putin put in
jail rose from the Rothschilds money. Mayer Amschel Bauer changed his 
name to
Rothschild or red shield. The he sent his sons to various countries in
Europe and become bankers there. Using an innovative system of pigeons
for communication and encoded letters, the family invested in wars
that he knew were coming by staying close to the centers of powers in
all the countries which they had infilterated.
google video and youtube have many videos on the family. You can set
aside part of your weekend for HEALTHY education so your
kids can learn how to avoid being hunted by these snakes.- Hide quoted 
text -

   - Show quoted text -

 Even if google was a company run by anti-semitic nut jobs (your type
 of folk), they would be right to prevent you from posting such things
 in a Python, tex or physics mailing list.

 Hey... everybody, if you use Google groups and are getting tons of
 this crap, report it as abuse! I don't know if they will do anything
 about it, but its getting to the point where I don't want to look at
 comp.lang.python at work.

Listen, self-hating zionazi, mossad spook, or informal zionist lobby
member:

He has perfect right for liberal education of the people.

For the moment your jew media strangles the flow of truth.

However, you flood the world with porn and debauchery.
For example, I support my claim with that zionist billionaire bitch
Ruth Parasol aka the parasite who has made billions by selling
porn and gambling to the Christian people.

He has perfect right to post well substantiated videos on 911 crime
by you bastards, that you painted on others.

Thermate

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


Deep comparison of sets?

2007-11-07 Thread Daryl Spitzer
The second assertion in the following code fails:

class Value(object):
def __init__(self, value):
super(Value, self).__init__()
self.value = value
def __cmp__(self, other):
if self.value  other.value: return 1
if self.value  other.value: return -1
return 0

if __name__ == __main__:
v1 = Value('one')
v2 = Value('one')
assert v1 == v2
s1 = set([v1])
s2 = set([v2])
assert s1 == s2

Is there any way to compare the two sets so that __cmp__ is called (I
guess this would be called a deep comparison) rather than just
(shallowly) comparing each object in the set?

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


Re: os.popen does not seem to catch stdout

2007-11-07 Thread [EMAIL PROTECTED]
On Nov 7, 11:31 am, [EMAIL PROTECTED] wrote:
 On Nov 7, 7:58 am, [EMAIL PROTECTED] wrote:



  Hi there,

  I've been banging my head against this for a day, and I can't take it
  anymore.  It's probably a stupid error, but I don't see where.

  I'm trying to use Python to call an external program, and then catch
  and process the output of that program.  Seems simple enough.  The
  command I'm trying to run, in the test, is:

  /Users/zane/svn/stress/satstress/satstress -r1.561e+06 -a5 -s45000 -
  e0 -R6.709e+08 -g1.31472 -m1.8987e+27 -Q57100.1 -n0.55 -Y9.29881e
  +09 -k1e+22 -Z1.19173 -z-6.293e-05 -V0.309434 -v-2.903e-05 -W1.81305 -
  w-0.00418645 -U0.474847 -u-0.00276624 -C /tmp/18_tmp.gen -b 60

  When I run it at my zsh prompt, I get the expected output.

  If I let ss_cmd equal the above string within ipython (or the standard
  python interactive interpreter):

  ss_outlines = os.popen(ss_cmd).readlines()

  ss_outlines contains the same output I saw when I ran the command at
  my zsh prompt, one line per list element, as expected.

  However, when I try doing the same thing from within a program, it
  fails.  ss_outlines is an empty list.

  I've tried using subprocess.Popen(), and subprocess.call(), and
  subprocess.check_call(), and all have yielded similar results.  I did
  find, however, that the return value python is getting from the
  program I'm calling is different from what I get at the command line
  (I get 0, python gets -11).

  Does this ring a bell for anyone?

  I'm using Python 2.5.1 on a Mac running OS X 10.5.

 I think when you use subprocess.Popen, you need to do something set
 the shell to True to get it to behave like running from a command
 prompt:

 subprocess.Popen('some command', shell=True)

 Seehttp://docs.python.org/lib/node529.htmlfor more details.

 You'll also find a fairly interesting thread on this topic here:

 http://mail.python.org/pipermail/chicago/2005-November/000141.htmlhttp://mail.python.org/pipermail/python-list/2005-October/347508.html

 This seems to be a recipe on it:

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

 Mike


That's right, and I think you also want to put the whole command in a
list or tuple, one item for each arg.  I don't know why though.

-Greg

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


Re: Strange behavior of __get__ in a descriptor in IPython

2007-11-07 Thread Fernando Perez
Jakub Hegenbart wrote:

 Hi,
 
 I'm studying the descriptor protocol and its usage from the following
 document:
 
 http://users.rcn.com/python/download/Descriptor.htm
 
 There is some sample code:
 
 http://users.rcn.com/python/download/Descriptor.htm#descriptor-example
 
 that behaves in a different way on my machine than the example suggests:
 
 In [2]: a=MyClass()
 
 In [3]: a.x
 Retrieving var x
 Retrieving var x
 Out[3]: 1
 
 On the other hand, in the 'plain' Python shell, it's invoked only once as
 expected:
 
 a=desc.MyClass()
 a.x
 Retrieving var x
 10

 
 Should I take as granted that IPython might in some cases access an
 attribute
 of an object more than once even in face of side effects, or is this a bug?

Yup, IPython does access attributes more than once in an attempt to determine
if things can be called as functions.  This behavior, however, only exists
if 'autocall' is active.  Here's an example:

In [1]: run desc

In [2]: m.x
Retrieving var x
Retrieving var x
Out[2]: 10

In [3]: m.x
Retrieving var x
Retrieving var x
Out[3]: 10

In [4]: autocall 0
Automatic calling is: OFF

In [5]: m.x
Retrieving var x
Out[5]: 10


As you can see, once autocall is disabled, the double access goes away.  There
really is no way to provide the autocall feature without any side effects
whatsoever, so if you need to avoid them at all costs, disable this feature. 
You can do it permanently by editing your ipythonrc file.

Cheers,

f

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


regular expression syntax the same in Python, Perl and grep?

2007-11-07 Thread [EMAIL PROTECTED]
How similar is Python's re module (regular expressions) compared
to Perl's and grep's regular expression syntaxes?

I really hope regular expression syntax is sufficiently standardized
that
we don't have to learn new dialects everytime we move from one
language or shell command to another.

chris

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


Re: Need help writing coroutine

2007-11-07 Thread Paul Hankin

Matthew Wilson wrote:
 I'm working on two coroutines -- one iterates through a huge stream, and
 emits chunks in pieces.  The other routine takes each chunk, then scores
 it as good or bad and passes that score back to the original routine, so
 it can make a copy of the stream with the score appended on.

 I have the code working, but it just looks really ugly.  Here's a vastly
 simplified version.  One function yields some numbers, and the other
 function tells me if they are even or odd.

 def parser():
 I just parse and wait for feedback.
 for i in 1, 2, 3, 4, 5:
 score = (yield i)
 if score:
 print %d passed! % i

 def is_odd(n):
 I evaluate each number n, and return True if I like it.
 if n and n % 2: return True

 def m():
 try:
 number_generator = parser()
 i = None
 while 1:
 i = number_generator.send(is_odd(i))
 except StopIteration: pass

 and here's the results when I run this:
 In [90]: m()
 1 passed!
 3 passed!
 5 passed!

 So, clearly, the code works.  But it is nonintuitive for the casual
 reader.

 I don't like the while 1 construct, I don't like manually
 trapping the StopIteration exception, and this line is really ugly:

 i = number_generator.send(is_odd(i))

 I really like the old for i in parser(): deal, but I can't figure out
 how to use .send(...) with that.

 Can anyone help me pretty this up?  I want to make this as intuitive as
 possible.

Why use coroutines?

def parser(score):
for i in xrange(1, 6):
yield i
if score(i):
print %d passed! % i

def is_odd(n):
return n % 2

def m():
for i in parser(is_odd):
# Presumably do something here...
pass

--
Paul Hankin

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


Re: Looking for a good Python environment

2007-11-07 Thread Paul Rubin
Colin J. Williams [EMAIL PROTECTED] writes:
 Could you elaborate on lightweight please? I find PyScripter to be a
 powerful editor/debugger combination.
 
 What functionality does Eclipse have that PyScripter does not?

While we're at it, do any of these debuggers implement a good way to
debug multi-threaded Python programs?
-- 
http://mail.python.org/mailman/listinfo/python-list


Mikhail Khodorkovsky was a Rothschild frontman and he obtained his initial capital and manipulation knowledge from there. Re: 911 operation by evil JEWS and Mossad

2007-11-07 Thread zionist . news2
Google is a half russian jew company. We have had to make new accounts
as a result of it sending us a cookie which cripples postings. The jew
agents involved in this process are the ones that make deflecting
replies. Their operating procedure: Deflect, when you cannot defend.
Therefore, we ignore them.

On Nov 7, 7:08 am, [EMAIL PROTECTED] wrote:
 911 carried out by evil jews and mossadhttp://www.guba.com/watch/2000991770

 911 truckload of Explosives on the George Washington 
 Bridgehttp://www.youtube.com/watch?v=J520P-MD9a0

 Benjamin Freedman's SEMINAL TESTIMONIAL 
 SPEECHhttp://video.google.com/videoplay?docid=3552214685532803163

 Benjamin Freedman speech with Slide Show (40 Minute 
 Excerpt)http://video.google.com/videoplay?docid=3552214685532803163

 Free pdf book: THE MANUFACTURE AND SALE of Saint Einstein
 @http://jewishracism.com/SaintEinstein.htm

 Author interviews @http://jewishracism.com/interviews.htm

 Rothschilds control half the world's wealth directly and indirectly
 using zionist proxies, and loyalty based on the zionist racist cult of
 hate and paranoia based on being caught for collective financial
 crimes and crimes of other categories

 History of the Rothschilds part 1http://www.youtube.com/watch?v=o_u2MaNg-EQ

 History of the Rothschilds part 2http://www.youtube.com/watch?v=o2cw-0N_Unk

 FBI, Where are the two Israelis with TRUCKLOAD of explosives at the
 George Washington Bridge ?http://www.youtube.com/watch?v=JfVumKHkcIA  
 - Shame stooopid
 americans

 Alex Jones Interviews David Mayer de 
 Rothschildhttp://video.google.com/videoplay?docid=4891699310483983031

 The rise of the Rothschild Money 
 Mastershttp://www.youtube.com/watch?v=ZT3GyphxJv8

 Rothschilds financed APARTHEID in South Africa. They corrupted Cecil
 Rhodes, the son of an anglican minister, by TEACHING him evil
 techniques of apartheid. Apartheid was taught to him by the father
 zionists themselves.

 Rothschilds control half the world's wealth directly and indirectly
 using zionist proxies, and loyalty based on the zionist racist 
 culthttp://www.youtube.com/watch?v=fXVJzXsraX4

 Was Hitler's father a bastard son of Rothschilds? Did the Salomon
 Mayer von Rothschild perhaps rape  Maria Anna Schicklgruber in dark so
 that she could not ever claim with certainty who the real father was?
 Look at his facial features, typical central asian khazar. What was
 the cause of Hitler's fanatical hatred for the Jews 
 ?http://en.wikipedia.org/wiki/Alois_Hitlerhttp://www.youtube.com/watch?v=TihCM_q59c8

 On Nov 6, 9:53 am, [EMAIL PROTECTED] wrote:



  The world has been after Bill Gates for no reason. The richest group
  was and remains the Zionist jew Rothschilds family who own HALF the
  worlds total wealth through numerous frontmen zionists.
  Mikhail Khodorkovsky, whom Russian President Vladimir I Putin put in
  jail rose from the Rothschilds money. Mayer Amschel Bauer changed his name 
  to
  Rothschild or red shield. The he sent his sons to various countries in
  Europe and become bankers there. Using an innovative system of pigeons
  for communication and encoded letters, the family invested in wars
  that he knew were coming by staying close to the centers of powers in
  all the countries which they had infilterated.
  google video and youtube have many videos on the family. You can set
  aside part of your weekend for HEALTHY education so your
  kids can learn how to avoid being hunted by these snakes.- Hide quoted text 
  -

 - Show quoted text -


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


Re: os.popen does not seem to catch stdout

2007-11-07 Thread kyosohma
On Nov 7, 7:58 am, [EMAIL PROTECTED] wrote:
 Hi there,

 I've been banging my head against this for a day, and I can't take it
 anymore.  It's probably a stupid error, but I don't see where.

 I'm trying to use Python to call an external program, and then catch
 and process the output of that program.  Seems simple enough.  The
 command I'm trying to run, in the test, is:

 /Users/zane/svn/stress/satstress/satstress -r1.561e+06 -a5 -s45000 -
 e0 -R6.709e+08 -g1.31472 -m1.8987e+27 -Q57100.1 -n0.55 -Y9.29881e
 +09 -k1e+22 -Z1.19173 -z-6.293e-05 -V0.309434 -v-2.903e-05 -W1.81305 -
 w-0.00418645 -U0.474847 -u-0.00276624 -C /tmp/18_tmp.gen -b 60

 When I run it at my zsh prompt, I get the expected output.

 If I let ss_cmd equal the above string within ipython (or the standard
 python interactive interpreter):

 ss_outlines = os.popen(ss_cmd).readlines()

 ss_outlines contains the same output I saw when I ran the command at
 my zsh prompt, one line per list element, as expected.

 However, when I try doing the same thing from within a program, it
 fails.  ss_outlines is an empty list.

 I've tried using subprocess.Popen(), and subprocess.call(), and
 subprocess.check_call(), and all have yielded similar results.  I did
 find, however, that the return value python is getting from the
 program I'm calling is different from what I get at the command line
 (I get 0, python gets -11).

 Does this ring a bell for anyone?

 I'm using Python 2.5.1 on a Mac running OS X 10.5.

I think when you use subprocess.Popen, you need to do something set
the shell to True to get it to behave like running from a command
prompt:

subprocess.Popen('some command', shell=True)

See http://docs.python.org/lib/node529.html for more details.

You'll also find a fairly interesting thread on this topic here:

http://mail.python.org/pipermail/chicago/2005-November/000141.html
http://mail.python.org/pipermail/python-list/2005-October/347508.html

This seems to be a recipe on it:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

Mike

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


Re: subprocess chokes on spaces in path

2007-11-07 Thread BartlebyScrivener
On Nov 6, 2:48 pm, Gabriel Genellina [EMAIL PROTECTED] wrote:

 Use a list of arguments [antiword, word_doc] and let subprocess handle the
 spaces the right way.


Got it working. Thank you both.

p = subprocess.Popen([antiword, word_doc], stdout=subprocess.PIPE)
doc_text = p.stdout.read()

rd




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


Re: What colour model does the image use in PIL

2007-11-07 Thread Hrvoje Niksic
Johny [EMAIL PROTECTED] writes:

 I would need to apply a threshold value to the image, where
 everything above a certain brightness level becomes white, and
 everything below the level becomes black.  How can I do that with
 PIL?

I think you're supposed to use the point method, but I don't have an
example ready.  See
http://mail.python.org/pipermail/image-sig/2004-November/003019.html
for a hint.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: finding bluetooth serial port

2007-11-07 Thread Grant Edwards
On 2007-11-07, Paul Sijben [EMAIL PROTECTED] wrote:

 To automate/ease configuration in my app I am trying to find
 out to which serial port a certain bluetooth device is
 connected. With pybluez I can find out which bluetooth devices
 I have, but it will not tell me the serial port they are
 mapped to.

 Is there a way to figure this out from python? (I am
 insterested in the platforms WinXP and linux primarily)

Under linux, the right thing to do is to write a udev rule so
that the device has a predictiable name (or symlink).

http://reactivated.net/writing_udev_rules.html

If you don't want to write a udev rule, you'll need to bascally
re-implement udev by parsing the sysfs directory tree until you
find the device you're looking for. Here's how to do it for USB
(I assume BT works in a similar fashion).  

Let's say I know the device has vendor ID 0403, product ID
6001, and serial number 123456.

I search through the directories under /sys/devices until I
find a directory containing three files named

  idProduct
  idVendor
  serial  

Which contain the three strings I'm looking for.

In this case:

# cat /sys/devices/pci:00/:00:10.3/usb5/5-1/idVendor 
0403
# cat /sys/devices/pci:00/:00:10.3/usb5/5-1/idProduct
6001
# cat /sys/devices/pci:00/:00:10.3/usb5/5-1/serial   
12345678

Once you've found that directory, you can look at the other
entries to find out whatever you want to know about the device:

/sys/devices/pci:00/:00:10.3/usb5/5-1/
|-- 5-1:1.0
|   |-- bAlternateSetting
|   |-- bInterfaceClass
|   |-- bInterfaceNumber
|   |-- bInterfaceProtocol
|   |-- bInterfaceSubClass
|   |-- bNumEndpoints
|   |-- bus - ../../../../../../bus/usb
|   |-- driver - ../../../../../../bus/usb/drivers/ftdi_sio
|   |-- ep_02 - 
../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep02
|   |-- ep_81 - 
../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep81
|   |-- interface
|   |-- modalias
|   |-- power
|   |   |-- state
|   |   `-- wakeup
|   |-- subsystem - ../../../../../../bus/usb
|   |-- ttyUSB0
|   |   |-- bus - ../../../../../../../bus/usb-serial
|   |   |-- driver - ../../../../../../../bus/usb-serial/drivers/ftdi_sio
|   |   |-- power
|   |   |   |-- state
|   |   |   `-- wakeup
|   |   |-- subsystem - ../../../../../../../bus/usb-serial
|   |   |-- tty:ttyUSB0 - ../../../../../../../class/tty/ttyUSB0
|   |   `-- uevent
|   |-- uevent
|   |-- usb_endpoint:usbdev5.42_ep02 - 
../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep02
|   |-- usb_endpoint:usbdev5.42_ep81 - 
../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep81
|   |-- usbdev5.42_ep02
|   |   |-- bEndpointAddress
|   |   |-- bInterval
|   |   |-- bLength
|   |   |-- bmAttributes
|   |   |-- dev
|   |   |-- device - 
../../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0
|   |   |-- direction
|   |   |-- interval
|   |   |-- power
|   |   |   |-- state
|   |   |   `-- wakeup
|   |   |-- subsystem - ../../../../../../../class/usb_endpoint
|   |   |-- type
|   |   |-- uevent
|   |   `-- wMaxPacketSize
|   `-- usbdev5.42_ep81
|   |-- bEndpointAddress
|   |-- bInterval
|   |-- bLength
|   |-- bmAttributes
|   |-- dev
|   |-- device - 
../../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0
|   |-- direction
|   |-- interval
|   |-- power
|   |   |-- state
|   |   `-- wakeup
|   |-- subsystem - ../../../../../../../class/usb_endpoint
|   |-- type
|   |-- uevent
|   `-- wMaxPacketSize
|-- bConfigurationValue
|-- bDeviceClass
|-- bDeviceProtocol
|-- bDeviceSubClass
|-- bMaxPacketSize0
|-- bMaxPower
|-- bNumConfigurations
|-- bNumInterfaces
|-- bcdDevice
|-- bmAttributes
|-- bus - ../../../../../bus/usb
|-- configuration
|-- devnum
|-- driver - ../../../../../bus/usb/drivers/usb
|-- ep_00 - 
../../../../../devices/pci:00/:00:10.3/usb5/5-1/usbdev5.42_ep00
|-- event_char
|-- idProduct
|-- idVendor
|-- manufacturer
|-- maxchild
|-- power
|   |-- state
|   `-- wakeup
|-- product
|-- serial
|-- speed
|-- subsystem - ../../../../../bus/usb
|-- uevent
|-- usb_device:usbdev5.42 - ../../../../../class/usb_device/usbdev5.42
|-- usb_endpoint:usbdev5.42_ep00 - 
../../../../../devices/pci:00/:00:10.3/usb5/5-1/usbdev5.42_ep00
|-- usbdev5.42_ep00
|   |-- bEndpointAddress
|   |-- bInterval
|   |-- bLength
|   |-- bmAttributes
|   |-- dev
|   |-- device - ../../../../../../devices/pci:00/:00:10.3/usb5/5-1
|   |-- direction
|   |-- interval
|   |-- power
|   |   |-- state
|   |   `-- wakeup
|   |-- subsystem - ../../../../../../class/usb_endpoint
|   |-- type
|   |-- uevent
|   `-- wMaxPacketSize
`-- version


If you want to search by something other than the product id,
vendor id and serial number, then pick some other of the files
above that will have identifiable contents and look for that.

-- 
Grant Edwards

Re: Looking for a good Python environment

2007-11-07 Thread Gerhard Häring
[EMAIL PROTECTED] wrote:
 Hey, I'm looking for a good Python environment. That is, at least an
 editor and a debugger, and it should run on Windows. Does anyone have
 any idea?

I like ERIC. You can get it at
http://www.die-offenbachs.de/eric/eric4-download.html

Or just download and install PyQt4, which includes it:

http://www.riverbankcomputing.com/Downloads/PyQt4/GPL/PyQt-Py2.5-gpl-4.3.1-1.exe

There's also a list of Python IDEs on the Python wiki:
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

-- Gerhard

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


Re: manually cutting a picture

2007-11-07 Thread Joseph king
Thanks that is a pretty good idea one thought that i came up with
(honestly the only one that made sense) was to give the user a type of
cookie cutter approach.  where they would be presented with a
selection of premade piece's that could divide the picture that they
chose to how ever many pieces that they wanted.  but the problem with
that is the possibility to have little shrivels of the image if they
did not cut the picture correctly.  But you gave me another look on
how to accomplish this...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good Python environment

2007-11-07 Thread Colin J. Williams
jwelby wrote:
 On Nov 6, 10:56 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:
 Hey, I'm looking for a good Python environment. That is, at least an
 editor and a debugger, and it should run on Windows. Does anyone have
 any idea?
 
 I currently use Python Scripter as a lightweight editor for Windows.

Could you elaborate on lightweight 
please? I find PyScripter to be a
powerful editor/debugger combination.

What functionality does Eclipse have 
that PyScripter does not?


Colin W.

 
 For project work I use Eclipse, which can be installed with PyDev and
 other useful plug-ins already included if you choose a suitable
 distribution of Easy Eclipse (http://www.easyeclipse.org/). There is a
 distribution specifically for Python development, and also one for
 LAMP, which includes a number of other components which will be of use
 if you are developing for the web.
 

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


Re: How to use list as key of dictionary?

2007-11-07 Thread Wildemar Wildenburger
Duncan Booth wrote:
 Better, just don't try passing it a recursive data structure.
 
 a = [1, 2, 3]
 a[1] = a
 a
 [1, [...], 3]
 tupleize(a)
 
 
 Traceback (most recent call last):
   File pyshell#5, line 1, in module
 tupleize(a)
   File pyshell#1, line 5, in tupleize
 return tuple(tupleize(thing) for thing in non_tuple)
   File pyshell#1, line 5, in genexpr
 return tuple(tupleize(thing) for thing in non_tuple)
   File pyshell#1, line 5, in tupleize
 return tuple(tupleize(thing) for thing in non_tuple)
   File pyshell#1, line 5, in genexpr
 return tuple(tupleize(thing) for thing in non_tuple)
   File pyshell#1, line 5, in tupleize
 return tuple(tupleize(thing) for thing in non_tuple)
 ...

Your'e a fiend!

;)

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


Re: a simple tcp server sample

2007-11-07 Thread Robert Hicks
On Nov 7, 1:54 pm, Tzury Bar Yochay [EMAIL PROTECTED] wrote:
 hi, the following sample (from docs.python.org) is a server that can
 actually serve only single client at a time.

 In my case I need a simple server that can serve more than one client.
 I couldn't find an example on how to do that and be glad to get a
 hint.

 Thanks in advance

 import socket

 HOST = '127.0.0.1'  # Symbolic name meaning the local host
 PORT = 50007# Arbitrary non-privileged port

 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.bind((HOST, PORT))
 s.listen(1)
 conn, addr = s.accept()

 print 'Connected by', addr

 while 1:
 data = conn.recv(1024)
 if not data:
 break
 conn.send(data)

 conn.close()

POE

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


a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
hi, the following sample (from docs.python.org) is a server that can
actually serve only single client at a time.

In my case I need a simple server that can serve more than one client.
I couldn't find an example on how to do that and be glad to get a
hint.

Thanks in advance

import socket

HOST = '127.0.0.1'  # Symbolic name meaning the local host
PORT = 50007# Arbitrary non-privileged port

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()

print 'Connected by', addr

while 1:
data = conn.recv(1024)
if not data:
break
conn.send(data)

conn.close()

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


Re: LaTeX tutorial updated [OT]

2007-11-07 Thread Caboose
that looks like a great latex resource. maybe you should post it to
latex users groups.

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Just Another Victim of the Ambient Morality

Neil Cerutti [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 2007-11-05, Just Another Victim of the Ambient Morality
 [EMAIL PROTECTED] wrote:
 Kay Schluehr [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I'm not sure one needs to start again with a naive approach
 just to avoid any parser theory. For a user of a parser it is
 quite important whether she has to wait 50 seconds for a parse
 to run or 50 milliseconds. I don't like to compromise speed
 for implementation simplicity here.

 This attitude is all too prevalent among computer
 professionals...  Of course it's a useful thing to shield users
 from the intricacies of parser theory!  Just as much as it is
 useful to shield drivers from needing automotive engineering or
 software users from programing.  How many people have come to
 this newsgroup asking about anomalous pyparsing behaviour,
 despite their grammars being mathematically correct.

 You might be interested in the Early parsing algorithm. It is
 more efficient than the naive approach used in your prototype,
 and still handles ambiguous grammars.

I think I might be interested in this algorithm, thank you!


 There is a Python module SPARK that provides generic classes for
 building small language compilers using an Early parser, and I
 was able to get it to parse your ambiguous grammar without
 trouble. It is not as convenient or as well documented as
 PyParsing, but the parsing algorithm provides the power you're
 looking for. It might serve as a backend for the library you're
 currently working on.

 http://www.cpsc.ucalgary.ca/~aycock/spark/

You know, I tried this thing but, for the life of me, I can't figure out 
how to use it and the few tutorials out there are less than illuminating...



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


Need help writing coroutine

2007-11-07 Thread Matthew Wilson
I'm working on two coroutines -- one iterates through a huge stream, and
emits chunks in pieces.  The other routine takes each chunk, then scores
it as good or bad and passes that score back to the original routine, so
it can make a copy of the stream with the score appended on.

I have the code working, but it just looks really ugly.  Here's a vastly
simplified version.  One function yields some numbers, and the other
function tells me if they are even or odd.

def parser():
I just parse and wait for feedback.
for i in 1, 2, 3, 4, 5:
score = (yield i)
if score: 
print %d passed! % i

def is_odd(n):
I evaluate each number n, and return True if I like it.
if n and n % 2: return True

def m():
try:
number_generator = parser()
i = None
while 1:
i = number_generator.send(is_odd(i))
except StopIteration: pass

and here's the results when I run this:
In [90]: m()
1 passed!
3 passed!
5 passed!

So, clearly, the code works.  But it is nonintuitive for the casual
reader.

I don't like the while 1 construct, I don't like manually
trapping the StopIteration exception, and this line is really ugly:

i = number_generator.send(is_odd(i))

I really like the old for i in parser(): deal, but I can't figure out
how to use .send(...) with that.

Can anyone help me pretty this up?  I want to make this as intuitive as
possible.

TIA

Matt

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


Re: a simple tcp server sample

2007-11-07 Thread Jean-Paul Calderone
On Wed, 07 Nov 2007 18:54:39 -, Tzury Bar Yochay [EMAIL PROTECTED] wrote:
hi, the following sample (from docs.python.org) is a server that can
actually serve only single client at a time.

In my case I need a simple server that can serve more than one client.
I couldn't find an example on how to do that and be glad to get a
hint.

Thanks in advance

import socket

HOST = '127.0.0.1'  # Symbolic name meaning the local host
PORT = 50007# Arbitrary non-privileged port

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()

print 'Connected by', addr

while 1:
data = conn.recv(1024)
if not data:
break
conn.send(data)

conn.close()

Even simpler, use Twisted:

from twisted.internet.protocol import ServerFactory, Protocol
from twisted.internet import reactor

HOST = '127.0.0.1'  # Symbolic name meaning the local host
PORT = 50007# Arbitrary non-privileged port

class Echo(Protocol):
def connectionMade(self):
print 'Connection from', self.transport.getPeer()

def dataReceived(self, bytes):
self.transport.write(bytes)

factory = ServerFactory()
factory.protocol = Echo
reactor.listenTCP(HOST, PORT, factory)
reactor.run()

This doesn't have the bug your version has (where it randomly drops some
data on the floor) and handles multiple clients.

Check it out:  http://twistedmatrix.com/

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


Re: python tutorial on a single html page?

2007-11-07 Thread Tony Nelson
In article [EMAIL PROTECTED],
 BartlebyScrivener [EMAIL PROTECTED] wrote:

 Is the main Python tutorial posted on single searchable page
 somewhere?  As opposed to browsing the index and clicking NEXT etc.

For completeness (though a bit late), I'll mention that Google can 
search a group of web pages with:

site:docs.python.org/tut/ search terms

TonyN.:'[EMAIL PROTECTED]
  '  http://www.georgeanelson.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


911 operation by evil JEWS and Mossad

2007-11-07 Thread zionist . jews
911 carried out by evil jews and mossad
http://www.guba.com/watch/2000991770

911 truckload of Explosives on the George Washington Bridge
http://www.youtube.com/watch?v=J520P-MD9a0

Benjamin Freedman's SEMINAL TESTIMONIAL SPEECH
http://video.google.com/videoplay?docid=3552214685532803163

Benjamin Freedman speech with Slide Show (40 Minute Excerpt)
http://video.google.com/videoplay?docid=3552214685532803163

Free pdf book: THE MANUFACTURE AND SALE of Saint Einstein
@
http://jewishracism.com/SaintEinstein.htm

Author interviews @
http://jewishracism.com/interviews.htm

Rothschilds control half the world's wealth directly and indirectly
using zionist proxies, and loyalty based on the zionist racist cult of
hate and paranoia based on being caught for collective financial
crimes and crimes of other categories

History of the Rothschilds part 1
http://www.youtube.com/watch?v=o_u2MaNg-EQ

History of the Rothschilds part 2
http://www.youtube.com/watch?v=o2cw-0N_Unk

FBI, Where are the two Israelis with TRUCKLOAD of explosives at the
George Washington Bridge ?
http://www.youtube.com/watch?v=JfVumKHkcIA   - Shame stooopid
americans

Alex Jones Interviews David Mayer de Rothschild
http://video.google.com/videoplay?docid=4891699310483983031

The rise of the Rothschild Money Masters
http://www.youtube.com/watch?v=ZT3GyphxJv8

Rothschilds financed APARTHEID in South Africa. They corrupted Cecil
Rhodes, the son of an anglican minister, by TEACHING him evil
techniques of apartheid. Apartheid was taught to him by the father
zionists themselves.

Rothschilds control half the world's wealth directly and indirectly
using zionist proxies, and loyalty based on the zionist racist cult
http://www.youtube.com/watch?v=fXVJzXsraX4

Was Hitler's father a bastard son of Rothschilds? Did the Salomon
Mayer von Rothschild perhaps rape  Maria Anna Schicklgruber in dark so
that she could not ever claim with certainty who the real father was?
Look at his facial features, typical central asian khazar. What was
the cause of Hitler's fanatical hatred for the Jews ?
http://en.wikipedia.org/wiki/Alois_Hitler
http://www.youtube.com/watch?v=TihCM_q59c8

On Nov 6, 9:53 am, [EMAIL PROTECTED] wrote:

 The world has been after Bill Gates for no reason. The richest group
 was and remains the Zionist jew Rothschilds family who own HALF the
 worlds total wealth through numerous frontmen zionists.

 Mikhail Khodorkovsky, whom Russian President Vladimir I Putin put in
 jail rose from the Rothschilds money. Mayer Amschel Bauer changed his name to
 Rothschild or red shield. The he sent his sons to various countries in
 Europe and become bankers there. Using an innovative system of pigeons
 for communication and encoded letters, the family invested in wars
 that he knew were coming by staying close to the centers of powers in
 all the countries which they had infilterated.

 google video and youtube have many videos on the family. You can set
 aside part of your weekend for HEALTHY education so your
 kids can learn how to avoid being hunted by these snakes.

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


os.popen does not seem to catch stdout

2007-11-07 Thread zane . selvans
Hi there,

I've been banging my head against this for a day, and I can't take it
anymore.  It's probably a stupid error, but I don't see where.

I'm trying to use Python to call an external program, and then catch
and process the output of that program.  Seems simple enough.  The
command I'm trying to run, in the test, is:

/Users/zane/svn/stress/satstress/satstress -r1.561e+06 -a5 -s45000 -
e0 -R6.709e+08 -g1.31472 -m1.8987e+27 -Q57100.1 -n0.55 -Y9.29881e
+09 -k1e+22 -Z1.19173 -z-6.293e-05 -V0.309434 -v-2.903e-05 -W1.81305 -
w-0.00418645 -U0.474847 -u-0.00276624 -C /tmp/18_tmp.gen -b 60

When I run it at my zsh prompt, I get the expected output.

If I let ss_cmd equal the above string within ipython (or the standard
python interactive interpreter):

ss_outlines = os.popen(ss_cmd).readlines()

ss_outlines contains the same output I saw when I ran the command at
my zsh prompt, one line per list element, as expected.

However, when I try doing the same thing from within a program, it
fails.  ss_outlines is an empty list.

I've tried using subprocess.Popen(), and subprocess.call(), and
subprocess.check_call(), and all have yielded similar results.  I did
find, however, that the return value python is getting from the
program I'm calling is different from what I get at the command line
(I get 0, python gets -11).

Does this ring a bell for anyone?

I'm using Python 2.5.1 on a Mac running OS X 10.5.

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


Re: regular expression syntax the same in Python, Perl and grep?

2007-11-07 Thread Martin Marcher
2007/11/7, Chris Mellon [EMAIL PROTECTED]:
 On Nov 7, 2007 12:11 PM, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
  How similar is Python's re module (regular expressions) compared
  to Perl's and grep's regular expression syntaxes?
 

 Somewhat.

  I really hope regular expression syntax is sufficiently standardized
  that
  we don't have to learn new dialects everytime we move from one
  language or shell command to another.

I forgot where I read that so can't back it up but:

Unices are just a collection of different dialects of regex

I think the same is true for about every implementation of regex you
can find. In theory it _should_ be same.

Then again, so should SQL but I bet that it's actually quite hard to
find a single statement that you can literally execute it on all DB
servers (major ones).


-- 
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deep comparison of sets?

2007-11-07 Thread Marc 'BlackJack' Rintsch
On Wed, 07 Nov 2007 10:22:27 -0800, Daryl Spitzer wrote:

 def __cmp__(self, other):
 if self.value  other.value: return 1
 if self.value  other.value: return -1
 return 0

This can be written a bit shorter::

def __cmp__(self, other):
return cmp(self.value, other.value)

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression syntax the same in Python, Perl and grep?

2007-11-07 Thread Chris Mellon
On Nov 7, 2007 12:11 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 How similar is Python's re module (regular expressions) compared
 to Perl's and grep's regular expression syntaxes?


Somewhat.

 I really hope regular expression syntax is sufficiently standardized
 that
 we don't have to learn new dialects everytime we move from one
 language or shell command to another.


It isn't, at least for non-trivial use of regexps.
-- 
http://mail.python.org/mailman/listinfo/python-list


command-line arguments in IDLE

2007-11-07 Thread Russ P.
Is it possible to pass command-line arguments when running a program
in IDLE? The Run menu does not seem to provide that option. Thanks.

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


Re: Retrieving all open applications ...

2007-11-07 Thread Gabriel Genellina
En Wed, 07 Nov 2007 06:36:49 -0300, Ajay Deshpande  
[EMAIL PROTECTED] escribió:

 well i still havent found a solution to this ... since i am using ubuntu
 7.10, i cannot use the hammond modules ...

As you said list of window handles I thought you were working on Windows.
Try with: man ps
Use the subprocess module to call ps with your desired options.

-- 
Gabriel Genellina

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


Re: Deep comparison of sets?

2007-11-07 Thread Diez B. Roggisch
Daryl Spitzer schrieb:
 The second assertion in the following code fails:
 
 class Value(object):
 def __init__(self, value):
 super(Value, self).__init__()
 self.value = value
 def __cmp__(self, other):
 if self.value  other.value: return 1
 if self.value  other.value: return -1
 return 0
 
 if __name__ == __main__:
 v1 = Value('one')
 v2 = Value('one')
 assert v1 == v2
 s1 = set([v1])
 s2 = set([v2])
 assert s1 == s2
 
 Is there any way to compare the two sets so that __cmp__ is called (I
 guess this would be called a deep comparison) rather than just
 (shallowly) comparing each object in the set?

You need to overload the __hash__-method as well.

 def __hash__(self):
 return hash(self.value)


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


Re: LaTeX tutorial updated [OT]

2007-11-07 Thread John DeRosa
On Wed, 07 Nov 2007 16:23:56 +0900, Byung-Hee HWANG [EMAIL PROTECTED]
wrote:

On Wed, 2007-11-07 at 00:10 +, [EMAIL PROTECTED] wrote:
 On Nov 6, 12:30 pm, Nicola Talbot [EMAIL PROTECTED] wrote:
  Hi,
 
  I've updated my Using LaTeX to write a PhD thesis tutorial. Both PDF

My understanding is that the correct nomenclature is, Master's
thesis, and, PhD dissertation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help for Otsu implementation from C

2007-11-07 Thread Johny
On Sep 22, 6:24 pm, azrael [EMAIL PROTECTED] wrote:
 Thanks Man, I did it. It works fantastic.

Can you please posted the working Python implementation of the Otsu
filter .
Thanks
L.

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


Re: global name is not defined

2007-11-07 Thread barronmo
Thanks, seems to be fixed with importing MySQLdb, menus, EMR_main, etc
in the Name_find module.  Is there a better way to do things?  I
thought I was avoiding using global variables by putting the shared
ones in their own module.

Thanks for the help.

Mike

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


Re: What colour model does the image use in PIL

2007-11-07 Thread Hrvoje Niksic
Johny [EMAIL PROTECTED] writes:

 I use PIL and with it im.getpixel((x,y)) to find out the colour of a
 pixel.  But how can I find out in which color model the the return
 value is?

im.mode gives you a string such as 'RGBA' or 'CMYK'.  im.getbands()
returns a tuple such as ('R', 'G', 'B', 'A').
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a simple tcp server sample

2007-11-07 Thread Erik Jones
On Nov 7, 2007, at 12:54 PM, Tzury Bar Yochay wrote:

 hi, the following sample (from docs.python.org) is a server that can
 actually serve only single client at a time.

 In my case I need a simple server that can serve more than one client.
 I couldn't find an example on how to do that and be glad to get a
 hint.

 Thanks in advance

That's when it stops being simple.  You'll need to spawn threads or  
fork off separate processes to do that.

Erik Jones

Software Developer | Emma®
[EMAIL PROTECTED]
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate  market in style.
Visit us online at http://www.myemma.com


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


Re: Populating huge data structures from disk

2007-11-07 Thread Rhamphoryncus
On Nov 6, 2:42 pm, Michael Bacarella [EMAIL PROTECTED] wrote:
  Note that you're not doing the same thing at all. You're
  pre-allocating the array in the C code, but not in Python (and I don't
  think you can). Is there some reason you're growing a 8 gig array 8
  bytes at a time?

  They spend about the same amount of time in system, but Python spends 4.7x
  as much
  CPU in userland as C does.

  Python has to grow the array. It's possible that this is tripping a
  degenerate case in the gc behavior also (I don't know if array uses
  PyObjects for its internal buffer), and if it is you'll see an
  improvement by disabling GC.

 That does explain why it's consuming 4.7x as much CPU.

   x = lengthy_number_crunching()
   magic.save_mmap(/important-data)

   and in the application do...

   x = magic.mmap(/important-data)
   magic.mlock(/important-data)

   and once the mlock finishes bringing important-data into RAM, at
   the speed of your disk I/O subsystem, all accesses to x will be
   hits against RAM.

  You've basically described what mmap does, as far as I can tell. Have
  you tried just mmapping the file?

 Yes, that would be why my fantasy functions have 'mmap' in their names.

 However, in C you can mmap arbitrarily complex data structures whereas
 in Python all you can mmap without transformations is an array or a string.
 I didn't say this earlier, but I do need to pull more than arrays
 and strings into RAM.  Not being able to pre-allocate storage is a big
 loser for this approach.

I don't see how needing transformations is an issue, as it's just a
constant overhead (in big-O terms.)

The bigger concern is if what your storing is self contained (numbers,
strings) or if it contains inter-object references.  The latter may
require you to translate between indexes and temporary handle
objects.  This in turn may require some sort of garbage collection
scheme (refcounting, tracing).  Note that the addresses of the mmap'd
region can change each time the program runs, so even in C you may
need to use indexes.  (You may also want to eliminate C's padding,
although that would make the objects not directly accessible (due to
hardware alignment requirements.))

Having a separate process (or thread) that occasionally pokes each
page (as suggested by Paul Rubin) seems like the cleanest way to
ensure they stay hot.  One pass during startup is insufficient, as
unused portions of a long-running program may get swapped out.  Also
note that poking need only touch 1 byte per page, much cheaper than
copying the entire page (so long as the page is already loaded from
disk.)


--
Adam Olsen, aka Rhamphoryncus

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


Re: os.popen does not seem to catch stdout

2007-11-07 Thread Marc 'BlackJack' Rintsch
On Wed, 07 Nov 2007 18:35:51 +, kyosohma wrote:

 I've never had to put the command into a list or tuple...but you're
 welcome to try it that way.

You don't *have* to but if you do the module takes care of quoting the
arguments if necessary.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


What colour model does the image use in PIL

2007-11-07 Thread Johny
I use PIL and with it  im.getpixel((x,y)) to find out the colour of a
pixel.
But how can I find out in which color model  the  the  return value
is?

For example  for png picture format

im.getpixel((20,50))  gives the result 60.

What does the value mean?
Is it possible to find out the RGB model values?

Thank you for help.
L.

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


Re: manually cutting a picture

2007-11-07 Thread Cameron Walsh
Amit Khemka wrote:

 Cut image by m X m grid (bigger the m, the more varied shapes you
 would be able to generate), this will give you m*m square pieces. With
 each piece store a vector which represents the polygon (say by storing
 co-ordinates of the corners).
 Now visualize this set of pieces as a graph with an edge between
 adjacent pieces. Now depending on the final number of pieces that you
 want to generate (N), you traverse the graph and for each node:
 
 1. Merge a node with a randomly selected neighbor
 
 Repeat step 1 until you have N pieces left
 
Doesn't that have the fairly likely possibility of ending up with 1 very 
large piece and n-1 very small pieces?  If you iterate over the graph 
merging with a neighbour at random, then each node has a 50% chance of 
being merged with a node that has already been merged.

*-*-* *-*
|   | |
* *-*-* *

* * * * * etc. could be the result of the first 8 steps.  Already every 
node touched is part of the same group.  Or have I misunderstood your 
algorithm?

A random region growing approach might work, with seeds scattered evenly 
throughout the image.  That would be prone to orphaning squares inside 
larger objects, but that may be what you want.  It would not be easy to 
program.

What I would do is break the graph in to m*m squares, then for each 
edge, randomly select a means of joining them - blob sticking out of 
piece A, or hole for blob in piece A; move hole/blob along the edge by a 
random amount, move edge in or out to get different sized pieces.  For 
each square this was applied to, it would apply the reverse sizing to 
the square touching on that edge.

I'd restrict in/out movement of edges and movement of blob/hole along 
the edge to a specific range, to avoid problems where the blob of one 
square is stuck on the furthest corner, but the piece touching that 
corner has had its edge moved in too far so the blob would overlap two 
squares.

Let me know how it goes, it sounds like a fun problem.

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


Re: a simple tcp server sample

2007-11-07 Thread Paul Rubin
Tzury Bar Yochay [EMAIL PROTECTED] writes:
 In my case I need a simple server that can serve more than one client.
 I couldn't find an example on how to do that and be glad to get a hint.

See the SocketServer module, both the documentation and the source code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List to Tuple and Tuple to List?

2007-11-07 Thread Wildemar Wildenburger
Davy wrote:
 Hi all,
 
 I am curious about whether there is function to fransform pure List to
 pure Tuple and pure Tuple to pure List?
 

Isn't that just the same topic as in your other thread? I think it is
somewhat unfriendly that you ignore that one. It makes me feel that you
see this group as some sort of helpdesk.

Which it isn't (strictly).

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


manually cutting a picture

2007-11-07 Thread Joseph king
well so far the problem for me is not the linking i have a kinda good
code for that.
here is a little snippet of the idea that i used on an old version
that split the picture without input from the user.

#this code defines that the edges have a place on the grid.
def join_point(self, type):
 orect = self.orig_image.get_rect()
 if type == north:
  return ((orec.width/2, 20))

but it relies on the fact that the image is on a grid then checks to
see where the puzzle piece is on the grid.

then to actualy link the piece i had this

def draw_connection(self, other)
  if self.north == other:
   spt = north
   opt = south
pass

which then would check several draw points that are defined in depth.
which i am sure that it can be modified with a little work.. my
main problem is getting the user input on what the size shape and yata
yata of the puzzle piece should be. sorry if i didn't make sense
before.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What colour model does the image use in PIL

2007-11-07 Thread Johny
On Nov 7, 2:53 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote:
 Johny [EMAIL PROTECTED] writes:
  I use PIL and with it im.getpixel((x,y)) to find out the colour of a
  pixel.  But how can I find out in which color model the the return
  value is?

 im.mode gives you a string such as 'RGBA' or 'CMYK'.  im.getbands()
 returns a tuple such as ('R', 'G', 'B', 'A').

Thank you for your help.
Can you please help me once more?
Now I would need to apply a threshold value to the image, where
everything above a certain brightness level becomes white, and
everything below the level becomes black.
How can I do that with PIL?
Thank you
L

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


Re: Confused about closures and scoping rules

2007-11-07 Thread Rhamphoryncus
On Nov 6, 5:37 pm, Chris Mellon [EMAIL PROTECTED] wrote:
 On Nov 6, 2007 6:23 PM, Jean-Paul Calderone [EMAIL PROTECTED] wrote:

  On Tue, 06 Nov 2007 17:07:47 -0700, Fernando Perez [EMAIL PROTECTED] 
  wrote:
   [snip]

  This struck me as counterintuitive, but I couldn't find anything in the
  official docs indicating what the expected behavior should be. Any
  feedback/enlightenment would be welcome.  This problem appeared deep 
  inside a
  complicated code and it took me almost two days to track down what was 
  going
  on...

  Lots of people ask about this.  The behavior you observed is the expected
  (by the implementors, anyway) behavior.

 Are there languages where closures *don't* behave like this? A closure
 that used a copy of the state rather than the actual state itself
 doesn't seem as useful. For references sake, JavaScript (the only
 language that a) has closures and b) I have a handy way to test with)
 does the same thing.

I've never needed to repeatedly modify closure variables.  However, I
may not set them until after the function is defined.  A simple
example is that of a recursive function:

def foo():
def bar():
bar()  # useful work omitted
return bar

Obviously, bar can't be set until after the function object is
created.

Showing changes also matches the behaviour of globals, which is a good
thing IMO.


--
Adam Olsen, aka Rhamphoryncus

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Just Another Victim of the Ambient Morality

Neil Cerutti [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 2007-11-07, Just Another Victim of the Ambient Morality
 [EMAIL PROTECTED] wrote:
 Neil Cerutti [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 You might be interested in the Early parsing algorithm. It is
 more efficient than the naive approach used in your prototype,
 and still handles ambiguous grammars.


 I'll take this opportunity to correct my misspelling. It's
 Earley.

 I think I might be interested in this algorithm, thank you!

 http://www.cpsc.ucalgary.ca/~aycock/spark/

 You know, I tried this thing but, for the life of me, I
 can't figure out how to use it and the few tutorials out there
 are less than illuminating...

 I'll send you the code I composed.

 The tricky part of Spark is the Token and AST classes you have to
 use. A type used as a token class is required to provide a
 __cmp__ function that behaves in the following confounding
 manner:

  class Token(object):
def __cmp__(self, o):
  return cmp(self.type, o)

 If you attempt to use a list, string or a tuple as token, it just
 barfs. AST's are required to provide an even weirder interface.

 In effect, you have to write badly designed wrappers around
 tuples and lists, respectively to take advantage of the generic
 classes.

 Go to the examples directory of the distribution to find working
 versions of these stupid classes.

 Once you get over that hurdle it becomes easier. Be sure to
 provide your Parser and Scanner classes with an error method to
 prevent the library from raising SystemExit(!) on errors. Scanner
 classes are also required to override the t_default method to
 prevent this mishap.

 In short, it hasn't really evovled into a user-friendly package
 yet.

Thank you.
How is it that I seem to be the only one in the market for a correct 
parser?  Earley has a runtine of O(n^3) in the worst case and O(n^2) 
typically.  I have trouble believing that everyone else in the world has 
such intense run-time requirements that they're willing to forego 
correctness.  Why can't I find a pyparsing-esque library with this 
implementation?  I'm tempted to roll my own except that it's a fairly 
complicated algorithm and I don't really understand how it's any more 
efficient than the naive approach...




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


Re: LaTeX tutorial updated [OT]

2007-11-07 Thread Wayne Brehaut
On Wed, 07 Nov 2007 09:00:12 -0800, John DeRosa [EMAIL PROTECTED]
wrote:

On Wed, 07 Nov 2007 16:23:56 +0900, Byung-Hee HWANG [EMAIL PROTECTED]
wrote:

On Wed, 2007-11-07 at 00:10 +, [EMAIL PROTECTED] wrote:
 On Nov 6, 12:30 pm, Nicola Talbot [EMAIL PROTECTED] wrote:
  Hi,
 
  I've updated my Using LaTeX to write a PhD thesis tutorial. Both PDF

My understanding is that the correct nomenclature is, Master's
thesis, and, PhD dissertation.

This may be more common usage in some regions, but thesis is more
general and quite correct in either case, as the following indicate.

===

Thinkmap Visual Thesaurus (http://www.visualthesaurus.com/):

exposition
a systematic interpretation or explanation (usually written) of a
given topic; an account that sets forth the meaning or intent of a
writing or discourse

treatise
a formal exposition

thesis
dissertation 
a treatise advancing a new point of view resulting from research;
usually a requirement for an advanced academic degree

===
Oxford Refernce Online--requires subscription
(http://0-www.oxfordreference.com.aupac.lib.athabascau.ca/views/GLOBAL.html):

The Concise Oxford Dictionary of Literary Terms:
thesis 
an argument  or proposition, which may be opposed by an antithesis ;
or a scholarly essay defending some proposition, usually a
dissertation submitted for an academic degree.

---

Pocket Fowler's Modern English Usage
thesis 
meaning ‘a dissertation’, has the plural form theses , pronounced thee
-seez .

---

The Concise Oxford Dictionary of English Etymology:
thesis 
proposition, theme XVI ; (theme of) a dissertation XVII .
===

Merriam-Webster Online (http://www.m-w.com/):

thesis 
4: a dissertation embodying results of original research and
especially substantiating a specific view; especially : one written by
a candidate for an academic degree

dissertation 
an extended usually written treatment of a subject; specifically : one
submitted for a doctorate

===

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


Re: How can i find the form name without nr=0

2007-11-07 Thread John J. Lee
alex23 [EMAIL PROTECTED] writes:

 On Nov 6, 8:56 am, scripteaze [EMAIL PROTECTED] wrote:
 Is it possible then to have a form with no name and if so, how can i
 access this form

 Hey scripteaze,

 I'm not sure about mechanize, but you might have more success using
 another one of the author's modules, ClientForm: 
 http://wwwsearch.sourceforge.net/ClientForm/

 from urllib2 import urlopen
 from ClientForm import ParseResponse

 response = urlopen(http://wwwsearch.sourceforge.net/ClientForm/
 example.html)
 forms = ParseResponse(response, backwards_compat=False)
 form = forms[0]

 As it returns a list of forms, you don't need to have a name to access
 it.

mechanize forms are ClientForm forms.

Quoting from mechanize.Browser.select_form().__doc__:


Another way to select a form is to assign to the .form attribute.  The
form assigned should be one of the objects returned by the .forms()
method.


forms = list(br.forms())
br.form = pick_a_form(forms, br.global_form())


The global form (couldn't think of a better term) consists of all
form controls not contained in any FORM element.


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


Re: Looking for a good Python environment

2007-11-07 Thread VSmirk
On Nov 7, 9:16 am, Gerhard Häring [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  Hey, I'm looking for a good Python environment. That is, at least an
  editor and a debugger, and it should run on Windows. Does anyone have
  any idea?

 I like ERIC. You can get it 
 athttp://www.die-offenbachs.de/eric/eric4-download.html

 Or just download and install PyQt4, which includes it:

 http://www.riverbankcomputing.com/Downloads/PyQt4/GPL/PyQt-Py2.5-gpl-...

 There's also a list of Python IDEs on the Python 
 wiki:http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

 -- Gerhard

WingIDE all the way.  After trying a number of deve environments, Wing
was the first I used that actually allowed me to be productive.

They offer a free version, but it's worth getting the professional
version, too.

http://www.wingide.com/

VSmirk

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

Re: Mikhail Khodorkovsky was a Rothschild frontman and he obtained his initial capital and manipulation knowledge from there. Re: 911 operation by evil JEWS and Mossad

2007-11-07 Thread Matimus
On Nov 7, 8:35 am, [EMAIL PROTECTED] wrote:
 Google is a half russian jew company. We have had to make new accounts
 as a result of it sending us a cookie which cripples postings. The jew
 agents involved in this process are the ones that make deflecting
 replies. Their operating procedure: Deflect, when you cannot defend.
 Therefore, we ignore them.

 On Nov 7, 7:08 am, [EMAIL PROTECTED] wrote:

  911 carried out by evil jews and mossadhttp://www.guba.com/watch/2000991770

  911 truckload of Explosives on the George Washington 
  Bridgehttp://www.youtube.com/watch?v=J520P-MD9a0

  Benjamin Freedman's SEMINAL TESTIMONIAL 
  SPEECHhttp://video.google.com/videoplay?docid=3552214685532803163

  Benjamin Freedman speech with Slide Show (40 Minute 
  Excerpt)http://video.google.com/videoplay?docid=3552214685532803163

  Free pdf book: THE MANUFACTURE AND SALE of Saint Einstein
  @http://jewishracism.com/SaintEinstein.htm

  Author interviews @http://jewishracism.com/interviews.htm

  Rothschilds control half the world's wealth directly and indirectly
  using zionist proxies, and loyalty based on the zionist racist cult of
  hate and paranoia based on being caught for collective financial
  crimes and crimes of other categories

  History of the Rothschilds part 1http://www.youtube.com/watch?v=o_u2MaNg-EQ

  History of the Rothschilds part 2http://www.youtube.com/watch?v=o2cw-0N_Unk

  FBI, Where are the two Israelis with TRUCKLOAD of explosives at the
  George Washington Bridge ?http://www.youtube.com/watch?v=JfVumKHkcIA 
  - Shame stooopid
  americans

  Alex Jones Interviews David Mayer de 
  Rothschildhttp://video.google.com/videoplay?docid=4891699310483983031

  The rise of the Rothschild Money 
  Mastershttp://www.youtube.com/watch?v=ZT3GyphxJv8

  Rothschilds financed APARTHEID in South Africa. They corrupted Cecil
  Rhodes, the son of an anglican minister, by TEACHING him evil
  techniques of apartheid. Apartheid was taught to him by the father
  zionists themselves.

  Rothschilds control half the world's wealth directly and indirectly
  using zionist proxies, and loyalty based on the zionist racist 
  culthttp://www.youtube.com/watch?v=fXVJzXsraX4

  Was Hitler's father a bastard son of Rothschilds? Did the Salomon
  Mayer von Rothschild perhaps rape  Maria Anna Schicklgruber in dark so
  that she could not ever claim with certainty who the real father was?
  Look at his facial features, typical central asian khazar. What was
  the cause of Hitler's fanatical hatred for the Jews 
  ?http://en.wikipedia.org/wiki/Alois_Hitlerhttp://www.youtube.com/watch...

  On Nov 6, 9:53 am, [EMAIL PROTECTED] wrote:

   The world has been after Bill Gates for no reason. The richest group
   was and remains the Zionist jew Rothschilds family who own HALF the
   worlds total wealth through numerous frontmen zionists.
   Mikhail Khodorkovsky, whom Russian President Vladimir I Putin put in
   jail rose from the Rothschilds money. Mayer Amschel Bauer changed his 
   name to
   Rothschild or red shield. The he sent his sons to various countries in
   Europe and become bankers there. Using an innovative system of pigeons
   for communication and encoded letters, the family invested in wars
   that he knew were coming by staying close to the centers of powers in
   all the countries which they had infilterated.
   google video and youtube have many videos on the family. You can set
   aside part of your weekend for HEALTHY education so your
   kids can learn how to avoid being hunted by these snakes.- Hide quoted 
   text -

  - Show quoted text -

Even if google was a company run by anti-semitic nut jobs (your type
of folk), they would be right to prevent you from posting such things
in a Python, tex or physics mailing list.

Hey... everybody, if you use Google groups and are getting tons of
this crap, report it as abuse! I don't know if they will do anything
about it, but its getting to the point where I don't want to look at
comp.lang.python at work.

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


Re: How to use list as key of dictionary?

2007-11-07 Thread Wildemar Wildenburger
Duncan Booth wrote:
 Wildemar Wildenburger [EMAIL PROTECTED] wrote:
 
 maybe something like this could help:

 def tupleize(non_tuple):
  try:
  return tuple(tupleize(thing) for thing in non_tuple)
  except TypeError:
  # non_tuple is not iterable
  return non_tuple

 
 Just don't try passing that a string or anything containing a string.
 
Outch! Right you are.

We'll that's the genius of paid updates for you.

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


pydoc - generating HTML docs from string input

2007-11-07 Thread [EMAIL PROTECTED]
Has anyone ever tried mucking with pydoc to the point where you can
get it to give you output from a string input?  For example I'd like
to give it a whole module to generate documentation for but all within
a string:

#little sample

module_code='''
Module docstring

def func1():
 some docstring
pass

...

'''

pydoc.html(module_code) - HTML output as a string

Any ideas?

-Greg

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


Re: os.popen does not seem to catch stdout

2007-11-07 Thread kyosohma
On Nov 7, 12:17 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 On Nov 7, 11:31 am, [EMAIL PROTECTED] wrote:



  On Nov 7, 7:58 am, [EMAIL PROTECTED] wrote:

   Hi there,

   I've been banging my head against this for a day, and I can't take it
   anymore.  It's probably a stupid error, but I don't see where.

   I'm trying to use Python to call an external program, and then catch
   and process the output of that program.  Seems simple enough.  The
   command I'm trying to run, in the test, is:

   /Users/zane/svn/stress/satstress/satstress -r1.561e+06 -a5 -s45000 -
   e0 -R6.709e+08 -g1.31472 -m1.8987e+27 -Q57100.1 -n0.55 -Y9.29881e
   +09 -k1e+22 -Z1.19173 -z-6.293e-05 -V0.309434 -v-2.903e-05 -W1.81305 -
   w-0.00418645 -U0.474847 -u-0.00276624 -C /tmp/18_tmp.gen -b 60

   When I run it at my zsh prompt, I get the expected output.

   If I let ss_cmd equal the above string within ipython (or the standard
   python interactive interpreter):

   ss_outlines = os.popen(ss_cmd).readlines()

   ss_outlines contains the same output I saw when I ran the command at
   my zsh prompt, one line per list element, as expected.

   However, when I try doing the same thing from within a program, it
   fails.  ss_outlines is an empty list.

   I've tried using subprocess.Popen(), and subprocess.call(), and
   subprocess.check_call(), and all have yielded similar results.  I did
   find, however, that the return value python is getting from the
   program I'm calling is different from what I get at the command line
   (I get 0, python gets -11).

   Does this ring a bell for anyone?

   I'm using Python 2.5.1 on a Mac running OS X 10.5.

  I think when you use subprocess.Popen, you need to do something set
  the shell to True to get it to behave like running from a command
  prompt:

  subprocess.Popen('some command', shell=True)

  Seehttp://docs.python.org/lib/node529.htmlformore details.

  You'll also find a fairly interesting thread on this topic here:

 http://mail.python.org/pipermail/chicago/2005-November/000141.htmlhtt...

  This seems to be a recipe on it:

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

  Mike

 That's right, and I think you also want to put the whole command in a
 list or tuple, one item for each arg.  I don't know why though.

 -Greg

I've never had to put the command into a list or tuple...but you're
welcome to try it that way.

Mike

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


os.EX_USAGE and friends not available in Windows?

2007-11-07 Thread Rush Manbert
I'm writing scripts that run on Mac OS X and Windows. For automated
testing purposes, I wanted to standardize my exit codes, so discovered
that the Unix sysexit codes were available from the posix module as
os.EX_*.

I changed things around on the Mac, then tested on Windows and the
constants don't seem to be available there. Have I missed something?

Thanks,
Rush

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Neil Cerutti
On 2007-11-07, Just Another Victim of the Ambient Morality
[EMAIL PROTECTED] wrote:
 Neil Cerutti [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 You might be interested in the Early parsing algorithm. It is
 more efficient than the naive approach used in your prototype,
 and still handles ambiguous grammars.


I'll take this opportunity to correct my misspelling. It's
Earley.

 I think I might be interested in this algorithm, thank you!

 http://www.cpsc.ucalgary.ca/~aycock/spark/

 You know, I tried this thing but, for the life of me, I
 can't figure out how to use it and the few tutorials out there
 are less than illuminating...

I'll send you the code I composed. 

The tricky part of Spark is the Token and AST classes you have to
use. A type used as a token class is required to provide a
__cmp__ function that behaves in the following confounding
manner:

  class Token(object):
def __cmp__(self, o):
  return cmp(self.type, o)

If you attempt to use a list, string or a tuple as token, it just
barfs. AST's are required to provide an even weirder interface.

In effect, you have to write badly designed wrappers around
tuples and lists, respectively to take advantage of the generic
classes.

Go to the examples directory of the distribution to find working
versions of these stupid classes.

Once you get over that hurdle it becomes easier. Be sure to
provide your Parser and Scanner classes with an error method to
prevent the library from raising SystemExit(!) on errors. Scanner
classes are also required to override the t_default method to
prevent this mishap.

In short, it hasn't really evovled into a user-friendly package
yet.

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Chris Mellon
On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality
[EMAIL PROTECTED] wrote:

  In short, it hasn't really evovled into a user-friendly package
  yet.

 Thank you.
 How is it that I seem to be the only one in the market for a correct
 parser?  Earley has a runtine of O(n^3) in the worst case and O(n^2)
 typically.  I have trouble believing that everyone else in the world has
 such intense run-time requirements that they're willing to forego
 correctness.  Why can't I find a pyparsing-esque library with this
 implementation?  I'm tempted to roll my own except that it's a fairly
 complicated algorithm and I don't really understand how it's any more
 efficient than the naive approach...



You have an unusual definition of correctness. Many people would say
that an ambiguous grammar is a bug, not something to support.

In fact, I often use pyparsing precisely in order to disambiguate
(according to specific rules, which are embodied by the parser)
ambiguous input, like bizarre hand-entered datetime value.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pydoc - generating HTML docs from string input

2007-11-07 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote:
 Has anyone ever tried mucking with pydoc to the point where you can
 get it to give you output from a string input?  For example I'd like
 to give it a whole module to generate documentation for but all within
 a string:

 #little sample

 module_code='''
 Module docstring

 def func1():
  some docstring
 pass

 ...

 '''

 pydoc.html(module_code) - HTML output as a string

 Any ideas?
   
The problem with this is that your module can do relative imports, and 
it DOES matter where your module is located in the filesystem.

In the very unlikely case when you store your modules in an external 
system (e.g in a database), and you use __import__ hacks to run your 
code, I would recommend to write a program that exports your stored 
modules into a real filesystem and run pydoc there.

Regards,

   Laszlo

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


PIL Problem

2007-11-07 Thread tonylabarbara
Hi;
I´ve installed Zope 2.10.5 on top of Python 2.4.2 (not optimal, but it will 
work, according to the build instructions). I installed Plone 3.0.2 and I get 
errors when I crank up Zope, all related to a non-existent PIL. So I d/l/d the 
latest PIL, plopped it in my Extensions dir, ran this:


python setup.py build_ext -i

and got this:


running build_ext

building '_imagingtk' extension

creating build/temp.freebsd-5.5-RELEASE-i386-2.4/Tk

cc -fno-strict-aliasing -DNDEBUG -O -pipe -D__wchar_t=wchar_t 
-DTHREAD_STACK_SIZE=0x10 -fPIC -I/usr/local/include/freetype2 -IlibImaging 
-I/usr/local/include -I/usr/include -I/usr/local/include/python2.4 -c 
_imagingtk.c -o build/temp.freebsd-5.5-RELEASE-i386-2.4/_imagingtk.o

_imagingtk.c:20:16: tk.h: No such file or directory

_imagingtk.c:23: error: syntax error before '*' token

_imagingtk.c:31: error: syntax error before Tcl_Interp

_imagingtk.c: In function `_tkinit':

_imagingtk.c:37: error: `Tcl_Interp' undeclared (first use in this function)

_imagingtk.c:37: error: (Each undeclared identifier is reported only once

_imagingtk.c:37: error: for each function it appears in.)

_imagingtk.c:37: error: `interp' undeclared (first use in this function)

_imagingtk.c:45: error: syntax error before ')' token

_imagingtk.c:50: error: `app' undeclared (first use in this function)

_imagingtk.c: At top level:

_imagingtk.c:55: warning: parameter names (without types) in function 
declaration

_imagingtk.c:55: error: conflicting types for 'TkImaging_Init'

_imagingtk.c:23: error: previous declaration of 'TkImaging_Init' was here

_imagingtk.c:55: error: conflicting types for 'TkImaging_Init'

_imagingtk.c:23: error: previous declaration of 'TkImaging_Init' was here

_imagingtk.c:55: warning: data definition has no type or storage class

_imagingtk.c:57: error: syntax error before '' token

error: command 'cc' failed with exit status 1

What do?
TIA,
Tony


running build_ext

building '_imagingtk' extension

creating build/temp.freebsd-5.5-RELEASE-i386-2.4/Tk

cc -fno-strict-aliasing -DNDEBUG -O -pipe -D__wchar_t=wchar_t 
-DTHREAD_STACK_SIZE=0x10 -fPIC -I/usr/local/include/freetype2 -IlibImaging 
-I/usr/local/include -I/usr/include -I/usr/local/include/python2.4 -c 
_imagingtk.c -o build/temp.freebsd-5.5-RELEASE-i386-2.4/_imagingtk.o

_imagingtk.c:20:16: tk.h: No such file or directory

_imagingtk.c:23: error: syntax error before '*' token

_imagingtk.c:31: error: syntax error before Tcl_Interp

_imagingtk.c: In function `_tkinit':

_imagingtk.c:37: error: `Tcl_Interp' undeclared (first use in this function)

_imagingtk.c:37: error: (Each undeclared identifier is reported only once

_imagingtk.c:37: error: for each function it appears in.)

_imagingtk.c:37: error: `interp' undeclared (first use in this function)

_imagingtk.c:45: error: syntax error before ')' token

_imagingtk.c:50: error: `app' undeclared (first use in this function)

_imagingtk.c: At top level:

_imagingtk.c:55: warning: parameter names (without types) in function 
declaration

_imagingtk.c:55: error: conflicting types for 'TkImaging_Init'

_imagingtk.c:23: error: previous declaration of 'TkImaging_Init' was here

_imagingtk.c:55: error: conflicting types for 'TkImaging_Init'

_imagingtk.c:23: error: previous declaration of 'TkImaging_Init' was here

_imagingtk.c:55: warning: data definition has no type or storage class

_imagingtk.c:57: error: syntax error before '' token

error: command 'cc' failed with exit status 1

What do?
TIA,
Tony


Email and AIM finally together. You've gotta check out free AOL Mail! - 
http://mail.aol.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: command-line arguments in IDLE

2007-11-07 Thread [EMAIL PROTECTED]
On Nov 7, 6:27 am, Russ P. [EMAIL PROTECTED] wrote:
 Is it possible to pass command-line arguments when running a program
 in IDLE? The Run menu does not seem to provide that option. Thanks.

Can't you just fake the command line args by setting sys.argv? This
isn't too sophisticated, but it appears to work:

import sys

try:
__file__
except:
  sys.argv = ['scriptname.py', 'this','is','a','test','within','idle']

for arg in sys.argv:
print arg

Running from within IDLE:


scriptname.py
this
is
a
test
within
idle


Running from the command prompt:

C:\Python24python.exe mystuff/argtest.py this is yet another test
mystuff/argtest.py
this
is
yet
another
test

C:\Python24

HTH,
Don

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-07 Thread Wayne Brehaut
On Thu, 28 Sep 2006 17:23:25 +0200, Ramon Diaz-Uriarte
[EMAIL PROTECTED] wrote:

Going back to the original question, a related question: does anybody
know why there are so few books on data structures and algorithms that
use Python?

I remember that, at least ~ 12 years ago there were many (and very
good) books that used Pascal for this topic. So when I did my own
search for one in Python (just for my own consumption and
enlightnment) and could only find the same one as the original poster
of this thread [1], I was very surprised. No publishers have felt the
need to fill this gap?

No, and you'll know why if you check for the number of university and
college computer science students  learning Python in their
introductory programming course (not the number of  institutions  that
teach a little bit in a physics course), and the number of textbooks
available to support that (and not free online or print tutorials).
There's just not a big enough market for (traditional) publishers to
be interested in publishing them or (traditional) authors in writing
them. 

Preiss (http://www.brpreiss.com/page1.html) translated his original
C++  text (1999)  into a number of other languages: Java (2000), C#
(2001),  Python (2003), and Ruby (2004). So he could easily afford to
Translate the early money-makers into less used languages because the
initial writing overhead was no longer an issue--and much of the
tyranslation was automated. And he uses his free online versions to
help market the publishe'rs small (relative to C++ and Java) print
runs, so they can afford to service this very small market.

DSA--formerly (i.e., in the Good Old Days) just Data Structures-- is
or was,  in the usual CS curriculum (a la ACM+IEEE)  at least, a
second-level course based on CS1; hence, most efficiently taught
using the students' introductory language (if it's at all suitable,
and texts are available) so only some finer points of the language
needed covering and one can concentrate on implementation of the data
structures themselves. 

So very  little CS1 in Python translates into very little--and
probably even less--CS2, etc., in Python.

wwwayne

Best,

R.

[1] http://thread.gmane.org/gmane.comp.python.general/486698/focus=486698
 Data Structures and Algorithms with Object Oriented Design Patterns
(http://www.brpreiss.com/books/opus7/html/book.html) and was surprised.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Steven D'Aprano
On Wed, 07 Nov 2007 21:15:50 +, Just Another Victim of the Ambient
Morality wrote:

 Why can't I find a pyparsing-esque library with this implementation? 
 I'm tempted to roll my own except that it's a fairly complicated
 algorithm and I don't really understand how it's any more efficient than
 the naive approach...

I think you may have just answered your own question :)


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


Re: command-line arguments in IDLE

2007-11-07 Thread Tal Einat
Russ P. wrote:
 Is it possible to pass command-line arguments when running a program
 in IDLE? The Run menu does not seem to provide that option. Thanks.

thunderfoot's workaround should work well, but requires changing the
script.

If you want IDLE environment, but don't mind running IDLE from the
command line, you can do the following:

idle.py -r scriptname.py this is a test

The script will run inside IDLE's shell with sys.argv set as you would
expect. The output will go to IDLE's shell, and once the script is
done running the shell will become interactive.

(idle.py is usually found in your Python installation under Lib/
idlelib/)

- Tal Einat
reduce(lambda m,x:[m[i]+s[-1] for i,s in enumerate(sorted(m))],
  [[chr(154-ord(c)) for c in '.-,l.Z95193+179-']]*18)[3]

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


Re: Retrieving all open applications ...

2007-11-07 Thread Paul Boddie
On 7 Nov, 21:33, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Wed, 07 Nov 2007 06:36:49 -0300, Ajay Deshpande
 [EMAIL PROTECTED] escribió:

  well i still havent found a solution to this ... since i am using ubuntu
  7.10, i cannot use the hammond modules ...

 As you said list of window handles I thought you were working on Windows.
 Try with: man ps
 Use the subprocess module to call ps with your desired options.

Something like xlsclients might do the job. For more information on
each window, try xwininfo with the -name option; something like this:

  xwininfo -name 'Mail - Kontact'

The xprop program can provide plenty more detail, and both programs
accept a -root option to refer to the root window instead of a named
window.

Paul

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-07 Thread Wayne Brehaut
On Thu, 28 Sep 2006 17:32:06 +0200, Fredrik Lundh
[EMAIL PROTECTED] wrote:

Ramon Diaz-Uriarte wrote:

 Going back to the original question, a related question: does anybody
 know why there are so few books on data structures and algorithms that
 use Python?

Probably because Python has better than textbook implementations of 
core structures, and better than textbook implementations of many core 
algorithms, so lots of things can be done more efficiently by combining 
existing structures and algorithms than by using textbook algorithms.

But this answers a diiferent question: university and (academic)
college data structure courses don't care how efficient a particular
language's built-in data structures are, since the intent is for the
students to learn how to implement data structures in general, and
probably in a particular language--the core languasge used in their
core programs--and then be able to apply that knowledge and skill to
implementing at least reasonably efficient ones when they need to in
languages that don't have any to speak of built in.

And, since many students will go direct to business or industry, and
may even be apprenticing there in co-op work terms during their
education, most could care less how efficient Python's built-in data
structures are.

Also,  it's a very rare DSA text that intends its DS code to be used
directly--especially  in serious applications. Preiss's texts, noted
by the OP, are one exception, and many could be used out of the box
in industrial strength applications.

So far as combining existing structures is concerned, it's highly
unlikely that any such combination of linear structures could be more
efficient in both--if either--storage and running time than one
specifically designed and implemented for non-linear structures, such
as (many) trees and algorithms on them. For general graphs efficient
list processing may be sufficient for an adjacncy structure for the
graph itself, of course, but how does that translate to storing a
subtree found using a DFS, for example, and efficiently processing it
in some way?

For learning DSA it's more important to have a clear, well-written and
well-documented implementation in a language of interest (again,
especially, the core language in one's programs) than just using or
even inspecting and trying to learn subtle details of some particular
implementation of a related DS or A in some other language.

How many of those who devleoped and improved  the very efficient data
structures in Python learned and honed their skills in Python (vs. C
or Pascal, for example)?

wwwayne

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Just Another Victim of the Ambient Morality

Chris Mellon [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality
 [EMAIL PROTECTED] wrote:

  In short, it hasn't really evovled into a user-friendly package
  yet.

 Thank you.
 How is it that I seem to be the only one in the market for a correct
 parser?  Earley has a runtine of O(n^3) in the worst case and O(n^2)
 typically.  I have trouble believing that everyone else in the world has
 such intense run-time requirements that they're willing to forego
 correctness.  Why can't I find a pyparsing-esque library with this
 implementation?  I'm tempted to roll my own except that it's a fairly
 complicated algorithm and I don't really understand how it's any more
 efficient than the naive approach...

 You have an unusual definition of correctness. Many people would say
 that an ambiguous grammar is a bug, not something to support.

I don't think I do.  Besides, you assume too much...
First off, we've already established that there are unambiguous grammars 
for which pyparsing will fail to parse.  One might consider that a bug in 
pyparsing...
Secondly, I get the impression you want to consider ambiguous grammars, 
in some sense, wrong.  They are not.  Even if they were, if you are 
parsing something for which you are not the creator and that something 
employs an ambiguous grammar, what choice do you have?  Furthermore, given a 
set of possible parsings, you might be able to decide which one you favour 
given the context of what was parsed!  There's a plethora of applications 
for parsing ambiguous grammars yet there are no tools for doing so?


 In fact, I often use pyparsing precisely in order to disambiguate
 (according to specific rules, which are embodied by the parser)
 ambiguous input, like bizarre hand-entered datetime value.

What do you mean?  How do you use pyparsing to disambiguate:


01-01-08


...? 


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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Just Another Victim of the Ambient Morality

Steven D'Aprano [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Wed, 07 Nov 2007 21:15:50 +, Just Another Victim of the Ambient
 Morality wrote:

 Why can't I find a pyparsing-esque library with this implementation?
 I'm tempted to roll my own except that it's a fairly complicated
 algorithm and I don't really understand how it's any more efficient than
 the naive approach...

 I think you may have just answered your own question :)

Yes, but my own answer lacks detail that I was hoping you could 
provide...



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


Re: pydoc - generating HTML docs from string input

2007-11-07 Thread [EMAIL PROTECTED]
On Nov 7, 4:47 pm, Laszlo Nagy [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  Has anyone ever tried mucking with pydoc to the point where you can
  get it to give you output from a string input?  For example I'd like
  to give it a whole module to generate documentation for but all within
  a string:

  #little sample

  module_code='''
  Module docstring

  def func1():
   some docstring
  pass

  ...

  '''

  pydoc.html(module_code) - HTML output as a string

  Any ideas?

 The problem with this is that your module can do relative imports, and
 it DOES matter where your module is located in the filesystem.

 In the very unlikely case when you store your modules in an external
 system (e.g in a database), and you use __import__ hacks to run your
 code, I would recommend to write a program that exports your stored
 modules into a real filesystem and run pydoc there.

 Regards,

Laszlo


That's a good point.  I was mainly thinking about the case of simple
modules with no other imports.  But looking at pydoc's code, it looks
like it would be quite a bit of work to make it work at all.

-Greg

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Chris Mellon
On Nov 7, 2007 5:15 PM, Just Another Victim of the Ambient Morality
[EMAIL PROTECTED] wrote:

 Chris Mellon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality
  [EMAIL PROTECTED] wrote:
 
   In short, it hasn't really evovled into a user-friendly package
   yet.
 
  Thank you.
  How is it that I seem to be the only one in the market for a correct
  parser?  Earley has a runtine of O(n^3) in the worst case and O(n^2)
  typically.  I have trouble believing that everyone else in the world has
  such intense run-time requirements that they're willing to forego
  correctness.  Why can't I find a pyparsing-esque library with this
  implementation?  I'm tempted to roll my own except that it's a fairly
  complicated algorithm and I don't really understand how it's any more
  efficient than the naive approach...
 
  You have an unusual definition of correctness. Many people would say
  that an ambiguous grammar is a bug, not something to support.

 I don't think I do.

There are an enormous variety of parsing tools, and it's the subject
of much research. And in all those tools, not one meets your
definition of correctness? You don't think that might make it unusual?


 Besides, you assume too much...
 First off, we've already established that there are unambiguous grammars
 for which pyparsing will fail to parse.  One might consider that a bug in
 pyparsing...

You might. Or you might not, since it's well known that there are lots
of types of parsers that can't parse all possible grammars, but that
doesn't make those parsers useless.


 Secondly, I get the impression you want to consider ambiguous grammars,
 in some sense, wrong.  They are not.

Sure they are, at least in many contexts. I understand that you want
support for them, but it's by far more common to want one and only one
set of results from parsing a particular document.

Even if they were, if you are
 parsing something for which you are not the creator and that something
 employs an ambiguous grammar, what choice do you have?

You either disambiguate, or you don't accept ambiguous input. The
third option seems to be what you want, which is to find all possible
solutions and return all of them (and wouldn't this be NP-hard in the
general case?) but that's not a satisfactory result in most
applications.

 Furthermore, given a
 set of possible parsings, you might be able to decide which one you favour
 given the context of what was parsed!  There's a plethora of applications
 for parsing ambiguous grammars yet there are no tools for doing so?


If you can do this, isn't this really a sign that your grammar is
context sensitive?


  In fact, I often use pyparsing precisely in order to disambiguate
  (according to specific rules, which are embodied by the parser)
  ambiguous input, like bizarre hand-entered datetime value.

 What do you mean?  How do you use pyparsing to disambiguate:


 01-01-08

The same way a human would - given an ambiguous date such as this, I
(arbitrarily) decided what it would mean. The alternative is to refuse
the input.
-- 
http://mail.python.org/mailman/listinfo/python-list


pydoc - how to generate documentation for an entire package?

2007-11-07 Thread Jens
I have a project/package for which I want to generate documentation
using pydoc.

My problem is that when I type pydoc.py -w MyPackage it only
generates documentation for the package - no modules, classes or
methods or sub-packages. Just a single HTML file called
MyPackage.html

That's strange - is there something here I'm missing. How do you
generate documentation for a whole package?

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


Re: a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
 Even simpler, use Twisted:

I am afraid Twisted is not the right choice in my case. I am looking
for smaller, simpler and minimal server sample.

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Just Another Victim of the Ambient Morality

Chris Mellon [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Nov 7, 2007 5:15 PM, Just Another Victim of the Ambient Morality
 [EMAIL PROTECTED] wrote:

 Chris Mellon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality
  [EMAIL PROTECTED] wrote:
 
   In short, it hasn't really evovled into a user-friendly package
   yet.
 
  Thank you.
  How is it that I seem to be the only one in the market for a 
  correct
  parser?  Earley has a runtine of O(n^3) in the worst case and O(n^2)
  typically.  I have trouble believing that everyone else in the world 
  has
  such intense run-time requirements that they're willing to forego
  correctness.  Why can't I find a pyparsing-esque library with this
  implementation?  I'm tempted to roll my own except that it's a fairly
  complicated algorithm and I don't really understand how it's any more
  efficient than the naive approach...
 
  You have an unusual definition of correctness. Many people would say
  that an ambiguous grammar is a bug, not something to support.

 I don't think I do.

 There are an enormous variety of parsing tools, and it's the subject
 of much research. And in all those tools, not one meets your
 definition of correctness? You don't think that might make it unusual?

It doesn't appear to be common, I'll grant you that!
However, there is some research.  For instance, the Earley parser 
appears to be what I want (in conjunction with a parse tree builder).  A CYK 
parser would probably do, too.  The algorithms are out there yet no one has 
chosen to use any of them.  At the same time, there are several LALR 
parsers.  Why did anyone need to write the second one after the first one 
was written?!
In fact, in a sense, my problem is solved.  There exists a solution to 
my problem.  It's just that no one has implemented that solution.  I guess 
you're right in that it really does appear to be an unusual problem but I 
don't understand how...


 Besides, you assume too much...
 First off, we've already established that there are unambiguous 
 grammars
 for which pyparsing will fail to parse.  One might consider that a bug in
 pyparsing...

 You might. Or you might not, since it's well known that there are lots
 of types of parsers that can't parse all possible grammars, but that
 doesn't make those parsers useless.

No one said they were useless.  I only said that a correct parser is 
useful.  Many people in this thread seem to disagree and I find this 
incredible...


 Secondly, I get the impression you want to consider ambiguous 
 grammars,
 in some sense, wrong.  They are not.

 Sure they are, at least in many contexts. I understand that you want
 support for them, but it's by far more common to want one and only one
 set of results from parsing a particular document.

Okay, in some contexts, an ambiguous grammar may be considered 
erroneous.  However, in many other contexts, it's merely a fact of life. 
How is it that there are no tools to address this?  If nothing else, 
pyparsing throws the same error it does when there is no valid parsing of 
the string.  Having no solution and having several solutions are not the 
same thing...


Even if they were, if you are
 parsing something for which you are not the creator and that something
 employs an ambiguous grammar, what choice do you have?

 You either disambiguate, or you don't accept ambiguous input. The
 third option seems to be what you want, which is to find all possible
 solutions and return all of them (and wouldn't this be NP-hard in the
 general case?) but that's not a satisfactory result in most
 applications.

What do you mean by disambiguate?  Do you mean disambiguate the 
grammar?  One of the conditions of the problem is that you have no control 
over the grammar, so that's really not an option.  Also, an implicit 
condition of solving a problem is that the problem be... solved, so not 
accepting the input is not an option, either.
While there are many applications that can't deal with multiple 
solutions, surely there are some?  Again, perhaps you can pick one solution 
over the other through the context of the parse results?  That's kind of 
hard to do if your parser refuses to return any results...
Just because a grammar is ambiguous doesn't mean the input string is. 
It can easily be the case that most or all the input you're expecting will, 
in practice, only produce one correct parse tree.  In this case, it would be 
useful for your parser to return a correct solution, even at random!
Finally, who cares if something is NP-Hard?  Okay, in some situations, 
you'd care.  In many others, you don't.  For instance, suppose your input 
length has an upper bound?  Unless that's a really high bound or a really 
complex grammar, its runtime is not likely relevant...


 Furthermore, given a
 set of possible parsings, you might be able to decide 

Re: How can i find the form name without nr=0

2007-11-07 Thread scripteaze
On Nov 7, 1:35 pm, [EMAIL PROTECTED] (John J. Lee) wrote:
 alex23 [EMAIL PROTECTED] writes:
  On Nov 6, 8:56 am, scripteaze [EMAIL PROTECTED] wrote:
  Is it possible then to have a form with no name and if so, how can i
  access this form

  Hey scripteaze,

  I'm not sure about mechanize, but you might have more success using
  another one of the author's modules, 
  ClientForm:http://wwwsearch.sourceforge.net/ClientForm/

  from urllib2 import urlopen
  from ClientForm import ParseResponse

  response = urlopen(http://wwwsearch.sourceforge.net/ClientForm/
  example.html)
  forms = ParseResponse(response, backwards_compat=False)
  form = forms[0]

  As it returns a list of forms, you don't need to have a name to access
  it.

 mechanize forms are ClientForm forms.

 Quoting from mechanize.Browser.select_form().__doc__:

 
 Another way to select a form is to assign to the .form attribute.  The
 form assigned should be one of the objects returned by the .forms()
 method.
 

 forms = list(br.forms())
 br.form = pick_a_form(forms, br.global_form())

 The global form (couldn't think of a better term) consists of all
 form controls not contained in any FORM element.

 John- Hide quoted text -

 - Show quoted text -

Thank you guys for replying, im sure that one of these methods will
suffice, after this project, im definatly going to do more in lui of
web apps for learning..Thanks again

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


911 operation by evil JEWS and Mossad

2007-11-07 Thread zionist . news
911 carried out by evil jews and mossad
http://www.guba.com/watch/2000991770

911 truckload of Explosives on the George Washington Bridge
http://www.youtube.com/watch?v=J520P-MD9a0

Benjamin Freedman's SEMINAL TESTIMONIAL SPEECH
http://video.google.com/videoplay?docid=3552214685532803163

Benjamin Freedman speech with Slide Show (40 Minute Excerpt)
http://video.google.com/videoplay?docid=3552214685532803163

Free pdf book: THE MANUFACTURE AND SALE of Saint Einstein
@
http://jewishracism.com/SaintEinstein.htm

Author interviews @
http://jewishracism.com/interviews.htm

Rothschilds control half the world's wealth directly and indirectly
using zionist proxies, and loyalty based on the zionist racist cult of
hate and paranoia based on being caught for collective financial
crimes and crimes of other categories

History of the Rothschilds part 1
http://www.youtube.com/watch?v=o_u2MaNg-EQ

History of the Rothschilds part 2
http://www.youtube.com/watch?v=o2cw-0N_Unk

FBI, Where are the two Israelis with TRUCKLOAD of explosives at the
George Washington Bridge ?
http://www.youtube.com/watch?v=JfVumKHkcIA   - Shame stooopid
americans

Alex Jones Interviews David Mayer de Rothschild
http://video.google.com/videoplay?docid=4891699310483983031

The rise of the Rothschild Money Masters
http://www.youtube.com/watch?v=ZT3GyphxJv8

Rothschilds financed APARTHEID in South Africa. They corrupted Cecil
Rhodes, the son of an anglican minister, by TEACHING him evil
techniques of apartheid. Apartheid was taught to him by the father
zionists themselves.

Rothschilds control half the world's wealth directly and indirectly
using zionist proxies, and loyalty based on the zionist racist cult
http://www.youtube.com/watch?v=fXVJzXsraX4

Was Hitler's father a bastard son of Rothschilds? Did the Salomon
Mayer von Rothschild perhaps rape  Maria Anna Schicklgruber in dark so
that she could not ever claim with certainty who the real father was?
Look at his facial features, typical central asian khazar. What was
the cause of Hitler's fanatical hatred for the Jews ?
http://en.wikipedia.org/wiki/Alois_Hitler
http://www.youtube.com/watch?v=TihCM_q59c8

On Nov 6, 9:53 am, [EMAIL PROTECTED] wrote:

 The world has been after Bill Gates for no reason. The richest group
 was and remains the Zionist jew Rothschilds family who own HALF the
 worlds total wealth through numerous frontmen zionists.

 Mikhail Khodorkovsky, whom Russian President Vladimir I Putin put in
 jail rose from the Rothschilds money. Mayer Amschel Bauer changed his name to
 Rothschild or red shield. The he sent his sons to various countries in
 Europe and become bankers there. Using an innovative system of pigeons
 for communication and encoded letters, the family invested in wars
 that he knew were coming by staying close to the centers of powers in
 all the countries which they had infilterated.

 google video and youtube have many videos on the family. You can set
 aside part of your weekend for HEALTHY education so your
 kids can learn how to avoid being hunted by these snakes.

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


Source insight support files

2007-11-07 Thread Jiwon Seo
Is there anyone who uses source insight for python source code editing/browsing?

It seems like Tim used to use it (
http://mail.python.org/pipermail/python-list/2001-May/082137.html
)..., but I'm not sure if he still uses it.

Anyway, if there's anyone who uses it and has a customized support
configuration/files, please let me use it, too. ;^) I'm currently
using source insight with Python.clf file and it's not bad, but not
satisfactory.

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


Re: a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
 See the SocketServer module, both the documentation and the source code.

I firstly looked at this module and its __doc__, yet I still need an
'hello world' sample. and couldn't get it straight how can I write my
own hello world sample with SocketServer objects.


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


Using python as primary language

2007-11-07 Thread Michel Albert
In our company we are looking for one language to be used as default
language. So far Python looks like a good choice (slacking behind
Java). A few requirements that the language should be able cope with
are:

* Database access to Sybase.
  This seems to be available for python, but the windows-binaries for
the library
  are not available. Self-Compiling them proved to be non-trivial (As
always
  on windows).
* Easy GUI creation.
  Solved using PyQt.
* Cross Platform (Linux + Windows).
  Again, PyQt, solves this
* Easy deployment.
  Solved using py2exe + innosetup
* Charting (Histograms, Line charts, bar charts, pie charts, ...)
  I am currently looking into PyQwt, which looks promising.
* Report generation with GUI support
  reportlab + rml?

So far, nearly all point seems to be manageable. But I was not yet
able to find a solution for the report generation. What we would like
to have is a sort of GUI interface to prepare the reports without
having to code the positioning. I found reportlab, and it looks like
it can do all that is needed in terms of output. But you still have to
code the report. And this is a no go. In context, I found RML and saw
links to graphical RML editors. But I have not yet found a concrete
example code, or documentation. What am I missing? Is RML a reportlab
creation or is it a recognised open standard? If not, is there an open
standard, that is easily to process with python?

Any pointers? I would prefer coding Python to coding Java or
worse. VB ;) which is another contender in our roundup.

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


Re: Confused about closures and scoping rules

2007-11-07 Thread Jakub Hegenbart
On Wed, 07 Nov 2007 01:37:00 +0100, Chris Mellon [EMAIL PROTECTED] wrote:

 Are there languages where closures *don't* behave like this? A closure
 that used a copy of the state rather than the actual state itself
 doesn't seem as useful. For references sake, JavaScript (the only
 language that a) has closures and b) I have a handy way to test with)
 does the same thing.

The results in an equivalent code might depend on the semantics of the
looping construct used. For example, take Scheme (I'm using Gauche Scheme):

(define (outer-1 nmax)
   (let ((aa '()))
(dotimes (n nmax)
  (push! aa (lambda (y) (list y: y n: n
aa))

(define (outer-2 nmax)
   (let ((aa '())
(n 0))
(until (= n nmax)
  (push! aa (lambda (y) (list y: y n: n)))
  (set! n (+ n 1)))
aa))

(print (map (lambda (f) (f 1)) (outer-1 5)))
(print (map (lambda (f) (f 1)) (outer-2 5)))

$ gosh closures.scm
((y: 1 n: 4) (y: 1 n: 3) (y: 1 n: 2) (y: 1 n: 1) (y: 1 n: 0))
((y: 1 n: 5) (y: 1 n: 5) (y: 1 n: 5) (y: 1 n: 5) (y: 1 n: 5))

In outer-1, the (dotimes ...) form expands into (do ...). R5RS defines
that a (do ...) loop is expected to _rebound_ all of its state variables
(here it is only n) in each iteration step. This means that each closure
created captures a different binding. Whereas in outer-2, I am updating
the binding destructively, so the value changes in the environment of
all the closures that have been already stored. Python seems to do the
latter. (I am not a pythonist right now, but I am learning... :))

Regards,

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


Re: Is pyparsing really a recursive descent parser?

2007-11-07 Thread Kay Schluehr
 What do you mean by disambiguate?  Do you mean disambiguate the
 grammar?  One of the conditions of the problem is that you have no control
 over the grammar, so that's really not an option.  Also, an implicit
 condition of solving a problem is that the problem be... solved, so not
 accepting the input is not an option, either.

Could you please learn some parser theory 101 and then come back when
you have complaints about one or the other implemententation of a
particular Python parser? When some guy enters a forum with a newbie
question most of the time people are willing to give a fair and
comprehensive answer but they don't want to mess around with him
endlessly when he is not willing to learn and to listen.


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


help parsing ipv6 addresses and subnets

2007-11-07 Thread Prabhu Gurumurthy
Hello list,

I would like to parse IPv6 addresses and subnet using re module in
python. I am able to either parse the ipv6 address or ipv6 network but
not both using single line. any help appreciated. BTW is there a
metacharacter for hex digits.

Thanks
Prabhu
-

-
#!/usr/bin/env python2.5
# $Id: $

import re, os, Queue, sys
from optparse import OptionParser

# for debug purposes only
import pdb

argc = len(sys.argv)
(dirname, program) = os.path.split(sys.argv[0])

def error(Message):
   if Message:
  global program
  print %s: %s %(program, Message)
  sys.exit(1)

def cisco_parse(FileName):
   if FileName:
  fh = None
  if os.path.exists(FileName):
 try:
fh = open(FileName, r)
 except IOError, message:
error(message)
 else:
count = 0
flag = True
while flag:
   try:
  lines = fh.next()
   except StopIteration:
  flag = False
   else:
  line = lines.strip()
  rehex = [A-Fa-f0-9]
  # to parse ipv6 address
  format = \
 ((%s{1,4}:?:){1,7}%s{1,4}) %(rehex, rehex)
  # to parse ipv6 subnet
  # format = \
  #   ((%s{1,4}:?:){1,7}%s{1,4}(?=(::/\d{1,3})))
%(rehex, rehex)
  reip6 = re.compile(format)
  match = reip6.search(line)
  if match is not None:
 tupleLen = len(match.groups())
 if tupleLen == 2:
print count, match.groups()[0]
 elif tupleLen == 3:
print count, match.groups()[0] + match.groups()[2]
 count += 1

fh.close()
fh = None

def ParseCmdLine():
   parser = OptionParser(usage=%prog [options], version=%prog 1.0)
   parser.add_option(-f, --filename,
 help=cisco config to read, dest=file)

   (options, args) = parser.parse_args()

   fileName = None
   if options.file:
  fileName = options.file

   if fileName:
  cisco_parse(fileName)

if __name__ == __main__:
   if argc = 1:
  error(too few arguments, use -h or --help to view all options)
   else:
  ParseCmdLine()


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


Re: a simple tcp server sample

2007-11-07 Thread Tzury Bar Yochay
here is its:
# a simple tcp server

import SocketServer


class EchoRequestHandler(SocketServer.BaseRequestHandler ):
def setup(self):
print self.client_address, 'connected!'
self.request.send('hi ' + str(self.client_address) + '\n')

def handle(self):
while 1:
data = self.request.recv(1024)
self.request.send(data)
if data.strip() == 'bye':
return

def finish(self):
print self.client_address, 'disconnected!'
self.request.send('bye ' + str(self.client_address) + '\n')

#server host is a tuple ('host', port)
server = SocketServer.ThreadingTCPServer(('', 50008),
EchoRequestHandler)
server.serve_forever()

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


An important message to all jobseekers ,and internet users

2007-11-07 Thread jobmasters
hi friends

An important message to all jobseekers ,and internet users

Hi,

this is your friend , administrator  -india

either you are fresher or experienced,  searching for any job, any
location in India.
[job  guarantee for your challenging career.]

 Do this two things

1] Post your resume on [EMAIL PROTECTED]

we just initiate and up date your resume
and foward it to all corporate Zones Which suits  to your Job profile
@ free of cost.

2]do ur email registration on softgeeks.blogspot.com .or
mbanaukri.blogspot.com [for very clear and advanced job updates]

[it depends on your job search category, if you donot registered your
request will not accepted.]

[ Your account has been created and activation link has been sent to
the e-mail address you entered.
Note that you must activate the account by clicking on the activation
link when you get the e-mail before you can login. ]


*All these for free of cost. We dont charge the jobseeker or employer
for any of our service.


regards

teams- softgeeks,mba naukri





our servicess list



1]essential education:www.mncpages.blogspot.com

[including ,group discussions ,puzzles ,repeated questions, practise
tests ,Resume section ,
quizzes ,apptitude tests ,interview questions, Reasoning ,brain
tesers ,tutorials,placement papers ]



2]higher studies information:www.hsmaster.blogspot.com

[including

ACT , ,GATE ,GED, GMAT ,GRE, ICET ,IELTS ,MBA ,NCLEX ,SAT, TOEFL ,
Credit Card ,VISA information]



3]essential skills :www.beforejobs.blogspot.com

[including,leadership ,personality test, communication
skills ,Attitude ,Personality Developement,
motivation, Stress Management, Time Management, Memory
Techniques ,decision making,
happiness,inspiration, Goal Setting, Positive Thinking, Problem
Solving Tips ,
Self Confidence, success ]



4]poems,freesms,jokes,quotes:www.smsadda.blogspot.com

[thuosands of sms,jokes,poems,quotes daily updated,
and also send free unlimited sms around the world,any mobile]



5]news,current events:www.worldnewsreporter.blogspot.com

[daily news
updates,India,international,business,sports,it ,educaton,current
events]



6]mba,engi,bpo jobs:www.mbanaukri.blogspot.com [email registration
must]

Accountants, All walkins, appsc notifications, Banking/insurance, Bpo/
kpo walkins, callcenter/bpo,

engineering,finance ,governament jobs, HR,Marketing, more experienced
jobs,defence jobs

 pharma/biotech, sales, telecom, like jobs daily updated]




7]latest software jobs :www.softgeeks.blogspot.com [email registration
must]

C/C++ Programmer, datawarehousing/mining ,dotnet, Embedded ,ERP/SAP ,

graphics, Java ,Mainframes, more experienced jobs,

more freshers, Network Engineer,  oracle/dba, php, Software Engineer,
System Administrator,

Technical/content writers,testing, walkin interviews, Web Designer,
Website Promotion Seo,and more

all categorys jobs daily updated both freshers and experienced]



*[if you are neglecting, you  mis a wonderful opportunity. or

if you are satisfied send this mail to your mailing list,friends, who
searching for jobs,and better jobs]

Wish U good luckss

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


easy 3D graphics for rendering geometry?

2007-11-07 Thread gsal

What would be the easiest way to go about offering 3D graphics for the
purpose of rendering geometry?

Suppose engineers (my co-workes) have to design some enclosure,
nozzle, bracket, or whatever physical part/component, I would like to
write a program where they can at least see the resulting geometry and
navigate it, i.e., zoon-in/out, rotate, pan.  On the side, I could
have data entry fields with the input parameters and when something is
changed, the graphics can be updated immediately (after the
necessary calculations have been done).

I know I need to learn something, and I am willing, I just need help
choosing what to learn.

I don't have any experience on this matter, don't know OpenGL, Mesa,
VTK, VRS, Maya...and all seem to have a steep learning curve. I don't
know any of the other graphics packages more oriented for game/
scenery/movie development (Panda, etc.), either.

I do know my trig and build my FEA parts parametrically from points,
to line, to surfaces, to volumes or from volume boolean algebra.

I would like the choice to be some kind of module/API that works
equally well on Linux as in Windows.

So:
What would be the easiest way?
and would it be worth learning?
or
is it better to shoot for something not so easy but worth learning?

thanks in advance for any pointers.

gsal

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


  1   2   >