Plumber, an alternative to mixin-based subclassing

2011-02-05 Thread Florian Friesdorf
An alternative to mixin-based subclassing:

http://pypi.python.org/pypi/plumber

-- 
Florian Friesdorf f...@chaoflow.net
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: f...@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: circuits-1.3.3 (Asynchronous Component-based Application Framework)

2011-02-05 Thread James Mills
Hi,

I'm pleased to announce the release of circuits-1.3.3

What is circuits ?
==

circuits is a Lightweight Event driven and Asynchronous Application
Framework for the Python Programming Language with a strong
Component Architecture. circuits also includes a lightweight,
high performance and scalable HTTP/WSGI web server
(with some similar features to CherryPy) as well as various I/O
and Networking components.


What's new ?


- New circuits.web.apps namespace with two mini-apps included
  - MemoryMonitor (a port of Dowser to debug memory leaks in your
circuits.web app)
  - WebConsole (a port of httprepl by the same author of Dowser to
give you an interactive
console in your circuits.web app)
- circuits.core.debugger: Debugger now takes an optional keyword argument chop
  to chop long lines when printing to sys.stderr
- A new jsonserializer.py example in examples/web/
- Several bug-fixes and other improvements.


Get it from PyPi: http://pypi.python.org/pypi/circuits/1.3.3

Read the documentation: http://packages.python.org/circuits

See the examples: https://bitbucket.org/prologic/circuits/src/1.3.3/examples/


Please give us feedback on the circuits-users groups
http://groups.google.com/group/circuits-users or on the
#circuits IRC Channel on the FreeNode IRC Network.

cheers
James


-- 
-- James Mills
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


LAST CHANCE: OSCON Call for Proposals (deadline 2/7)

2011-02-05 Thread Aahz
DEADLINE Monday February 7

OSCON (O'Reilly Open Source Convention), the premier Open Source
gathering, will be held in Portland, OR July 25-29.  We're looking for
people to deliver tutorials and shorter presentations.

http://www.oscon.com/oscon2011
http://www.oscon.com/oscon2011/public/cfp/144

Hope to see you there!
--
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

All problems in computer science can be solved by another level of 
indirection.  --Butler Lampson
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: python crash problem

2011-02-05 Thread John Machin
On Feb 3, 8:21 am, Terry Reedy tjre...@udel.edu wrote:
 On 2/2/2011 2:19 PM, Yelena wrote:

.

 When having a problem with a 3rd party module, not part of the stdlib,
 you should give a source.
    http://sourceforge.net/projects/dbfpy/
 This appears to be a compiled extension. Nearly always, when Python
 crashes running such, it is a problem with the extension. So you
 probably need to direct your question to the author or a project mailing
 list if there is one.

It has always appeared to me to be a pure-Python package. There are
no .c or .pyx files in the latest source (.tgz) distribution. The
Windows installer installs only files whose extensions match
py[co]?.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-05 Thread flebber
On Feb 5, 10:24 am, Stephen Hansen me+list/pyt...@ixokai.io wrote:
 On 2/4/11 3:01 PM, rantingrick wrote:

  Put your money where your mouth is.

  ditto!

 I thought as much.

 My money is where my mouth is: but that is not IDLE, as I have no use
 for it and no interest in it at all. The status quo with regards to IDLE
 is satisfactory to me.

 You're the one talking so much about how it needs to improve. So do it.
 Get started. Now.

 But you'll just find another excuse to rant on like you always do, and
 be basically useless.

 Me, I _have_ contributed patches: I have released actual code that
 actual people have found actually useful. I do run two build slaves and
 proactively try to assist in resolving issues that come up with Python's
 testing (usually: ouch, there's a lot of red at the moment, must get
 cracking) and stability.

 So, yeah. You're the hypocrite here, man.

 --

    Stephen Hansen
    ... Also: Ixokai
    ... Mail: me+list/python (AT) ixokai (DOT) io
    ... Blog:http://meh.ixokai.io/

  signature.asc
  1KViewDownload

Idlefork isn't dead to rick! just pining for the alps!
-- 
http://mail.python.org/mailman/listinfo/python-list


psd estimation no matplotlib

2011-02-05 Thread Jack Yu
Hi all,
Is there a function psd() for estimating power spectral density that is not
dependent on the importing of matplotlib or pylab, like there is
numpy.linalg.svd() to pylab.svd().  I would like to run some codes which
estimate psd on the computing nodes on a cluster, but the system
administrator says that it is impractical to install matplotlib on all of
them, because it requires X window, which takes up a lot of memory, which
the computing nodes do not have.  Thanks for any help in advance.

Cheers,

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


Unable to register com component built with python2.7

2011-02-05 Thread sniffer
Hi all,
I have built a com component using python2.7 on win 7 but the
component refuses to register ,every time i try to register it says
the specified module could not be found unable to load python.dll ,i
also tried building the same com server with python2.7 again on a win-
xp system  but to no avail ,i even tried building and registring the
com server after removing all imports and just leaving 1 function
which returns nothing but the string hello world any pointers would
be great


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


Re: itertools.groupby usage to get structured data

2011-02-05 Thread Slafs
On 5 Lut, 05:58, Paul Rubin no.em...@nospam.invalid wrote:
 Slafs slaf...@gmail.com writes:
  What i want to have is:
  a big nested dictionary with 'g1' values as 1st level keys and a
  dictionary of aggregates and subgroups in it

  I was looking for a solution that would let me do that kind of
  grouping with variable lists of 2) and 3) i.e. having also 'g3' as
  grouping element so the 'g2' dicts could also have their own
  subgroup and be even more nested then.
  I was trying something with itertools.groupby and updating nested
  dicts, but as i was writing the code it started to feel too verbose to
  me :/

  Do You have any hints maybe? because i'm kind of stucked :/

 I'm not sure I understood the problem and it would help if you gave
 sample data with the deeper nesting that you describe.  But the
 following messy code matches the sample that you did give:

     from pprint import pprint
     from itertools import groupby

     x1 = [ { 'g1' : 1, 'g2' : 8, 's_v1' : 5.0, 's_v2' : 3.5 },
               { 'g1' : 1, 'g2' : 9, 's_v1' : 2.0, 's_v2' : 3.0 },
               { 'g1' : 2, 'g2' : 8, 's_v1' : 6.0, 's_v2' : 8.0}
               ]
     x2 = ['g1', 'g2']
     x3 = ['s_v1', 's_v2']

     def agg(xdata, group_keys, agg_keys):
         if not group_keys:
             return {}
         k0, ks = group_keys[0], group_keys[1:]
         r = {}
         def gk(d): return d[k0]
         for k, g in groupby(sorted(xdata, key=gk), gk):
             gs = list(g)
             aggs = dict((ak,sum(d[ak] for d in gs)) for ak in agg_keys)
             r[k] = aggs
             if ks:
                 r[k][ks[0]] = agg(gs,group_keys[1:], agg_keys)
         return r

     pprint (agg(x1, x2, x3))

Thank you both Steven and Paul for your replies.

@Steven:
 Perhaps you should consider backing up and staring from somewhere else
 with different input data, or changing the requirements. Just a thought.

I think it's not the issue. The data as you noticed i well structured
(as a table for instance) and I don't think I can go better than that.

 I don't think groupby is the tool you want. It groups *consecutive* items
 in sequences:

I was using groupby just like in Paul's code.

@Paul:
OMG. I think this is it! (getting my jaw from the floor...)
The funny part is that I was kind of close to this solution ;). I was
considering the use of recursion for this.

Thank You so much!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use the Source Luke

2011-02-05 Thread Daniel Fetchinson
 For the Python world though, there does seem
 to have been a change.  A decade ago in this newsgroup, there were
 frequent references to standard library source.  I don't see that
 much anymore.

Popularity has a price. A decade ago only hackers were exposed to
python who are happy to chat about the source code but these days
average computer users (my grandma) frequently come across python and
ask questions from a user perspective.

So I'd think your observation is correct that the ratio of source
related posts to non-source related posts on this list went down but
the reason is not because the total number of source related questions
decreased but because the total number of non-source related questions
increased.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create classes at runtnime

2011-02-05 Thread Marc Aymerich
Thank you all for the answers!

I'll try to give you the context in which I need to generate classes
like this.

I'm developing a reusable control panel for an ISP. I have several
modules (VirtualUser, SystemUser, VPS, VirtualHost, ...) and they all
share the fact that you can have limits on resource consumption. for
example.

VPS: has limits on swap, memory, cpu and disk.
SystemUser: has limits on disk and traffic.

As all modules share this property of being limited I have decided to
split the limit functionality in a separate module (called resources).
Resources are associated dinamically with (vps, systemuser ...)
through a Monitor class. So it's up to you decide what limits you are
interested to put in the VPS or in the SystemUser ...

So when you attach the disk limit to SystemUser model is necessary
to create a web form for SystemUser a bit different than if you decide
to have disk and traffic limits. That is what my posted code is
supposed to do.

Do you think that I am on the wrong way designing the control panel
like this?

Btw, I've seen several interesting ideas to create the class
dinamically (with class factorys, MetaClass, dictionaries ..), but I
have not yet clear whether this will be usefull for create the
__init__ function at runtime too. Any clue on this?

Many, many thanks!! :)
Marc

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


Re: Create classes at runtnime

2011-02-05 Thread Peter Otten
Carl Banks wrote:

 On Feb 4, 1:32 pm, Peter Otten __pete...@web.de wrote:
 Marc Aymerich wrote:
  I need to create a pretty complex class at runtime. something like
  this one:

 I have a hunch that you've never heard the famous Kernighan quote:

 Everyone knows that debugging is twice as hard as writing a program in
 the first place. So if you're as clever as you can be when you write it,
 how will you ever debug it?

 Or that if you've heard it you don't heed it.
 
 [snip]
 
  What is your recommendation?

 Find something that is simple and robust. Something else.
 
 
 I've done things like this before, and I would say the Kernigan quote
 is not appropriate here, and the implication that isn't not simple and
 robust is incorrect.  It's repetitive code like the OP posted that's
 complex and flimsy.  Repetitive code is the exact opposite of the DRY
 principle, and there's a reason DRY is one of the most often cited
 principles here.
 
 Using advanced techniques like metaclasses to exploit the similarity
 to reduce or eliminate the repetitiveness can, if done well, simplify
 code.  By a lot.
 
 Advanced is not the same thing as complex.
 
 
 In this particular case I'd say the recommendation to do something
 else is a good one, but it's not true in general.

The trouble with metaclasses is that they are not completely transparent.
Instead of two levels (class and instance) you have to consider three. 
Steven D'Aprano has involuntarily given an example of what may go wrong.

Marc has asked another question with a problem that could be attacked with a 
metaclass before. Had he been comfortable with metaclasses by now we 
wouldn't have seen the above post. So he is operating at the limits of his 
current understanding of Python in an area where it is not unlikely that 
he'll run into unexpected side effects of the django database wrapper. 

I think a reminder that he has to debug the whole thing is in order ;)

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


Re: itertools.groupby usage to get structured data

2011-02-05 Thread Peter Otten
Slafs wrote:

 Hi there!
 
 I'm having trouble to wrap my brain around this kind of problem:
 
 What I have :
   1) list of dicts
   2) list of keys that i would like to be my grouping arguments of
 elements from 1)
   3) list of keys that i would like do aggregation on the elements
 of 1) with some function e.g. sum
 
 For instance i got:
 1) [ { 'g1' : 1, 'g2' : 8, 's_v1' : 5.0, 's_v2' : 3.5 },
   { 'g1' : 1, 'g2' : 9, 's_v1' : 2.0, 's_v2' : 3.0 },
   {'g1' : 2, 'g2' : 8, 's_v1' : 6.0, 's_v2' : 8.0}, ... ]
 2) ['g1', 'g2']
 3) ['s_v1', 's_v2']
 
 To be precise 1) is a result of a values_list method from a QuerySet
 in Django; 2) is the arguments for that method; 3) those are the
 annotation keys. so 1) is a result of:
qs.values_list('g1', 'g2').annotate(s_v1=Sum('v1'), s_v2=Sum('v2'))
 
 What i want to have is:
 a big nested dictionary with 'g1' values as 1st level keys and a
 dictionary of aggregates and subgroups in it.
 
 In my example it would be something like this:
 {
   1 : {
   's_v1' : 7.0,
   's_v2' : 6.5,
   'g2' :{
8 : {
   's_v1' : 5.0,
   's_v2' : 3.5 },
9 :  {
   's_v1' : 2.0,
   's_v2' : 3.0 }
 }
},
   2 : {
's_v1' : 6.0,
's_v2' : 8.0,
'g2' : {
 8 : {
   's_v1' : 6.0,
   's_v2' : 8.0}
}
},
 ...
 }
 
 # notice the summed values of s_v1 and s_v2 when g1 == 1
 
 I was looking for a solution that would let me do that kind of
 grouping with variable lists of 2) and 3) i.e. having also 'g3' as
 grouping element so the 'g2' dicts could also have their own
 subgroup and be even more nested then.
 I was trying something with itertools.groupby and updating nested
 dicts, but as i was writing the code it started to feel too verbose to
 me :/
 
 Do You have any hints maybe? because i'm kind of stucked :/
 
 Regards
 
 Sławek

Not super-efficient, but simple:

$ cat python sumover.py
cat: python: No such file or directory
data = [ { 'g1' : 1, 'g2' : 8, 's_v1' : 5.0, 's_v2' : 3.5 },
 { 'g1' : 1, 'g2' : 9, 's_v1' : 2.0, 's_v2' : 3.0 },
 {'g1' : 2, 'g2' : 8, 's_v1' : 6.0, 's_v2' : 8.0}]
sum_over = [s_v1, s_v2]
group_by = [g1, g2]

wanted = {
  1 : {
  's_v1' : 7.0,
  's_v2' : 6.5,
  'g2' :{
   8 : {
  's_v1' : 5.0,
  's_v2' : 3.5 },
   9 :  {
  's_v1' : 2.0,
  's_v2' : 3.0 }
}
   },
  2 : {
   's_v1' : 6.0,
   's_v2' : 8.0,
   'g2' : {
8 : {
  's_v1' : 6.0,
  's_v2' : 8.0}
   }
   },
}

def calc(data, group_by, sum_over):
tree = {}
group_by = group_by + [None]
for item in data:
d = tree
for g in group_by:
for so in sum_over:
d[so] = d.get(so, 0.0) + item[so]
if g:
d = d.setdefault(g, {}).setdefault(item[g], {})
return tree

got = calc(data, group_by, sum_over)[group_by[0]]
assert got == wanted
$ python sumover.py
$

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


Init a dictionary with a empty lists

2011-02-05 Thread Lisa Fritz Barry Griffin
Hi there,

How can I do this in a one liner:

maxCountPerPhraseWordLength = {}
for i in range(1,MAX_PHRASES_LENGTH+1):
maxCountPerPhraseWordLength[i] = 0

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


Re: Init a dictionary with a empty lists

2011-02-05 Thread Shashwat Anand
On Sat, Feb 5, 2011 at 6:38 PM, Lisa Fritz Barry Griffin 
lisaochba...@gmail.com wrote:

 Hi there,

 How can I do this in a one liner:

maxCountPerPhraseWordLength = {}
for i in range(1,MAX_PHRASES_LENGTH+1):
maxCountPerPhraseWordLength[i] = 0


maxCountPerPhraseWordLength = {}
[maxCountPerPhraseWordLength.setdefault(i, 0) for i
in range(1,MAX_PHRASES_LENGTH+1)]

From setdefaults documentation,
'D.setdefault(k[,d]) - D.get(k,d), also set D[k]=d if k not in D'




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




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


Re: Init a dictionary with a empty lists

2011-02-05 Thread Daniel Urban
On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin
lisaochba...@gmail.com wrote:
 Hi there,

 How can I do this in a one liner:

        maxCountPerPhraseWordLength = {}
        for i in range(1,MAX_PHRASES_LENGTH+1):
            maxCountPerPhraseWordLength[i] = 0

maxCountPerPhraseWordLength = {0 for i in range(1,MAX_PHRASES_LENGTH+1)}
But I suggest using a defaultdict:
http://docs.python.org/dev/py3k/library/collections#defaultdict-objects

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


Re: Init a dictionary with a empty lists

2011-02-05 Thread Peter Otten
Lisa Fritz Barry Griffin wrote:

 How can I do this in a one liner:
 
 maxCountPerPhraseWordLength = {}
 for i in range(1,MAX_PHRASES_LENGTH+1):
 maxCountPerPhraseWordLength[i] = 0

You can init a dictionary with zeroes with

d = dict.fromkeys(range(1, MAX_PHRASES_LENGTH+1), 0)

but this won't work as expected for mutable values:

 d = dict.fromkeys(range(5), [])
 d
{0: [], 1: [], 2: [], 3: [], 4: []}
 d[0].append(42)
 d
{0: [42], 1: [42], 2: [42], 3: [42], 4: [42]}

Oops! all values refere to the same list.
Instead you can use a defaultdict which adds items as needed:

 from collections import defaultdict
 d = defaultdict(list)
 d
defaultdict(type 'list', {})
 d[0].append(42)
 d
defaultdict(type 'list', {0: [42]})
 d[7].append(123)
 d
defaultdict(type 'list', {0: [42], 7: [123]})

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


Re: Init a dictionary with a empty lists

2011-02-05 Thread Vlastimil Brom
2011/2/5 Lisa Fritz Barry Griffin lisaochba...@gmail.com:
 Hi there,

 How can I do this in a one liner:

        maxCountPerPhraseWordLength = {}
        for i in range(1,MAX_PHRASES_LENGTH+1):
            maxCountPerPhraseWordLength[i] = 0

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


Hi,
as has been already suggested, using collections.defaultdict may be
appropriate, but it's fairly straightforward to mimic the original
code with a generator expression in dict(...)
maxCountPerPhraseWordLength = dict((i,0) for i in range(1,MAX_PHRASES_LENGTH+1))
or with a dict literal (in newer python versions)
maxCountPerPhraseWordLength = {i:0 for i in range(1,MAX_PHRASES_LENGTH+1)}

(possibly using xrange for larger dicts - in pyton 2)

hth,
  vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code structure advise for a model

2011-02-05 Thread Martin De Kauwe
On Feb 4, 8:41 pm, Marco Nawijn naw...@gmail.com wrote:
 On Feb 4, 3:43 am, Martin De Kauwe mdeka...@gmail.com wrote:





  Hi,

  I am translating some c++ code to python and just wanted to ask some
  advise on structure. The original has everything declared globally and
  nothing passed via function (I assume, but don't know, that this isn't
  just standard c++ practice!). So given this, I have a pretty much
  clean slate as I can't quite just copy the functions over. I was
  thinking something like this

  class Params:

      def __init__(self, fname):
          self.set_inital_condtions()
          self.read_input_file(fname)

      def set_inital_conditons(self):
          self.some_parm = 0.0

      def read_input_file(fname):

          #read file, change initial params if specified

  then I thought I could pass this as an object to the model class

  class Model(Params):

      def __init__(self):
          # blah

      def some_func(self):
           if (Params.some_param == something):
               foo

  OR this just a very bad way to structure it?

  The other thing I can't decide on is how to pass the parameters and
  variables through the class. So because of the way the original is
  written (everything is global), I could just inherit things, but it
  does means there is a lot of self. syntax. So I wondered if it might
  be better to pass things as function arguments? Any thoughts? I am
  also half considering other users from non-python backgrounds and what
  might seem very alien (syntax) to them.

  thanks in advance

  (ps. I am cross posting this on comp.lang.python as I am not sure
  where is more appropriate).

 I would structure it in three classes/functions:
 1. A parser class/function that reads an input file and returns a
 Parameters object
 2. A Parameters class
 3. A Model class that uses the Parameters

 You would end up with something like the following:

 class MyParser(object):

     def __init__(self, filename=None):
         self.filename = filename

     def parse(self, filename):

         params = Parameters()

         ...read info from filename and update parameters

         return params

 class Parameters(object):

     def __init__(self):
          self.myAttribute1 = 0
          self.myAttribute2 = A string

 class MyModel(object):

    def __init__(self, parameters):
        self.parameters = parameters

    def solve(self):
         ...solve the problem

 The driver program would look something like this:

 parser = MyParser()

 params = parser.parse('inputfile')

 model = MyModel(params)
 model.solve()

 I hope this is helpfull for you.

 Regards,

 Marco

thanks for that. I decided to read the params straight into a set of
dictionaries and then pass these dictionaries around the various model
methods.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Init a dictionary with a empty lists

2011-02-05 Thread Steven D'Aprano
On Sat, 05 Feb 2011 14:38:29 +0100, Daniel Urban wrote:

 On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin
 lisaochba...@gmail.com wrote:
 Hi there,

 How can I do this in a one liner:

        maxCountPerPhraseWordLength = {}
        for i in range(1,MAX_PHRASES_LENGTH+1):
            maxCountPerPhraseWordLength[i] = 0
 
 maxCountPerPhraseWordLength = {0 for i in range(1,MAX_PHRASES_LENGTH+1)}

Unfortunately not. In versions before Python 2.7, it will give a 
SyntaxError. In 2.7 or better it gives a set instead of a dict:

 MAX_PHRASES_LENGTH = 5
 maxCountPerPhraseWordLength={0 for i in range(1,MAX_PHRASES_LENGTH+1)}
 maxCountPerPhraseWordLength
set([0])


This will do the job most simply:

 dict(zip(range(1, MAX_PHRASES_LENGTH+1), [0]*MAX_PHRASES_LENGTH))
{1: 0, 2: 0, 3: 0, 4: 0, 5: 0}


Or this:

 dict((i, 0) for i in range(1, MAX_PHRASES_LENGTH+1))
{1: 0, 2: 0, 3: 0, 4: 0, 5: 0}


But perhaps the most simple solution is to just leave the dict empty, and 
instead of fetching items with dict[i], use dict.get(i, 0) or 
dict.setdefault(i, 0).



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


Guy Steele on Parallel Programing

2011-02-05 Thread Xah Lee
might be interesting.

〈Guy Steele on Parallel Programing〉
http://xahlee.org/comp/Guy_Steele_parallel_computing.html

--

Guy Steele on Parallel Programing

Xah Lee, 2011-02-05

A fascinating talk by the well respected computer scientist Guy
Steele. (famously known as one of the author of Scheme Lisp)

How to Think about Parallel Programming: Not! (2011-01-14) By Guy
Steele. @ http://www.infoq.com/presentations/Thinking-Parallel-Programming

The talk is a bit long, at 70 minutes. The first 26 minutes he goes
thru 2 computer programs written for 1970's machines. It's quite
interesting to see how software on punch card works. For most of us,
we never seen a punch card. He actually goes thru it “line by line”,
actually “hole by hole”. Watching it, it gives you a sense of how
computers are like in the 1970s.

At 00:27, he starts talking about “automating resource management”,
and quickly to the main point of his talk, as in the title, about what
sort of programing paradigms that are good for parallel programing.
Here, parallel programing means solving a problem by utilizing
multiple CPU or nodes (as in clusters or grid). This is important
today, because CPU don't get much faster anymore; instead, each our
computer are getting more CPU (multi-core).

In the rest 40 min of the talk, he steps thru 2 programs that solves a
simple problem of splitting a sentence into words. First program is
typical sequential style, using do-loop (accumulator). The second
program is written in his language Fortress, using functional style.
He then summarizes a few key problems with traditional programing
patterns, and introduces a few critical programing patterns that he
thinks is critical for programing languages to automate parallel
computing.

In summary, as a premise, he believes that programers should not worry
about parallelism at all, but the programing language should
automatically do it. Then, he illustrates that there are few
programing patterns that we must stop using, because if you do write
your code in such paradigm, then it would be very hard to parallelize
the code, either manually or by machine AI.

If you are a functional programer and read FP news in the last couple
of years, his talk doesn't cover much new. However, i find it very
interesting, because:

* ① This is the first time i see Guy Steele talk. He talks
slightly fast. Very bright guy.
* ② The detailed discussion of punch card code on 1970's machine
is quite a eye-opener for those of us who's not in that era.
* ③ You get to see Fortress code, and its use of fancy unicode
chars.
* ④ Thru the latter half of talk, you get a concrete sense of some
critical “do's & don'ts” in coding paradigms about what makes
automated parallel programing possible or impossible.

In much of 2000s, i did not understand why compilers couldn't just
automatically do parallelism. I thought about it in 2009, and realized
why. See: Why Must Software Be Rewritten For Multi-Core Processors?.


Parallel Computing vs Concurrency Problems

Note that parallel programing and concurrency problem are not the same
thing.

Parallel programing is about writing code that can use multiple CPU.
Concurrency problems is about problems of concurrent computations
using the same resource or time (e.g. race condition, file locking).
See: Parallel computing ◇ Concurrency (computer science)


Fortress & Unicode

It's interesting that Fortress language freely uses unicode chars. For
example, list delimiters are not the typical {} or [], but the unicode
angle bracket 〈〉. (See: Matching Brackets in Unicode.) It also uses
the circle plus ⊕ as operator. (See: Math Symbols in Unicode.)

I really appreciate such use of unicode. The tradition of sticking to
the 95 chars in ASCII of 1960s is extremely limiting. It creates
complex problems manifested in:

* String Escape mechanism (C's “\n”, widely adopted.)

* Complex delimiters (Python's triple quotes and perl's variable
delimiters q() q[] q{} m//, and heredoc. (See: Strings in Perl and
Python ◇ Heredoc mechanism in PHP and Perl.)

* Crazy leaning toothpick syndrome, especially bad in emacs regex.

* Complexities in character representation (See: Emacs's Key
Notations Explained (/r, ^M, C-m, RET, return, M-, meta) ◇ HTML
entities problems. See: HTML Entities, Ampersand, Unicode, Semantics.)

* URL Percent Encoding problems and complexities: Javascript
Encode URL, Escape String

All these problems occur because we are jamming so many meanings into
about 20 symbols in ASCII.

See also:

* Computer Language Design: Strings Syntax
* HTML6: Your JSON and SXML Simplified

Was this page useful to you?

Also, almost all of today's languages do not support unicode in
function or variable names, so you can forget about using unicode in
variable names (e.g. α=3) or function names (e.g. “lambda” as “λ” or
“function” as “ƒ”), or defining your own 

Re: Init a dictionary with a empty lists

2011-02-05 Thread Daniel Urban
On Sat, Feb 5, 2011 at 15:38, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Sat, 05 Feb 2011 14:38:29 +0100, Daniel Urban wrote:

 On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin
 lisaochba...@gmail.com wrote:
 Hi there,

 How can I do this in a one liner:

        maxCountPerPhraseWordLength = {}
        for i in range(1,MAX_PHRASES_LENGTH+1):
            maxCountPerPhraseWordLength[i] = 0

 maxCountPerPhraseWordLength = {0 for i in range(1,MAX_PHRASES_LENGTH+1)}

 Unfortunately not. In versions before Python 2.7, it will give a
 SyntaxError. In 2.7 or better it gives a set instead of a dict:

Yeah, sorry, that should have been  {i: 0 for i in
range(1,MAX_PHRASES_LENGTH+1)}


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


Re: Create classes at runtnime

2011-02-05 Thread Marc Aymerich
On Feb 5, 1:06 pm, Marc Aymerich glicer...@gmail.com wrote:
 Thank you all for the answers!

 I'll try to give you the context in which I need to generate classes
 like this.

 I'm developing a reusable control panel for an ISP. I have several
 modules (VirtualUser, SystemUser, VPS, VirtualHost, ...) and they all
 share the fact that you can have limits on resource consumption. for
 example.

 VPS: has limits on swap, memory, cpu and disk.
 SystemUser: has limits on disk and traffic.

 As all modules share this property of being limited I have decided to
 split the limit functionality in a separate module (called resources).
 Resources are associated dinamically with (vps, systemuser ...)
 through a Monitor class. So it's up to you decide what limits you are
 interested to put in the VPS or in the SystemUser ...

 So when you attach the disk limit to SystemUser model is necessary
 to create a web form for SystemUser a bit different than if you decide
 to have disk and traffic limits. That is what my posted code is
 supposed to do.

 Do you think that I am on the wrong way designing the control panel
 like this?

 Btw, I've seen several interesting ideas to create the class
 dinamically (with class factorys, MetaClass, dictionaries ..), but I
 have not yet clear whether this will be usefull for create the
 __init__ function at runtime too. Any clue on this?


this seems to work :)

def makeLimitForm(name, monitors, _model):

class Meta:
model = _model
dct = { 'Meta': Meta }

for monitor in monitors:
field_name = monitor.resource + _limit
dct[field_name] = forms.CharField(max_length=100,
initial=monitor.default_limit)

def __init__(self, *args, **kwargs):
ModelForm.__init__(self, *args, **kwargs)
if 'instance' in kwargs:
for monitor in monitors:
field_name = monitor.resource + _limit
print monitor
self.fields[field_name].initial =
kwargs['instance'].monitoring.filter(monitor=monitor)[0].current

dct['__init__'] = __init__

return type(name,(ModelForm,),dct)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-05 Thread MRAB

On 05/02/2011 09:44, flebber wrote:

On Feb 5, 10:24 am, Stephen Hansenme+list/pyt...@ixokai.io  wrote:

On 2/4/11 3:01 PM, rantingrick wrote:


Put your money where your mouth is.



ditto!


I thought as much.

My money is where my mouth is: but that is not IDLE, as I have no use
for it and no interest in it at all. The status quo with regards to IDLE
is satisfactory to me.

You're the one talking so much about how it needs to improve. So do it.
Get started. Now.

But you'll just find another excuse to rant on like you always do, and
be basically useless.

Me, I _have_ contributed patches: I have released actual code that
actual people have found actually useful. I do run two build slaves and
proactively try to assist in resolving issues that come up with Python's
testing (usually: ouch, there's a lot of red at the moment, must get
cracking) and stability.

So, yeah. You're the hypocrite here, man.

--

Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog:http://meh.ixokai.io/

  signature.asc
  1KViewDownload


Idlefork isn't dead to rick! just pining for the alps!


alps? That should be fjords! :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-05 Thread Robert

On 2011-02-04 13:34:42 -0500, rantingrick said:


I don't care who *that* person is as long as *they* are willing to
push IDLE forward. I would be honored to accept the reigns and lead OR
follow someone else's lead. But we need to receive the old idlefork or
have them delete the old idle fork as too much confusion will spread
with when two idleforks exists.


There is a movement afoot to update IDLE. I am going to be a part of that.

There is an implementation called VIDLE that made some changes and 
those are going to be integrated in before the major refactorings 
begin. This initial push will hit both 2.7.x (I think I read it right) 
and 3.x lines.


Going forward though we are going to focus on IDLE in the 3.x series 
only. There is a nice list of changes and some folks that are willing 
to help when the repo goes into Mercurial.


--
Robert


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


Re: Create classes at runtnime

2011-02-05 Thread Miki Tebeka
 I need to create a pretty complex class at runtime.
You can take the approach that namedtuple does and create a python code for the 
class as string and then exec it. See 
http://svn.python.org/view/python/trunk/Lib/collections.py?view=markup

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


Re: Unable to register com component built with python2.7

2011-02-05 Thread Stephen Hansen
On 2/5/11 2:33 AM, sniffer wrote:
 Hi all,
 I have built a com component using python2.7 on win 7 but the
 component refuses to register ,every time i try to register it says
 the specified module could not be found unable to load python.dll ,i
 also tried building the same com server with python2.7 again on a win-
 xp system  but to no avail ,i even tried building and registring the
 com server after removing all imports and just leaving 1 function
 which returns nothing but the string hello world any pointers would
 be great

It sounds like your Python install directory (C:\Python27 probably) is
not on your PATH. Which is the default. There's much debate about that
on and off, but in short-- if you go add it to your environment
variables things will probably work.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



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


Re: Guy Steele on Parallel Programing

2011-02-05 Thread Rui Maciel
Xah Lee wrote:

 might be interesting.
 
 〈Guy Steele on Parallel Programing〉
 http://xahlee.org/comp/Guy_Steele_parallel_computing.html

Very interesting.  Thanks for the link.


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


sending through non-default gateway

2011-02-05 Thread Nikola Skoric
Is there a way to create a TCP connection using a gateway of my
choice?

I have a regular user account on a WinXP machine. It has a DNS server
and default gateway configured, and that DNS server and default
gateway don't see the rest of the Internet, just the local
network. But, I know an IP address of another DNS/gateway pair which
is used to access the Internet, and I can ping them (and send nslookup
queries) from my machine.

So, is there a way to tell python don't use my default gateway, here
is an address of the gateway I want you to use? I've been googling,
but to no avail...

-- 
Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending through non-default gateway

2011-02-05 Thread Dan Stromberg
IIRC, this is an instance of what's called source routing, and was
largely shut off after network admins realized it was a security
issue.

Of course, if you have root/administrator permission, you could
probably do it.  But if you have that, you could probably just fix the
routing table.

On Sat, Feb 5, 2011 at 11:30 AM, Nikola Skoric n...@fly.srk.fer.hr wrote:
 Is there a way to create a TCP connection using a gateway of my
 choice?

 I have a regular user account on a WinXP machine. It has a DNS server
 and default gateway configured, and that DNS server and default
 gateway don't see the rest of the Internet, just the local
 network. But, I know an IP address of another DNS/gateway pair which
 is used to access the Internet, and I can ping them (and send nslookup
 queries) from my machine.

 So, is there a way to tell python don't use my default gateway, here
 is an address of the gateway I want you to use? I've been googling,
 but to no avail...

 --
 Now the storm has passed over me
 I'm left to drift on a dead calm sea
 And watch her forever through the cracks in the beams
 Nailed across the doorways of the bedrooms of my dreams
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Oktest 0.7.0 released - a new-style testing library

2011-02-05 Thread Makoto Kuwata
I released Oktest 0.7.0.
http://pypi.python.org/pypi/Oktest/
http://packages.python.org/Oktest/

Oktest is a new-style testing library for Python.
::

from oktest import ok
ok (x)  0 # same as assert_(x  0)
ok (s) == 'foo'# same as assertEqual(s, 'foo')
ok (s) != 'foo'# same as assertNotEqual(s, 'foo')
ok (f).raises(ValueError)  # same as assertRaises(ValueError, f)
ok (u'foo').is_a(unicode)  # same as assert_(isinstance(u'foo', unicode))
not_ok (u'foo').is_a(int)  # same as assert_(not isinstance(u'foo', int))
ok ('A.txt').is_file() # same as assert_(os.path.isfile('A.txt'))
not_ok ('A.txt').is_dir()  # same as assert_(not os.path.isdir('A.txt'))

See http://packages.python.org/Oktest/ for details.

NOTICE!! Oktest is a young project and specification may change in the future.


Enhancements and Changes


* enhanced to allow users to define custom assertion functions. ::

import oktest
from oktest import ok
#
@oktest.assertion
def startswith(self, arg):
boolean = self.target.startswith(arg)
if boolean == self.expected:
return True
self.failed(%r.startswith(%r) : failed. % (self.target, arg))
#
ok (Sasaki).startswith(Sas)

* rename 'ok().hasattr()' to 'ok().has_attr()'.
  (but old name is also available for backward compatibility.)

* change 'chdir()' to take a function as 2nd argument. ::

def f():
  ... do_something ...
chdir('build', f)

# The above is same as:
with chdir('build'):
  ... do_something ...

* add document of 'oktest.helper.dummy_io()'. ::

with dummy_io(SOS) as io:
assert sys.stdin.read() == SOS
print(Haruhi)
assert io.stdout == Haruhi\n
assert io.stderr == 

* fix 'oktest.tracer.Call#__repr__()' to change output according to
  whether '==' is called or not. This is aimed to make output of
  'ok(tr[0]) == [...]' to be more readable.

* change 'Runner#run()' to skip AssertionError if it is raised by
  'assert ' and not 'ok() == ...'.

* fix example code for some helper functions.

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


Re: psd estimation no matplotlib

2011-02-05 Thread Corey Richardson
On 02/05/2011 05:19 AM, Jack Yu wrote:
 Hi all,
 Is there a function psd() for estimating power spectral density that is not
 dependent on the importing of matplotlib or pylab [snip]
 

There is not built into Python, but you could rip the function right out
of pylab's or matplotlib's source and put it in your own code, or even
just write it yourself.

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


Fully functioning email client in Python

2011-02-05 Thread iaoua iaoua
Hi all,

I'm a complete newbie to this newsgroup and to Python (pretty much) so
please be nice and give me a warm welcome.

First of all please allow me to properly introduce myself. My name is
James Christian and I am a PhD student at the University of Essex in
England doing research on Machine Translation. You can see my
minimalist homepage at http://privatewww.essex.ac.uk/~jcread

Aside from machine translation I also have other AI related research
interests that have led me to seek the wisom of Python users and
developers on this newsgroup. In a nutshell my problem is this. I have
developed an intelligent conversational agent which dialogues with a
user to find out what they are really searching for. The domain is
open and helps the user find which businesses/websites offer the
services or products the user is looking for according to needs
elicited from the user during the dialogue. I have small but growing
base of experimental users who want to access the agent via email (the
agent can be quite slow at times due to the complexity of the system)
so that they can ask questions and forget about them until an answer
comes to their inbox. And so I need to extend my agent so that it can
receive and send emails and extract the relevant text answers to
questions from the user. This requires full threading capabilities and
automatic text extraction of only the new and relevant material (minus
signatures of course).

Now, I'm not completely lazy and so I have already done a little
homework. I've been reading O'Reilly's Programming Python and
Foundations of Python Network Programming which have both been very
helpful in ascertaining that Python is a strong candidate solution.
Both books talk about the email (for message and header construction
and parsing) sendmail (for sending mail via SMTP) and poplib (for
receiving mail with POP3) libraries.

However, as you can imagine I already really quite have my work cut
out with maintaining and expanding the dialogue of the system and with
the research on Machine Translation.

What I really need is a ready made fully functional Python client that
already has it that offers me a simple interface to extract text from
received messages along with a message id that I can use to associate
the response to a question with and allows me to send out new
questions or answers along with a message id I can use to track future
responses with. I need something that already has the whole shebang.
Can support POP3, IMAP, SSL authentication, message threading etc.

Can anyone point to something that will save me the effort of building
this thing from scratch and first principles? Thanks in advance for
any useful suggestions.

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


Re: Unable to register com component built with python2.7

2011-02-05 Thread sniffer
Stephen thanks for your reply but my python installation directory is in my 
path any other pointers
-- 
http://mail.python.org/mailman/listinfo/python-list


P2PU Python Challenges

2011-02-05 Thread Corey Richardson
In my journeys across the face of the Internet, I found this:
http://p2pu.org/general/python-challenges

Not sure what it's really going to be, but any new programmers/people
looking for something to do might be interested. I'm not quite sure how
a class can be organised around a web riddle, but it's there so someone
must have figured it out.

Just thought I'd share.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending through non-default gateway

2011-02-05 Thread Nikola Skoric
Dana Sat, 5 Feb 2011 14:13:11 -0800, 
Dan Stromberg drsali...@gmail.com kaze:
 IIRC, this is an instance of what's called source routing, and was
 largely shut off after network admins realized it was a security
 issue.

 Of course, if you have root/administrator permission, you could
 probably do it.  But if you have that, you could probably just fix the
 routing table.

Yeah, I don't have admin priviledges, it's my office computer which is
supposed to be cut of the Internet.

I did a bit of reading on source routing and I'd like to try it. Just
for fun, in case our router accepts such packets. So, is there a way
to do it in python?

-- 
Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue11109] socketserver.ForkingMixIn leaves zombies

2011-02-05 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +gregory.p.smith
stage:  - patch review
versions: +Python 2.7, Python 3.2, Python 3.3 -Python 3.1

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



[issue11119] Passing a socket to a process (multiprocessing module)

2011-02-05 Thread Antoine Pitrou

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

Well, sockets cannot be pickled on any platform:

 sock = socket.create_connection((www.python.org, 80))
__main__:1: ResourceWarning: unclosed socket.socket object, fd=3, family=2, 
type=1, proto=0
 s = pickle.loads(pickle.dumps(sock))
 s.getpeername()
Traceback (most recent call last):
  File stdin, line 1, in module
socket.error: getsockaddrlen: bad family
 s.fileno()
-1

The reason your code works under Linux is that multiprocessing uses fork() and 
therefore all objects and file handles are transparently inherited by the 
child. Windows doesn't have fork(), it instead spawns a new process to which it 
must marshal objects using pickle. You'll have to create your socket in the 
child for it to work at all.

By the way, multi-threading is much more appropriate than multi-processing when 
writing servers under Windows. Also, see the socketserver module for helpers to 
write both multi-threaded and multi-processed servers: 
http://docs.python.org/library/socketserver.html

--
nosy: +pitrou
resolution:  - invalid
status: open - pending

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



[issue11127] sockets should not be pickleable

2011-02-05 Thread Antoine Pitrou

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

Like already done for file objects, sockets should refuse pickling by raising a 
TypeError.

--
components: Library (Lib)
messages: 127976
nosy: pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: sockets should not be pickleable
type: behavior
versions: Python 3.3

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



[issue11119] Passing a socket to a process (multiprocessing module)

2011-02-05 Thread Antoine Pitrou

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

Opened issue11127 for raising a TypeError when trying to pickle any socket.

--
status: pending - closed

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



[issue11124] test_posix failure on the Leopard buildbot

2011-02-05 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
resolution:  - duplicate
stage:  - committed/rejected
status: open - closed
superseder:  - posix.getgroups() failure on Mac OS X

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



[issue1227748] subprocess: inheritance of std descriptors inconsistent

2011-02-05 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
assignee: astrand - docs@python
nosy: +docs@python
stage: needs patch - patch review

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



[issue11076] Iterable argparse Namespace

2011-02-05 Thread Virgil Dupras

Virgil Dupras hs...@hardcoded.net added the comment:

I didn't know about vars() (well, I knew it existed, but never was quite sure 
what it did).

Given that I'm not a Python newbie, I'm guessing I'm not alone in this 
situation. Maybe that instead of making the Namespace iterable, we should just 
add an example usage of vars() in argparse's documentation?

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Martin v . Löwis

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

My claim is that Tkinter is thread-safe as it stands. A lot of thought has been 
put into making Tkinter thread-safe, so if there is any claim to the contrary, 
we would need more details: what exact Python version is being used, what exact 
operating system is being used, what exact code is run, and what exact output 
is produced.

--
nosy: +loewis

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



[issue11103] Python 3.2 installer doesn't register file extensions on Windows 7

2011-02-05 Thread Martin v . Löwis

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

Terry, if you are installing Python for all users, but have the Open rebound 
just for yourself, it is unreasonable to expect that the Python installation 
procedure changes it. Per-user settings override machine settings; this is by 
Microsoft design.

Darren: did you install for all users or just for me?

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Scott M

Scott M scott.m...@comcast.net added the comment:

I'll look into making the crash easier to reproduce this coming week.

Is Tkinter's thread safety new? Because after I started getting crashes, I did 
my due diligence in Google and found a number of people writing about how it 
was necessary to use a Queue and Tkinter's after() timer, to draw from multiple 
threads. And in experiments in 2.7.1 on Windows, it turned out that it wasn't 
just the drawing calls from a thread other than the mainloop() thread, that 
invited a crash; even just trying to set an .after() timer from a different 
thread caused tracebacks, randomly.

At any rate this is less of an issue now, for me at least. I'm putting together 
a small graphic library for my coworkers. It will have a tiny fraction of 
Tkinter's capabilities, it will be Windows-only and won't even have native 
Windows look and feel; but it will be completely, rock-solid, idiot-proof 
thread safe - any operation (including widget deletes), any thread, any time, 
with no polling or timers needed. My coworkers are not technical and will get 
instantly lost if I have to describe queues and timers just to draw a line on a 
screen.

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Martin v . Löwis

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

 Is Tkinter's thread safety new?

It's supported on Unix since 1.5.1, and on Windows since 2.3.

--

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



[issue11116] mailbox and email errors

2011-02-05 Thread Steffen Daode Nurpmeso

Steffen Daode Nurpmeso sdao...@googlemail.com added the comment:

Well, here is the long-asked-for 'fp_mailbox.py' test thing.
Note: it generates a 'test.mbox' in CWD!

print(USAGE: fp_mailbox.py 0|1|2,
 0 = use raw UTF-8 string,
 1 = use UTF-8 string,
 2 = use escaped byte string, sep=\n)

It does not use FeedParser directly, but email.message_from_*.  It's simple 
minded, but a dumb new python(1) user (like me) does not know otherwise, i 
guess.  Of course the input is malformed, but, you know, shit happens (you may 
trust me in respect to that).  I want to point out that .defects is the empty 
list, even though the input is *not* correctly converted (quopri/base64) and 
blows mailbox.add later on for test cases 0 and 1 (resulting in corrupted 
mailbox files).  2 does not cause a traceback and is mailbox.add()ed, but the 
resulting mail is not standart-conforming either.  For me and my (S-)Postman 
all of this means that i have to encapsulate all of this with a 
'MessageBuilder' layer on top of the python(1) builtin email package.



  I personally will encapsulate the email.* stuff with a MessageBuilder

--
Added file: http://bugs.python.org/file20683/fp_mailbox.py

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



[issue11046] setup.py/configure [darwin]

2011-02-05 Thread Steffen Daode Nurpmeso

Steffen Daode Nurpmeso sdao...@googlemail.com added the comment:

ronaldoussoren: thanks for the MACOSX_DEPLOYMENT_TARGET=10.5 hint!!  I did Py3K 
yesterday, and it was a matter of 'configure --prefix=x YZ  make  make 
install' as if it were a real UNIX!

I *really* think there should be a configure command line option for this thing 
- i would *not* have found that out on my own!

And of course the problem with libedit is it's ignorance for a long-time-grown 
multi-UNIX multi-term '.inputrc'.

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Scott M

Scott M scott.m...@comcast.net added the comment:

The new version runs 40 parabolas, then quits. I usually have to run this 
version 20 times or so to get the crash, so be patient. In general if it's 
going to crash it does so in the first 6 or so parabolas. Caveat: creates up to 
40 threads, so a bit of a CPU pig. You may want to change the 40 in 
(self.tracks  40) to 8.

Here's one crash. I got this by double clicking the .py file from Windows 
explorer, but I can get them with F5 in IDLE too.
---
UpdateStringProc should not be invoked for type cmdName

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Exception in thread Thread-6:
Traceback (most recent call last):
  File C:\Python27\lib\threading.py, line 530, in __bootstrap_inner
self.run()
  File H:\PMT2\MyProjects\TkinterCrash2.py, line 47, in run
self.deliverToQueue((self.target, z, y))
  File H:\PMT2\MyProjects\TkinterCrash2.py, line 129, in arrival_122
new_yz[1])
  File C:\Python27\lib\lib-tk\Tkinter.py, line 2201, in create_line
return self._create('line', args, kw)
  File C:\Python27\lib\lib-tk\Tkinter.py, line 2189, in _create
*(args + self._options(cnf, kw
TclError: bad screen distance create

--
versions: +Python 2.7 -Python 3.3
Added file: http://bugs.python.org/file20684/TkinterCrash2.py

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



[issue11128] decimal.py: to_integral() corner cases

2011-02-05 Thread Stefan Krah

New submission from Stefan Krah stefan-use...@bytereef.org:

Hi,

to_integral() should behave like quantize() for negative exponents:

Otherwise (the operand has a negative exponent) the result is the
 same as using the quantize operation using the given operand as the
 left-hand-operand, 1E+0 as the right-hand-operand, and the precision
 of the operand as the precision setting. The rounding mode is taken
 from the context, as usual.


There are some corner cases where this matters:


 from decimal import *
 c = Context(prec=1, Emin=-1, Emax=1, traps=[])
 d = Context(prec=4, Emin=-1, Emax=1, traps=[])
 
 c.to_integral(Decimal(999.9))
Decimal('1000')
 d.quantize(Decimal(999.9), Decimal(1e0))
Decimal('NaN')


Indeed, decNumber returns NaN for to_integral(). This is an odd
situation, since for the result it is possible to exceed the
precision but not Emax:


 c = Context(prec=3, Emin=-3, Emax=3, traps=[])
 d = Context(prec=4, Emin=-3, Emax=3, traps=[])
 c.to_integral(Decimal(999.9))
Decimal('1000')
 d.quantize(Decimal(999.9), Decimal(1e0))
Decimal('1000')


The specification is on the side of decNumber, but I wonder if this is
an oversight.

--
components: Library (Lib)
messages: 127986
nosy: mark.dickinson, skrah
priority: normal
severity: normal
status: open
title: decimal.py: to_integral() corner cases
type: behavior
versions: Python 3.3

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



[issue11117] Implementing Async IO

2011-02-05 Thread David Beazley

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

Anyone contemplating the use of aio_ functions should first go read The Story 
of Mel.

http://www.catb.org/jargon/html/story-of-mel.html

--
nosy: +dabeaz

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Antoine Pitrou

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

I can't reproduce either, but the latest traceback posted in msg127985 seems to 
hint at a parameter marshalling problem. create is one of the parameters to 
the called Tk function, but it seemed to be mistaken for another.

Since it's arguably threading-related, saying I can't reproduce doesn't seem 
like a sufficient reason to close the issue. There can be all kinds of 
influencing factors (OS, CPU, background tasks) and the marshalling code in 
Modules/_tkinter.c is far from trivial.

--
nosy: +amaury.forgeotdarc, pitrou
type: feature request - crash

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

I think launching external tools like ifconfig and ipconfig can be avoided 
pretty easily. There are many recipes around the net how to use native API's.
About ctypes' horrible logic during find_library call - don't know yet.

--
nosy: +nvetoshkin

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



[issue11117] Implementing Async IO

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

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

Thanks, David, for the link. The story is really touching :-).

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Martin v . Löwis

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

Tk produces bad screen distance in Tk_GetScreenMM (convert string to screen 
millimeters) and TkGetDoublePixels (convert string to number of pixels) when 
strtod fails on the string being passed. It also produces the error in 
SetPixelAny (convert object to pixel) if the string doesn't start with a 
double, and SetMMFromAny (convert object to millimeters) if the string either 
is no double, or not followed by [cimp]. Finally, TkPixelParseProc returns 
the error if TkGetDoublePixels returns a negative number.

In relationship to the canvas line command, TkPixelParseProc is used for 
converting the -width, -activewidth, and -disabledwidth arguments. None of 
these are used in the test case, though, so it's not clear which pixel parsing 
fails specifically.

--

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



[issue11129] logging: allow multiple entries in qualname config

2011-02-05 Thread anatoly techtonik

New submission from anatoly techtonik techto...@gmail.com:

When configuration is specified in external file, qualname attribute should 
allow several values. Maybe comma separated.

--
messages: 127992
nosy: techtonik
priority: normal
severity: normal
status: open
title: logging: allow multiple entries in qualname config
versions: Python 2.7

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Scott M

Scott M scott.m...@comcast.net added the comment:

If it helps, over the many iterations of this test code, there have been two 
kinds of issues:

1. pythonw.exe crashes with the Windows variant of a SEGV. No traceback, just a 
crash. These are rare.

2. Evidence of confusion over which string the code should be looking at, and 
it's always down in the create function of Tkinter. Variations of this 
confusion have been Int() complaining that it can't translate None, strings 
like .667748474.7464 not being recognized as parameter names...  all of it 
sounds like Tkinter has somehow managed to be looking at the wrong string. Even 
when the only Tkinter call I do outside the mainloop thread is .after(), the 
crashes would happen when I went to draw a line.

My (trivial) experience in extending Python makes me wonder if some reference 
count, somewhere, didn’t get mismanaged. The only times I ever got a hard crash 
out pythonw.exe in my own projects is when I mishandled a count.

As a side note, if Tkinter is intended to be thread safe, the documentation 
should say so. Clearly, and in the first paragraph. Once I started having 
problems, I started Googling, and everything I read lead me to conclude that 
neither Tkinter nor wx were even intended to be thread safe, so I've started to 
write my own GUI code. This is a project I might have skipped if it has been 
clear that Tkinter is at least intended to be thread safe.

--

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



[issue11117] Implementing Async IO

2011-02-05 Thread David Beazley

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

Glad you liked it!   I think there is a bit of a cautionary tale in there 
though. With aio_, there is the promise of better performance, but you're also 
going to need a *LOT* of advance planning and thought to avoid creating a 
tangled coding nightmare with it.

Just as an aside, one of the uses of aio_ related functions is to implement 
parts of user-level thread libraries in C (e.g., pthreads, etc.). A library 
might use the asynchronous I/O callbacks as part of implementing non-kernel 
(green) threads.  The code for doing this tends to be very low level and hairy 
with lots of signal handling--for example, if you want to context-switch 
between two user-level threads in C, you usually do it inside a signal handler 
(i.e., you thread-switch inside the signal handler called in response to aio_ 
completions). 

Whether it's feasible to expose aio_* all the way up to Python or not is an 
open question. I suspect it will be fraught with lots of tricky issues. In the 
end, it might just be easier to use threads.  Nevertheless, you'll learn a lot 
about Python internals by working on this :-).

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Antoine Pitrou

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

The UpdateStringProc should not be invoked for type cmdName message (as 
quoted above in the traceback) apparently can mean that there's a mismanagement 
of Tcl reference counts.

From 
http://sourceforge.net/tracker/?func=detailatid=110894aid=1326087group_id=10894:

“This crash (actually, a panic) hints at defective Tcl_Obj
handling - possibly in the core, more likely in an extension
if you're using one. It indicates that Tcl_GetString() or
Tcl_GetStringFromObj() has been called on a cmdNameType
Tcl_Obj that has no string representation, a state that
should never occur.”

Intuitively, cmdNameType seems to refer to createcommand() / deletecommand(). 
Also, the following code in Tkinter.py looks a bit suspicious:

def after(self, ms, func=None, *args):
Call function once after given time.

MS specifies the time in milliseconds. FUNC gives the
function which shall be called. Additional parameters
are given as parameters to the function call.  Return
identifier to cancel scheduling with after_cancel.
if not func:
# I'd rather use time.sleep(ms*0.001)
self.tk.call('after', ms)
else:
def callit():
try:
func(*args)
finally:
try:
self.deletecommand(name)
except TclError:
pass
name = self._register(callit)
return self.tk.call('after', ms, name)

That is, we call deletecommand() while the command is still being executed.
Perhaps that, together with concurrent memory allocation from another thread 
(Tcl_Alloc() doesn't use Python's Tcl lock), might explain why the cmdName or 
other things sometimes become corrupted (Tcl_DeleteCommand deletes a command 
from a command interpreter. Once the call completes, attempts to invoke cmdName 
in interp will result in errors).

--

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



[issue11077] Tkinter is not thread safe

2011-02-05 Thread Antoine Pitrou

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

 As a side note, if Tkinter is intended to be thread safe, the 
 documentation should say so. Clearly, and in the first paragraph.

I'm no Tkinter specialist but, judging by its source code, Tkinter (the Python 
module) *is* intended to be thread-safe using locking and/or marshalling.

As for wxPython, you are right that it is not thread safe.

--

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



[issue5285] hmac throws TypeErrors

2011-02-05 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

This damn bug ruined my day. MoinMoin couldn't reset password on many outdated 
wikies  1.8.2 (including Python's one probably), because of it.

http://moinmo.in/MoinMoinBugs/1.8_ResetPasswordError

--
nosy: +techtonik

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Kenny Meyer

Kenny Meyer knny.m...@gmail.com added the comment:

With the attached patch the heavy work will be done on request, when calling 
uuid1() or uuid4() not on import.

I am working off from the py3k svn branch. Is it necessary to submit a separate 
patch for py2 branch?

--
keywords: +patch
nosy: +knny-myer
Added file: http://bugs.python.org/file20685/issue11063.patch

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



[issue11130] SocketServer: server_address is... a socket

2011-02-05 Thread ProgVal

New submission from ProgVal prog...@gmail.com:

Hello,

I have issues with a script I'm programming (TypeError at every client 
connection), so I edited BaseServer's __init__():
def __init__(self, server_address, RequestHandlerClass):
Constructor.  May be extended, do not override.
if isinstance(server_address, socket._socketobject):
raise Exception()
self.server_address = server_address
self.RequestHandlerClass = RequestHandlerClass
self.__is_shut_down = threading.Event()
self.__shutdown_request = False
And it raises sometimes this traceback:
Exception happened during processing of request from ('127.0.0.1', 32810)
Traceback (most recent call last):
  File /usr/lib/python2.6/SocketServer.py, line 285, in 
_handle_request_noblock
self.process_request(request, client_address)
  File /usr/lib/python2.6/SocketServer.py, line 311, in process_request
self.finish_request(request, client_address)
  File /usr/lib/python2.6/SocketServer.py, line 324, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File /usr/lib/python2.6/SocketServer.py, line 400, in __init__
BaseServer.__init__(self, server_address, RequestHandlerClass)
  File /usr/lib/python2.6/SocketServer.py, line 198, in __init__
raise Exception()

Best regards,
ProgVal

--
components: Library (Lib)
messages: 127999
nosy: ProgVal
priority: normal
severity: normal
status: open
title: SocketServer: server_address is... a socket
versions: Python 2.6

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



[issue11130] SocketServer: server_address is... a socket

2011-02-05 Thread ProgVal

ProgVal prog...@gmail.com added the comment:

The problem happens on Python 2.7 too.

Additionaly, here is the traceback, if I don't edit the library:
Exception happened during processing of request from ('127.0.0.1', 50378)
Traceback (most recent call last):
  File /usr/lib/python2.7/SocketServer.py, line 284, in 
_handle_request_noblock
self.process_request(request, client_address)
  File /usr/lib/python2.7/SocketServer.py, line 310, in process_request
self.finish_request(request, client_address)
  File /usr/lib/python2.7/SocketServer.py, line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File /usr/lib/python2.7/SocketServer.py, line 408, in __init__
self.server_bind()
  File /usr/lib/python2.7/SocketServer.py, line 419, in server_bind
self.socket.bind(self.server_address)
  File /usr/lib/python2.7/socket.py, line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: getsockaddrarg: AF_INET address must be tuple, not _socketobject

--
versions: +Python 2.7

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Senthil Kumaran

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

Kenny, I don't see a problem with uuid is *imported*, it just creates a couple 
of STANDARD UUID class objects for use later. And this seems to just set the 
number and validates it. I don't see any subprocess calls performed. Perhaps 
you were referring to scenarios of using uuid1/uuid5 methods in mac and 
suggesting improvements to it by your patch?

--
nosy: +orsenthil

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



[issue11130] SocketServer: server_address is... a socket

2011-02-05 Thread ProgVal

ProgVal prog...@gmail.com added the comment:

This seems odd to me: this line:
self.RequestHandlerClass(request, client_address, self)
calls TCPServer's constructor:
def __init__(self, server_address, RequestHandlerClass, 
bind_and_activate=True):

--

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



[issue11130] SocketServer: server_address is... a socket

2011-02-05 Thread ProgVal

ProgVal prog...@gmail.com added the comment:

Oh, excuse me, it's because of my code!

class MyRequestHandler(SocketServer.TCPServer):

--
resolution:  - invalid

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



[issue11130] SocketServer: server_address is... a socket

2011-02-05 Thread Senthil Kumaran

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

Unable to determine the bug here. If you have questions with using python, 
please ask python-l...@python.org

--
nosy: +orsenthil
stage:  - committed/rejected
status: open - closed
type:  - behavior

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



[issue11122] bdist_rpm fails

2011-02-05 Thread James

James purplei...@gmail.com added the comment:

I'll write a docs and script patch for this next week...

I'm happy to do the work,

Thanks for the comments.

James

--

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




[issue9364] some problems with the documentation of pydoc

2011-02-05 Thread yeswanth

yeswanth swamiyeswa...@yahoo.com added the comment:

Suggestions are good . One thing I came across when going through the doc is 
that when you run help(help) after importing help from pydoc , i noticed that 
the first line of the help utility is 


Welcome to Python 3.2!  This is the online help utility.

which could be changed to 

Welcome to Python help utility as the help utility is already inbuilt .

--
nosy: +swamiyeswanth

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



[issue11131] decimal.py: plus/minus with ROUND_FLOOR

2011-02-05 Thread Stefan Krah

New submission from Stefan Krah stefan-use...@bytereef.org:

Another exciting corner case in plus/minus:

The operations are evaluated using the same rules as add and subtract;
 the operations plus(a) and minus(a) (where a and b refer to any numbers)
 are calculated as the operations add(’0’, a) and subtract(’0’, b)
 respectively, where the ’0’ has the same exponent as the operand.


But add and subtract have a special rule for the sign with ROUND_FLOOR:

Otherwise, the sign of a zero result is 0 unless either both operands 
 were negative or the signs of the operands were different and the 
 rounding is round-floor.


So, +Decimal(-0) and -Decimal(0) should be a negative zero. I checked
this against decNumber. Currently:


 c = getcontext()
 c.rounding = ROUND_FLOOR
 +Decimal(-0)
Decimal('0')
 -Decimal(0)
Decimal('0')

--
components: Library (Lib)
messages: 128007
nosy: mark.dickinson, skrah
priority: normal
severity: normal
status: open
title: decimal.py: plus/minus with ROUND_FLOOR
type: behavior
versions: Python 3.2, Python 3.3

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread R. David Murray

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

If you do 'python -c import uuid under strace, _posixsubprocess is definitely 
loaded, and a pipe2 call is made.

Take a look at the code starting at (py3k trunk) line 418 (try:).  That's where 
the weird stuff happens, which is what the patch is addressing.

Ken: thanks for working on this.

--
nosy: +r.david.murray

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



[issue9364] some problems with the documentation of pydoc

2011-02-05 Thread yeswanth

yeswanth swamiyeswa...@yahoo.com added the comment:

Patch for the change i have suggested in pydoc .
@Eric I will try to implement the patch suggestions you have made. I still have 
to figure out how to make crosslinks

--
keywords: +patch
Added file: http://bugs.python.org/file20686/pydoc.diff

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Antoine Pitrou

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

Thanks for posting a patch! I have two comments:
- Have you run test_uuid? When I run it, it seems to go into an infinite loop 
somewhere and I need to kill the process.
- uuid should work even when ctypes is not available, so you can't just put an 
import statement at the top-level without a fallback

--
nosy: +pitrou
stage: needs patch - patch review

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



[issue11127] sockets should not be pickleable

2011-02-05 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

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



[issue11109] socketserver.ForkingMixIn leaves zombies

2011-02-05 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

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



[issue11116] mailbox and email errors

2011-02-05 Thread R. David Murray

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

Thanks, much easier to communicate when runnable code is involved :) Now I can 
see what you mean about it writing the From.  I will figure out why and fix it 
so that the From line is not written.

The traceback from email.generator is unfortunate.  I should have 
message_from-string reject non-ASCII input with a clear error message like 
mailbox.add does now, but I didn't think of it.  I will see if the release 
manager will let me make that change.

For case (2) it is working as designed: faithfully writing the non-conformant 
message to the mbox.  If you wish to do other sorts of handling of 
non-conformant email you need to write code to do that.  You can use the email 
package to make it technically conformant (and ASCII only) by doing something 
like message_from_string(str(message_from_bytes(non_conformant_message)))  I'm 
not sure why you'd want to do that, though :)

--
nosy: +georg.brandl

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

uuid should work even when ctypes is not available
A bit of offtopic: why can't we assume that ctypes is available?

--

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Antoine Pitrou

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

 A bit of offtopic: why can't we assume that ctypes is available?

Because ctypes (or, actually, the libffi it relies on) needs specific low-level 
code for each platform it runs on, and not all platforms have such code.

Another reason is that ctypes is dangerous and some administrators might prefer 
to disable it (especially on shared hosting ala Google App Engine).

--

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



[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-02-05 Thread Gerard van Helden

Gerard van Helden dremel...@gmail.com added the comment:

The reporter imho is 100% right. Simply because of the fact that in the current 
situation, there is no way to supply an argument starting with a dash (not even 
for instance a filename). That is, of course, total nonsense to be dictated by 
the parser library.

--
nosy: +drm

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Kenny Meyer

Kenny Meyer knny.m...@gmail.com added the comment:

Thanks for pointing that out! I guess that is the reason you did the import
in a try block.

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

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11063
___font face=courier new,monospaceThanks/font for pointing that out! I guess 
that is the reason you did the import in a try block.br
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

Maybe I understood and ctypes ImportError simply must be handled and fallbacked 
to something else. But there are only 3 ways of getting MAC address:
1. using popen
2. using ctypes and native calls
3. using C API and performing native calls in extension

And ctypes seems to be the best choice: it's portable across Python VMs (better 
that 3) and faster (better than 1).

--

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Antoine Pitrou

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

 Maybe I understood and ctypes ImportError simply must be handled and
 fallbacked to something else.

Indeed.

 But there are only 3 ways of getting MAC address:
 1. using popen
 2. using ctypes and native calls
 3. using C API and performing native calls in extension
 
 And ctypes seems to be the best choice: it's portable across Python
 VMs (better that 3) and faster (better than 1).

Perhaps, but doing without ctypes should still be possible, otherwise
it's a regression.

--

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Keith Dart

Keith Dart ke...@dartworks.biz added the comment:

It's also possible using existing wrapped os system calls. One exaple is here: 
http://code.google.com/p/pycopia/source/browse/trunk/aid/pycopia/ifconfig.py

Although that one doesn't current support MAC addresses, but it could. The 
socket module also now support the netlink socket on Linux, so it shouldbe 
possible to use that for getting MAC address on Linux.

--

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Vetoshkin Nikita

Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment:

It's also possible using existing wrapped os system calls.
That's right, on linux we can use ioctls but windows would require win api 
calls like this one: 
http://stackoverflow.com/questions/166506/finding-local-ip-addresses-in-python/166992#166992

--

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Kenny Meyer

Changes by Kenny Meyer knny.m...@gmail.com:


Removed file: http://bugs.python.org/file20687/unnamed

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Keith Dart

Keith Dart ke...@dartworks.biz added the comment:

I'm thinking Python could use a general purpose ifconfig/mac-layer module that 
uuid.py could then just use.

--

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



[issue11063] uuid.py module import has heavy side effects

2011-02-05 Thread Antoine Pitrou

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

 I'm thinking Python could use a general purpose ifconfig/mac-layer
 module that uuid.py could then just use.

Perhaps, but that's really out of scope for this issue. Feel free to
open another issue.

--

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



[issue11121] libpython3.so support with --enable-shared

2011-02-05 Thread Martin v . Löwis

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

Thanks for the review. Committed as r88350.

--
resolution:  - accepted
status: open - closed

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



[issue11067] Py_LIMITED_API breaks most PySomething_Check() functions

2011-02-05 Thread Martin v . Löwis

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

Thanks for the review. Committed as r88351.

--
status: open - closed

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



[issue10882] Add os.sendfile()

2011-02-05 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

Patch in attachment provides a complete test suite.
It also fixes a problem which occurred on BSD platforms when using non-blocking 
sockets: EAGAIN/EBUSY are now raised if the transmitted data == 0 bytes 
reflecting socket's send() behavior:

+if (ret  0) {
+if ((errno == EAGAIN) || (errno == EBUSY)) {
+if (sbytes != 0) {
+// some data has been sent
+goto done;
+}
+else {
+// no data has been sent; upper application is supposed
+// to retry on EAGAIN or EBUSY
+return posix_error();
+}
+}
+return posix_error();
+}
+goto done;

The test suite shows that trailer argument does not work.
I couldn't manage to figure out what's wrong though.

--
Added file: http://bugs.python.org/file20688/sendfile_v6.patch

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



[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-02-05 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

While I also dislike the existing behavior, note that you can get what you want 
by using an equal sign.

 import argparse
 parser = argparse.ArgumentParser(prog='a2x')
 parser.add_argument('--asciidoc-opts',
... action='store', dest='asciidoc_opts', default=''
... metavar='ASCIIDOC_OPTS', help='asciidoc options')
 parser.parse_args(['--asciidoc-opts', '-1'])
Namespace(asciidoc_opts='-1')
 parser.parse_args(['--asciidoc-opts=-one'])
Namespace(asciidoc_opts='-one')

I always use the equal sign, so I've never noticed this behavior before.

I wish that help would display the equal sign, but that's another issue.

--
versions: +Python 3.3 -Python 3.2

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



[issue11109] socketserver.ForkingMixIn leaves zombies

2011-02-05 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

Rather than depending on the internal details of ForkingMixIn in your 
BaseServer.serve_forever modification I'd prefer to see that simply call 
self._cleanup()

Define a do-nothing _periodic_cleanup method in BaseServer.  ForkingMixIn 
should implement its own _periodic_cleanup method that does the active_children 
test and calls collect_children as appropriate.

--

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



[issue7108] test_commands.py failing on OS X 10.5.7 due to '@' in ls output

2011-02-05 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
assignee: ronaldoussoren - 

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



[issue11085] expose _abcoll as collections.abc

2011-02-05 Thread Raymond Hettinger

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

I'll use the packaging approach.  The os.path technique predated packages and 
is no longer the preferred way of doing things.

--

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



[issue7678] subprocess.Popen pipeline example code in the documentation is lacking

2011-02-05 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

documentation updated in r88352.  thanks!

--
assignee: docs@python - gregory.p.smith
resolution:  - fixed
status: open - closed

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



[issue1615376] subprocess doesn\'t handle SIGPIPE

2011-02-05 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

The need to call p1.stdout.close() has now been documented as part of 
issue7678.  Python 3.2's subprocess also has restore_signals=True as its 
default behavior so SIGPIPE is restored by default.

I do not think it is appropriate to to add the synchronization Peter suggested 
to the subprocess module to optimize that close call.  The potential delay due 
to python having to call p1.stdout.close() is non-fatal and should be assumed 
to exist anyways as you can't guarantee when an async event like a signal (in 
this case SIGPIPE) will actually reach the other process.

--
assignee:  - gregory.p.smith
resolution:  - wont fix
status: open - closed

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



[issue11079] Make OS X entry in Applications like that in Windows

2011-02-05 Thread Ned Deily

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

Ping!  Raymond, this needs review and release manager approval to make it into 
3.2 final.

--

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



[issue969718] BASECFLAGS are not passed to module build line

2011-02-05 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Éric, the Debian patch looks good to me and it solves my build problem.

The only question I have is why EXTRA_CFLAGS still go behind CFLAGS
and cannot be overridden via the environment.

But as it is, the patch is an improvement. I'm attaching the version
for 2.7.

--
stage:  - patch review
Added file: http://bugs.python.org/file20689/sysconfig-flags.patch

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



[issue969718] BASECFLAGS are not passed to module build line

2011-02-05 Thread Antoine Pitrou

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

Why is OPT duplicated in get_config_vars(...)?
Why do OPT and BASECFLAGS environ vars override their Makefile values instead 
of accumulating with them?
Why is EXTRA_CFLAGS not configurable through environ?

--

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



  1   2   >