ANN : PySWITCH Release – 0.1alpha

2010-12-28 Thread Godson Gera
Hi All,

I am glad to announce the first alpha release of PySWITCH.

http://pyswitch.sf.net


The idea of PySWITCH is to offer a complete library to Python and Twisted
programmers for interacting with FreeSWITCH using EventSocket interface. The
target is to cover all FreeSWITCH API commands and Dialplan tools. PySWITCH
handles all the low level details in executing FreeSWITCH commands, so the
programmer can easily concentrate on quickly building FreeSWITCH
applications. As an example, the API functions offered by PySWITCH often
executes many FreeSWITCH commands under the hood and finally returns the
desired result. Suppose you execute a background job, PySWITCH API will
automatically wait and catch the backgroundjob event parse the result and
will fire the deferred.

The current release covers good amount of API commands and a few Dialplan
tools. The protocol communication issues are ironed out. It has a nice event
call back interface. I’ll present its usage in couple of tutorials soon.


-- 
Thanks  Regards,
Godson Gera
http://godson.in
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


[ANNOUNCE] MyHDL 0.7

2010-12-28 Thread Jan Decaluwe

I'm happy to announce MyHDL 0.7.

MyHDL is Python used as a Hardware Description Language.

Overview:
http://www.myhdl.org/doku.php/overview

What's new in this release:
http://www.myhdl.org/doc/0.7/whatsnew/0.7.html

Download:
http://sourceforge.net/project/showfiles.php?group_id=91207

Best regards,

Jan Decaluwe

--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
  Python as a HDL: http://www.myhdl.org
  VHDL development, the modern way: http://www.sigasi.com
  Analog design automation: http://www.mephisto-da.com
  World-class digital design: http://www.easics.com

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

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


hai

2010-12-28 Thread sakthivel vel
webpage : http://123maza.com/35/city149/
-- 
http://mail.python.org/mailman/listinfo/python-list


hai how are you

2010-12-28 Thread sakthivel vel
webpage : http://123maza.com/35/city149/
-- 
http://mail.python.org/mailman/listinfo/python-list


mutiprocessing, manager, list threading ?

2010-12-28 Thread mika . saari
Hi,

  Testing if I could be able to use multiprocessing BaseManager to manage
list of instance pointers between processes. If my intance inherits
Thread, I get pickling error about _thread.lock.

  I found  Steven Bethard's recipe for this kind of problem in
http://bytes.com/topic/python/answers/552476-why-cant-you-pickle-instancemethods,
but I do not to get the idea how to copyreg the _thread.lock.

  Is it even possible to save instance pointer to list which is
synchronized between separate processes ?

  Thanks a lot,
-Mika


Client side code:

from multiprocessing.managers import BaseManager
from threading import Thread, Lock

class ListManager(BaseManager):
pass

class Testing(Thread):
def __init__(self):
Thread.__init__(self)

def nothing(self):
print(Nothing)

ListManager.register('get_list')
ListManager.register('Testing',Testing)
m = ListManager(address=('', 5), authkey=b'abc')
m.connect()

list1 = m.get_list()
test = Testing()
print(TEST:,test)
list1.append(test)
print(TEST:,test)


Error:
---
Traceback (most recent call last):
  File mpclit.py, line 23, in module
list1.append(test)
  File string, line 2, in append
  File /usr/local/lib/python3.1/multiprocessing/managers.py, line 735,
in _callmethod

conn.send((self._id, methodname, args, kwds))
  File /usr/local/lib/python3.1/pickle.py, line 1358, in dumps
Pickler(f, protocol, fix_imports=fix_imports).dump(obj)
_pickle.PicklingError: Can't pickle built-in method release of
_thread.lock object at 0x1af710f0: attribute lookup __main__.release
failed


References:
--
http://bytes.com/topic/python/answers/552476-why-cant-you-pickle-instancemethods

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


Python - NAWIT / Community

2010-12-28 Thread flebber
I just wanted to put out a question about IDE's but this is NAWIT -
not another which ide thread.

My question relates to community contribution. My concern arose when
recently installing the pydev.org extensions in Eclipse. Now as far as
my understanding goes the licensing on both is open source GPL.
However Pydev became open source as part of aptana's acquistion, and
for the moment pydev can be installed as part of the Aptana studio 2/3
releases individually as a plugin, but moving on if you vist the
aptana site there is sweet little about python on their site, their
site is dominated by Radrails.

Can't help thinking they open sourced Pydev so they could bench it. So
I started thinking that the only consistent env each python person has
is idle as it ships in the install.

Sometimes we can contribute with money and sometimes with time, if I
was to contribute money to ensure that I and all new coming python
programmers could have a first class development environment to use
what would I donate to? At the moment no particular group seems
applicable.

Is pydev actively being developed and for who? SPE is a great idea but
is Stan still developing? Pyscripter is good but not 64 capable. Plus
none of these projects seem community centric.

Maybe its just my wish, maybe something already exists, but to my mind
why is there not a central python community ide or plugin setup like
pydev or using pydev(since currently it is very good - to me), which I
know or at least could confidently donate time or money to further
python.

This could apply to many python area's does python use easy_install or
pypm, well if you want camelot or zope (unless you have business
edition) its easy_install, but you wont find an ide with built in egg
or pypm support? Why every Ruby ide has gems manager, and for that
fact look at netbeans, the ide is good but support for python is
mentioned on a far flung community page where some developers are
trying to maintain good python support. PS they seem to be doing a
good job, but a review of the mailing list archives shows little
activity.

One could say that activestate puts in good support but then they do
not provide an ide within the means of the average part time person
retailing its main edition at over $300, Pycharm a good ide at $99 but
then where is my money going.

I think a community plugin architecture which contained components
like pydev, pyscripter, eclipse and eggs/pypm packages would give a
place I can contribute time as my skills grow and confidently donate
money knowing I am assisting the development of community tools and
packages we all can use. No need to reinvent the wheel most things
already exist, for example apt-get  rpm style package management time
tested and could be easily used to manage python eggs for example.

Anyway I have had my 2 cents, if someone is contributing more than I
know, and this wasn't intended to dimnish anyone's effort, just
wanting to look to growing and fostering a stronger python community.

Sayth



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


Re: Python - NAWIT / Community

2010-12-28 Thread Adam Tauno Williams
On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
 Can't help thinking they open sourced Pydev so they could bench it. 

So?  That isn't uncommon at all;  to Open Source when you've moved on.

 I started thinking that the only consistent env each python person has
 is idle as it ships in the install.

There is a plethora of Python IDE's [personally I use Monodevelop, which
supports Python, and is fast and stable].

 Sometimes we can contribute with money and sometimes with time, if I
 was to contribute money to ensure that I and all new coming python
 programmers could have a first class development environment to use
 what would I donate to? At the moment no particular group seems
 applicable.

Many projects accept donations via PayPal.  Sourceforge supports this.

 Is pydev actively being developed and for who? SPE is a great idea but
 is Stan still developing? Pyscripter is good but not 64 capable. Plus
 none of these projects seem community centric.

Why not just check the repo and see the real answer for yourself?  It is
Open Source after all.
https://github.com/aptana/Pydev/commits/master

 Maybe its just my wish, maybe something already exists, but to my mind
 why is there not a central python community ide or plugin setup like
 pydev or using pydev(since currently it is very good - to me), which I
 know or at least could confidently donate time or money to further
 python.

You could checkout the code of any Python IDE and hack on it.

 I think a community plugin architecture which contained components
 like pydev, pyscripter, eclipse and eggs/pypm packages would give a
 place I can contribute time as my skills grow and confidently donate
 money knowing I am assisting the development of community tools and
 packages we all can use.

So just do it.

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


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 10:16 pm, Adam Tauno Williams awill...@whitemice.org
wrote:
 On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
  Can't help thinking they open sourced Pydev so they could bench it.

 So?  That isn't uncommon at all;  to Open Source when you've moved on.

  I started thinking that the only consistent env each python person has
  is idle as it ships in the install.

 There is a plethora of Python IDE's [personally I use Monodevelop, which
 supports Python, and is fast and stable].

  Sometimes we can contribute with money and sometimes with time, if I
  was to contribute money to ensure that I and all new coming python
  programmers could have a first class development environment to use
  what would I donate to? At the moment no particular group seems
  applicable.

 Many projects accept donations via PayPal.  Sourceforge supports this.

  Is pydev actively being developed and for who? SPE is a great idea but
  is Stan still developing? Pyscripter is good but not 64 capable. Plus
  none of these projects seem community centric.

 Why not just check the repo and see the real answer for yourself?  It is
 Open Source after all.
 https://github.com/aptana/Pydev/commits/master

  Maybe its just my wish, maybe something already exists, but to my mind
  why is there not a central python community ide or plugin setup like
  pydev or using pydev(since currently it is very good - to me), which I
  know or at least could confidently donate time or money to further
  python.

 You could checkout the code of any Python IDE and hack on it.

  I think a community plugin architecture which contained components
  like pydev, pyscripter, eclipse and eggs/pypm packages would give a
  place I can contribute time as my skills grow and confidently donate
  money knowing I am assisting the development of community tools and
  packages we all can use.

 So just do it.

Yes you can answer questions, but have you really? Your answer seems
to be things are open source so who cares about community.

 Many projects accept donations via PayPal.  Sourceforge supports this.

Of course any fool can throw his/her money away thats no challenge why
even use Paypal, I could have fun and by 10 bottles of vino and hand
them out to recovering alcoholics.

Don't answer things just for the sake of it, if you have nothing
producive to say about furthering python and its community then say
that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 10:24 pm, flebber flebber.c...@gmail.com wrote:
 On Dec 28, 10:16 pm, Adam Tauno Williams awill...@whitemice.org
 wrote:



  On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
   Can't help thinking they open sourced Pydev so they could bench it.

  So?  That isn't uncommon at all;  to Open Source when you've moved on.

   I started thinking that the only consistent env each python person has
   is idle as it ships in the install.

  There is a plethora of Python IDE's [personally I use Monodevelop, which
  supports Python, and is fast and stable].

   Sometimes we can contribute with money and sometimes with time, if I
   was to contribute money to ensure that I and all new coming python
   programmers could have a first class development environment to use
   what would I donate to? At the moment no particular group seems
   applicable.

  Many projects accept donations via PayPal.  Sourceforge supports this.

   Is pydev actively being developed and for who? SPE is a great idea but
   is Stan still developing? Pyscripter is good but not 64 capable. Plus
   none of these projects seem community centric.

  Why not just check the repo and see the real answer for yourself?  It is
  Open Source after all.
  https://github.com/aptana/Pydev/commits/master

   Maybe its just my wish, maybe something already exists, but to my mind
   why is there not a central python community ide or plugin setup like
   pydev or using pydev(since currently it is very good - to me), which I
   know or at least could confidently donate time or money to further
   python.

  You could checkout the code of any Python IDE and hack on it.

   I think a community plugin architecture which contained components
   like pydev, pyscripter, eclipse and eggs/pypm packages would give a
   place I can contribute time as my skills grow and confidently donate
   money knowing I am assisting the development of community tools and
   packages we all can use.

  So just do it.

 Yes you can answer questions, but have you really? Your answer seems
 to be things are open source so who cares about community.

  Many projects accept donations via PayPal.  Sourceforge supports this.

 Of course any fool can throw his/her money away thats no challenge why
 even use Paypal, I could have fun and by 10 bottles of vino and hand
 them out to recovering alcoholics.

 Don't answer things just for the sake of it, if you have nothing
 producive to say about furthering python and its community then say
 that.

My apologise I didn't mean to be that aggressive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python - NAWIT / Community

2010-12-28 Thread Adam Tauno Williams
On Tue, 2010-12-28 at 03:24 -0800, flebber wrote:
 On Dec 28, 10:16 pm, Adam Tauno Williams awill...@whitemice.org
 wrote:
  On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
   Is pydev actively being developed and for who? SPE is a great idea but
   is Stan still developing? Pyscripter is good but not 64 capable. Plus
   none of these projects seem community centric.
  Why not just check the repo and see the real answer for yourself?  It is
  Open Source after all.
  https://github.com/aptana/Pydev/commits/master

 Yes you can answer questions, but have you really? Your answer seems
 to be things are open source so who cares about community.
  Many projects accept donations via PayPal.  Sourceforge supports this.
 Of course any fool can throw his/her money away thats no challenge why
 even use Paypal, I could have fun and by 10 bottles of vino and hand
 them out to recovering alcoholics.
 Don't answer things just for the sake of it, if you have nothing
 producive to say about furthering python and its community then say
 that.

I provided two concrete points, thank you:

(1) Is a project actively developed?  Look at the repo. That is the
answer to the question [this isn't necessarily obvious to those new to
Open Source].
(1.1.) Is PyDev a potential unifying force amoung IDEs?  Which is the
implied question - that is up to the OP and others who do/do-not
contribute to it.
(2) How can I donate cash? There is a fairly standard mechanism for
that.

Otherwise I think the OP's thoughts on community and how Open Source
works are somewhat flawed.  Community is a manifestation of people
*doing* things; it does *not* arise out of people being concerned about
things [since doing is quite apparently not a natural result of
concern. Concern is like watching TV.  Doing is getting out of the
chair.]


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


Re: Trying to parse a HUGE(1gb) xml file

2010-12-28 Thread Adam Tauno Williams
On Tue, 2010-12-28 at 07:08 +0100, Stefan Behnel wrote:
 Roy Smith, 28.12.2010 00:21:
  To go back to my earlier example of
   Parental-AdvisoryFALSE/Parental-Advisory
  using 432 bits to store 1 bit of information, stuff like that doesn't
  happen in marked-up text documents.  Most of the file is CDATA (do they
  still use that term in XML, or was that an SGML-ism only?).  The markup
  is a relatively small fraction of the data.  I'm happy to pay a factor
  of 2 or 3 to get structured text that can be machine processed in useful
  ways.  I'm not willing to pay a factor of 432 to get tabular data when
  there's plenty of other much more reasonable ways to encode it.
 If the above only appears once in a large document, I don't care how much 
 space it takes. If it appears all over the place, it will compress down to 
 a couple of bits, so I don't care about the space, either.

+1

 It's readability that counts here. Try to reverse engineer a binary format 
 that stores the above information in 1 bit.

I think a point many of the arguments against XML miss is the HR cost of
custom solutions.  Every time you come up with a cool super-efficient
solution it has to be weighed against the increase in the tool-stack
[whereas XML is, essentially, built-in] and
nobody-else-knows-about-your-super-cool-solution [1].  IMO, tool-stack
bloat is a *big* problem in shops with an Open Source tendency.  Always
tossing the new and shiny thing [it's free!] into the bucket for some
theoretical benefit. [This is an unrecognized benefit to expensive
software - it creates focus].  Soon the bucket is huge and maintaining
it becomes a burden.

[1] The odds you sufficiently documented your super-cool-solution is
probably nil.

So I'm one of those you'd have to make a *really* good argument *not* to
use XML.  XML is known, the tools are good, the knotty problems are
solved [thanks to the likes of SAX, lxml / ElementTree, and
ElementFlow].  If the premise argument is bloat I'd probably dismiss
it out of hand since removing that bloat will necessitate adding bloat
somewhere else; that somewhere else almost certainly being more
expensive.

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


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 10:37 pm, Adam Tauno Williams awill...@whitemice.org
wrote:
 On Tue, 2010-12-28 at 03:24 -0800, flebber wrote:
  On Dec 28, 10:16 pm, Adam Tauno Williams awill...@whitemice.org
  wrote:
   On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
Is pydev actively being developed and for who? SPE is a great idea but
is Stan still developing? Pyscripter is good but not 64 capable. Plus
none of these projects seem community centric.
   Why not just check the repo and see the real answer for yourself?  It is
   Open Source after all.
   https://github.com/aptana/Pydev/commits/master
  Yes you can answer questions, but have you really? Your answer seems
  to be things are open source so who cares about community.
   Many projects accept donations via PayPal.  Sourceforge supports this.
  Of course any fool can throw his/her money away thats no challenge why
  even use Paypal, I could have fun and by 10 bottles of vino and hand
  them out to recovering alcoholics.
  Don't answer things just for the sake of it, if you have nothing
  producive to say about furthering python and its community then say
  that.

 I provided two concrete points, thank you:

 (1) Is a project actively developed?  Look at the repo. That is the
 answer to the question [this isn't necessarily obvious to those new to
 Open Source].
 (1.1.) Is PyDev a potential unifying force amoung IDEs?  Which is the
 implied question - that is up to the OP and others who do/do-not
 contribute to it.
 (2) How can I donate cash? There is a fairly standard mechanism for
 that.

 Otherwise I think the OP's thoughts on community and how Open Source
 works are somewhat flawed.  Community is a manifestation of people
 *doing* things; it does *not* arise out of people being concerned about
 things [since doing is quite apparently not a natural result of
 concern. Concern is like watching TV.  Doing is getting out of the
 chair.]

Fair point.

You have mistaken somewhat what I intended, partly my fault due to the
verbosity. I wanted gaugue feedback on others perception of the
current status quo. I am happy personally currently, currently being
the main word.

Community is a manifestation of people
 *doing* things; it does *not* arise out of people being concerned about
 things

But concern is derived from interaction and observation and like fear
and joy tells us we need to take an action. If someone chooses to sir
idly by good for them I haven't the time or inclination personally.

Tony Robbins Acheiving a goal is simple, decide what your goal is,
set out towards it and consistently review whether you are getting
closer or further from your goal and take action immediately.

From a language perspective going to python 3 this definitely seems to
be occurring well and strongly lead.

Sometimes the fault in open source is the lack of a crystalized and
shared goal and proper infrastructure.Gentoo as an example. Could
get to they were going because they didn't share the same vision of
what it was.

I meant no attack by reviewing, just a somewhat newbies observations
of python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 11:10 pm, flebber flebber.c...@gmail.com wrote:
 On Dec 28, 10:37 pm, Adam Tauno Williams awill...@whitemice.org
 wrote:



  On Tue, 2010-12-28 at 03:24 -0800, flebber wrote:
   On Dec 28, 10:16 pm, Adam Tauno Williams awill...@whitemice.org
   wrote:
On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
 Is pydev actively being developed and for who? SPE is a great idea but
 is Stan still developing? Pyscripter is good but not 64 capable. Plus
 none of these projects seem community centric.
Why not just check the repo and see the real answer for yourself?  It is
Open Source after all.
https://github.com/aptana/Pydev/commits/master
   Yes you can answer questions, but have you really? Your answer seems
   to be things are open source so who cares about community.
Many projects accept donations via PayPal.  Sourceforge supports this.
   Of course any fool can throw his/her money away thats no challenge why
   even use Paypal, I could have fun and by 10 bottles of vino and hand
   them out to recovering alcoholics.
   Don't answer things just for the sake of it, if you have nothing
   producive to say about furthering python and its community then say
   that.

  I provided two concrete points, thank you:

  (1) Is a project actively developed?  Look at the repo. That is the
  answer to the question [this isn't necessarily obvious to those new to
  Open Source].
  (1.1.) Is PyDev a potential unifying force amoung IDEs?  Which is the
  implied question - that is up to the OP and others who do/do-not
  contribute to it.
  (2) How can I donate cash? There is a fairly standard mechanism for
  that.

  Otherwise I think the OP's thoughts on community and how Open Source
  works are somewhat flawed.  Community is a manifestation of people
  *doing* things; it does *not* arise out of people being concerned about
  things [since doing is quite apparently not a natural result of
  concern. Concern is like watching TV.  Doing is getting out of the
  chair.]

 Fair point.

 You have mistaken somewhat what I intended, partly my fault due to the
 verbosity. I wanted gaugue feedback on others perception of the
 current status quo. I am happy personally currently, currently being
 the main word.

 Community is a manifestation of people

  *doing* things; it does *not* arise out of people being concerned about
  things

 But concern is derived from interaction and observation and like fear
 and joy tells us we need to take an action. If someone chooses to sir
 idly by good for them I haven't the time or inclination personally.

 Tony Robbins Acheiving a goal is simple, decide what your goal is,
 set out towards it and consistently review whether you are getting
 closer or further from your goal and take action immediately.

 From a language perspective going to python 3 this definitely seems to
 be occurring well and strongly lead.

 Sometimes the fault in open source is the lack of a crystalized and
 shared goal and proper infrastructure.Gentoo as an example. Could
 get to they were going because they didn't share the same vision of
 what it was.

 I meant no attack by reviewing, just a somewhat newbies observations
 of python.

Edit Gentoo couldn't get to where they were going because of lack of
vision and a shared goal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Ulrich Eckhardt
Steven D'Aprano wrote:
 class InternedTuple(tuple):
 ... _cache = {}
 ... def __new__(cls, *args):
 ... t = super().__new__(cls, *args)
 ... return cls._cache.setdefault(t, t)

That looks good. The only thing that first bothered me is that it creates an 
object and then possibly discards it again. However, there is no way around 
that, since at least the key to the dict must be created for lookup. Since 
key and value are the same here, this is even for free.

What I also found was that with the above, I can't provide __eq__ and __ne__ 
that just check for identity. If I do, the lookup in setdefault() will never 
find an existing tuple and I will never save memory for a single object.


Thanks!

Uli

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


Re: Python - NAWIT / Community

2010-12-28 Thread Steven D'Aprano
On Tue, 28 Dec 2010 04:10:15 -0800, flebber wrote:

 Tony Robbins Acheiving a goal is simple, decide what your goal is, set
 out towards it and consistently review whether you are getting closer or
 further from your goal and take action immediately.

Writing bug-free code is simple: decide what you want your code to do, 
write code to do it, and consistently review whether you are getting more 
or fewer bugs, and take action immediately.


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


Re: Trying to parse a HUGE(1gb) xml file

2010-12-28 Thread BartC



Stefan Behnel stefan...@behnel.de wrote in message
news:mailman.335.1293516506.6505.python-l...@python.org...

Roy Smith, 28.12.2010 00:21:

To go back to my earlier example of

 Parental-AdvisoryFALSE/Parental-Advisory

using 432 bits to store 1 bit of information, stuff like that doesn't
happen in marked-up text documents.  Most of the file is CDATA (do they
still use that term in XML, or was that an SGML-ism only?).  The markup
is a relatively small fraction of the data.  I'm happy to pay a factor
of 2 or 3 to get structured text that can be machine processed in useful
ways.  I'm not willing to pay a factor of 432 to get tabular data when
there's plenty of other much more reasonable ways to encode it.


If the above only appears once in a large document, I don't care how much
space it takes. If it appears all over the place, it will compress down to
a couple of bits, so I don't care about the space, either.

It's readability that counts here. Try to reverse engineer a binary format
that stores the above information in 1 bit.


The above typically won't get much below 2 bytes (as one character plus a
separator, eg. in comma-delimited-format). So it's more like 27:1, if you're
going to stay with a text format.

Still, that's 27 times as much as it need be. Readability is fine, but why
does the full, expanded, human-readable textual format have to be stored on
disk too, and for every single instance?

What if the 'Parental-Advisory' tag was even longer? Just how long do these
things have to get before even the advocates here admit that it's getting
ridiculous?

Isn't it possible for XML to define a shorter alias for these tags? Isn't
there a shortcut available for /Parental-Advisory in simple examples like
this (I seem to remember something like this)?

And why not use 1 and 0 for TRUE and FALSE? Even the consumer appliances in
my house have 1 and 0 on their power switches! With the advantage that they 
are internationally recognised.


--
Bartc 


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


etl tool!!!!!

2010-12-28 Thread krishna kumar
Is there any efficient etl tool developed in python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: etl tool!!!!!

2010-12-28 Thread Stefan Sonnenberg-Carstens

Am 28.12.2010 13:57, schrieb krishna kumar:

Is there any efficient etl tool developed in python?

Yes, Python.
--
http://mail.python.org/mailman/listinfo/python-list


Re: etl tool!!!!!

2010-12-28 Thread Adam Tauno Williams
On Tue, 2010-12-28 at 07:57 -0500, krishna kumar wrote:
 Is there any efficient etl tool developed in python? 

What does efficient mean to you?

I work on a Python workflow solution that I use to do ETL.
https://sourceforge.net/projects/coils/
https://lists.sourceforge.net/lists/listinfo/coils-project

-- 
Adam Tauno Williams awill...@whitemice.org LPIC-1, Novell CLA
http://www.whitemiceconsulting.com
OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


NameError: global name 'btn_Matlab' is not defined ?

2010-12-28 Thread Stef Mientki
hello,

Never seen this before and I've no explanation whatsoever (Python 2.6)

I've some dynamic generated code,
one of objects generated is a wx.Button, called 'btn_Matlab'.

After the code is generated, I can see that the button is created in the local 
namespace
 
   print locals()['btn_Matlab']

wx._controls.Button; proxy of Swig Object of type 'wxButton *' at 0x3602d28 

but if I try to print the button (at exactly the same location), I get an error

print btn_Matlab

NameError: global name 'btn_Matlab' is not defined ?

Why isn't the compiler first checking the local namespace ?
any clues ?

thanks,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Steven D'Aprano
On Tue, 28 Dec 2010 13:42:39 +0100, Ulrich Eckhardt wrote:

 Steven D'Aprano wrote:
 class InternedTuple(tuple):
 ... _cache = {}
 ... def __new__(cls, *args):
 ... t = super().__new__(cls, *args) 
 ... return cls._cache.setdefault(t, t)
 
 That looks good. The only thing that first bothered me is that it
 creates an object and then possibly discards it again. However, there is
 no way around that, since at least the key to the dict must be created
 for lookup. Since key and value are the same here, this is even for
 free.
 
 What I also found was that with the above, I can't provide __eq__ and
 __ne__ that just check for identity. If I do, the lookup in setdefault()
 will never find an existing tuple and I will never save memory for a
 single object.

If all you want is to save memory, you don't need to change the __eq__ 
method. But if you still want to, try this:


# Untested
class InternedTuple(tuple):
_cache = {}
def __new__(cls, *args):
t = super().__new__(cls, *args) 
return cls._cache.setdefault(args, t)
def __eq__(self, other):
return self is other
def __ne__(self, other):
return self is not other



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


Re: NameError: global name 'btn_Matlab' is not defined ?

2010-12-28 Thread Steven D'Aprano
On Tue, 28 Dec 2010 14:34:19 +0100, Stef Mientki wrote:

 hello,
 
 Never seen this before and I've no explanation whatsoever (Python 2.6)
 
 I've some dynamic generated code,
 one of objects generated is a wx.Button, called 'btn_Matlab'.

How do you generate the code?

What code is generated? What does it do?


 After the code is generated, I can see that the button is created in the
 local namespace
  
print locals()['btn_Matlab']
 
 wx._controls.Button; proxy of Swig Object of type 'wxButton *' at
 0x3602d28 
 
 but if I try to print the button (at exactly the same location), I get
 an error
 
 print btn_Matlab
 
 NameError: global name 'btn_Matlab' is not defined ?
 
 Why isn't the compiler first checking the local namespace ? any clues ?


My guess is that you've declared btn_Matlab as global, and then 
dynamically created a local with the same name using exec or similar.



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


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Stefan Behnel

Steven D'Aprano, 28.12.2010 15:11:

On Tue, 28 Dec 2010 13:42:39 +0100, Ulrich Eckhardt wrote:


Steven D'Aprano wrote:

class InternedTuple(tuple):

... _cache = {}
... def __new__(cls, *args):
... t = super().__new__(cls, *args)
... return cls._cache.setdefault(t, t)


That looks good. The only thing that first bothered me is that it
creates an object and then possibly discards it again. However, there is
no way around that, since at least the key to the dict must be created
for lookup. Since key and value are the same here, this is even for
free.

What I also found was that with the above, I can't provide __eq__ and
__ne__ that just check for identity. If I do, the lookup in setdefault()
will never find an existing tuple and I will never save memory for a
single object.


If all you want is to save memory, you don't need to change the __eq__
method. But if you still want to, try this:

# Untested


Yep, that' the problem. ;)



class InternedTuple(tuple):
 _cache = {}
 def __new__(cls, *args):
 t = super().__new__(cls, *args)
 return cls._cache.setdefault(args, t)
 def __eq__(self, other):
 return self is other
 def __ne__(self, other):
 return self is not other


What Ulrich meant, was: doing this will actually kill the caching, because 
the first time the comparison is called is when looking up the tuple while 
adding it to the interning dict. Since the new tuple is, well, new, it will 
not be equal (read: identical) to any cached tuple, thus resulting in a new 
entry regardless of its content.


Stefan

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


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Christian Heimes
Am 28.12.2010 15:11, schrieb Steven D'Aprano:
 # Untested
 class InternedTuple(tuple):
 _cache = {}
 def __new__(cls, *args):
 t = super().__new__(cls, *args) 
 return cls._cache.setdefault(args, t)
 def __eq__(self, other):
 return self is other
 def __ne__(self, other):
 return self is not other

The code doesn't work, you have to change super().__new__(cls, *args) to
super().__new__(cls, args). Don't ask me why. I'm surprised, too.

 InternedTuple(1)
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 4, in __new__
TypeError: 'int' object is not iterable


Also this code is going to use much more memory than an ordinary tuple
since every instance of InternedTuple has a __dict__ attribute. This
code works but I had to move the cache outside the class because of
__slots__.

_ituple_cache = {}

class ituple(tuple):
__slots__ = () # no __dict__

def __new__(cls, *args):
cached = _ituple_cache.get(args)
if cached is not None:
return cached
self = _ituple_cache[args] = super(ituple, cls).__new__(cls, args)
return self

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


Replacing Greenlets with Threads or Processes

2010-12-28 Thread Nathanael Abbotts
I need to replace the use of 'greenlets' in an application with threads or 
processes, but as I've never used greenlets, I don't know where to start when 
replacing them. 
Could anyone explain to me how I can do this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while True or while 1

2010-12-28 Thread Francesco

hehehehehehe...

On 17/12/2010 2.01, Steven D'Aprano wrote:

On Thu, 16 Dec 2010 23:34:21 +, BartC wrote:


In terms of a more realistic function (admittedly still a little
contrived, as the loop would be written differently), I tried this:

def p2(n):
   p=1
   while True:
 if n=p: return p
 p=1
   return 0

for i in xrange(100):
   x=p2(i)

p2() calculates the smallest power of 2= it's operand.

Using while True as shown, it took 3.4 seconds. Using While 1, it took
2.6 seconds (Python 2.5).



Right. And a saving of 0.8 microseconds per iteration is a micro-
optimization which is likely to be invisible in any real situation.

I mean, yes, you saved almost an entire second. Wow. Save another 179 of
them and you'll almost have enough time to make yourself a coffee.

Bart, we get it. Nobody denies that the optimization is real, only that
it is generally meaningful. Who cares whether it takes 2 seconds or 4
seconds to generate one million results if the rest of the application
takes 3 minutes to run?

*If* your application is such that saving 0.8 microseconds per iteration
actually is useful, AND your loop has to be written as a while True loop,
then this *may* be a useful micro-optimization to save 0.8 microseconds
per iteration. That's a vanishingly tiny proportion of all code written.
If your code happens to meet those conditions, then by all means use
while 1. Or move to Python 3, where while True has the same
optimization performed.

But in general, such micro-optimizations are not terribly useful. If you
shave off 1 second off a program that runs in 3 seconds, chances are
nobody is even going to notice. Two seconds or three, who cares? Either
way, it's too short to do anything else, and not long enough to matter.
If you shave off an hour off a program that takes 20 hours, who is going
to care?

But so long as it doesn't introduce bugs, or make maintenance harder, or
add complexity, such micro-optimizations don't harm either.



HEY! That was MY argument! ;-))

Newsgroups: comp.lang.python
Subject: Re: If/then style question
Date: Tue, 21 Dec 2010 20:54:02 +0100

I'd bet you would stress your point Steven! But you don't need to persuade me, 
I do already agree.
I just meant to say that, when the advantage is little, there's no need to 
rewrite a working function.
And that with modern CPUs, if tests take so little time, that even some 
redundant one is not so much of a nuisance.
in your working example, the payload is just a couple of integer calculations, that take very little time too. So the overhead due 
to redundant if tests does show clearly. And also in that not-really-real situation, 60% overhead just meant less than 3 seconds. 
Just for the sake of discussion, I tried to give both functions some plough to pull, and a worst-case situation too:


 t1 = Timer('for x in range(100): print func1(0),',
...  'from __main__ import func1')

 t2 = Timer('for x in range(100): print func2(0),',
...  'from __main__ import func2')

 min(t1.repeat(number=1, repeat=1))
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
53.011015366479114
 min(t2.repeat(number=1, repeat=1))
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
47.55442856564332

that accounts for a scant 11% overhead, on more than one million tests per 
cycle.

That said,  let's make really clear that I would heartily prefer func2 to func1, based both on readability and speed. Thank you for 
having spent some time playing with me!

Francesco

On 19/12/2010 1.05, Steven D'Aprano wrote:
 Well, let's try it with a working (albeit contrived) example. This is
 just an example -- obviously I wouldn't write the function like this in
 real life, I'd use a while loop, but to illustrate the issue it will do.

 def func1(n):
  result = -1
  done = False
  n = (n+1)//2
  if n%2 == 1:
  result = n
  done = True
  if not done:
  n = (n+1)//2
  if n%2 == 1:
  result = n
  done = True
  if not done:
  n = (n+1)//2
  if n%2 == 1:
  result = n
  done = True
  if not done:
  for i in range(100):
  if not done:
  n = (n+1)//2
  if n%2 == 1:
  result = n
  done = True
  return result


 def func2(n):
  n = (n+1)//2
  if n%2 == 1:
  return n
  n = (n+1)//2
  if n%2 == 1:
  return n
  n = (n+1)//2
  if n%2 

hi

2010-12-28 Thread phani indra

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


Re: Replacing Greenlets with Threads or Processes

2010-12-28 Thread Emile van Sebille

On 12/28/2010 6:59 AM Nathanael Abbotts said...

I need to replace the use of 'greenlets' in an application with threads or 
processes, but as I've never used greenlets, I don't know where to start when 
replacing them.
Could anyone explain to me how I can do this?


Looks like your choice may be limited to processes...

http://groups.google.com/group/pycsp/browse_thread/thread/45209957e27e0293/b67445b092872750?q=python+greenlets

Emile

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


Re: Trying to parse a HUGE(1gb) xml file

2010-12-28 Thread Sherm Pendley
BartC b...@freeuk.com writes:

 Roy Smith, 28.12.2010 00:21:
 To go back to my earlier example of

  Parental-AdvisoryFALSE/Parental-Advisory


 Isn't it possible for XML to define a shorter alias for these tags? Isn't
 there a shortcut available for /Parental-Advisory in simple examples like
 this (I seem to remember something like this)?

Yes, you can define your own entities in a DTD:

  !ENTITY paf Parental-AdvisoryFALSE/Parental-Advisory
  !ENTITY pat Parental-AdvisoryTRUE/Parental-Advisory

Later, in your document:

  paf;
  pat;

Although, this is a bit of a contrived example - if space is such a
major concern, one wouldn't be so wasteful of it to begin with, but
might instead use a short tag form whose value attribute defaults to
FALSE.

  !ELEMENT advisory EMPTY
  !ATTLIST advisory value (TRUE | FALSE) FALSE

Later, in your document:

  movie title=Bambiadvisory//movie
  movie title=Scarfaceadvisory value=TRUE//movie

To save even more space, one could instead define a pa attribute as
part of the movie element, with a default value that would then take
no space at all:

  !ATTLIST movie pa (TRUE | FALSE) FALSE

Later, in your document:

  movie name=Bambi/
  movie name=Scarface pa=TRUE/

When you see someone doing stupid things with a tool, it's usually not
the tool's fault. Far more often, it's someone using the wrong tool for
the task at hand, or using the right tool the wrong way.

 And why not use 1 and 0 for TRUE and FALSE?

Sounds reasonable in general, although a parental advisory would more
often be a range of possible values (G, PG, R, MA, etc.) rather than a
boolean.

sherm--

-- 
Sherm Pendley
   http://camelbones.sourceforge.net
Cocoa Developer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacing Greenlets with Threads or Processes

2010-12-28 Thread Nathanael Abbotts
Processes are better for me - the application is already multiprocessing based.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trying to parse a HUGE(1gb) xml file

2010-12-28 Thread Roy Smith
In article ifcmru$ab...@news.eternal-september.org,
 BartC b...@freeuk.com wrote:

 Still, that's 27 times as much as it need be. Readability is fine, but why
 does the full, expanded, human-readable textual format have to be stored on
 disk too, and for every single instance?

Well, I know the answer to that one.  The particular XML feed I'm 
working with is a dump from an SQL database.  The element names in the 
XML are exactly the same as the column names in the SQL database.

The difference being that in the database, the string 
Parental-Advisory appears in exactly one place, in some schema 
metadata table.  In the XML, it appears (doubled!) once per row.

It's still obscene.  That fact that I understand the cause of the 
obscenity doesn't make it any less so.

Another problem with XML is that some people don't use real XML tools to 
write their XML files.  DTD?  What's that?  So you end up with tag soup 
that the real XML tools can't parse on the other end.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacing Greenlets with Threads or Processes

2010-12-28 Thread Nathanael Abbotts
That thread seems to deal with mixing them. I want to replace them completely - 
is that possible (with either threads or processes)?

Some loss of functionality isn't a problem, as the code only seems to use the 
most basic features of Greenlets.

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


Re: mutiprocessing, manager, list threading ?

2010-12-28 Thread John Nagle

On 12/28/2010 1:38 AM, mika.sa...@wipsl.com wrote:

Hi,

   Testing if I could be able to use multiprocessing BaseManager to manage
list of instance pointers between processes. If my intance inherits
Thread, I get pickling error about _thread.lock.


The multiprocessing module works by running completely separate
programs which communicate by copying data back and forth through
pipes or sockets.  You can't share thread locks.  (There's a gimmick
that lets you put an array of fixed type and size in shared memory,
but that's very limited, because Python's locking doesn't really
understand multiprocessing.)

If you need to access a list from several processes, have
one process own the list, and use a Manager from the multiprocessing
module to create a proxy to access the list from the other processes.
Note that this is slower than regular list access.  But if you just
need to have a to-do list that feeds multiple processes, that's a way
to do it.

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


Re: Replacing Greenlets with Threads or Processes

2010-12-28 Thread Emile van Sebille

On 12/28/2010 8:07 AM Nathanael Abbotts said...

That thread seems to deal with mixing them. I want to replace them
completely - is that possible (with either threads or processes)?


Are you working with pycsp?  the info at 
http://code.google.com/p/pycsp/wiki/Getting_Started_With_PyCSP says:


The API is implemented in four versions: Threads, processes, greenlets 
and net. All implementations share an almost identical API making it 
trivial to switch from one implementation to another. 


Emile

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


Re: How to programmatically exit from wsgi's serve_forever() loop

2010-12-28 Thread python
Hi Ian,

You are correct - I missed the following 2 nuances:

# need to set poll_interval in order to recognize shutdown request
httpd.serve_forever(poll_interval=0.5)

# shutdown request must be initiated from ANOTHER thread or will block
import threading
threading.Thread(target=httpd.shutdown).start()

Thank you for your help - really appreciated!

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


Re: Digitally Signing a XML Document (using SHA1+RSA or SHA1+DSA)

2010-12-28 Thread Anurag Chourasia
Dear all,

I am required to use the Private Key from that XML below to generate a
digital signature.

The public key can then be used to validate the generated signature.

http://stuvel.eu/rsa does not support PKCS#1 and hence I am required to look
for alternates.

Please let me know if there is something else out there that could help meet
my requirement.

Regards,
Anurag

On Tue, Dec 28, 2010 at 6:36 AM, Adam Tauno Williams awill...@whitemice.org
 wrote:

 On Tue, 2010-12-28 at 03:25 +0530, Anurag Chourasia wrote:
  Hi All,

  I have a requirement to digitally sign a XML Document using SHA1+RSA
  or SHA1+DSA
  Could someone give me a lead on a library that I can use to fulfill
  this requirement?

 http://stuvel.eu/rsa  Never used it though.

  The XML Document has values such as
  RSASK-BEGIN RSA PRIVATE KEY-
  MIIBOgIBAAJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqguw76g/jmeO6f4i31rDLVQ
  n7sYilu65C8vN+qnEGnPB824t/A3yfMu1G0CAQMCQQCOd2lLpgRm6esMblO18WOG
  3h8oCNcaydfUa1QmaX0apHlDFnI7UDXpYaHp2VL9gvtSJT5L3ZASMzxRPXJSvzcT
  AiEA/16jQh18BAD4q3yk1gKw19I8OuJOYAxFYX9noCEFWUMCIQDWOiYfPtxK3A1s
  AFARsDnnHTL4FbRPpiZ79vP+VgqojwIhAKo/F4Fo/VgApceobeQByzqMKCdBiZVd
  g5ZU78AWA5DXAiEAjtFuv389hz1eSAA1YSAmmhN3UA54NRlu/U9NVDlccF8CIBkc
  Z52oGxy/skwVwI5TBcB1YqXJTT47/6/hTAVMTwaA -END RSA PRIVATE
  KEY-/RSASK
  RSAPUBK-BEGIN PUBLIC KEY-
  MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqgu
  w76g/jmeO6f4i31rDLVQn7sYilu65C8vN+qnEGnPB824t/A3yfMu1G0CAQM= -END
  PUBLIC KEY-/RSAPUBK

 Is this any kind of standard or just something someone made up?  Is
 there a namespace for the document?

 It seems quite odd that the document contains a *private* key.

 If all you need to do is parse to document to retrieve the values that
 seems straight-forward enough.

  And the XML also has another node that has a Public Key with Modules
  and Exponents etc that I apparently need to utilize.
  RSAPK
M1bMd8XkGml7gkqV9kOoVSk0uvA1CqC7DvqD
  +OZ47p/iLfWsMtVCfuxiKW7rkLy836qcQac8Hzbi38DfJ8y7UbQ==/M
EAw==/E
  /RSAPK

  I am a little thin on this concept and expecting if you could guide me
  to a library/documentation that I could utilize.



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

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


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread John Nagle

On 12/27/2010 3:05 AM, Ulrich Eckhardt wrote:

Hi!

I'm trying to solve a computational problem and of course speed and size is
important there.


Then you probably shouldn't be using CPython.


Apart from picking the right algorithm, I came across an
idea that could help speed up things and keep memory requirements down. What
I have is regions described by min and max coordinates. At first, I just
modeled these as a simple class containing two values for each axis.


There are more effective techniques for that.  In game physics
collision detection systems, it's common to use axis-ordered lists
of bounding boxes to partition objects.  This still works even when
the ranges overlap.  Look up I-Collide for a classic implementation.

 Am I looking in the wrong direction? Is there some better approach?
 Please
 don't tell me to use C, as I'm specifically interested in
 learning Python,
 I'm pretty sure I could have solved the problem quickly in
 C++ otherwise.

CPython is a naive interpreter which does dictionary
lookups for every variable and attribute access.  If you're doing
fast manipulation of linked data structures in CPython, performance
is going to suck.

Check out Shed Skin 0.7, which is a much faster Python
system.  It's limited, but for the kind of data structure work
you're doing, all the features you should need already work.

John Nagle


In a second step, I derived this class from tuple instead of object. Some
code then moved from __init__ to __new__ and some code that modified these
objects had to be changed to replace them instead. The upside to this is
that they can be used as keys in sets and dicts, which isn't the case for
mutable types[1].

What I'm now considering is to only allow a single instance of these objects
for each set of values, similar to interned strings. What I would gain is
that I could safely compare objects for identity instead of equality. What
I'm not yet sure is how much overhead that would give me and/or how to keep
it low. The idea is to store each instance in a set and after creating a new
object I would first look up an equal object in the global set and return
that instead, otherwise add the new one.

The problem I foresee is that if I define equality as identity, this lookup
when creating will never eliminate duplicates. If I only fall back to
equality comparison for non-identical objects, I would probably sacrifice
most of the gain. If I build a dict mapping between the values and the
actual objects, I would have doubled the required memory and uselessly store
the same values twice there.


Cheers!

Uli


[1] Somebody correct me if I'm wrong, but I believe I could have defined a
hashing function for the type and thus allowed its use in a set or dict,
right? However, goofing up because you accidentally modified an object and
changed its hash value is something I don't want to risk anyway.



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


Re: O'Reilly Python Certification

2010-12-28 Thread J. Altman
On 2010-12-16, Steve Holden st...@holdenweb.com wrote:
 Each lesson required you to complete a practical assignment. You submit
 these assignments for evaluation, and do not proceed to the next lesson
 until your assignment reaches a satisfactory standard. Thus, less
 experienced students will tend to have more interaction with their tutors.

 A class will typically have between twelve and sixteen lessons. There
 are also quizzes and a final practical project.

 regards
  Steve

I have a general question.

Does it seem odd that a certificate in Python, an Open Source
language; taught at O'Reilly, which offers an Open Source Programming
Certificate and is something like waist-deep in Open Source
publishing; is offered to the world at large but only (IIUC) if one
runs some version of Windows by MS?

Based on what I am given to understand from my correspondence with
OST, it seems that I *must* install an instance of Windows to take the
certificate's courses.

Not that I particularly want to bash MS, but I am running FreeBSD, and
have Python 2.x and 3.x installed; I can call either IDE; and I am
competent at the shell, I think sufficiently, to manage coding at the
shell.

Is it normal for people in CS courses at the University and/or
certificate level to learn a given language under Windows?

Or is it just me who thinks it odd that an OS like FreeBSD won't
(apparently, I stress) work with the O'Reilly Sandbox?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Hrvoje Niksic
Christian Heimes li...@cheimes.de writes:

 Also this code is going to use much more memory than an ordinary tuple
 since every instance of InternedTuple has a __dict__ attribute. This
 code works but I had to move the cache outside the class because of
 __slots__.

Wouldn't it work inside the class as well?  __slots__ applies to
instances, not to classes themselves.  In Python 3.1:

 class Foo(tuple):
...   __slots__ = ()
...   _cache = {}
... 
 Foo._cache# works as expected
{}
 Foo()._cache  # and so does this
{}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: round in 2.6 and 2.7

2010-12-28 Thread Martin v. Loewis
 Float-to-string and string-to-float conversions are correctly rounded.
 The round() function is also now correctly rounded.

 Not sure that this is correct English; I think it means that the
 round() function is now correct.
 
 Well, the correct result of the example the OP gave would be 9.9
 exactly.  But since 9.9 isn't exactly representable as a Python float,
 we necessarily get an approximation.  The language above is intended
 to convey that it's the 'correctly rounded' approximation

I see. Shouldn't it say then The round() function
gives/produces/returns correctly rounded results now, instead of saying
that
the round function *is* correctly rounded? ISTM that the round
function cannot be rounded (correctly or not):

py round(round)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: a float is required

But then, I'm not a native speaker (of English).

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


Re: Keeping track of the N largest values

2010-12-28 Thread Miki
 I'm processing a stream of N numbers and want to keep track of the K 
 largest.  There's too many numbers in the stream (i.e. N is too large) 
 to keep in memory at once.  K is small (100 would be typical).
 ...

deque can be bounded by maxsize, might fit the bill:
 from collections import deque
 d = deque([], 3)
 for i in range(10): d.append(i)
 d
deque([7, 8, 9], maxlen=3)
 


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


Re: Language Detection Library/Code

2010-12-28 Thread Katie T
On Tue, Dec 28, 2010 at 12:42 AM, Shashwat Anand
anand.shash...@gmail.com wrote:
 Regarding dictionary lookup+n-gram approach I didn't quite understand what
 you wanted to say.

Run through trigram analysis first, if it identified multiple
languages as being matches within the error margin then split the text
into words, and look up each word in the respective dictionaries to
get a second opinion.

Katie
-- 
CoderStack
http://www.coderstack.co.uk/python-jobs
The Software Developer Job Board
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacing Greenlets with Threads or Processes

2010-12-28 Thread Nathanael Abbotts
On Tuesday, December 28, 2010 5:04:48 PM UTC, Emile van Sebille wrote:
 On 12/28/2010 8:07 AM Nathanael Abbotts said...
  That thread seems to deal with mixing them. I want to replace them
  completely - is that possible (with either threads or processes)?
 
 Are you working with pycsp?  the info at 
 http://code.google.com/p/pycsp/wiki/Getting_Started_With_PyCSP says:
 
 The API is implemented in four versions: Threads, processes, greenlets 
 and net. All implementations share an almost identical API making it 
 trivial to switch from one implementation to another. 
 
 Emile

Unfortunately not. I wish I was! That sounds brilliant. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: round in 2.6 and 2.7

2010-12-28 Thread Terry Reedy

On 12/28/2010 4:47 PM, Martin v. Loewis wrote:

Float-to-string and string-to-float conversions are correctly rounded.
The round() function is also now correctly rounded.


The second line was written to be parallel to the first, but the first 
is slightly ambiguous in that 'conversions' can refer to either process 
(not rounded, correctly or otherwise ;-) or result. However the 
parallelism does not does as 'round() function' is the instrument of the 
process and definitly not the result.


...


I see. Shouldn't it say then The round() function
gives/produces/returns correctly rounded results now, instead of saying
that
the round function *is* correctly rounded? ISTM that the round
function cannot be rounded (correctly or not):


In 2.7 Float-to-string and string-to-float conversion results are 
correctly rounded, as are the results of the round() function.


--
Terry Jan Reedy

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


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Christian Heimes
Am 28.12.2010 21:16, schrieb Hrvoje Niksic:
 Christian Heimes li...@cheimes.de writes:
 
 Also this code is going to use much more memory than an ordinary tuple
 since every instance of InternedTuple has a __dict__ attribute. This
 code works but I had to move the cache outside the class because of
 __slots__.
 
 Wouldn't it work inside the class as well?  __slots__ applies to
 instances, not to classes themselves.  In Python 3.1:

You are right as long as you don't try to rebind the variable. I
recalled that class attributes of classes with __slots__ behave slightly
different than ordinary classes. For example you can't have a writeable
slot and class default values at the same time.

 class Example2(object):
... __slots__ = ()
... _cache = {}
...
 Example2()._cache
{}
 Example2()._cache = {}
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'Example2' object attribute '_cache' is read-only

Christian

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


Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Rami Chowdhury
On Wed, Dec 29, 2010 at 00:45, Christian Heimes li...@cheimes.de wrote:
 Am 28.12.2010 21:16, schrieb Hrvoje Niksic:
 Christian Heimes li...@cheimes.de writes:

 Also this code is going to use much more memory than an ordinary tuple
 since every instance of InternedTuple has a __dict__ attribute. This
 code works but I had to move the cache outside the class because of
 __slots__.

 Wouldn't it work inside the class as well?  __slots__ applies to
 instances, not to classes themselves.  In Python 3.1:

 You are right as long as you don't try to rebind the variable. I
 recalled that class attributes of classes with __slots__ behave slightly
 different than ordinary classes. For example you can't have a writeable
 slot and class default values at the same time.

 class Example2(object):
 ...     __slots__ = ()
 ...     _cache = {}
 ...
 Example2()._cache
 {}
 Example2()._cache = {}
 Traceback (most recent call last):
  File stdin, line 1, in module
 AttributeError: 'Example2' object attribute '_cache' is read-only

Forgive me if I'm misunderstanding, but if you want to cache instances
of a class, surely

 Example2()._cache = {}

would defeat the purpose, at least for that instance of Example2? The
slot seems writeable enough, after all

 Example2()._cache['foo'] = 'bar'

seems to work?


-- 
Rami Chowdhury
Never assume malice when stupidity will suffice. -- Hanlon's Razor
+44-7581-430-517 / +1-408-597-7068 / +88-0189-245544
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic list name from a string

2010-12-28 Thread DevPlayer

# dynamic_named_obj.py
# comp.lang.python
# 2010-12 Dec-28
# Topic: Dynamic list name from a string Options
# attempts to answer OP's question
# DevPlayer  - not a solution I'd use


# TO Original Poster OP:

# Start from the bottom OPTION, the one you requested.
# Work your way up and see how it gets simpler and
# simpler to do what you want. Dynamically named
# references start to look pointless.

# I hope I addressed your question and hopefully shown
# you the right direction and right reasons to avoid
# using dynamically made named references.
# But I could be wrong in your case.


import time

class DataStore(object):
A namespace similar to a module global scope.

#def concatenate( one, two):
#Function to concatonate two lists.
#return list( one + two)

# =
class Animal(object):
A base class for no real reason.
def __init__(self, name):
self.name = name
self.date = time.clock()

# -
class Bear(Animal):
def __init__(self, name):
super(Bear, self).__init__(name)

class BearCub(Bear):
def __init__(self, name):
super(BearCub, self).__init__(name)

# -
class Doe(Animal):
def __init__(self, name):
super(Doe, self).__init__(name)

class Fawn(Doe):
def __init__(self, name):
super(Fawn, self).__init__(name)


# An alternate namespace instead of module global
ns = DataStore()

OPTION = BETTER YET

if OPTION == BETTER YET:
# don't name your lists, just make the global_list and use it
# no intermediary lists needed really.

ns.Animals = [
# -- 1st set of classes
Bear(bob),
Bear(bill),
BearCub(obo),
BearCub(Bill jr.),

# -- 2nd set of classes
Doe(DoeADear),
Doe(AFemaleDear),
Fawn(Ray),
Fawn(Adropof),
]

for animal in ns.Animals:
kind = animal.__class__.__name__
name = animal.name
date = animal.date
print kind, name, date

# make a sorted, by date, list of bears
old_bears = [obj for obj in ns.Animals if type(obj) is Bear]
old_bears.sort(None, key=lambda animal: animal.date)
ns.bears = old_bears

# or sort all animals by date
animals = [obj for obj in ns.Animals]
animals.sort(None, key=lambda animal: animal.date)

# then get just bears
bears = [obj for obj in animals if type(obj) is Bear]


elif OPTION == BETTER:
# don't name your lists, trust in checking if objects have
attributes
# that matter

ns.Animals = {
# -- 1st set of classes
bob: Bear(bob),
Bill: Bear(bill),
obo: BearCub(obo),
Bill jr.: BearCub(Bill jr.),

# -- 2nd set of classes
DoeADear: Doe(DoeADear),
AFemaleDear: Doe(AFemaleDear),
Ray: Fawn(Ray),
Adropof: Fawn(Adropof),
}

print ns.Animals['bob'].date

# make a sorted list of objects based on an attribute -like date
# sort by date for just bears
# http://wiki.python.org/moin/HowTo/Sorting
# look at Operator Module Functions too

# make a sorted, by date, list of bears
old_bears = [obj for obj in ns.Animals.values() if type(obj) is
Bear]
old_bears.sort(None, key=lambda animal: animal.date)
ns.bears = old_bears

# or sort all animals by date
animals = [obj for obj in ns.Animals.values()]
animals.sort(None, key=lambda animal: animal.date)

# then get just bears
bears = [obj for obj in animals if type(obj) is Bear]


elif OPTION == SOSO1:
# alternative to dynamically named references (object attributes)
# Each item in global_dict is a sub dict

ns.Animals = {}
# -- 1st set of classes
ns.Animals[ Bear ] =  {bob: Bear(bob), Bill: Bear(Bill)}
ns.Animals[ BearCub ] = {obo: BearCub(obo), Bill jr.:
Bearcub(Bill jr.)}
# -- 2nd set of classes
ns.Animals[ Doe ] = {DoeADear: Doe(DoeADear), AFemaleDear:
Doe(AFemaleDear)}
ns.Animals[ Fawn ] = {Ray: Fawn(Ray), Adropof:
Fawn(Adropof)}

print ns.Animals[Bear][bob].date
print ns.Animals[BearCub][Bill jr.].date

elif OPTION == SOSO2:
# alternative to dynamically named references (object attributes)
# don't use names at all -
# Each item in a dict is a list of objects
# use class itself as key (not class name)

ns.Animals = {}
# -- 1st set of classes
ns.Animals[ Bear ] =  [Bear(bob), Bear(Bill)]
ns.Animals[ BearCub ] = [BearCub(obo), Bearcub(Bill jr.)]
# -- 2nd set of classes
ns.Animals[ Doe ] = [Doe(DoeADear), Doe(AFemaleDear)]
ns.Animals[ Fawn ] = [Fawn(Ray), Fawn(Adropof)]

print ns.Animals[Bear][0].date

elif OPTION == SOSO3:
# alternative to dynamically named references (object attributes)
# use class __name__ as key

ns.Animals = {}
# -- 1st set of classes
ns.Animals[ Bear.__name__ ] =  [Bear(bob), Bear(Bill)]
ns.Animals[ BearCub.__name__ ] = 

[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

 At this point a feature change seems unlikely,

Amaury, it is not too late to fix anything that's broken.  New features are 
out, but we are free to fix anything hosed this badly.

--

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread Amaury Forgeot d'Arc

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

But there are probably working usages with unicode strings out there. For 
example, I've seen code like struct.pack('6sHHBBB', 'GIF87a', ...)
Do you suggest to make this 3.1 code stop working in 3.2?

In any case, the 'c' format should probably be changed as well.

--

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread STINNER Victor

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

Amaury At this point a feature change seems unlikely,
Amaury but it's not too late to emit a DeprecationWarning.

I prefer to break the API today than having to maintain a broken API for
10 or 20 years :-)  And we have a very small user base using Python 3,
it's easier to change it now, than in the next release.

Amaury But there are probably working usages with unicode strings out
Amaury there. For example, I've seen code like
Amaury struct.pack('6sHHBBB','GIF87a', ...)
Amaury Do you suggest to make this 3.1 code stop working in 3.2?

Yes. As I wrote in my previous message, this can be changed to
struct.pack('6sHHBBB', b'GIF87a', ...), which works on 3.1 and 3.2
(patched).

--

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



[issue10773] Building C and C++ Extensions on Windows documentation shows 2.x way of initializing module

2010-12-28 Thread Georg Brandl

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

Thanks, fixed in r87524.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue1823] Possible to set invalid Content-Transfer-Encoding on email.mime.multipart.MIMEMultipart

2010-12-28 Thread Georg Brandl

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

Fine with me to fix this API during beta.

--

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



[issue10738] webbrowser.py bug with Opera on Linux

2010-12-28 Thread Georg Brandl

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

By all means.

--

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



[issue10766] optparse uses %s in gettext calls

2010-12-28 Thread Georg Brandl

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

Hmm, argparse is new, so that is a different story.  Not so sure about 
optparse, so I would not put this into 3.2.

--

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



[issue9824] SimpleCookie should escape commas and semi-colons

2010-12-28 Thread Georg Brandl

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

Looks good.

--

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



[issue10679] make altinstall may clobber OS provided scripts

2010-12-28 Thread Georg Brandl

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

Committed in r87525.

--
resolution:  - fixed
status: open - closed

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



[issue2775] Implement PEP 3108

2010-12-28 Thread Georg Brandl

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

Alas, too late for 3.2 now.

--
versions: +Python 3.3 -Python 3.2

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



[issue10784] os.getpriority() and os.setpriority()

2010-12-28 Thread Georg Brandl

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

Looks good.  Would there be a point in making any of the parameters optional?

--
nosy: +georg.brandl

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread Georg Brandl

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

I agree this automatic conversion is broken and should be fixed.  Not sure if 
emitting a DeprecationWarning now and fixing it 18 months later is the right 
thing, especially since DeprecationWarnings are now silent.
As Victor says, the incompatibility is explicit, and the fix is simple and 
fully backwards compatible, while the current behavior will cause nasty 
intermittent surprises.

--
nosy: +georg.brandl

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



[issue10784] os.getpriority() and os.setpriority()

2010-12-28 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Looks good.  Would there be a point in making any of the parameters optional?

No. The API should look exactly as it does on the system level. Anybody
calling these functions should know how call them.

--

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



[issue10777] xml.etree.register_namespace dictionary changed size during iteration

2010-12-28 Thread Georg Brandl

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

Thanks, this should be fixed in r87526.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10768] Bug in scrolledtext

2010-12-28 Thread Georg Brandl

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

Fixed in r87527.  Terry, the reason why calling example() interactively failed 
is the strange way __doc__ is imported -- it is None in your case and that 
causes the Tkinter type error.  I fixed this as well.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10767] Lib/test/crashers/README is out of date

2010-12-28 Thread Georg Brandl

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

Fixed in r87530.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10742] memoryview.readonly attribute is not documented

2010-12-28 Thread Georg Brandl

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

Added in r87531.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10781] minidom Node.writexml method doesn't manage encoding parameter correctly

2010-12-28 Thread Georg Brandl

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

Fixed in r87532.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10708] Misc/porting should be folded in to the development FAQ

2010-12-28 Thread Georg Brandl

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

Same for Misc/SpecialBuilds.

--
nosy: +georg.brandl

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



[issue6785] IncompleteRead / BadStatus when parsing http://peakoil.mobi

2010-12-28 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
status: pending - closed

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



[issue10739] Subprocess behavior on Windows

2010-12-28 Thread Georg Brandl

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

I agree that this belongs in the makefile docs.  Fixed in r87535.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10670] Provide search scope limits

2010-12-28 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
Removed message: http://bugs.python.org/msg123928

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



[issue10609] dbm documentation example doesn't work (iteritems())

2010-12-28 Thread Georg Brandl

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

Fixed in r87536.

--
resolution:  - fixed
status: open - closed

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread Amaury Forgeot d'Arc

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

Since the Release Manager agrees with the change, I withdraw my objection.

I have three remarks to the patch: 

- Some examples in the documentation should be fixed:
http://docs.python.org/dev/py3k/library/struct.html#examples
 pack('ci', '*', 0x12131415)
will now raise an exception.

- the message argument for 's' must be a bytes looks a bit weird. a bytes 
object seems better.

- the 'p' format (Pascal String) should be changed as well. This is the last 
call to _PyUnicode_AsDefaultEncodedString() in this file...

--

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



[issue6210] Exception Chaining missing method for suppressing context

2010-12-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 I'm not sure how that's going to help as I don't want my library code
 to be responsible for printing out exceptions, I just want them to
 print reasonably -- and it seems very unreasonable to have the
 exception I'm converting /from/ show up in the traceback.

I don't know if it's unreasonable. In some cases it can definitely help.
Besides, if you are writing library code (as opposed to application
code), you shouldn't care at all how tracebacks are displayed, should
you?

--

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread David Beazley

David Beazley d...@dabeaz.com added the comment:

As a user of Python 3, I would like echo Victor's comment about fixing the API 
right now as opposed to having to deal with it later.  I can only speak for 
myself, but I would guess that anyone using Python 3 already understands that 
it's bleeding edge and that the bytes/strings distinction is really important.  
If fixing this breaks some third party libraries, I say good--they shouldn't 
have been blindly passing Unicode into struct in the first place.  Better to 
deal with it now when the number of users is relatively small.

--

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread STINNER Victor

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

Fixed by r87537. Thanks Amaury for your review!

I also removed some ugly (implicit) conversions from test_struct.

--
resolution:  - fixed
status: open - closed

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread Georg Brandl

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

Thanks, Victor!

--

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



[issue10783] struct.pack() and Unicode strings

2010-12-28 Thread David Beazley

David Beazley d...@dabeaz.com added the comment:

Thanks everyone for looking at this!

--

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



[issue10348] multiprocessing: use SysV semaphores on FreeBSD

2010-12-28 Thread STINNER Victor

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

Informations about SysV semaphores:
 - functions: semget(), semop(), semctl(), ftok()
 - http://perldoc.perl.org/IPC/SysV.html
 - http://beej.us/guide/bgipc/output/html/multipage/semaphores.html

--

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



[issue10348] multiprocessing: use SysV semaphores on FreeBSD

2010-12-28 Thread STINNER Victor

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

Examples of programs using SysV semaphores:

http://firebird.cvs.sourceforge.net/viewvc/firebird/firebird2/src/jrd/isc_sync.cpp?revision=HEADview=markup
(Firebird, search #ifdef USE_SYS5SEMAPHORE sections)

https://github.com/mono/mono/blob/master/mono/io-layer/shared.c#L501
(Mono)

--

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



[issue9333] Expose a way to enable os.symlink on Windows

2010-12-28 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

Thanks for having a look.
Checked in with the suggested changes to r87539.

--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue10759] HTMLParser.unescape() fails on HTML entities with incorrect syntax (e.g. #hearts; )

2010-12-28 Thread Senthil Kumaran

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

Fixed this in r87542 in (py3k). unescape is undocumented helper method, so no 
docs are added.

There was already an issue ( Issue6662) on malformed charref handling and it is 
fixed.

--
resolution:  - fixed
stage: patch review - committed/rejected

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



[issue10759] HTMLParser.unescape() fails on HTML entities with incorrect syntax (e.g. #hearts; )

2010-12-28 Thread Senthil Kumaran

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

r87544 (release27-maint) and r87545 (release31-maint).

--
status: open - closed

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



[issue10254] unicodedata.normalize('NFC', s) regression

2010-12-28 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

Committed backports:

r87540 (3.1)
r87541 (2.7)
r87546 (2.6)

--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed
versions: +Python 3.2

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



[issue10786] unittest.TextTextRunner does not respect redirected stderr

2010-12-28 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
keywords: +easy
nosy: +michael.foord
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6

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



[issue10786] unittest.TextTextRunner does not respect redirected stderr

2010-12-28 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

TextTestRunner is initialised with a stream to output messages on that defaults 
to sys.stderr. The correct way to redirect messages is to construct it with a 
different stream. 

If you want a redirectable stream then construct the runner with a stream that 
delegates operations to a 'backend stream' but allows you to redirect it.

Fixing TextTestRunner to dynamically lookup up sys.stderr would not be 
compatible with systems that redirect sys.stderr but *don't* expect this to 
prevent test run information from being output.

I suggest closing as wontfix.

--
assignee:  - michael.foord

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



[issue10786] unittest.TextTextRunner does not respect redirected stderr

2010-12-28 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Actually I can't see a good reason why not to just lookup the *current* 
sys.stderr at instantiation time instead of binding at import time as is the 
current behaviour.

Patch with tests will make it more likely that this change goes in sooner 
rather than later.

--
stage:  - needs patch

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



[issue10787] [random.gammavariate] Add the expression of the distribution in a comprehensive form for random.gammavariate

2010-12-28 Thread David Kremer

New submission from David Kremer david.kremer...@gmail.com:

Could you please add the exact form of the distribution, because it's rather 
confusing in the current form.

In this url, the role of k and theta is precised with a formula :
[http://tinyurl.com/24jxfrk]*

It seems that in 
[http://docs.python.org/library/random.html#random.gammavariate] , alpha is 
playing the role of k and beta is playing the role of theta.

But it's still not clear, because one can confuse beta with 1/beta and vice et 
versa, like there is two usual representation for the gamma distribution 
[http://en.wikipedia.org/wiki/Gamma_distribution]

[http://docs.scipy.org/doc/numpy-1.5.x/reference/generated/numpy.random.gamma.html#numpy.random.gamma]*

Please update the documentation to avoid this ambiguity.

I provide an indicative patch which is updating the doc string in random.py

--
assignee: d...@python
components: Documentation
files: patch_documentation_random.py.diff
keywords: patch
messages: 124803
nosy: David.Kremer, d...@python
priority: normal
severity: normal
status: open
title: [random.gammavariate] Add the expression of the distribution in a 
comprehensive form for random.gammavariate
versions: Python 2.7
Added file: http://bugs.python.org/file20181/patch_documentation_random.py.diff

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



[issue9333] Expose a way to enable os.symlink on Windows

2010-12-28 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

Checked in a small doc update in r87547. Removes the part about os.symlink not 
being available, and mentions the OSError.

--

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



[issue6027] test_xmlrpc_net fails when the ISP returns 302 Found

2010-12-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

+1 on simply removing this test. *.xmlrpc.com look(s) totally unmaintained.

--
nosy: +pitrou

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



[issue1772833] -q (quiet) option for python interpreter

2010-12-28 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Is it on purpose that no sys.flags attribute has been added for quiet?

--
nosy: +eric.araujo
versions: +Python 3.2 -Python 2.6

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



[issue10764] sysconfig and alternative implementations

2010-12-28 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I suggest this bug is superseded by #9878.

--

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



[issue10788] test_logging failure

2010-12-28 Thread Antoine Pitrou

New submission from Antoine Pitrou pit...@free.fr:

This on the Windows Server 2008 buildbot:

(http://www.python.org/dev/buildbot/all/builders/AMD64%20Windows%20Server%202008%203.x)

Re-running test 'test_logging' in verbose mode
test_flat (test.test_logging.BuiltinLevelsTest) ... FAIL
test_nested_explicit (test.test_logging.BuiltinLevelsTest) ... FAIL
test_nested_inherited (test.test_logging.BuiltinLevelsTest) ... FAIL
test_nested_with_virtual_parent (test.test_logging.BuiltinLevelsTest) ... FAIL
test_callable_filter (test.test_logging.BasicFilterTest) ... FAIL
test_filter (test.test_logging.BasicFilterTest) ... FAIL
test_handler_filter (test.test_logging.CustomLevelsAndFiltersTest) ... FAIL
test_logger_filter (test.test_logging.CustomLevelsAndFiltersTest) ... FAIL
test_specific_filters (test.test_logging.CustomLevelsAndFiltersTest) ... FAIL
test_flush (test.test_logging.MemoryHandlerTest) ... FAIL
test_config0_ok (test.test_logging.ConfigFileTest) ... FAIL
test_config1_ok (test.test_logging.ConfigFileTest) ... FAIL
test_config2_failure (test.test_logging.ConfigFileTest) ... FAIL
test_config3_failure (test.test_logging.ConfigFileTest) ... FAIL
test_config4_ok (test.test_logging.ConfigFileTest) ... FAIL
test_config5_ok (test.test_logging.ConfigFileTest) ... FAIL
test_config6_ok (test.test_logging.ConfigFileTest) ... FAIL
test_output (test.test_logging.SocketHandlerTest) ... FAIL
test_persistent_loggers (test.test_logging.MemoryTest) ... FAIL
test_encoding_cyrillic_unicode (test.test_logging.EncodingTest) ... FAIL
test_encoding_plain_file (test.test_logging.EncodingTest) ... FAIL
test_warnings (test.test_logging.WarningsTest) ... FAIL
test_config0_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config11_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config12_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config13_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config1_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config2_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config2a_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config2b_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config3_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config4_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config4a_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config5_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config6_failure (test.test_logging.ConfigDictTest) ... FAIL
test_config7_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config_10_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config_8_ok (test.test_logging.ConfigDictTest) ... FAIL
test_config_9_ok (test.test_logging.ConfigDictTest) ... FAIL
test_listen_config_10_ok (test.test_logging.ConfigDictTest) ... FAIL
test_listen_config_1_ok (test.test_logging.ConfigDictTest) ... FAIL
test_manager_loggerclass (test.test_logging.ManagerTest) ... FAIL
test_braces (test.test_logging.FormatterTest) ... ok
test_dollars (test.test_logging.FormatterTest) ... ok
test_percent (test.test_logging.FormatterTest) ... ok
test_logrecord_class (test.test_logging.LogRecordFactoryTest) ... FAIL
test_child_loggers (test.test_logging.ChildLoggerTest) ... FAIL
test_queue_handler (test.test_logging.QueueHandlerTest) ... FAIL
test_file_created (test.test_logging.RotatingFileHandlerTest) ... FAIL
test_rollover_filenames (test.test_logging.RotatingFileHandlerTest) ... FAIL
test_should_not_rollover (test.test_logging.RotatingFileHandlerTest) ... FAIL
test_should_rollover (test.test_logging.RotatingFileHandlerTest) ... FAIL
test_last_resort (test.test_logging.LastResortTest) ... FAIL

==
FAIL: test_flat (test.test_logging.BuiltinLevelsTest)
--
Traceback (most recent call last):
  File 
c:\buildslave-py3k\3.x.curtin-win2008-amd64\build\lib\test\test_logging.py, 
line 93, in setUp
self.assertFalse(self.logger1.hasHandlers())
AssertionError: True is not false

==
FAIL: test_nested_explicit (test.test_logging.BuiltinLevelsTest)
--
Traceback (most recent call last):
  File 
c:\buildslave-py3k\3.x.curtin-win2008-amd64\build\lib\test\test_logging.py, 
line 93, in setUp
self.assertFalse(self.logger1.hasHandlers())
AssertionError: True is not false

==
FAIL: test_nested_inherited (test.test_logging.BuiltinLevelsTest)
--
Traceback (most recent call last):
  File 
c:\buildslave-py3k\3.x.curtin-win2008-amd64\build\lib\test\test_logging.py, 
line 93, in setUp
self.assertFalse(self.logger1.hasHandlers())
AssertionError: True is not false


[issue10774] test_logging leaves temp files

2010-12-28 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Great, thanks!

--

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



[issue10787] [random.gammavariate] Add the expression of the distribution in a comprehensive form for random.gammavariate

2010-12-28 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +rhettinger

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



[issue10764] sysconfig and alternative implementations

2010-12-28 Thread Amaury Forgeot d'Arc

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

Indeed

--
resolution:  - duplicate
status: open - closed
superseder:  - Avoid parsing pyconfig.h and Makefile by autogenerating 
extension module

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



[issue10764] sysconfig and alternative implementations

2010-12-28 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

No, issue 9878 can't be implemented for Python 2.7 whereas the issues other 
implementations have with sysconfig *could* still be resolved in 2.7 as a 
bugfix. (Specifically for IronPython on Mac OS X it would mean not assuming 
that being on a posix platform means there is a Makefile.)

--
status: closed - open

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



[issue1772833] -q (quiet) option for python interpreter

2010-12-28 Thread Georg Brandl

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

No, pure ignorance -- should be fixed in r87549.

--

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



[issue6027] test_xmlrpc_net fails when the ISP returns 302 Found

2010-12-28 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

See also issue 6533.

--

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



[issue9824] SimpleCookie should escape commas and semi-colons

2010-12-28 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Committed to py3k in r87550.  Since the only application that would trip up 
would be one not using SimpleCookie to read SimpleCookie generated cookies 
*and* that doesn't implement unescaping (in which case it wasn't really 
handling SimpleCookie cookies, was it?), I went ahead and backported it to 3.1 
in r87551 and 2.7 in r87552.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue10738] webbrowser.py bug with Opera on Linux

2010-12-28 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

3.2,3.1,2.7: r87553, r87554, r87555

--
assignee:  - terry.reedy
components: +Library (Lib)
resolution:  - fixed
status: open - closed
type:  - behavior

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



[issue2636] Regexp 2.7 (modifications to current re 2.2.2)

2010-12-28 Thread Matthew Barnett

Matthew Barnett pyt...@mrabarnett.plus.com added the comment:

issue2636-20101228a.zip is a new version of the regex module.

It now compiles the pattern quickly.

--
Added file: http://bugs.python.org/file20182/issue2636-20101228a.zip

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



  1   2   >