Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel

Matt Funk, 21.02.2011 23:40:

On 2/21/2011 3:28 PM, Stefan Behnel wrote:

Matt Funk, 21.02.2011 23:07:

thank you for your advice.
I am running into an issue though (which is likely a newbie problem):

My xml file looks like (which i got from the internet):


 
Gambardella, Matthew
XML Developer's Guide
Computer
44.95
2000-10-01
An in-depth look at creating applications
with XML.
 


Then i try to access it as:

from lxml import etree
from lxml import objectify

inputfile="../input/books.xml"
parser = etree.XMLParser(ns_clean=True)
parser = etree.XMLParser(remove_comments=True)


Change that to

parser = objectify.makeparser(ns_clean=True, remove_comments=True)


root = objectify.parse(inputfile,parser)


Change that to

root = objectify.parse(inputfile,parser).getroot()


According to your instructions i do:

parser = objectify.makeparser(ns_clean=True, remove_comments=True)
root = objectify.parse(inputfile,parser).getroot()
print root.catalog.book.author.text


root == 

Try "print root.tag", and read the tutorial.

Stefan

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


Re: Python Tutorial on Multithreading

2011-02-21 Thread Terry Reedy

On 2/21/2011 7:02 PM, KevinSimonson wrote:

On Feb 21, 4:04 pm, Alexander Kapps  wrote:


That tutorial seems to be wrong.

According to the official docs:

"If the subclass overrides the constructor, it must make sure to
invoke the base class constructor (Thread.__init__()) before doing
anything else to the thread."

http://docs.python.org/library/threading.html#thread-objects

So, change your __init__ to this:

class myThread (threading.Thread):
  def __init__(self, threadID, name, q):
  threading.Thread.__init__(self)
  self.threadID = threadID
  self.name = name
  self.q = q



Alexander, thanks!  Your suggestion fixed my problem.


Please report the problem and solution on the tracker so the tutorial 
can be fixed.


--
Terry Jan Reedy

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


Re: Return Values & lambda

2011-02-21 Thread pradeepbpin
On Feb 22, 5:59 am, Steven D'Aprano  wrote:
> On Mon, 21 Feb 2011 16:43:49 -0800, Rafe Kettler wrote:
> > On Feb 21, 1:59 pm, pradeepbpin  wrote:
> >> I have a main program module that invokes an input dialog box via  a
> >> menu item. Now, the code for drawing and processing the input of dialog
> >> box is in another module, say 'dialogs.py'. I connect the menu item to
> >> this dialog box by a statement like,
>
> >> manu_item.connect('activate', lambda a: dialogs.open_dilaog())
>
> >> If this function open_dialog() returns a list of dialog inputs values,
> >> how can I access those values in the main module ?
>
> > Moreover, I don't see why you need a lambda in this case. Why not just
> > pass the function itself?
>
> My guess is that the callback function is passed a single argument, and
> open_dialog doesn't take any arguments, hence the wrapper which just
> ignores the argument and calls the function.
>
> --
> Steven


Thanks to all.

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


Ruby on rails training for Python developers

2011-02-21 Thread Wan Li Zhu
If you're a Python developer in the Boston area looking to learn Ruby,
Fairhaven Capital and thoughtbot are teaming up to offer Ruby on Rails
training courses in Boston at 50% off regular price ($600 for 2 full
days of training, intro and advanced levels).

Details at http://workshops.thoughtbot.com/fairhaven
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2 or 3 ? with Django , My SQL and YUI

2011-02-21 Thread Sumit
Python 2 or 3 ? with Django , My SQL and YUI

For a web project We have decided to work on Python 2 or 3 ? with
Django , My SQL and YUI, and this would be the first time to work with
Python, just now I explored a little and found Python -2 vs 3 Stuff ,

Is there experienced python dev can guide me in very simple terms
should I go for Python 2 or 3 ?

How about Python with Django and MySQL and YUI Stuff ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Long Lists

2011-02-21 Thread Dan Stromberg
On Mon, Feb 21, 2011 at 7:24 PM, Dan Stromberg  wrote:

>
> On Mon, Feb 21, 2011 at 6:57 PM, Kelson Zawack <
> zawack...@gis.a-star.edu.sg> wrote:
>
>> I have a large (10gb) data file for which I want to parse each line into
>> an object and then append this object to a list for sorting and further
>> processing.  I have noticed however that as the length of the list increases
>> the rate at which objects are added to it decreases dramatically.  My first
>> thought was that  I was nearing the memory capacity of the machine and the
>> decrease in performance was due to the os swapping things in and out of
>> memory.  When I looked at the memory usage this was not the case.  My
>> process was the only job running and was consuming 40gb of the the total
>> 130gb and no swapping processes were running.  To make sure there was not
>> some problem with the rest of my code, or the servers file system, I ran my
>> program again as it was but without the line that was appending items to the
>> list and it completed without problem indicating that the decrease in
>> performance is the result of some part of the process of appending to the
>> list.  Since other people have observed this problem as well (
>> http://tek-tips.com/viewthread.cfm?qid=1096178&page=13,
>> http://stackoverflow.com/questions/2473783/is-there-a-way-to-circumvent-python-list-append-becoming-progressively-slower-i)
>> I did not bother to further analyze or benchmark it.  Since the answers in
>> the above forums do not seem very definitive  I thought  I would inquire
>> here about what the reason for this decrease in performance is, and if there
>> is a way, or another data structure, that would avoid this 
>> problem.
>
>
> Do you have 130G of physical RAM, or 130G of virtual memory?  That makes a
> big difference.  (Yeah, I know, 130G of physical RAM is probably pretty rare
> today)
>
> Disabling garbage collection is a good idea, but if you don't have well
> over 10G of physical RAM, you'd probably better also use a (partially)
> disk-based sort.  To do otherwise would pretty much beg for swapping and a
> large slowdown.
>
> Merge sort works very well for very large datasets.
> http://en.wikipedia.org/wiki/Merge_sort  Just make your sublists be disk
> files, not in-memory lists - until you get down to a small enough sublist
> that you can sort it in memory, without thrashing.  Timsort (list_.sort())
> is excellent for in memory sorting.
>
> Actually, GNU sort is very good at sorting huge datasets - you could
> probably just open a subprocess to it, as long as you can make your data fit
> the line-oriented model GNU sort expects, and you have enough temporary disk
> space.
>

Depending on what you're doing after the sort, you might also look at
bsddb.btopen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Return Values & lambda

2011-02-21 Thread Rafe Kettler
On Feb 21, 7:59 pm, Steven D'Aprano  wrote:
> On Mon, 21 Feb 2011 16:43:49 -0800, Rafe Kettler wrote:
> > On Feb 21, 1:59 pm, pradeepbpin  wrote:
> >> I have a main program module that invokes an input dialog box via  a
> >> menu item. Now, the code for drawing and processing the input of dialog
> >> box is in another module, say 'dialogs.py'. I connect the menu item to
> >> this dialog box by a statement like,
>
> >> manu_item.connect('activate', lambda a: dialogs.open_dilaog())
>
> >> If this function open_dialog() returns a list of dialog inputs values,
> >> how can I access those values in the main module ?
>
> > Moreover, I don't see why you need a lambda in this case. Why not just
> > pass the function itself?
>
> My guess is that the callback function is passed a single argument, and
> open_dialog doesn't take any arguments, hence the wrapper which just
> ignores the argument and calls the function.
>
> --
> Steven

That would sound reasonable.

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


Re: Python on OSX

2011-02-21 Thread Jason Swails
On Mon, Feb 21, 2011 at 7:08 PM, Chris Rebert  wrote:

> On Mon, Feb 21, 2011 at 3:54 PM, Robert  wrote:
> > Can I install 2.7 and 3.2 side by side?
>
> Yes, of course. Just don't fiddle with the "System Python" (i.e. the
> copy preinstalled by Apple).
>

Good advice.  I second it.


> You may wish to install your additional Pythons via Fink or MacPorts.
>

I have python24, 25, 26, 27, and 32 installed with MacPorts, and
"python_select" (also from MacPorts) allows you to change the default python
version quickly and cleanly with a single command.  It's quite useful for
testing compatibility of scripts that use "#!/usr/bin/env python" as the
shebang line.  I haven't tried Fink, but the MacPorts approach works well
for me.

Good luck!
Jason


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



-- 
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
352-392-4032
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Long Lists

2011-02-21 Thread Ben Finney
Kelson Zawack  writes:

> I have a large (10gb) data file for which I want to parse each line
> into an object and then append this object to a list for sorting and
> further processing.

What is the nature of the further processing?

Does that further processing access the items sequentially? If so, they
don't all need to be in memory at once, and you can produce them with a
generator http://docs.python.org/glossary.html#term-generator>.

Note that, if you just want lines of text from a file, the file object
itself is a generator for the lines of text within it.

If, on the other hand, you need arbitrary access all over that large
data set, you probably want a data type better suited. The standard
library has the ‘array’ module for this purpose; the third-party NumPy
library provides even more power.

-- 
 \   “Remember: every member of your ‘target audience’ also owns a |
  `\   broadcasting station. These ‘targets’ can shoot back.” —Michael |
_o__)   Rathbun to advertisers, news.admin.net-abuse.email |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Long Lists

2011-02-21 Thread Dan Stromberg
On Mon, Feb 21, 2011 at 6:57 PM, Kelson Zawack
wrote:

> I have a large (10gb) data file for which I want to parse each line into an
> object and then append this object to a list for sorting and further
> processing.  I have noticed however that as the length of the list increases
> the rate at which objects are added to it decreases dramatically.  My first
> thought was that  I was nearing the memory capacity of the machine and the
> decrease in performance was due to the os swapping things in and out of
> memory.  When I looked at the memory usage this was not the case.  My
> process was the only job running and was consuming 40gb of the the total
> 130gb and no swapping processes were running.  To make sure there was not
> some problem with the rest of my code, or the servers file system, I ran my
> program again as it was but without the line that was appending items to the
> list and it completed without problem indicating that the decrease in
> performance is the result of some part of the process of appending to the
> list.  Since other people have observed this problem as well (
> http://tek-tips.com/viewthread.cfm?qid=1096178&page=13,
> http://stackoverflow.com/questions/2473783/is-there-a-way-to-circumvent-python-list-append-becoming-progressively-slower-i)
> I did not bother to further analyze or benchmark it.  Since the answers in
> the above forums do not seem very definitive  I thought  I would inquire
> here about what the reason for this decrease in performance is, and if there
> is a way, or another data structure, that would avoid this 
> problem.


Do you have 130G of physical RAM, or 130G of virtual memory?  That makes a
big difference.  (Yeah, I know, 130G of physical RAM is probably pretty rare
today)

Disabling garbage collection is a good idea, but if you don't have well over
10G of physical RAM, you'd probably better also use a (partially) disk-based
sort.  To do otherwise would pretty much beg for swapping and a large
slowdown.

Merge sort works very well for very large datasets.
http://en.wikipedia.org/wiki/Merge_sort  Just make your sublists be disk
files, not in-memory lists - until you get down to a small enough sublist
that you can sort it in memory, without thrashing.  Timsort (list_.sort())
is excellent for in memory sorting.

Actually, GNU sort is very good at sorting huge datasets - you could
probably just open a subprocess to it, as long as you can make your data fit
the line-oriented model GNU sort expects, and you have enough temporary disk
space.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Long Lists

2011-02-21 Thread John Bokma
alex23  writes:

> On Feb 22, 12:57 pm, Kelson Zawack 
> wrote:
>> I did not bother to further analyze or benchmark it.  Since the answers
>> in the above forums do not seem very definitive  I thought  I would
>> inquire here about what the reason for this decrease in performance is,
>> and if there is a way, or another data structure, that would avoid this
>> problem.
>
> The first link is 6 years old and refers to Python 2.4. Unless you're
> using 2.4 you should probably ignore it.
>
> The first answer on the stackoverflow link was accepted by the poster
> as resolving his issue. Try disabling garbage collection.

I just read http://bugs.python.org/issue4074 which discusses a patch
that has been included 2 years ago. So using a recent Python 2.x also
doesn't have this issue?

-- 
John Bokma   j3b

Blog: http://johnbokma.com/Facebook: http://www.facebook.com/j.j.j.bokma
Freelance Perl & Python Development: http://castleamber.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Long Lists

2011-02-21 Thread alex23
On Feb 22, 12:57 pm, Kelson Zawack 
wrote:
> I did not bother to further analyze or benchmark it.  Since the answers
> in the above forums do not seem very definitive  I thought  I would
> inquire here about what the reason for this decrease in performance is,
> and if there is a way, or another data structure, that would avoid this
> problem.

The first link is 6 years old and refers to Python 2.4. Unless you're
using 2.4 you should probably ignore it.

The first answer on the stackoverflow link was accepted by the poster
as resolving his issue. Try disabling garbage collection.
-- 
http://mail.python.org/mailman/listinfo/python-list


Creating Long Lists

2011-02-21 Thread Kelson Zawack
I have a large (10gb) data file for which I want to parse each line into 
an object and then append this object to a list for sorting and further 
processing.  I have noticed however that as the length of the list 
increases the rate at which objects are added to it decreases 
dramatically.  My first thought was that  I was nearing the memory 
capacity of the machine and the decrease in performance was due to the 
os swapping things in and out of memory.  When I looked at the memory 
usage this was not the case.  My process was the only job running and 
was consuming 40gb of the the total 130gb and no swapping processes were 
running.  To make sure there was not some problem with the rest of my 
code, or the servers file system, I ran my program again as it was but 
without the line that was appending items to the list and it completed 
without problem indicating that the decrease in performance is the 
result of some part of the process of appending to the list.  Since 
other people have observed this problem as well 
(http://tek-tips.com/viewthread.cfm?qid=1096178&page=13,  
http://stackoverflow.com/questions/2473783/is-there-a-way-to-circumvent-python-list-append-becoming-progressively-slower-i) 
I did not bother to further analyze or benchmark it.  Since the answers 
in the above forums do not seem very definitive  I thought  I would 
inquire here about what the reason for this decrease in performance is, 
and if there is a way, or another data structure, that would avoid this 
problem.


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


Re: Python on OSX

2011-02-21 Thread Ned Deily
In article 
,
 Chris Rebert  wrote:
> On Mon, Feb 21, 2011 at 3:54 PM, Robert  wrote:
> > Can I install 2.7 and 3.2 side by side?
> 
> Yes, of course. Just don't fiddle with the "System Python" (i.e. the
> copy preinstalled by Apple).
> You may wish to install your additional Pythons via Fink or MacPorts.

Or the python.org installers for OS X:

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

-- 
 Ned Deily,
 n...@acm.org

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


ANN: pyTenjin 1.0.0 - a high-speed and full-featured template engine

2011-02-21 Thread Makoto Kuwata
Hi all,

I released pyTenjin 1.0.0.
http://pypi.python.org/pypi/Tenjin/
http://www.kuwata-lab.com/tenjin/

This release contains a lot of enhancements and changes.


Overview


* Very fast: about 10 times faster than Django template engine
* Easy to learn: no need to learn template-original language
* Full-featured: nestable layout template, partial template, preprocessing, etc.
* Lightweight: only 2000 lines of code and very fast to import.
* Google App Engine supported


Documents
-

* User's Guide
  http://www.kuwata-lab.com/tenjin/pytenjin-users-guide.html
* Examples
  http://www.kuwata-lab.com/tenjin/pytenjin-examples.html
* CHANGES
  http://www.kuwata-lab.com/tenjin/pytenjin-CHANGES.txt


Install
---

$ sudo easy_install Tenjin

Or:

$ wget http://pypi.python.org/packages/source/T/Tenjin/Tenjin-1.0.0.tar.gz
$ tar xzf Tenjin-1.0.0.tar.gz
$ cd Tenjin-1.0.0/
$ sudo python setup.py install


Example
---

## views/example.pyhtml

${title}

  
  
  
${item}
  
  


## main.py
import tenjin
#tenjin.set_template_encoding('utf-8')  # optional (default 'utf-8')
from tenjin.helpers import *
from tenjin.html import *
engine = tenjin.Engine(path=['views'])
context = {'title': 'Example', 'items': ['Haruhi', 'Mikuru', 'Yuki'] }
output = engine.render('example.pyhtml', context)
print(output)

## output
$ python main.py
Example

  
Haruhi
  
  
Mikuru
  
  
Yuki
  



Enhancements


* (IMPORTANT!!) Performance is improved (about 5 percent).
  To improve performance, compiled Python code is changed.
  This means that YOU MUST TOUCH ALL TEMPLATE FILES AND UPDATE TIME STAMPS
  OF THEM in order to clear cache data before using this release.

## touch all template files to clear cache data
$ find . -name '*.pyhtml' | xargs touch
## show compiled python code
$ cat ex.pyhtml


  ${item}


$ pytenjin -sb ex.pyhtml
_extend=_buf.extend;_to_str=to_str;_escape=escape;
_extend(('''\n''', ));
for item in items:
_extend(('''  ''', _escape(_to_str(item)), '''\n''', ));
#endfor
_extend(('''\n''', ));

* (IMPORTANT!!) Free-indent style supported. Now there is no limitation
  about indent.

## In the previous version, there is strong restriction about indent.

  


  
${item}
  


  


## In this release, you can place statements freely.

  

  
  
${item}
  
  

  


* (IMPORTANT!!) SafeTemplate and SafeEngine classes are now provided.
  These classes support autoescaping similar to Django or Jinja2.
  See
http://www.kuwata-lab.com/tenjin/pytenjin-users-guide.html#auto-escaping
  for details.

* (IMPORTANT!!) New function 'tenjin.set_template_encoding()' is provided.
  If you prefer templates to be unicode-base like Django or Jinja2,
  call it before importing helpers.

 ## change Tenjin to be unicode-based
 import tenjin
 tenjin.set_template_encoding('utf-8')  # call before importing helpers
 from tenjin.helpers import *
 ## The above is same as:
 #import tenjin
 #Template.encoding = 'utf-8'
 #tenjin.helpers.to_str = tenjin.helpers.generate_tostrfunc(decode='utf-8')
 #from tenjin.helpers import *

  Notice that you should NOT write '' into template
  files if you call tenjin.set_template_encoding(). If you wrote it,
  SyntaxError exception would be raised.

* (IMPORTANT!!) New helper function 'cache_as()' is available for
fragment cache.
  This replaces 'not_cached()' and 'echo_cached()'.

 ## previous (obsolete)
 
   ...
 
 

 ## using new helper
 
   ...
 

  'not_cached()' and 'echo_cached()' are still available but not recommended.

* (IMPORTANT!!) New helper 'capture_as()' is available for capturing template.
  This replaces 'start_capture()' and 'stop_capture()'.

 ## preivous (obsolete)
 
   
 

 ## using new helper
 
   
 

  'start_capture()' and 'stop_capture()' are still available but not
recommended.

  New helper 'capture_as()' allows you to nest capturing which is
  impossible with 'start_capture()' and 'stop_capture()'.

* If 'trace=True' is passed to Template class (or Engine class), output
  string will contain template file name. For example:

 
 
   Hello World!
 
 

* tenjin.Engine now helps M17N of templates. If you pass 'lang' option to
  Engine, it will generates cache files for each langs from a file.
  This feature is intened to use with preprocessing in order to reduce
  catalog expantion cost (such as '${_("Hello")}')

  ## for lang='en'
  engine_en = tenjin.Engine(lang='en', preprocess=True)
  engine_en.render('index.pyhtml')  # generate

Re: Return Values & lambda

2011-02-21 Thread Steven D'Aprano
On Mon, 21 Feb 2011 16:43:49 -0800, Rafe Kettler wrote:

> On Feb 21, 1:59 pm, pradeepbpin  wrote:
>> I have a main program module that invokes an input dialog box via  a
>> menu item. Now, the code for drawing and processing the input of dialog
>> box is in another module, say 'dialogs.py'. I connect the menu item to
>> this dialog box by a statement like,
>>
>> manu_item.connect('activate', lambda a: dialogs.open_dilaog())
>>
>> If this function open_dialog() returns a list of dialog inputs values,
>> how can I access those values in the main module ?
> 
> Moreover, I don't see why you need a lambda in this case. Why not just
> pass the function itself?

My guess is that the callback function is passed a single argument, and 
open_dialog doesn't take any arguments, hence the wrapper which just 
ignores the argument and calls the function.



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


Re: An amazing one-minute bit of fun at the interactive prompt

2011-02-21 Thread Raymond Hettinger
On Feb 21, 12:08 am, Mark Dickinson  wrote:
> On Feb 20, 8:08 am, Raymond Hettinger  wrote:
>
> > [...]
> > >>> n * e
>
> > 3.1415926

> Very neat!  Is it supposed to be obvious why this gives an
> approximation to pi?  If so, I'll think about it a bit more;  if not,
> do you have any references?

Even after reading the proof, I still don't find it to be obvious ;-)

http://home.comcast.net/~davejanelle/mandel.pdf


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


Re: Return Values & lambda

2011-02-21 Thread Rafe Kettler
On Feb 21, 1:59 pm, pradeepbpin  wrote:
> I have a main program module that invokes an input dialog box via  a
> menu item. Now, the code for drawing and processing the input of
> dialog box is in another module, say 'dialogs.py'. I connect the menu
> item to this dialog box by a statement like,
>
> manu_item.connect('activate', lambda a: dialogs.open_dilaog())
>
> If this function open_dialog() returns a list of dialog inputs values,
> how can I access those values in the main module ?

Moreover, I don't see why you need a lambda in this case. Why not just
pass the function itself?

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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Westley Martínez
On Tue, 2011-02-22 at 00:48 +0100, Alexander Kapps wrote:
> On 22.02.2011 00:34, Westley Martínez wrote:
> > On Mon, 2011-02-21 at 11:28 -0800, rantingrick wrote:
> 
> >> The ascii char "i" would suffice. However some languages fell it
> >> necessary to create an ongoing tutorial of the language. Sure French
> >> and Latin can sound "pretty", however if all you seek is "pretty
> >> music" then listen to music. Language should be for communication and
> >> nothing more.
> > Nicely said; you're absolutely right.
> 
> http://en.wikipedia.org/wiki/Newspeak
> 
> 
> (Babbling Rick is just an Orwellian Nightmare, try to ignore him)
> 
I don't quite get what you mean, but I'm just loving the troll.

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


Re: Python on OSX

2011-02-21 Thread Chris Rebert
On Mon, Feb 21, 2011 at 3:54 PM, Robert  wrote:
> Can I install 2.7 and 3.2 side by side?

Yes, of course. Just don't fiddle with the "System Python" (i.e. the
copy preinstalled by Apple).
You may wish to install your additional Pythons via Fink or MacPorts.

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


Re: Python Tutorial on Multithreading

2011-02-21 Thread KevinSimonson
On Feb 21, 4:04 pm, Alexander Kapps  wrote:
>
> That tutorial seems to be wrong.
>
> According to the official docs:
>
> "If the subclass overrides the constructor, it must make sure to
> invoke the base class constructor (Thread.__init__()) before doing
> anything else to the thread."
>
> http://docs.python.org/library/threading.html#thread-objects
>
> So, change your __init__ to this:
>
> class myThread (threading.Thread):
>      def __init__(self, threadID, name, q):
>          threading.Thread.__init__(self)
>          self.threadID = threadID
>          self.name = name
>          self.q = q
>

Alexander, thanks!  Your suggestion fixed my problem.

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


Re: Python 3.2 and html.escape function

2011-02-21 Thread Martin v. Loewis
> Well, I just learned something, thank you. I was under the mistaken 
> impression that adding new functionality after the first alpha release 
> was not permitted by the Python devs.

It's the first beta release after which no new functionality could be added.

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


Python on OSX

2011-02-21 Thread Robert

Can I install 2.7 and 3.2 side by side?

--
Robert


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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Alexander Kapps

On 22.02.2011 00:34, Westley Martínez wrote:

On Mon, 2011-02-21 at 11:28 -0800, rantingrick wrote:



The ascii char "i" would suffice. However some languages fell it
necessary to create an ongoing tutorial of the language. Sure French
and Latin can sound "pretty", however if all you seek is "pretty
music" then listen to music. Language should be for communication and
nothing more.

Nicely said; you're absolutely right.


http://en.wikipedia.org/wiki/Newspeak


(Babbling Rick is just an Orwellian Nightmare, try to ignore him)

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


Re: return an object of a different class

2011-02-21 Thread Steven D'Aprano
On Mon, 21 Feb 2011 14:23:10 +0100, Jean-Michel Pichavant wrote:

> What is not legit, is to return different objects for which the caller
> has to test the type to know what attributes he can use.

Well, I don't know... I'm of two minds.

On the one hand, I find it *really annoying* when this happens:

>>> re.search(pattern, text).group()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'NoneType' object has no attribute 'group'

The problem is that re.search and re.match return None instead of a match-
object when they don't find anything. Perhaps they should return an empty 
match object?


But on the other hand, there is a well known failure mode caused by doing 
this:

# Strip everything after a comment symbol.
offset = text.find("#")
text = text[:offset]

See the bug? If there's no # in the string, it drops the last character. 
The most insidious part of the bug is that you might not notice, if your 
strings end with whitespace. If str.find() returned None, at least you 
would get a nice TypeError as soon as you tried to use it as a integer 
offset.

So, it's not clear to me whether under *these* circumstances it's better 
to return a completely different type, which cannot possibly be mistaken 
for success, or a magic value of the same type.

(The third alternative is to raise an exception, and the unspeakably 
awful alternative is to have a single global error flag for the operation 
which must be checked.)



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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Westley Martínez
On Mon, 2011-02-21 at 11:28 -0800, rantingrick wrote:
> On Feb 20, 7:08 pm, "BartC"  wrote:
> > "WestleyMartínez"  wrote in message
> >
> > news:mailman.202.1298081685.1189.python-l...@python.org...
> >
> > > You have provided me with some well thought out arguments and have
> > > stimulated my young programmer's mind, but I think we're coming from
> > > different angles. You seem to come from a more math-minded, idealist
> > > angle, while I come from a more practical angle. Being a person who has
> > > had to deal with the í in my last name
> >
> > What purpose does the í serve in your last name, and how is it different
> > from i?
> 
> Simple, it does not have a purpose. Well, that is,  except to give the
> *impression* that a few pseudo intellectuals have a reason to keep
> their worthless tenure at universities world wide. It's window
> dressing, and nothing more.
> 
> > (I'd have guessed it indicated stress, but it looks Spanish and I thought
> > that syllable was stressed anyway.)
> 
> The ascii char "i" would suffice. However some languages fell it
> necessary to create an ongoing tutorial of the language. Sure French
> and Latin can sound "pretty", however if all you seek is "pretty
> music" then listen to music. Language should be for communication and
> nothing more.
Nicely said; you're absolutely right.

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


Pickle compatibility between Python 2.7 and python 3.2

2011-02-21 Thread Jesus Cea
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I have 10MB pickled structure generated in Python 2.7. I only use basic
types (no clases) like sets, dictionaries, lists, strings, etc.

The pickle stores a lot of strings. Some of them should be "bytes",
while other should be "unicode". My idea is to import ALL the strings as
bytes in Python 3.2 and navigate the data structure to convert the
appropiate values to unicode, in a one-time operation (I version the
structure, so I can know if this conversion is already done, simply
storing a new version value).

But I get this error:

"""
Python 3.2 (r32:88445, Feb 21 2011, 13:34:07)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f=open("file.pickle", mode="rb").read()
>>> len(f)
9847316
>>> b=pickle.loads(f,encoding="latin1")
Traceback (most recent call last):
  File "", line 1, in 
ValueError: operation forbidden on released memoryview object
"""

I use the encoding "latin1" for transparent byte/unicode conversion (do
not touch the values!).

This seems to be a bug in Python 3.2. Any suggestion?.

PS: The bytestream is protocol 2.

- -- 
Jesus Cea Avion _/_/  _/_/_/_/_/_/
j...@jcea.es - http://www.jcea.es/ _/_/_/_/  _/_/_/_/  _/_/
jabber / xmpp:j...@jabber.org _/_/_/_/  _/_/_/_/_/
.  _/_/  _/_/_/_/  _/_/  _/_/
"Things are not so easy"  _/_/  _/_/_/_/  _/_/_/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/_/_/_/  _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQCVAwUBTWL0xplgi5GaxT1NAQL+NwQAmIXK5er0rJysH0KudC05ys8DxGpswsez
oEv60rAVMOImF+2ftizNudvB8FaCoQqEDeshJ3oPN/AmnZ2vqlrMLJdO5hjG88pS
W39+qEpRz0JNz2RUdLOpXdLqm9aU56KUqq9F0P8nqI02djsSXTYTmmUHZd37GhPt
pV1l7+1cpb0=
=pjS+
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Tutorial on Multithreading

2011-02-21 Thread Alexander Kapps

On 21.02.2011 23:30, KevinSimonson wrote:

I've been teaching myself Python from the tutorial routed at "http://
www.tutorialspoint.com/python/index.htm".  It's worked out pretty
well, but when I copied its multithreading example from the bottom of
the page at "http://www.tutorialspoint.com/python/
python_multithreading.htm" and tried to run it I got the error
messages:

C:\Users\kvnsmnsn\Python>python mt.py
Traceback (most recent call last):
   File "mt.py", line 38, in
 thread = myThread(threadID, tName, workQueue)
   File "mt.py", line 10, in __init__
 self.name = name
   File "C:\Python27\lib\threading.py", line 667, in name
 assert self.__initialized, "Thread.__init__() not called"
AssertionError: Thread.__init__() not called

I don't really understand why it's giving me these messages.
<__initialized>  gets set to  when<__init__()>  gets called.
Granted my Python program calls<__init__()>  with only one parameter,
and the constructor in "threading.py" takes _seven_ parameters, but
all but one have default values, so a call with just one parameter
should be legal.  Why then is<__initialized>  getting set to?

My code follows.


That tutorial seems to be wrong.

According to the official docs:

"If the subclass overrides the constructor, it must make sure to 
invoke the base class constructor (Thread.__init__()) before doing 
anything else to the thread."


http://docs.python.org/library/threading.html#thread-objects

So, change your __init__ to this:

class myThread (threading.Thread):
def __init__(self, threadID, name, q):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.q = q


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


python on a cray xt5, ImportError: No module named site

2011-02-21 Thread Burlen Loring

Hi,

Got some trouble running python on a Cray XT5 which has a reduced os on 
the compute nodes, and you're supposed to link everything statically. I 
configured the build with --disable-shared and uncommented the modules 
in Modules/Setup which made sense (nearly all of them), and built with 
Cray's compiler wrappers. I set PYTHONHOME to point to the install.


I am able to run the build fine on the login nodes but when I run on the 
compute nodes I get the error:


"ImportError: No module named site".

Full output from -v pasted below. site.py is present. I tried running 
with -S, and the got "ImportError: No module named os", again os is 
present. When I commented out the os stuff and ran with -S and just 
printed sys.path it worked.


I'm not sure what the problem is. Can any one shed some light on what's 
going on here??


Thanks
Burlen

krakenpf5:/lustre/scratch/bloring$aprun -n 1 python -v ./test.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
ImportError: No module named site
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] signal
# cleanup[1] exceptions
# cleanup[1] _warnings
# cleanup sys
# cleanup __builtin__
# cleanup ints: 5 unfreed ints
# cleanup floats
Application 5091634 exit codes: 1
Application 5091634 resources: utime 0, stime 0

#test.py---
import sys
#import os
print sys.path
#print "Hello from %d"%(os.getpid())
#
--
http://mail.python.org/mailman/listinfo/python-list


Re: LDFLAGS problem

2011-02-21 Thread Stefan Krah
Philip Semanchuk  wrote:
> On Feb 21, 2011, at 12:56 PM, Robin Becker wrote:
> > After installing python 2.7.1 on a Freebsd 8.0 system with the normal 
> > configure make dance
> > 
> > ./configure --prefix=$HOME/PYTHON --enable-unicode=ucs2
> > make
> > make install
> > 
> > I find that when I build extensions PIL, MySQLdb I'm getting errors related 
> > to a dangling ${LDFLAGS}
> > 
> > eg  MySQLdb
> > 
> >> running build_ext
> >> building '_mysql' extension
> >> creating build/temp.freebsd-7.0-RELEASE-i386-2.7
> >> gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall 
> >> -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) 
> >> -D__version__=1.2.2 -I/usr/local/include/mysql 
> >> -I/home/rptlab/PYTHON/include/python2.7 -c _mysql.c -o 
> >> build/temp.freebsd-7.0-RELEASE-i386-2.7/_mysql.o -fno-strict-aliasing -pipe
> >> gcc -pthread -shared ${LDFLAGS} 
> >> build/temp.freebsd-7.0-RELEASE-i386-2.7/_mysql.o -L/usr/local/lib/mysql 
> >> -lmysqlclient_r -lz -lcrypt -lm -o 
> >> build/lib.freebsd-7.0-RELEASE-i386-2.7/_mysql.so
> >> gcc: ${LDFLAGS}: No such file or directory
> >> error: command 'gcc' failed with exit status 1
> > 
> > where should I be looking to fix this problem?

Try the patch from http://bugs.python.org/issue10547 or use an svn checkout.
The patch didn't make it into 2.7.1.


Stefan Krah


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


Re: python and parsing an xml file

2011-02-21 Thread Matt Funk
Hi Stefan,
i don't mean to be annoying so sorry if i am.
According to your instructions i do:

parser = objectify.makeparser(ns_clean=True, remove_comments=True)
root = objectify.parse(inputfile,parser).getroot()
print root.catalog.book.author.text

which still gives the following error:
AttributeError: no such child: catalog

matt



On 2/21/2011 3:28 PM, Stefan Behnel wrote:
> Matt Funk, 21.02.2011 23:07:
>> thank you for your advice.
>> I am running into an issue though (which is likely a newbie problem):
>>
>> My xml file looks like (which i got from the internet):
>> 
>> 
>> 
>>Gambardella, Matthew
>>XML Developer's Guide
>>Computer
>>44.95
>>2000-10-01
>>An in-depth look at creating applications
>>with XML.
>> 
>> 
>>
>> Then i try to access it as:
>>
>> from lxml import etree
>> from lxml import objectify
>>
>> inputfile="../input/books.xml"
>> parser = etree.XMLParser(ns_clean=True)
>> parser = etree.XMLParser(remove_comments=True)
>
> Change that to
>
> parser = objectify.makeparser(ns_clean=True, remove_comments=True)
>
>> root = objectify.parse(inputfile,parser)
>
> Change that to
>
> root = objectify.parse(inputfile,parser).getroot()
>
> Stefan
>

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


Re: LDFLAGS problem

2011-02-21 Thread Philip Semanchuk

On Feb 21, 2011, at 12:56 PM, Robin Becker wrote:

> After installing python 2.7.1 on a Freebsd 8.0 system with the normal 
> configure make dance
> 
> ./configure --prefix=$HOME/PYTHON --enable-unicode=ucs2
> make
> make install
> 
> I find that when I build extensions PIL, MySQLdb I'm getting errors related 
> to a dangling ${LDFLAGS}
> 
> eg  MySQLdb
> 
>> running build_ext
>> building '_mysql' extension
>> creating build/temp.freebsd-7.0-RELEASE-i386-2.7
>> gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall 
>> -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) 
>> -D__version__=1.2.2 -I/usr/local/include/mysql 
>> -I/home/rptlab/PYTHON/include/python2.7 -c _mysql.c -o 
>> build/temp.freebsd-7.0-RELEASE-i386-2.7/_mysql.o -fno-strict-aliasing -pipe
>> gcc -pthread -shared ${LDFLAGS} 
>> build/temp.freebsd-7.0-RELEASE-i386-2.7/_mysql.o -L/usr/local/lib/mysql 
>> -lmysqlclient_r -lz -lcrypt -lm -o 
>> build/lib.freebsd-7.0-RELEASE-i386-2.7/_mysql.so
>> gcc: ${LDFLAGS}: No such file or directory
>> error: command 'gcc' failed with exit status 1
> 
> where should I be looking to fix this problem?

It's been a while since I built anything on FreeBSD, but one thing that jumps 
out at me is that you say you're building on 8.0 but the build output you gave 
us mentions 7.0. That doesn't sound right at all.

Are you using ports?

bye
Philip



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


Python Tutorial on Multithreading

2011-02-21 Thread KevinSimonson
I've been teaching myself Python from the tutorial routed at "http://
www.tutorialspoint.com/python/index.htm".  It's worked out pretty
well, but when I copied its multithreading example from the bottom of
the page at "http://www.tutorialspoint.com/python/
python_multithreading.htm" and tried to run it I got the error
messages:

C:\Users\kvnsmnsn\Python>python mt.py
Traceback (most recent call last):
  File "mt.py", line 38, in 
thread = myThread(threadID, tName, workQueue)
  File "mt.py", line 10, in __init__
self.name = name
  File "C:\Python27\lib\threading.py", line 667, in name
assert self.__initialized, "Thread.__init__() not called"
AssertionError: Thread.__init__() not called

I don't really understand why it's giving me these messages.
<__initialized> gets set to  when <__init__()> gets called.
Granted my Python program calls <__init__()> with only one parameter,
and the constructor in "threading.py" takes _seven_ parameters, but
all but one have default values, so a call with just one parameter
should be legal.  Why then is <__initialized> getting set to ?

My code follows.

Kevin Simonson

import Queue
import threading
import time

exitFlag = 0

class myThread (threading.Thread):
def __init__(self, threadID, name, q):
self.threadID = threadID
self.name = name
self.q = q
threading.Thread.__init__(self)
def run(self):
print "Starting " + self.name
process_data(self.name, self.q)
print "Exiting " + self.name

def process_data(threadName, q):
while not exitFlag:
queueLock.acquire()
if not workQueue.empty():
data = q.get()
queueLock.release()
print "%s processing %s" % (threadName, data)
else:
queueLock.release()
time.sleep(1)

threadList = ["Thread-1", "Thread-2", "Thread-3"]
nameList = ["One", "Two", "Three", "Four", "Five"]
queueLock = threading.Lock()
workQueue = Queue.Queue(10)
threads = []
threadID = 1

# Create new threads
for tName in threadList:
thread = myThread(threadID, tName, workQueue)
thread.start()
threads.append(thread)
threadID += 1

# Fill the queue
queueLock.acquire()
for word in nameList:
workQueue.put(word)
queueLock.release()

# Wait for queue to empty
while not workQueue.empty():
pass

# Notify threads it's time to exit
exitFlag = 1

# Wait for all threads to complete
for t in threads:
t.join()
print "Exiting Main Thread"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel

Matt Funk, 21.02.2011 23:07:

thank you for your advice.
I am running into an issue though (which is likely a newbie problem):

My xml file looks like (which i got from the internet):



   Gambardella, Matthew
   XML Developer's Guide
   Computer
   44.95
   2000-10-01
   An in-depth look at creating applications
   with XML.



Then i try to access it as:

from lxml import etree
from lxml import objectify

inputfile="../input/books.xml"
parser = etree.XMLParser(ns_clean=True)
parser = etree.XMLParser(remove_comments=True)


Change that to

parser = objectify.makeparser(ns_clean=True, remove_comments=True)


root = objectify.parse(inputfile,parser)


Change that to

root = objectify.parse(inputfile,parser).getroot()

Stefan

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


Re: python and parsing an xml file

2011-02-21 Thread Matt Funk
HI Stefan,
thank you for your advice.
I am running into an issue though (which is likely a newbie problem):

My xml file looks like (which i got from the internet):


   
  Gambardella, Matthew
  XML Developer's Guide
  Computer
  44.95
  2000-10-01
  An in-depth look at creating applications
  with XML.
   


Then i try to access it as:

from lxml import etree
from lxml import objectify

inputfile="../input/books.xml"
parser = etree.XMLParser(ns_clean=True)
parser = etree.XMLParser(remove_comments=True)
root = objectify.parse(inputfile,parser)

I try to access elements by (for example):
print root.catalog.book.author.text

But it errors out with:
AttributeError: 'lxml.etree._ElementTree' object has no attribute 'catalog'

So i guess i don't understand why this is.
Also, how can i print all the attributes of the root for examples or
obtain keys?

I really appreciate your help
thanks
matt


On 2/21/2011 10:43 AM, Stefan Behnel wrote:
> Matt Funk, 21.02.2011 18:30:
>> I want to create a set of xml input files to my code that look as
>> follows:
>> 
>>
>> 
>> 
>>
>>  
>>  
>>  
>>  
>>  Alg1
>>
>>  
>>  ./Alg1.in
>>
>> 
>>
>>
>> 
>> 
>>
>>  
>>  c:\tmp
>>
>>  
>>  
>>  
>>  
>>  1
>>
>> 
>
> That's not XML. XML documents have exactly one root element, i.e. you
> need an enclosing element around these two tags.
>
>
>> So there are comments, whitespace etc ... in it.
>> I would like to be able to put everything into some sort of structure
>
> Including the comments or without them? Note that ElementTree will
> ignore comments.
>
>
>> such that i can access it as:
>> structure['Algorithm']['Type'] == Alg1
>
> Have a look at lxml.objectify. It allows you to write
>
> alg_type = root.Algorithm.Type.text
>
> and a couple of other niceties.
>
> http://lxml.de/objectify.html
>
>
>> I was wondering if there is something out there that does this.
>> I found and tried a few things:
>> 1)
>> http://code.activestate.com/recipes/534109-xml-to-python-data-structure/
>> It simply doesn't work. I get the following error:
>> raise exception
>> xml.sax._exceptions.SAXParseException::1:2: not well-formed
>> (invalid token)
>
> "not well formed" == "not XML".
>
>
>> But i removed everything from the file except:> encoding="UTF-8"?>
>> and i still got the error.
>
> That's not XML, either.
>
>
>> Anyway, i looked at ElementTree, but that error out with:
>> xml.parsers.expat.ExpatError: junk after document element: line 19,
>> column 0
>
> In any case, ElementTree is preferable over a SAX based solution, both
> for performance and maintainability reasons.
>
> Stefan
>

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


Re: python and parsing an xml file

2011-02-21 Thread Matt Funk
Hi Terry,

On 2/21/2011 11:22 AM, Terry Reedy wrote:
> On 2/21/2011 12:30 PM, Matt Funk wrote:
>> Hi,
>> I was wondering if someone had some advice:
>> I want to create a set of xml input files to my code that look as
>> follows:
>
> Why?
mmmh. not sure how to answer this question exactly. I guess it's a
design decision. I am not saying that it is best one, but it seemed
suitable to me. I am certainly open to suggestions. But here are some
requirements:
1) My boss needs to be able to read the input and make sense out of it.
XML seems fairly self explanatory, at least when you choose suitable
names for the properties/tags etc ...
2) I want reproducability of a given run without changes to the code.
I.e. all the inputs need to be stored external to the code such that the
state of the run is captured from the input files entirely.



>
>
> ...
>> So there are comments, whitespace etc ... in it.
>> I would like to be able to put everything into some sort of structure
>> such that i can access it as:
>> structure['Algorithm']['Type'] == Alg1
>
> Unless I have a very good reason otherwise, I would just put
> everything in nested dicts  in a .py file to begin with. 
That is certainly a possibility and it should work. However, eventually
the input files might be written by a webinterface (likely php). Even
though what you are suggesting is still possible it just feels a little
awkward (i.e. to use php to write a python file).


> Or if I needed cross language portability, a JSON file, which is close
> to the same thing.
>
again, i am certainly not infallible and open to suggestions of there is
a better solution.


thanks
matt

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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread rantingrick
On Feb 20, 7:08 pm, "BartC"  wrote:
> "WestleyMartínez"  wrote in message
>
> news:mailman.202.1298081685.1189.python-l...@python.org...
>
> > You have provided me with some well thought out arguments and have
> > stimulated my young programmer's mind, but I think we're coming from
> > different angles. You seem to come from a more math-minded, idealist
> > angle, while I come from a more practical angle. Being a person who has
> > had to deal with the í in my last name
>
> What purpose does the í serve in your last name, and how is it different
> from i?

Simple, it does not have a purpose. Well, that is,  except to give the
*impression* that a few pseudo intellectuals have a reason to keep
their worthless tenure at universities world wide. It's window
dressing, and nothing more.

> (I'd have guessed it indicated stress, but it looks Spanish and I thought
> that syllable was stressed anyway.)

The ascii char "i" would suffice. However some languages fell it
necessary to create an ongoing tutorial of the language. Sure French
and Latin can sound "pretty", however if all you seek is "pretty
music" then listen to music. Language should be for communication and
nothing more.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Return Values & lambda

2011-02-21 Thread Benjamin Kaplan
On Mon, Feb 21, 2011 at 1:59 PM, pradeepbpin  wrote:
> I have a main program module that invokes an input dialog box via  a
> menu item. Now, the code for drawing and processing the input of
> dialog box is in another module, say 'dialogs.py'. I connect the menu
> item to this dialog box by a statement like,
>
> manu_item.connect('activate', lambda a: dialogs.open_dilaog())
>
> If this function open_dialog() returns a list of dialog inputs values,
> how can I access those values in the main module ?

You can't. The event handler just calls a method. It's expected that
you'll do everything you need in that. Make your own method for the
menu item that starts off by creating the dialog and then handles the
results.

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


Re: Python 3.2 and html.escape function

2011-02-21 Thread Rafe Kettler
On Feb 20, 8:15 am, Gerald Britton  wrote:
> I see that Python 3.2 includes a new module -- html -- with a single
> function -- escape.  I would like to know how this function differs
> from xml.sax.saxutils.escape and, if there is no difference (or only a
> minor one), what the need is for this new module and its lone function
>
> --
> Gerald Britton

I believe that they're trying to organize a new top-level package
called html that will, at some point, contain all HTML functionality.
It's sort of similar to what they're doing with the concurrent package.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel

Terry Reedy, 21.02.2011 19:22:

On 2/21/2011 12:30 PM, Matt Funk wrote:

Hi,
I was wondering if someone had some advice:
I want to create a set of xml input files to my code that look as follows:


Why?

...

So there are comments, whitespace etc ... in it.
I would like to be able to put everything into some sort of structure
such that i can access it as:
structure['Algorithm']['Type'] == Alg1


Unless I have a very good reason otherwise, I would just put everything in
nested dicts in a .py file to begin with. Or if I needed cross language
portability, a JSON file, which is close to the same thing.


Hmm, right, good call. There's also the configparser module in the stdlib 
which may provide a suitable format here.


Stefan

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


Return Values & lambda

2011-02-21 Thread pradeepbpin
I have a main program module that invokes an input dialog box via  a
menu item. Now, the code for drawing and processing the input of
dialog box is in another module, say 'dialogs.py'. I connect the menu
item to this dialog box by a statement like,

manu_item.connect('activate', lambda a: dialogs.open_dilaog())

If this function open_dialog() returns a list of dialog inputs values,
how can I access those values in the main module ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: hmac module and key format

2011-02-21 Thread Peter Pearson
On Mon, 21 Feb 2011 02:27:36 -0800 (PST), Stuart Longland wrote:
[snip]
> Before I worried about that though, I needed to have some kind of
> understanding as to how the hmac module was used.  "Arbitrary string",
> sounds to me like I give it something akin to a passphrase, and that
> is hashed(?) to provide the symmetric key for the HMAC.  Wikipedia
> seems to suggest it depends on the length of the key given, so if I
> give it a string that's exactly 160-bits (for HMAC-SHA1) it'll use it
> unmodified.  Would that be a correct assertion?

Yes.  I predict that you will be glad you look at RFC 2104,

http://www.ietf.org/rfc/rfc2104.txt

where you will find HMAC summarized as

H(K XOR opad, H(K XOR ipad, text))

Here, opad is a block filled with the byte 0x5C, and ipad is
a block filled with the byte 0x36.  If the key is no longer
than one block (and a block is 64 bytes for SHA and MD5), then
K is just the key itself; otherwise, K is a hash of the key.

-- 
To email me, substitute nowhere->spamcop, invalid->net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which non SQL Database ?

2011-02-21 Thread Dave
Interesting thread. It started as a discussion of small footprint, embeddable 
non-SQL databases and has ranged all over the place. 

For the original purpose of this thread, it certainly sounds like SQLite fits 
the bill. It's a great package. If you need SQLite's ease of use and 
simplicity, but you're looking for multi-threaded concurrent access and 
replication for High Availability, then I would suggest Berkeley DB. It's 
completely compatible wit SQLite's SQL API, but provides better concurrency and 
scalability, as well has HA. 

If you're looking for a non-SQL solution, Berkeley DB offers several non-SQL 
APIs, including the original BDB key/value pair API, a Java Collections API and 
a POJO-style Java API (called the Data Persistence Layer). 

Disclaimer: I'm one of the product managers for Berkeley DB, so I'm a little 
biased. :-) But I was amused to see claims that BDB wasn't concurrent (not 
true) or that there were products which were "BDB-like" (why not use the real 
thing?) so I thought that I would chime in. Good luck on your search. 

Regards, 

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


Re: python and parsing an xml file

2011-02-21 Thread Terry Reedy

On 2/21/2011 12:30 PM, Matt Funk wrote:

Hi,
I was wondering if someone had some advice:
I want to create a set of xml input files to my code that look as follows:


Why?

...

So there are comments, whitespace etc ... in it.
I would like to be able to put everything into some sort of structure
such that i can access it as:
structure['Algorithm']['Type'] == Alg1


Unless I have a very good reason otherwise, I would just put everything 
in nested dicts  in a .py file to begin with. Or if I needed cross 
language portability, a JSON file, which is close to the same thing.


--
Terry Jan Reedy

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


Europython 2011 - Call for Papers

2011-02-21 Thread Fabio Pliger

Europython is coming back around! Europython will be held in Florence,
Italy from the 20th to the 25th of june.

EuroPython is a conference for the Python programming language
community. It is aimed at everyone in the Python community, of all
skill levels, both users and programmers. It's one of the largest open
source conferences in Europe and last year it include over 100 talks,
tutorials, sprints and social events.

The Call For Paper is the moment when Europython organizers ask the
European community to submit their proposals of the talks that will be
given at the conference. If you think you have got an interesting
topic to talk about, don't hesitate and send us an abstract following
the Call for Paper guidelines suggested on this website.

This year, we are introducing 4-hours hands-on trainings during the
conference, in addition to the regular tracks. During the submission,
make sure to specify whether you are willing to change the talk into a
4-hour training. To compensate for the longer preparation required,
speakers that will give a training will be rewarded with a free ticket
and possibly also a small fee (crossing our fingers that the budget
will allow this). Speakers of regular talks will instead benefit from
a reduced conference fee.

Europython has been proving year after year to be a conference made by
the community and for the community, and that's why this year we are
happy to introduce the community-based talk voting. We will elaborate
on this later on, so stay tuned!

We remind everybody that you can follow the updates on the conference,
in addition to this blog, both on the official Facebook page and on
the Twitter profile @Europython.

Many more info can be found at the conference website: www.europython.eu
or at the call for papers page: www.europython.eu/call-for-paper

See you soon and...we're waiting for your abstracts!

The Europython Team
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Westley Martínez
On Mon, 2011-02-21 at 01:08 +, BartC wrote:
> 
> "WestleyMartínez"  wrote in message 
> news:mailman.202.1298081685.1189.python-l...@python.org...
> 
> 
> > You have provided me with some well thought out arguments and have
> > stimulated my young programmer's mind, but I think we're coming from
> > different angles. You seem to come from a more math-minded, idealist
> > angle, while I come from a more practical angle. Being a person who has
> > had to deal with the í in my last name
> 
> What purpose does the í serve in your last name, and how is it different 
> from i?
> 
> (I'd have guessed it indicated stress, but it looks Spanish and I thought 
> that syllable was stressed anyway.)
> 
> -- 
> Bartc
>  
> 
I don't know. I don't speak Spanish, but to my knowledge it's not a
critical diacritic like in some languages.

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


LDFLAGS problem

2011-02-21 Thread Robin Becker
After installing python 2.7.1 on a Freebsd 8.0 system with the normal configure 
make dance


./configure --prefix=$HOME/PYTHON --enable-unicode=ucs2
make
make install

I find that when I build extensions PIL, MySQLdb I'm getting errors related to a 
dangling ${LDFLAGS}


eg  MySQLdb


running build_ext
building '_mysql' extension
creating build/temp.freebsd-7.0-RELEASE-i386-2.7
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 
-I/usr/local/include/mysql -I/home/rptlab/PYTHON/include/python2.7 -c _mysql.c 
-o build/temp.freebsd-7.0-RELEASE-i386-2.7/_mysql.o -fno-strict-aliasing -pipe
gcc -pthread -shared ${LDFLAGS} 
build/temp.freebsd-7.0-RELEASE-i386-2.7/_mysql.o -L/usr/local/lib/mysql 
-lmysqlclient_r -lz -lcrypt -lm -o 
build/lib.freebsd-7.0-RELEASE-i386-2.7/_mysql.so
gcc: ${LDFLAGS}: No such file or directory
error: command 'gcc' failed with exit status 1


where should I be looking to fix this problem?
--
Robin Becker

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


Re: python and parsing an xml file

2011-02-21 Thread Stefan Behnel

Matt Funk, 21.02.2011 18:30:

I want to create a set of xml input files to my code that look as follows:





 
 
 
 
 Alg1

 
 ./Alg1.in







 
 c:\tmp

 
 
 
 
 1




That's not XML. XML documents have exactly one root element, i.e. you need 
an enclosing element around these two tags.




So there are comments, whitespace etc ... in it.
I would like to be able to put everything into some sort of structure


Including the comments or without them? Note that ElementTree will ignore 
comments.




such that i can access it as:
structure['Algorithm']['Type'] == Alg1


Have a look at lxml.objectify. It allows you to write

alg_type = root.Algorithm.Type.text

and a couple of other niceties.

http://lxml.de/objectify.html



I was wondering if there is something out there that does this.
I found and tried a few things:
1) http://code.activestate.com/recipes/534109-xml-to-python-data-structure/
It simply doesn't work. I get the following error:
raise exception
xml.sax._exceptions.SAXParseException::1:2: not well-formed
(invalid token)


"not well formed" == "not XML".



But i removed everything from the file except:
and i still got the error.


That's not XML, either.



Anyway, i looked at ElementTree, but that error out with:
xml.parsers.expat.ExpatError: junk after document element: line 19, column 0


In any case, ElementTree is preferable over a SAX based solution, both for 
performance and maintainability reasons.


Stefan

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


python and parsing an xml file

2011-02-21 Thread Matt Funk
Hi,
I was wondering if someone had some advice:
I want to create a set of xml input files to my code that look as follows:







   

Alg1
   

./Alg1.in
   





   

c:\tmp
   


   
   
1




So there are comments, whitespace etc ... in it.
I would like to be able to put everything into some sort of structure
such that i can access it as:
structure['Algorithm']['Type'] == Alg1
I was wondering if there is something out there that does this.
I found and tried a few things:
1) http://code.activestate.com/recipes/534109-xml-to-python-data-structure/
It simply doesn't work. I get the following error:
raise exception
xml.sax._exceptions.SAXParseException: :1:2: not well-formed
(invalid token)
But i removed everything from the file except: 
and i still got the error.

Anyway, i looked at ElementTree, but that error out with:
xml.parsers.expat.ExpatError: junk after document element: line 19, column 0


Anyway, if anyone can give me advice of point me somewhere i'd greatly
appreciate it.

thanks
matt

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


ANN: Wing IDE 4.0 Released

2011-02-21 Thread Wingware

Hi,

Wingware has released version 4.0 of Wing IDE, an integrated development
environment designed specifically for the Python programming language.

Wing IDE is a cross-platform Python IDE that provides a professional code
editor with vi, emacs, and other key bindings, auto-completion, call tips,
refactoring, a powerful graphical debugger, version control, unit testing,
search, and many other features.

**Changes in Version 4.0**

Version 4.0 adds the following new major features:

* Refactoring -- Rename and move symbols, and extract code to function 
or method

* Find Uses -- Find all points of use of a symbol
* Diff/Merge -- Graphical file and repository comparison and merge
* Django Support -- Debug Django templates, run Django unit tests, and more
* matplotlib Support -- Maintains live-updating plots in shell and debugger
* Simplified Licensing -- Includes all OSes and adds Support+Upgrades 
subscriptions


Complete Change Log:   
http://wingware.com/pub/wingide/4.0.0/CHANGELOG.txt

Details on Licensing Changes:  http://wingware.com/news/2011-02-16

**About Wing IDE**

Wing IDE is an integrated development environment designed specifically for
the Python programming language.  It provides powerful editing, testing, and
debugging features that help reduce development and debugging time, cut down
on coding errors, and make it easier to understand and navigate Python code.
Wing IDE can be used to develop Python code for web, GUI, and embedded
scripting applications.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free simplified version designed
for teaching beginning programming courses with Python.

Version 4.0 of Wing IDE Professional includes the following major features:

* Professional quality code editor with vi, emacs, and other keyboard
  personalities
* Code intelligence for Python:  Auto-completion, call tips, find uses,
  goto-definition, error indicators, refactoring, smart indent and 
rewrapping,

  and source navigation
* Advanced multi-threaded debugger with graphical UI, command line 
interaction,

  conditional breakpoints, data value tooltips over code, watch tool, and
  externally launched and remote debugging
* Powerful search and replace options including keyboard driven and 
graphical

  UIs, multi-file, wild card, and regular expression search and replace
* Version control integration for Subversion, CVS, Bazaar, git, 
Mercurial, and

  Perforce
* Integrated unit testing with unittest, nose, and doctest frameworks
* Django support:  Debugs Django templates, provides project setup tools,
  and runs Django unit tests
* Many other features including project manager, bookmarks, code snippets,
  diff/merge tool, OS command integration, indentation manager, PyLint
  integration, and perspectives
* Extremely configurable and may be extended with Python scripts
* Extensive product documentation and How-Tos for Django, matplotlib,
  Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks

Please refer to http://wingware.com/wingide/features for a detailed listing
of features by product level.

System requirements are Windows 2000 or later, OS X 10.3.9 or later 
(requires
X11 Server), or a recent Linux system (either 32 or 64 bit).  Wing IDE 
supports

Python versions 2.0.x through 3.2.x and Stackless Python.

For more information, see the http://wingware.com/

**Downloads**

Wing IDE Professional and Wing IDE Personal are commercial software and
require a license to run. A free trial can be obtained directly from the
product when launched.

Wing IDE Pro -- Full-featured product:
http://wingware.com/downloads/wingide/4.0

Wing IDE Personal -- A simplified IDE:
http://wingware.com/downloads/wingide-personal/4.0

Wing IDE 101 -- For teaching with Python:
http://wingware.com/downloads/wingide-101/4.0

**Purchasing and Upgrading**

Wing 4.0 requires an upgrade for Wing IDE 2.x and 3.x users at a cost of
1/2 the full product pricing.

Upgrade a license:   https://wingware.com/store/upgrade
Purchase a new license:  https://wingware.com/store/purchase

--

The Wingware Team
Wingware | Python IDE
Advancing Software Development

www.wingware.com


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


Re: Python 3.2

2011-02-21 Thread Stefan Behnel

Rafe Kettler, 21.02.2011 17:30:

On Feb 21, 10:54 am, Duncan Booth wrote:

Georg Brandl  wrote:

Please consider trying Python 3.2 with your code and reporting any bugs
you may notice to:



http://bugs.python.org/


It looks like this release breaks the builtin `input()` function on Windows
by leaving a trailing '\r' on the end of the string.

Reported as issue 11272:http://bugs.python.org/issue11272


Are fixes for these bugs going to wait until the next release (3.2.1 I
guess)


Yes. That's what "the next release" means.



or will update as soon as the fixes are available?


You mean: as soon as someone writes a fix?



I want to know if I should be on the lookout for a better version of 3.2.


Better test now and report any problems you find. (Actually, that's what 
the beta/RC phase was there for, but it's never too late to find a bug.)


Stefan

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


Re: Converting from shell to python

2011-02-21 Thread Peter Otten
Rita wrote:

> Hello,
> 
> I have been using shell for a "long" time and I decided to learn python
> recently. So far I am liking it a lot especially the argparse module which
> makes my programs more professional like.
> 
> 
> Currently, I am rewriting my bash scripts to python so I came across a
> subprocess and environment problem.
> 
> My bash script looks like this,
> 
> #!/usr/bin/env bash
> 
> export JAVA_HOME="/opt/java"
> export  PROG="dbconn"
> export JAVA_ARGS="-Xmx16g"
> export ARGS="-out outdata.dat"
> 
> $JAVA_HOME $JAVA_ARGS $PROG $ARGS
> 
> 
> To convert this into python I did something like this (which isn't working
> properly)
> 
> #!/usr/bin/env python
> import subprocess,os
> def execute():
>   try:
> 
> cmd="$JAVA_HOME $JAVA_ARGS $PROG $ARGS"
> cmd=cmd.split()

Here you turn cmd into a list

p=subprocess.Popen([cmd],env={"JAVA_HOME":"/opt/java","PROG":"dbconn","JAVA_ARGS":"-
Xmx16g","ARGS":"-out

and now you are wrapping it to [...], i. e. you get a list of list. Also, to 
enable shell expansion you have to invoke Popen(..., shell=True).

> outdata.dat"},
>  stdout=subprocess.PIPE)
>   except OSError, e:
>print >>sys.stderr," Execution failed: ",e
>  return p.stdout
> 
> 
> So, I was wondering if this is the correct way of doing it? or is there an
> alternative?

I think the easiest way is to avoid environment variables and use python 
variables instead, e. g.

JAVA_HOME = "/opt/java"
JAVA_ARGS = "-Xmx16g"
#...

cmd = [JAVA_HOME, JAVA_ARGS, ...]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)


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


Re: Converting from shell to python

2011-02-21 Thread Ritesh Nadhani
Hello

cmd is already a list after cmd.split().

So,

suprocess.Popen(cmd, )

On Mon, Feb 21, 2011 at 8:33 AM, Rita  wrote:
> Hello,
>
> I have been using shell for a "long" time and I decided to learn python
> recently. So far I am liking it a lot especially the argparse module which
> makes my programs more professional like.
>
>
> Currently, I am rewriting my bash scripts to python so I came across a
> subprocess and environment problem.
>
> My bash script looks like this,
>
> #!/usr/bin/env bash
>
> export JAVA_HOME="/opt/java"
> export  PROG="dbconn"
> export JAVA_ARGS="-Xmx16g"
> export ARGS="-out outdata.dat"
>
> $JAVA_HOME $JAVA_ARGS $PROG $ARGS
>
>
> To convert this into python I did something like this (which isn't working
> properly)
>
> #!/usr/bin/env python
> import subprocess,os
> def execute():
>   try:
>
>     cmd="$JAVA_HOME $JAVA_ARGS $PROG $ARGS"
>     cmd=cmd.split()
>
> p=subprocess.Popen([cmd],env={"JAVA_HOME":"/opt/java","PROG":"dbconn","JAVA_ARGS":"-Xmx16g","ARGS":"-out
> outdata.dat"},
>  stdout=subprocess.PIPE)
>   except OSError, e:
>    print >>sys.stderr," Execution failed: ",e
>  return p.stdout
>
>
> So, I was wondering if this is the correct way of doing it? or is there an
> alternative?
>
>
>
>
>
>
>
>
>
>
> --
> --- Get your facts first, then you can distort them as you please.--
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
Ritesh
http://www.beamto.us
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2

2011-02-21 Thread Rafe Kettler
On Feb 21, 10:54 am, Duncan Booth 
wrote:
> Georg Brandl  wrote:
> > Please consider trying Python 3.2 with your code and reporting any bugs
> > you may notice to:
>
> >    http://bugs.python.org/
>
> It looks like this release breaks the builtin `input()` function on Windows
> by leaving a trailing '\r' on the end of the string.
>
> Reported as issue 11272:http://bugs.python.org/issue11272
>
> --
> Duncan Boothhttp://kupuguy.blogspot.com

Are fixes for these bugs going to wait until the next release (3.2.1 I
guess) or will update as soon as the fixes are available? I want to
know if I should be on the lookout for a better version of 3.2.

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


Converting from shell to python

2011-02-21 Thread Rita
Hello,

I have been using shell for a "long" time and I decided to learn python
recently. So far I am liking it a lot especially the argparse module which
makes my programs more professional like.


Currently, I am rewriting my bash scripts to python so I came across a
subprocess and environment problem.

My bash script looks like this,

#!/usr/bin/env bash

export JAVA_HOME="/opt/java"
export  PROG="dbconn"
export JAVA_ARGS="-Xmx16g"
export ARGS="-out outdata.dat"

$JAVA_HOME $JAVA_ARGS $PROG $ARGS


To convert this into python I did something like this (which isn't working
properly)

#!/usr/bin/env python
import subprocess,os
def execute():
  try:

cmd="$JAVA_HOME $JAVA_ARGS $PROG $ARGS"
cmd=cmd.split()

p=subprocess.Popen([cmd],env={"JAVA_HOME":"/opt/java","PROG":"dbconn","JAVA_ARGS":"-Xmx16g","ARGS":"-out
outdata.dat"},
 stdout=subprocess.PIPE)
  except OSError, e:
   print >>sys.stderr," Execution failed: ",e
 return p.stdout


So, I was wondering if this is the correct way of doing it? or is there an
alternative?










-- 
--- Get your facts first, then you can distort them as you please.--
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: QWebView: notify python when I clicked on a certain web eleemnt

2011-02-21 Thread Дамјан Георгиевски
> I have a web page (existing page, can't modify it) and I would like
> to browse it in a QtWebview. (This is already working)
> 
> Now I Wonder how I could achieve following behaviour:
> 
> When I click on a certain element e.g. ""
> I would like to notify my python script.
> 
> What is important:
> I don't want to change anything else in the web pages behaviour (This
> means if clicking on this element will call some java script
> functions, load a pag, then this should still happen.


You can inject JavaScript using the method 
QWebElement::evaluateJavaScript()

Also you can insert a Python object in the JS runtime with 
QWebFrame::addToJavaScriptWindowObject()
see here:
http://pysnippet.blogspot.com/2010/01/calling-python-from-javascript-in-
pyqts.html


so make a Python object with some methods you'd wish to call, then 
evaluate some small JS that will bind the click event on your element to 
the method of the Python object.


-- 
дамјан ((( http://damjan.softver.org.mk/ )))

Teaching a pig to sing wastes your time & annoys the pig.

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


Re: [RELEASED] Python 3.2

2011-02-21 Thread Duncan Booth
Georg Brandl  wrote:

> Please consider trying Python 3.2 with your code and reporting any bugs
> you may notice to:
> 
> http://bugs.python.org/
> 

It looks like this release breaks the builtin `input()` function on Windows 
by leaving a trailing '\r' on the end of the string.

Reported as issue 11272: http://bugs.python.org/issue11272

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


Re: "ImportError: No module named gobject"

2011-02-21 Thread Luther
I've tried installing pygtk, pygobject, and gobject-introspection from
source, but none of them will compile, and nothing I install through
synaptic has any effect.

I've tried too many things to post all the details here, but I'll post
any details on request.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "ImportError: No module named gobject"

2011-02-21 Thread Виталий Волков
You should install python-gobject

2011/2/21 Luther 

> I recently had to install 2.7.1 from source, and since then, I have
> been unable to run exaile, which comes with Trisquel 4.0. Here is the
> error message:
>
> Traceback (most recent call last):
>  File "/usr/lib/exaile/exaile.py", line 52, in 
>main()
>  File "/usr/lib/exaile/exaile.py", line 49, in main
>exaile = main.Exaile()
>  File "/usr/lib/exaile/xl/main.py", line 74, in __init__
>self.mainloop_init()
>  File "/usr/lib/exaile/xl/main.py", line 439, in mainloop_init
>import gobject
> ImportError: No module named gobject
>
> Is there some special way to compile Python? Do I have to install
> another Debian package?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


"ImportError: No module named gobject"

2011-02-21 Thread Luther
I recently had to install 2.7.1 from source, and since then, I have
been unable to run exaile, which comes with Trisquel 4.0. Here is the
error message:

Traceback (most recent call last):
  File "/usr/lib/exaile/exaile.py", line 52, in 
main()
  File "/usr/lib/exaile/exaile.py", line 49, in main
exaile = main.Exaile()
  File "/usr/lib/exaile/xl/main.py", line 74, in __init__
self.mainloop_init()
  File "/usr/lib/exaile/xl/main.py", line 439, in mainloop_init
import gobject
ImportError: No module named gobject

Is there some special way to compile Python? Do I have to install
another Debian package?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: return an object of a different class

2011-02-21 Thread Jean-Michel Pichavant

alex23 wrote:

Jean-Michel Pichavant  wrote:
  

You simply don't return inconsistent types with a return statement. This
is a general rule in programming that has probably exceptions but
regarding what you're saying, you clearly don't want to do that.



I don't think they were intended to be inconsistent types, but
subclasses of the same type. Returning different subclasses is exactly
what a factory is for. And given Python's propensity for duck typing,
they don't even really need to be subclassed for the same object, they
just need the interface that is required.

  

Immagine the following code:

oNumber = MyNumbers(random.int(100)) # note that oNumber is not a
MyNumbers instance... quite confusing don't you think ?
oNumber. ... wait a minute, which methods am I allowed to call ???
SmallNumbers adn BigNumbers have differents methods.



What if they have different implementations rather than methods?
  
The answer is quite simple, from a OOP POV, the factory class/function 
returns a MyNumber instance, not a SmallNumber nor BigNumber one. This 
is what the documentation should state. Note that SmallNumber and 
BigNumber instances are both MyNumber instances. But from a user POV, 
there's no need to know about Small and Big implementations. All you 
need to know is the base classe MyNumber methods.


Regarding duck typing, it is all about implementing an interface that is 
not explicit. That way, factory functions return consistent types if 
they return instances with a common interface. That's perfectly legit.


What is not legit, is to return different objects for which the caller 
has to test the type to know what attributes he can use.


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


Re: Python 3.2 and html.escape function

2011-02-21 Thread Tim Delaney
On 21 February 2011 19:56, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Sun, 20 Feb 2011 15:33:39 +0100, Peter Otten wrote:
>
> > Steven D'Aprano wrote:
> >
> >> On Sun, 20 Feb 2011 08:15:35 -0500, Gerald Britton wrote:
> >>
> >>> I see that Python 3.2 includes a new module -- html -- with a single
> >>> function -- escape.  I would like to know how this function differs
> >>> from xml.sax.saxutils.escape and, if there is no difference (or only a
> >>> minor one), what the need is for this new module and its lone function
> >>
> >> Unless the html API has changed radically since Python 3.2a, I believe
> >> you are mistaken.
> >
> > Adding a function is not /that/ radical, and it has happened, see
> >
> > http://docs.python.org/dev/py3k/library/html.html
>
> Well, I just learned something, thank you. I was under the mistaken
> impression that adding new functionality after the first alpha release
> was not permitted by the Python devs.
>

Nope - it's after first beta that features are frozen, barring something
important enough to convince the current release manager (with input from
many others) that the release should go back to alpha status. I've followed
a number of such discussions and the bar is set very high.

Python is one of the few projects around these days that follows the
nomenclature of:

alpha: early release to test new features, everything subject to change;
beta: feature-complete, but expected to contain bugs; people testing the
beta version can rely on APIs not changing in the release version;
release candidate: may be promoted to release with just a version change;
any other changes should result in another release candidate.

IIRC there have been one or two cases in the not-recent past where a release
has been made which includes a bugfix not included in any RC (and I
distinctly remember at least one brown paper bag release following just such
a situation), but at least for the last few years on python-dev the release
managers have been strongly against this.

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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Tim Wintle
On Fri, 2011-02-18 at 12:27 +, Ian wrote:
> 2) Culture. In the West, a designer will decide the architecture of a 
> major system, and it is a basis
> for debate and progress. If he gets it wrong, it is not a personal 
> disgrace or career limiting.  If it is
> nearly right, then that is a major success. In Japan, the architecture 
> has to be a debated and agreed.
> This takes ages, costs lots, and ultimately fails.  The failure is 
> because architecture is always a trade off -
> there is no perfect answer.

I find this really interesting - we spend quite a lot of time studying
the Toyota production system and seeing how we can do programming work
in a similar way, and it's worked fairly well for us (Kanban, Genchi
Genbutsu, eliminating Muda & Mura, etc).

I would have expected Japanese software to have worked quite smoothly,
with continuous improvement taking in everybody's opinions etc -
although I suppose that if production never starts because the
improvements are done to a spec, rather than the product, it would be a
massive hindrance.

Tim Wintle

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


Re: IDLE won't wrap lines of text

2011-02-21 Thread Duncan Booth
André Roberge  wrote:

> On Sunday, February 20, 2011 10:51:38 PM UTC-4, Dick Moores wrote:
>> Problem is I know of no text editor that can handle Japanese.
>> 
> 
> The editor in Crunchy (http://code.google.com/p/crunchy) appears to be
> working just fine with the sample code you posted (at least when using
> Python 3 - I got an error when using it to run the code with Python
> 2). That being said, I would not recommend it for heavy work 
> 
> An editor that seems to work just fine (although it took a long time
> to load the sample code) is SublimeText (http://www.sublimetext.com/)
> - version 2 alpha; it is becoming my editor of choice. 
> 

FWIW, Lugaru Epsilon (http://lugaru.com/) seems to handle it just fine 
though you do have to set it to use a fixed pitch font which has Japanese 
glyphs (MS Mincho was the only suitable font on my system but would suck 
for general editing).

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


Re: hmac module and key format

2011-02-21 Thread Stuart Longland
On Feb 21, 4:59 am, Peter Pearson  wrote:
> On Sun, 20 Feb 2011 04:01:20 -0800, Paul Rubin  
> wrote:
> > Stuart Longland  writes:
> >> What format does hmac require the key to be in?
>
> > It's an arbitrary string.  
>
> >     I have a key in hexadecimal, do I give it the hex?  Do I decode that
> >     to binary and give it that?  
>
> > Probably yes.  Do you have test vectors?  See if they work.
>
> Test case from http://www.faqs.org/rfcs/rfc2104.html:
[...]
> >>> hmac.hmac_md5( "Hi There", 16*"\x0b" )
>
> '\x92\x94rz68\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d'

No worries, thanks to both you Peter and Paul, I'll give this a shot.
By the looks of things it is possible to just decode the hexadecimal
to a binary string and give it that.

I should perhaps elaborate on what I'm doing in case the specifics
make a difference.  I have a YubiKey which internally supports a
challenge-response mode based on HMAC-SHA1.  I've got a key, a sample
challenge and the sample output which is included in the python-yubico
module demos:

https://github.com/yubico/python-yubico

Before I worried about that though, I needed to have some kind of
understanding as to how the hmac module was used.  "Arbitrary string",
sounds to me like I give it something akin to a passphrase, and that
is hashed(?) to provide the symmetric key for the HMAC.  Wikipedia
seems to suggest it depends on the length of the key given, so if I
give it a string that's exactly 160-bits (for HMAC-SHA1) it'll use it
unmodified.  Would that be a correct assertion?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making Line Graphs

2011-02-21 Thread Jean-Michel Pichavant

spam head wrote:

I'm looking for an easy way to display simple line graphs generated by
a python program in Windows.  It could be done from within the
program, or I could write the information out to a file and call an
external program.  Either is fine.

Does anybody have any recommendations for a good program from
generating these simple graphs?
  

http://matplotlib.sourceforge.net/

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


Re: Python leaks in cyclic garbage collection

2011-02-21 Thread n00m
> Wild guess:
> maybe when python exits they are called but sys.stdout has already been 
> closed and nothing gets written on it anymore.

Certainly NOT.


class Foo():
def __init__(self):
self.b = Bar(self)
def __del__(self):
print "Free Foo"

class Bar():
def __init__(self, f):
self.f = f
def __del__(self):
print "Free Bar"


f = Foo()
print f.b.f.b.f.b.f.b.f.b.f.b.f.b.f.b.f
print f.b.f.b.f.b.f.b.f.b.f.b.f.b.f.b.f.b



*Console output:***

<__main__.Foo instance at 0x00AF7328>
<__main__.Bar instance at 0x00AF7350>

D:\v3>

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


Re: Python 3.2 and html.escape function

2011-02-21 Thread Steven D'Aprano
On Sun, 20 Feb 2011 15:33:39 +0100, Peter Otten wrote:

> Steven D'Aprano wrote:
> 
>> On Sun, 20 Feb 2011 08:15:35 -0500, Gerald Britton wrote:
>> 
>>> I see that Python 3.2 includes a new module -- html -- with a single
>>> function -- escape.  I would like to know how this function differs
>>> from xml.sax.saxutils.escape and, if there is no difference (or only a
>>> minor one), what the need is for this new module and its lone function
>> 
>> Unless the html API has changed radically since Python 3.2a, I believe
>> you are mistaken.
> 
> Adding a function is not /that/ radical, and it has happened, see
> 
> http://docs.python.org/dev/py3k/library/html.html

Well, I just learned something, thank you. I was under the mistaken 
impression that adding new functionality after the first alpha release 
was not permitted by the Python devs.



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


fastPATX Bison is here! for your speedy and safe web browsing needs!

2011-02-21 Thread patx
fastPATX 7.0.0 codenamed Bison is now out! You can get it at
patx.me/fastpatx. If you have never tried fastPATX your missing out on the
pinnacle of Python and PyQt4 development. Try it, you'll like it, and maybe
even learn something from it.

It has been awhile since the last fastPATX release, but hopefully this
release will re-spark the tiny fastPATX fan base. In Bison a lot has
changed. The first thing you will notice is that everything is smoother.
Downloads work way better then in previous releases, it is easier to view
the source code of a page, and the interface has been completely redesigned.
We also added tabbed browsing. But we didn’t just add tabbed browsing we
made it fit perfectly into fastPATX so that it looks like it was there from
the beginning.

Note there //is// a screenshot on the site so you can see what has changed,
you will like it. If you have any questions please just email me.
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011 - Call for Participation

2011-02-21 Thread Richard Jones
The second PyCon AU will be held in Sydney on the weekend of the 20th
and 21st of August at the Sydney Masonic Center.

  http://pycon-au.org/

We are looking for proposals for Talks on all aspects of Python programming
from novice to advanced levels; applications and frameworks, or how you
have been involved in introducing Python into your organisation. We're
especially interested in short presentations that will teach conference-goers
something new and useful. Can you show attendees how to use a module?
Explore a Python language feature? Package an application?

We welcome first-time speakers; we are a community conference and we are
eager to hear about your experience. If you have friends or colleagues
who have something valuable to contribute, twist their arms to tell us
about it! Please also forward this Call for Proposals to anyone that you
feel may be interested.

To find out more go to the official Call for Proposals page here:

   http://pycon-au.org/2011/conference/proposals/

The deadline for proposal submission is the 2nd of May.


See you in Sydney in August!

 Richard Jones
 PyCon AU Program Chair
-- 
http://mail.python.org/mailman/listinfo/python-list


CENTERIS’2011 | Conference on ENTERprise Information Systems | Call for Papers

2011-02-21 Thread CENTERIS’2011 | Conference on ENTERprise Information Systems | Call for Papers
Please excuse us if you receive this email more than one.
We would be very grateful if you could disseminate this call among your 
research peers and colleagues.

--
-- CENTERIS’2011  |  Call for Papers 
-- Conference on ENTERprise Information Systems
-- Vilamoura, Algarve, Portugal, 2011, 5-7 October
--
http://centeris.eiswatch.org
submission deadline:  March 14, 2011
--

Dear Professor / Dr.,

It is our great pleasure to invite you to the CENTERIS’2011 - Conference on 
ENTERprise Information Systems – aligning technology, organizations and people. 
Already in its third edition, CENTERIS’2011 will be held in Vilamoura, Algarve, 
Portugal, from 5 to 7 October.

During this 3-day conference, under the leitmotiv of Enterprise Information 
Systems, academics, scientists, IT/IS professionals, scientists, managers and 
solution providers from all over the world will have the opportunity to share 
experiences, bring new ideas, debate issues, and introduce the latest 
developments in the largely multidisciplinary field embraced by the Enterprise 
Information Systems (EIS), from the social, organizational and technological 
perspectives.

All accepted full papers will be published by Springer-Verlag in a CCIS series 
book (Communications in Computer and Information Science), which is listed in 
the ISI proceedings index and SCOPUS. Papers can also be accepted as posters, 
and an extended abstract of it will be published in a book of abstracts (with 
ISBN) or in a CD-ROM (with ISBN). Authors of selected papers will be invited to 
extend the paper for possible publication in international journals and in 
edited books.
Submissions will be reviewed on a double-blind review basis. 
Only original contributions will be accepted.

--
-- Submission Procedure

Researchers and practitioners are invited to submit their manuscript 
electronically at the Conference webpage (http://centeris.eiswatch.org) until 
March 14, 2011. 
Submitted papers will be reviewed on a double-blind review basis.

--
-- Important dates

Deadline for paper submission: March 14, 2011
Notification of acceptance/rejection: May 20, 2011
Revised version: June 10, 2011

-- 

For more detailed information, please visit http://centeris.eiswatch.org

We hope to see you in Portugal.

With our best regards,

Maria Manuela Cruz-Cunha
João Eduardo Varajão


-- Conference Co-chairs
---  Maria Manuela Cruz-Cunha  (mcu...@ipca.pt)
  Polytechnic Institute of Cávado and Ave, Portugal
---  João Eduardo Varajão (jvara...@utad.pt)
University of Trás-os-Montes e Alto Douro, Portugal

-- Program Chair
---  Philip Powell
University of London, UK

-- Organization Chair
---  Ricardo Martinho  (ricardo.martinho@ipleira.p)
  Polytechnic Institute of Leiria, Portugal

-- Secretariat
  secretar...@centeris.eiswatch.org

--
You are receiving this email because of your research activities on the 
conference topic. 
To unsubscribe please send an email to secretar...@centeris.eiswatch.org with 
the subject "Unsubscribe" 
--





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


CENTERIS’2011 | Conference on ENTERprise Information Systems | Call for Papers

2011-02-21 Thread CENTERIS 2011- Conference on ENTERprise Information Systems
Please excuse us if you receive this email more than one.
We would be very grateful if you could disseminate this call among your 
research peers and colleagues.

--
-- CENTERIS’2011  |  Call for Papers 
-- Conference on ENTERprise Information Systems
-- Vilamoura, Algarve, Portugal, 2011, 5-7 October
--
http://centeris.eiswatch.org
submission deadline:  March 14, 2011
--

Dear Professor / Dr.,

It is our great pleasure to invite you to the CENTERIS’2011 - Conference on 
ENTERprise Information Systems – aligning technology, organizations and people. 
Already in its third edition, CENTERIS’2011 will be held in Vilamoura, Algarve, 
Portugal, from 5 to 7 October.

During this 3-day conference, under the leitmotiv of Enterprise Information 
Systems, academics, scientists, IT/IS professionals, scientists, managers and 
solution providers from all over the world will have the opportunity to share 
experiences, bring new ideas, debate issues, and introduce the latest 
developments in the largely multidisciplinary field embraced by the Enterprise 
Information Systems (EIS), from the social, organizational and technological 
perspectives.

All accepted full papers will be published by Springer-Verlag in a CCIS series 
book (Communications in Computer and Information Science), which is listed in 
the ISI proceedings index and SCOPUS. Papers can also be accepted as posters, 
and an extended abstract of it will be published in a book of abstracts (with 
ISBN) or in a CD-ROM (with ISBN). Authors of selected papers will be invited to 
extend the paper for possible publication in international journals and in 
edited books.
Submissions will be reviewed on a double-blind review basis. 
Only original contributions will be accepted.

--
-- Submission Procedure

Researchers and practitioners are invited to submit their manuscript 
electronically at the Conference webpage (http://centeris.eiswatch.org) until 
March 14, 2011. 
Submitted papers will be reviewed on a double-blind review basis.

--
-- Important dates

Deadline for paper submission: March 14, 2011
Notification of acceptance/rejection: May 20, 2011
Revised version: June 10, 2011

-- 

For more detailed information, please visit http://centeris.eiswatch.org

We hope to see you in Portugal.

With our best regards,

Maria Manuela Cruz-Cunha
João Eduardo Varajão


-- Conference Co-chairs
---  Maria Manuela Cruz-Cunha  (mcu...@ipca.pt)
  Polytechnic Institute of Cávado and Ave, Portugal
---  João Eduardo Varajão (jvara...@utad.pt)
University of Trás-os-Montes e Alto Douro, Portugal

-- Program Chair
---  Philip Powell
University of London, UK

-- Organization Chair
---  Ricardo Martinho  (ricardo.martinho@ipleira.p)
  Polytechnic Institute of Leiria, Portugal

-- Secretariat
  secretar...@centeris.eiswatch.org

--
You are receiving this email because of your research activities on the 
conference topic. 
To unsubscribe please send an email to secretar...@centeris.eiswatch.org with 
the subject "Unsubscribe" 
--





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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Ian

On 18/02/2011 07:50, Chris Jones wrote:

  Always
struck me as odd that a country like Japan for instance, with all its
achievements in the industrial realm, never came up with one single
major piece of software.

I think there are two reasons for this.

1) Written Japanese is so hard that the effective illiteracy rate in 
Japan is astonishingly high.


Both UK and Japan claim 99% literacy rate, but UK has 10-20% who find 
reading so hard they
don't read. In Japan by some estimates the proportion is about half. 
Figures from memory.


Result - too many users struggle to read instructions and titles on 
screen. Help texts? Forgetaboutit.


2) Culture. In the West, a designer will decide the architecture of a 
major system, and it is a basis
for debate and progress. If he gets it wrong, it is not a personal 
disgrace or career limiting.  If it is
nearly right, then that is a major success. In Japan, the architecture 
has to be a debated and agreed.
This takes ages, costs lots, and ultimately fails.  The failure is 
because architecture is always a trade off -

there is no perfect answer.

I was involved in one software project where a major Japanese company 
had done the the feasibility
study. It was much much too expensive. The UK company I worked for was 
able, not only to win the bid,
but complete the job profitably for less than the Japanese giant had 
charged for the feasibility study.
We ignored their study - we did not have time to read through the 
documentation which took

10 foot of shelf space to house.

Ian

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


CEFP 2011 Summer School: call for participation

2011-02-21 Thread CEFP Summer School

=
4TH CENTRAL EUROPEAN FUNCTIONAL PROGRAMMING SCHOOL (CEFP 2011)

EOTVOS LORAND UNIVERSITY, BUDAPEST, HUNGARY

June 14-24, 2011

http://plc.inf.elte.hu/cefp

THE REGISTRATION IS OPEN!
=


SCOPE OF THE SUMMER SCHOOL

The Central-European Functional Programming School is an
intensive summer school in the field of functional programming.
The invited lecturers are the most prominent researchers in the
field in Europe, and they will present state-of-the-art functional
programming techniques:

* Andrew Butterfield (University of Dublin, Ireland): Reasoning about
I/O in functional programs
* Clemens Grelck (University of Amsterdam, The Netherlands): Multicore
SAC
* Johan Jeuring (Utrecht University, The Netherlands): Strategies for
learning functional programming
* Rita Loogen (Philipps University Marburg, Germany): Eden
* Simon Marlow (Microsoft Research, United Kingdom): Distributed Haskell
* Greg Michaelson (Heriot-Watt University Edinburgh, Scotland): Box
Calculus
* Rinus Plasmeijer (Radboud University Nijmegen, The Netherlands):
Defining distributed GUI applications with iTasks
* Kostis Sagonas (University of Athens, Greece): Multicore Erlang
* Mary Sheeran (Chalmers University of Technology, Sweden): Feldspar:
Implementation and Application

AIMS OF THE SUMMER SCHOOL

The main goal of the summer school is to bring together computer
scientists, researchers, graduate and PhD students.

The programme of the summer school includes:

* In depth lectures about a selected number of recently emerged
advanced functional programming techniques, taught by experts in
the field.

* Practical exercises accompanying the lectures to be solved by the
students at the school. These exercises guide the students'
learning to a great extent. A high quality lab is available at the
school site.

* Team work is stimulated, such that the students can also learn
from each other.

* Forum for PhD students.

The CEFP school provides a forum for PhD students to present their
research results as part of the workshop programme. Abstract
submission is before the summer school, full paper version
after the summer school. Selected and reviewed papers will be
published in the LNCS Volume of the revised lectures.

*** IMPORTANT: THE DEADLINE FOR THE ABSTRACTS IS APRIL 30, 2011 ***

LOCATION

The event is organized and hosted by the Department of Programming
Languages and Compilers, Faculty of Informatics, Eötvös Loránd
University, Budapest, Hungary.
Budapest is the capital of Hungary with nearly 2.000.000
inhabitants. It is divided into two parts by the river Danube. There
are nine bridges over the river which connect the two sides. The
most beautiful ones are Chain Bridge (Lánchíd), Elisabeth Bridge
(Erzsébet híd) and Liberty Bridge (Szabadság híd).
One of the best places to walk around is the Castle District. There
is a breath-taking view of the city from the Fisherman's
Bastion. Across from the Fisherman's Bastion is Matthias Church
named after the Hungarian King Matthias. In the Castle District you
can find the Sándor Palace, the residence and workplace of the
Head of the State.
Budapest is richly endowed with natural springs of thermal waters
possessing various medicinal properties (Gellért Baths and Hotel,
Széchenyi Baths, Lukács Medicinal Baths etc.).
The largest building in the country is the building of the Hungarian
Parliament, which is situated on the bank of the Danube. The
Neo-Gothic building complex was built between 1884 and 1904
according to the plans of Imre Steindl.
There are many other sights in Budapest, just like Heroes’ Square,
St. Stephen’s Basilica, Andrássy Avenue, Margaret-island, Gellért
Hill and the Citadell etc.
For more information about Budapest, please visit the
http://www.budapestinfo.hu/ home page.

INFORMATION

The registration fee is EUR 410. The registration fee does not include
the price of the accommodation!
For more information please visit our website where you can find more
details about the CEFP 2011 School and the programme.
Our website is: http://plc.inf.elte.hu/cefp

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


Re: [RELEASED] Python 3.2

2011-02-21 Thread Stefan Behnel

Georg Brandl, 20.02.2011 23:22:

On behalf of the Python development team, I'm delighted to announce
Python 3.2 final release.
[...]
Please consider trying Python 3.2 with your code and reporting any bugs
you may notice to:

 http://bugs.python.org/


Note to packagers: This release has a critical bug in distutils that 
prevents .pyc files from being byte compiled to their proper location 
during installation, thus preventing them from being used.


http://bugs.python.org/issue11254

Stefan

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


Re: An amazing one-minute bit of fun at the interactive prompt

2011-02-21 Thread Mark Dickinson
On Feb 20, 8:08 am, Raymond Hettinger  wrote:
> [...]
> >>> n * e
>
> 3.1415926
>
> Compute ð ± e by counting Mandlebrot set iterations :-)

Very neat!  Is it supposed to be obvious why this gives an
approximation to pi?  If so, I'll think about it a bit more;  if not,
do you have any references?

Maybe you should have saved this for March 14th...

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


Re: [RELEASED] Python 3.2

2011-02-21 Thread Peter Otten
Georg Brandl wrote:

> On behalf of the Python development team, I'm delighted to announce
> Python 3.2 final release.

Congratulations for your first as release manager, and a big thank you to 
you and all who contributed to this realease.

> Python 3.2 is a continuation of the efforts to improve and stabilize the
> Python 3.x line.  Since the final release of Python 2.7, the 2.x line
> will only receive bugfixes, and new features are developed for 3.x only.
> 
> Since PEP 3003, the Moratorium on Language Changes, is in effect, there
> are no changes in Python's syntax and built-in types in Python 3.2.
> Development efforts concentrated on the standard library and support for
> porting code to Python 3.  Highlights are:
> 
> * numerous improvements to the unittest module
> * PEP 3147, support for .pyc repository directories
> * PEP 3149, support for version tagged dynamic libraries
> * PEP 3148, a new futures library for concurrent programming
> * PEP 384, a stable ABI for extension modules
> * PEP 391, dictionary-based logging configuration
> * an overhauled GIL implementation that reduces contention
> * an extended email package that handles bytes messages
> * a much improved ssl module with support for SSL contexts and certificate
>   hostname matching
> * a sysconfig module to access configuration information
> * additions to the shutil module, among them archive file support
> * many enhancements to configparser, among them mapping protocol support
> * improvements to pdb, the Python debugger
> * countless fixes regarding bytes/string issues; among them full support
>   for a bytes environment (filenames, environment variables)
> * many consistency and behavior fixes for numeric operations

This is an impressive list. It looks like Python 3 is now ready for mass 
adoption :)
-- 
http://mail.python.org/mailman/listinfo/python-list