Python3: API Documentation generator

2010-09-27 Thread Tim Diels

 Hi all

I've just switched to python3 and it turns out my current API 
documentation generator (epydoc) no longer works. I am looking for a 
tool that reads the docstrings of all classes, ... in my project and 
turns it into HTML documentation.


Thanks for your time

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


Re: Python3: API Documentation generator

2010-09-27 Thread Chris Rebert
On Sun, Sep 26, 2010 at 11:56 PM, Tim Diels fark...@gmail.com wrote:
  Hi all

 I've just switched to python3 and it turns out my current API documentation
 generator (epydoc) no longer works. I am looking for a tool that reads the
 docstrings of all classes, ... in my project and turns it into HTML
 documentation.

Sphinx (http://sphinx.pocoo.org/ ) is the new gold standard. You'll
want to enable the `autodoc` extension:
http://sphinx.pocoo.org/ext/autodoc.html

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


Re: Calling an arbitrary function with the right arguments

2010-09-27 Thread Bruno Desthuilliers

John O'Hagan a écrit :
How to call a function with the right arguments without knowing in advance 
which function? 


(snip)

For most use case I can think of, I can only second Steven and Chris - 
if your functions are interchangeable then they should have a same API.


Now there's at least one use case I know where you need to dynamically 
select a function then build the right arguments set for it: when 
mapping urls to http request handler functions. There's a good example 
in Django's url to view mapping system.

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


Re: Calling an arbitrary function with the right arguments

2010-09-27 Thread Peter Otten
John O'Hagan wrote:

 How to call a function with the right arguments without knowing in advance
 which function? For example:
 
 import random
 
 def f1():
 pass
 
 def f2(foo):
 pass
 
 def f3(foo, bar):
 pass
 
 foo=random.choice((1,2,3))
 bar=random.choice((1,2,3))
 
 myfunc=random.choice((f1, f2, f3))
 
 How to call myfunc with the right arguments?
 I've been doing it this way:
 
 f1.args=()
 f2.args=('foo',)
 f3.args=('foo', 'bar')
 
 args=[vars()[i] for i in myfunc.args]
 
 myfunc(*args)
 
 But it seems redundant to manually tag the functions with their own
 arguments' names, and I don't like using vars(). Is there a nicer pattern?

You can use inspect.getargspec() to determine the argument names:

args = [vars()[argname] for argname in inspect.getargspec(myfunc).args]


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


Re: Calling an arbitrary function with the right arguments

2010-09-27 Thread Jean-Michel Pichavant

John O'Hagan wrote:
How to call a function with the right arguments without knowing in advance 
which function? For example:


import random

def f1():
pass

def f2(foo):
pass

def f3(foo, bar):
pass

foo=random.choice((1,2,3))
bar=random.choice((1,2,3))

myfunc=random.choice((f1, f2, f3))

How to call myfunc with the right arguments?
I've been doing it this way:

f1.args=()
f2.args=('foo',)
f3.args=('foo', 'bar')

args=[vars()[i] for i in myfunc.args]

myfunc(*args)

But it seems redundant to manually tag the functions with their own arguments' 
names, and I don't like using vars(). Is there a nicer pattern? 


Regards,

John

  

Hi,

func, args = random.choice(((f1, ()), (f2, (foo,)), (f3, (foo, bar
func(*args)

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


check path.exists() with a converted path

2010-09-27 Thread Alessandro
Hi, I'm a python newbie with a problem too hard to tackle.

I have a string defining a path, were all the spaces have been
converted to underscores.
How can I find if it corresponds to a real path?

e.g. a string like '/some/path_to/directory_1/and_to/directory_2'
with a real path: '/some/path_to/directory 1/and_to/directory 2'

notice that the real path can contain BOTH spaces and underscores.

How can I feed it to os.path.exists() ???

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


Re: check path.exists() with a converted path

2010-09-27 Thread Chris Rebert
On Mon, Sep 27, 2010 at 2:23 AM, Alessandro alexxx.ma...@gmail.com wrote:
 Hi, I'm a python newbie with a problem too hard to tackle.

 I have a string defining a path, were all the spaces have been
 converted to underscores.
 How can I find if it corresponds to a real path?

 e.g. a string like '/some/path_to/directory_1/and_to/directory_2'
 with a real path: '/some/path_to/directory 1/and_to/directory 2'

 notice that the real path can contain BOTH spaces and underscores.

 How can I feed it to os.path.exists() ???

Use the `glob` module instead: http://docs.python.org/library/glob.html

from glob import glob
real_paths = glob(underscored_path.replace('_','[_ ]'))
#note: it's possible for there to be multiple matches

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


problem in Gasp !

2010-09-27 Thread n.a.s
Hi,

I want to ask about graphics using Gasp .Attached is exercise 10 (houses at
night) http://openbookproject.net/thinkCSpy/ch04.html#exercises ,if  i
call the draw_house function once it will work properly ,but more than one
call,windows and doors disappear from some houses .

Any one can advice?


Thanks,


house.pyw
Description: Binary data
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: check path.exists() with a converted path

2010-09-27 Thread Paul Rudin
Alessandro alexxx.ma...@gmail.com writes:

 Hi, I'm a python newbie with a problem too hard to tackle.

 I have a string defining a path, were all the spaces have been
 converted to underscores.
 How can I find if it corresponds to a real path?

 e.g. a string like '/some/path_to/directory_1/and_to/directory_2'
 with a real path: '/some/path_to/directory 1/and_to/directory 2'

 notice that the real path can contain BOTH spaces and underscores.

 How can I feed it to os.path.exists() ???

If you just have the converted string then you can't know what the
original string is, you have no way of knowing which underscores were
actually underscores in the original and which where spaces. 

You could generate all possible candidate original strings and check for
file existence, but in general there are many different original strings
that will yield the same converted string, possibly more than one of
those corresponds to a file that exists.





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


Re: check path.exists() with a converted path

2010-09-27 Thread Raphaël Plasson
On Sep 27, 6:23 pm, Alessandro alexxx.ma...@gmail.com wrote:


 I have a string defining a path, were all the spaces have been
 converted to underscores.

(...)

 notice that the real path can contain BOTH spaces and underscores.

 How can I feed it to os.path.exists() ???


You are losing some information, there is no other choice to test all
the combinations.
Something like this should do the trick (/!\ quick and dirty
solution /!\)

def testpath(path):
tmp=path.split(_)
for i in range(2**(len(tmp)-1)):
res=
for j in range(len(tmp)):
if j0:
if (i  2**(j-1))==0:
res +=  
else:
res += _
res+=tmp[j]
if os.path.exists(res):
return True
return False

Raphael

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


Re: check path.exists() with a converted path

2010-09-27 Thread Peter Otten
Alessandro wrote:

 Hi, I'm a python newbie with a problem too hard to tackle.
 
 I have a string defining a path, were all the spaces have been
 converted to underscores.
 How can I find if it corresponds to a real path?
 
 e.g. a string like '/some/path_to/directory_1/and_to/directory_2'
 with a real path: '/some/path_to/directory 1/and_to/directory 2'
 
 notice that the real path can contain BOTH spaces and underscores.
 
 How can I feed it to os.path.exists() ???

$ mkdir -p aa{\ ,_}aa/bb{\ ,_}b{\ ,_}/c\ c
$ tree
.
|-- aa aa
|   |-- bb b
|   |   `-- c c
|   |-- bb b_
|   |   `-- c c
|   |-- bb_b
|   |   `-- c c
|   `-- bb_b_
|   `-- c c
`-- aa_aa
|-- bb b
|   `-- c c
|-- bb b_
|   `-- c c
|-- bb_b
|   `-- c c
`-- bb_b_
`-- c c

18 directories, 0 files
$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type help, copyright, credits or license for more information.
 import glob
 path = aa_aa/bb_b_/c_c
 glob.glob(path.replace(_, [_ ]))
['aa_aa/bb b_/c c', 'aa_aa/bb_b /c c', 'aa_aa/bb b /c c', 'aa_aa/bb_b_/c c', 
'aa aa/bb b_/c c', 'aa aa/bb_b /c c', 'aa aa/bb b /c c', 'aa aa/bb_b_/c c']

I didn't want to throw away my demo just because your question was already 
anwered ;)

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


Re: check path.exists() with a converted path

2010-09-27 Thread Alessandro
people, you're great - best newsgroup I've ever been!

I think I'll go with the glob suggestion - works like a charm!!!

thank you...


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


Re: Too much code - slicing

2010-09-27 Thread Antoon Pardon
On Thu, Sep 23, 2010 at 12:23:22AM +, Steven D'Aprano wrote:
 On Tue, 21 Sep 2010 16:17:48 +0200, Antoon Pardon wrote:
 
  On Tue, Sep 21, 2010 at 12:07:07AM +, Steven D'Aprano wrote:
  On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote:
  
   Not necessarily. Some of us have the impression that Guido
   deliberatly chose an ugly format for the ternary operator.
  
  If he did, then he must have changed his mind, because there is nothing
  ugly about the ternary operator we ended up with.
  
  That is a question of taste 
 
 Yes, it certainly is. Describing it as an ugly format is also a matter 
 of taste -- taste which in my opinion simply isn't justified by anything 
 other than familiarity.

There is the facts that it broke familiarity with a common pattern.

  This form only ranked fourth (or maybe third), with the first three all
  wanting ar structure with the elelement is this order: condition, true
  case, false case
  
   Guido has alwasys been
   against a ternary operator but the requests kept coming. So
   eventually he introduced one. But the impression is that he chose an
   ugly format in the hope of discouraging people to use it.
  
  That's sheer and unadulterated nonsense. The fact is that Guido changed
  his mind about ternary if after discovering that the work-around
  
  true-clause and condition or false-clause
  
  is buggy -- it gives the wrong answer if true-clause happens to be a
  false value like [], 0 or None. If I recall correctly, the bug bit
  Guido himself.
  
  Nonsense. That the work around was buggy was known years before the
  ternary operator was finally introduced.
 
 But people kept forgetting it, and it bit the right person one time too 
 many.

So? That it took years between the knowledge that the work-around failed
and a ternary operator finally appearing is still a fact. Which casts doubts
that is was this knowledge that made him change his mind.

  The introduction of list
  comprehension made a ternary operator that more usefull but every time
  it came up the supporters of Guido, told us we just had to define a
  function if we wanted the items to depend on a condition.
 
 A function can't do the job, because it isn't lazy:
 
 def ifte(condition, x, y):
 if condition: return x
 else: return y
 
 n = 0
 ifte(n != 0, 100/n, -1)
 
 will fail. This was perhaps *the* killer argument for a ternary-if 
 operator.

You really don't seem to remember what happened then.

Someone would come with a problem that we can now solve as follows.

ls = [ el / 2 if el % 2 == 0 else 3 * el + 1 for el in ls ]

and the respons would be that we just needed to write is as follows:

def f(el):
  if el % 2 == 0:
return el / 2
  else:
return 3 * el + 1

ls = [ f(el) for el in ls ]

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


Plone Conference 2010 schedule published

2010-09-27 Thread Matt Hamilton
Over 400 attendees are set to meet at the 8th annual Plone Conference
for a week-long programme of training, talks and developer sprints
from the 25th to 31st October at the Thistle Grand Hotel in Bristol,
UK.

Plone Conference 2010 registrations are open.

Plone, an Open Source Content Management System used throughout the
world has a massive following and Plone events are held around the
globe. The largest of these is the annual Plone Conference and this
year will be held in the UK. Plone is used for developing websites,
intranet and portals for corporations, NGOs and the public sector.

Organised by Netsight Internet Solutions, it promises to bring
together developers, designers, end users and business people. This
year an additional event is being planned as a one-day mini-conference
on the 26th October called Plone in Business which will be aimed
specifically at analysts, advisors, evaluators and information
professionals looking to find out more about Plone and see a showcase
of successful Plone projects from across the sectors. It will also see
the launch of the JBoye Plone Community of Practice.

The main part of the conference, from the 27th - 29th October, has
over 50 scheduled talks from speakers from 19 countries and includes
an 'unconference' day in which talks will be proposed by the
attendees. 

Plone Conference 2010 scheduled talks include:

* Easier and faster Plone theming with Deliverance
* Design and Development with Dexterity
* Enterprise Search in Plone with Solr
* Boosting productivity with Plone-driven Plone development
* Brasil.gov.br: Building a digital nation with Plone

Alan Runyan, co-founder of Plone and president of Enfold Systems along
with Alex Limi, fellow co-founder of Plone and now Firefox User
Experience Lead at Mozilla will be delivering a keynote. There will
also be a guest keynote by Richard Noble, OBE, project director of the
Bloodhound SSC project attempting be build a car to pass the 1,000mph
land speed mark.

The conference falls at a great time, with the recent release of Plone
4, a product that raises the bar in the Content Management System
market with a faster, more user-friendly and more refined version of
the product.

So far, registrations for the conference have come from over 30
countries around the world. To find out more about the conference and
to register, visit http://ploneconf2010.org.


-- 
Matt Hamilton ma...@netsight.co.uk
Netsight Internet Solutions, Ltd.  Business Vision on the Internet
http://www.netsight.co.uk   +44 (0)117 9090901
Web Design | Zope/Plone Development and Consulting | Co-location | Hosting


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


possible circular import problem with python-3, but not python-2

2010-09-27 Thread Darren Dale
I am attempting to contribute to the h5py project by porting the code
for python-3. The code is available in a branch at github:
http://github.com/darrendale/h5py/tree/py3k . That code uses cython to
wrap the hdf5 library.

So far, only a few minor changes have been needed (relative imports,
changes concerning strings/bytes), and I have been able to generate
the c sources, build and install h5py for py3k. But I can't actually
import the library. On Snow Leopard, using the python-3 installed via
MacPorts:

 import h5py
Traceback (most recent call last):
  File stdin, line 1, in module
  File /Users/darren/.local/lib/python3.1/site-packages/
h5py-1.3.1.dev-py3.1-macosx-10.6-x86_64.egg/h5py/__init__.py, line
34, in module
from . import h5, h5a, h5d, h5f, h5fd, h5g, h5l, h5o, h5i, h5p,
h5r, h5s, h5t, h5z
  File h5t.pxd, line 17, in init h5py.h5a (h5py/h5a.c:5248)
  File h5p.pxd, line 23, in init h5py.h5t (h5py/h5t.c:16481)
  File h5t.pxd, line 17, in init h5py.h5p (h5py/h5p.c:9297)
ImportError: No module named h5t

That looks like it might be a circular import problem, but it works
fine with python-2.6. I'm at a loss on how to proceed, could anyone
please offer a suggestion?

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


Re: Errors with PyPdf

2010-09-27 Thread flebber
On Sep 27, 2:46 pm, Dave Angel da...@ieee.org wrote:
 On 2:59 PM, flebber wrote:

  snip
  Traceback (most recent call last):
     File C:/Python26/Pdfread, line 16, inmodule
       open('x.txt', 'w').write(content)
  NameError: name 'content' is not defined
  When i use.

  import pyPdf

  def getPDFContent(path):
       content =C:\Components-of-Dot-NET.txt
       # Load PDF into pyPDF
       pdf =yPdf.PdfFileReader(file(path, rb))
       # Iterate pages
       for i in range(0, pdf.getNumPages()):
           # Extract text from page and add to content
           content +=df.getPage(i).extractText() + \n
       # Collapse whitespace
       content = .join(content.replace(u\xa0,  ).strip().split())
       return content

  print getPDFContent(rC:\Components-of-Dot-NET.pdf).encode(ascii,
  ignore)
  open('x.txt', 'w').write(content)

 There's no global variable content, that was local to the function.  So
 it's lost when the function exits.  it does return the value, but you
 give it to print, and don't save it anywhere.

 data = getPDFContent(rC:\Components-of-Dot-NET.pdf).encode(ascii,
 ignore)

 outfile = open('x.txt', 'w')
 outfile.write(data)

 close(outfile)

 I used a different name to emphasize that this is *not* the same
 variable as content inside the function.  In this case, it happens to
 have the same value.  And if you used the same name, you could be
 confused about which is which.

 DaveA

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


Re: Raw Sockets - IP-Encapsulation

2010-09-27 Thread Alexander Gattin
Hello,

On Fri, Sep 24, 2010 at 04:51:01PM +0100, Nobody
wrote:
 On Thu, 23 Sep 2010 21:41:19 +0200, Matthias
 Guentert wrote:
  I would like to create an IP tunnel using the
  IP protocol type 4 (socket.IPPROTO_IPIP) on a
  Linux host. (I also would be happy if I could
  create a GRE tunnel)
  
  The thing is, I just don't understand how I
  such a socket could be created and then later
  on handled.
 
 You don't create sockets for IPPROTO_IPIP or
 IPPROTO_GRE.  Outside of the kernel, those
 identifiers are only likely to be used for
 specifying protocols when e.g. configuring
 packet filtering.
 
 Tunnelling only involves user-space for
 configuration.

For GRE/IPIP this is true, but with /dev/tun
and /dev/tap tunnels it isn't -- userspace
program actually reads from/writes to tun/tap
device file descriptor.

-- 
With best regards,
xrgtn
-- 
http://mail.python.org/mailman/listinfo/python-list


minimal D: need software testers

2010-09-27 Thread Kruptein
Hey,

I've released the second alpha for minimal-D a program I've written in
python which should make developing easier.
I need people to test the app on bugs and give ideas.

It is written in python using the wxPython toolkit and is linux-only.
(using on windows is on own risk)

You can download a .deb or a .tar.gz from http://launchpad.net/minimal
-- 
http://mail.python.org/mailman/listinfo/python-list


reduced-tagged (was Re: toy list processing problem: collect similar terms)

2010-09-27 Thread Mirko
On Sep 26, 12:05 am, Xah Lee xah...@gmail.com wrote:

I am hijacking the following post and driving it to Cuba (the Monthy
Python fans will know what I refer to).  I want to create a `reduce'-
like function that can handle similar problems.

Xah said:
 here's a interesting toy list processing problem.

 I have a list of lists, where each sublist is labelled by
 a number. I need to collect together the contents of all sublists
 sharing
 the same label. So if I have the list

 ((0 a b) (1 c d) (2 e f) (3 g h) (1 i j) (2 k l) (4 m n) (2 o p) (4 q
 r) (5 s t))

 where the first element of each sublist is the label, I need to
 produce:

 output:
 ((a b) (c d i j) (e f k l o p) (g h) (m n q r) (s t))

 stuffed deleted.

Here is my Common Lisp (and I only care about Common Lisp answers)
attempt to create a `reduce'-like function to handle this kind of a
problem (you will see that I am still struggling with the code and the
documentation).

(defun reduce-tagged (function sequence key
 (key-tag #'first)
 (key-datum #'rest))
  Use a binary operation, `function' to combine a sequence of tagged
elements.  like-tagged elements are `reduce'd according to `function'
and returned in a list ...

`sequence' is a sequence of tagged elements.  reduce-m will reduce
like-tagged-elements.

If `key-tag' is supplied it is used to extract the element tag.  If
`key-tag' is not supplied, the function `first' is used.

If `key-datum' is supplied, it is used to extract the element datum.
If `key-datum' is not supplied, the function `rest' is used.


  (let ((hash (make-hash-table)))
(dolist (datum sequence)
  (let ((tag (funcall key-tag datum))
(values (funcall key-datum datum)))
(multiple-value-bind (it present)
(gethash tag hash)
  (if present
  (setf (gethash tag hash)
(apply function (gethash tag hash) values))
  (setf (gethash tag hash) values)
(let (result)
  (dohash (key value hash)
(push (list key value) result))
  result)))

Comments, improvements?  I am looking for a general purpose function
like reduce that I
can apply in various situations.

Thanks,

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


Re: reduce-tagged (was Re: toy list processing problem: collect similar terms)

2010-09-27 Thread Mirko
On Sep 27, 11:18 am, Mirko mirko.vuko...@gmail.com wrote:
 On Sep 26, 12:05 am, Xah Lee xah...@gmail.com wrote:

 I am hijacking the following post and driving it to Cuba (the Monthy
 Python fans will know what I refer to).  I want to create a `reduce'-
 like function that can handle similar problems.

 Xah said:



  here's a interesting toy list processing problem.

  I have a list of lists, where each sublist is labelled by
  a number. I need to collect together the contents of all sublists
  sharing
  the same label. So if I have the list

  ((0 a b) (1 c d) (2 e f) (3 g h) (1 i j) (2 k l) (4 m n) (2 o p) (4 q
  r) (5 s t))

  where the first element of each sublist is the label, I need to
  produce:

  output:
  ((a b) (c d i j) (e f k l o p) (g h) (m n q r) (s t))

  stuffed deleted.

 Here is my Common Lisp (and I only care about Common Lisp answers)
 attempt to create a `reduce'-like function to handle this kind of a
 problem (you will see that I am still struggling with the code and the
 documentation).

 (defun reduce-tagged (function sequence key
                  (key-tag #'first)
                  (key-datum #'rest))
   Use a binary operation, `function' to combine a sequence of tagged
 elements.  like-tagged elements are `reduce'd according to `function'
 and returned in a list ...

 `sequence' is a sequence of tagged elements.  reduce-m will reduce
 like-tagged-elements.

 If `key-tag' is supplied it is used to extract the element tag.  If
 `key-tag' is not supplied, the function `first' is used.

 If `key-datum' is supplied, it is used to extract the element datum.
 If `key-datum' is not supplied, the function `rest' is used.

 
   (let ((hash (make-hash-table)))
     (dolist (datum sequence)
       (let ((tag (funcall key-tag datum))
             (values (funcall key-datum datum)))
         (multiple-value-bind (it present)
             (gethash tag hash)
           (if present
               (setf (gethash tag hash)
                     (apply function (gethash tag hash) values))
               (setf (gethash tag hash) values)
     (let (result)
       (dohash (key value hash)
         (push (list key value) result))
       result)))

 Comments, improvements?  I am looking for a general purpose function
 like reduce that I
 can apply in various situations.

 Thanks,

 Mirko

Correction: the previous code used a non-portable clisp macro
`dohash' (looks nice, doesn't it?)

Here is the version with maphash:

(defun reduce-tagged (function sequence key
 (key-tag #'first)
 (key-datum #'rest))
  Use a binary operation, `function' to combine a sequence of tagged
elements.  like-tagged elements are `reduce'd according to `function'

`sequence' is a sequence of tagged elements.  reduce-m will reduce
like-tagged-elements.

If `key-tag' is supplied it is used to extract the element tag.  If
`key-tag' is not supplied, the function `first' is used.

If `key-datum' is supplied, it is used to extract the element datum.
If `key-datum' is not supplied, the function `rest' is used.


  (let ((hash (make-hash-table)))
(dolist (datum sequence)
  (let ((tag (funcall key-tag datum))
(values (funcall key-datum datum)))
(multiple-value-bind (it present)
(gethash tag hash)
  (declare (ignore it))
  (if present
  (setf (gethash tag hash)
(apply function (gethash tag hash) values))
  (setf (gethash tag hash) values)
(let (result)
  (maphash #'(lambda(key value)
   (push (list key value) result))
   hash)
  result)))

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


Introducing Kids to Programming: 2 or 3?

2010-09-27 Thread Marco Gallotta
Hi there

I'm sure you get a lot of 2 or 3 questions, but here's another.
Umonya [1] uses Python to introduce school kids to programming. The
initiative is only 15 months old and up till now we've been using
existing notes and exercises and thus Python 2. But we're at the stage
where we can either stick with 2 for the next few years, or go to 3
now.

We received a grant from Google to reach 1,000 kids in South Africa
with our course in 2011. People have also shown interest in running
the course in Croatia, Poland and Egypt. We're also eyeing developing
African countries in the long-term. As such, we're taking the time now
to write our very own specialised course notes and exercises, and we
this is why we need to decide *now* which path to take: 2 or 3? As we
will be translating the notes we'll probably stick with out choice for
the next few years.

Since these are kids, we feel the nice changes in 3 such as removing
integer division will help in teaching. It will also remove confusion
when they go to download Python and grab the latest version. Since
they're just starting, chances are almost none will be hit by the
limited library support for at least a year or two. They will,
however, be hit by the confusion of seeing Python 2 code all over the
web.

We're tending towards 3, but I am a little cautious myself.

Marco

[1] http://umonya.co.za

-- 
Marco Gallotta
MSc Student
Department of Computer Science, University of Cape Town
people.cs.uct.ac.za/~mgallott | marco-za.blogspot.com
marco AT gallotta DOT co DOT za | 073 170  | 021 552 2731
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reduce-tagged (was Re: toy list processing problem: collect similar terms)

2010-09-27 Thread Mirko
On Sep 27, 11:40 am, Mirko mirko.vuko...@gmail.com wrote:
 On Sep 27, 11:18 am, Mirko mirko.vuko...@gmail.com wrote:



  On Sep 26, 12:05 am, Xah Lee xah...@gmail.com wrote:

  I am hijacking the following post and driving it to Cuba (the Monthy
  Python fans will know what I refer to).  I want to create a `reduce'-
  like function that can handle similar problems.

  Xah said:

   here's a interesting toy list processing problem.

   I have a list of lists, where each sublist is labelled by
   a number. I need to collect together the contents of all sublists
   sharing
   the same label. So if I have the list

   ((0 a b) (1 c d) (2 e f) (3 g h) (1 i j) (2 k l) (4 m n) (2 o p) (4 q
   r) (5 s t))

   where the first element of each sublist is the label, I need to
   produce:

   output:
   ((a b) (c d i j) (e f k l o p) (g h) (m n q r) (s t))

   stuffed deleted.

  Here is my Common Lisp (and I only care about Common Lisp answers)
  attempt to create a `reduce'-like function to handle this kind of a
  problem (you will see that I am still struggling with the code and the
  documentation).

 ... faulty code deleted

Aaand one more fix (apply - funcall)  (This version at least produces
a close
facsimile of the desired output)

(defun reduce-tagged (function sequence key
 (key-tag #'first)
 (key-datum #'rest))
  Use a binary operation, `function' to combine a sequence of tagged
elements.  like-tagged elements are `reduce'd according to `function'

`sequence' is a sequence of tagged elements.  reduce-m will reduce
like-tagged-elements.

If `key-tag' is supplied it is used to extract the element tag.  If
`key-tag' is not supplied, the function `first' is used.

If `key-datum' is supplied, it is used to extract the element datum.
If `key-datum' is not supplied, the function `rest' is used.


  (let ((hash (make-hash-table)))
(dolist (datum sequence)
  (let ((tag (funcall key-tag datum))
(values (funcall key-datum datum)))
(multiple-value-bind (it present)
(gethash tag hash)
  (declare (ignore it))
  (if present
  (setf (gethash tag hash)
(funcall function (gethash tag hash) values))
  (setf (gethash tag hash) values)
(let (result)
  (maphash #'(lambda(key value)
   (push (list key value) result))
   hash)
  result)))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Introducing Kids to Programming: 2 or 3?

2010-09-27 Thread Andreas Waldenburger
On Mon, 27 Sep 2010 17:48:06 +0200 Marco Gallotta
ma...@gallotta.co.za wrote:

 Since these are kids, we feel the nice changes in 3 such as removing
 integer division will help in teaching. It will also remove confusion
 when they go to download Python and grab the latest version. Since
 they're just starting, chances are almost none will be hit by the
 limited library support for at least a year or two.

That's your answer right there.


 They will, however, be hit by the confusion of seeing Python 2 code
 all over the web.

Good point. Here is may suggestion: Make the kids aware of the 2/3
issue as early as possible, but don't go into detail. Maybe start with
the obligatory Hello world program, and a few other simple things.
Then, when you get to the how do help myself on the net part of the
course (you're including that, right?), you make strong distinction
between Py2 and Py3 and tell them to make absolutely certain that it's
Python 3 code they're looking at. Maybe give the print() syntax as a
hint, but have them rely on more explicit descriptions that come with
the code. Later on (once they know more programming constructs to
appreciate the differences), include another lecture, specifically on
the difference between Python 2 and Python 3.

Disclaimer: I'm not an educator. Maybe this is horrible advice. Someone
with a better understanding of kids' and learner's minds please debunk
any nonsense I may have spouted here. I just like to go by the general
rule that, unlike adults, most kids aren't idiots.

/W

-- 
INVALID? DE!

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


Konya - Turkish Company Directory - NEW ! - Seyfi Suna www.een.kso.org.tr

2010-09-27 Thread Seyfi Suna
Konya - Turkish Company Directory - NEW ! - Seyfi Suna www.een.kso.org.tr
http://www.een.kso.org.tr/en/konya-firma-rehberi/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python3: API Documentation generator

2010-09-27 Thread Tim Diels

On 27/09/2010 09:02, Chris Rebert wrote:

On Sun, Sep 26, 2010 at 11:56 PM, Tim Dielsfark...@gmail.com  wrote:

  Hi all

I've just switched to python3 and it turns out my current API documentation
generator (epydoc) no longer works. I am looking for a tool that reads the
docstrings of all classes, ... in my project and turns it into HTML
documentation.


Sphinx (http://sphinx.pocoo.org/ ) is the new gold standard. You'll
want to enable the `autodoc` extension:
http://sphinx.pocoo.org/ext/autodoc.html

Cheers,
Chris
--
http://blog.rebertia.com


I tried, but it fails to run through python code that's not backwards 
compatible with older python versions.


It fails with: ...autodoc can't import/find module 'pytilities', it 
reported error: invalid syntax (overload.py, line 55)...


This is line 55 (runs in python3, not in python):
def process_args(self, *args, kwargs={})

Greetings

Tim (limyreth)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Strong typing vs. strong testing

2010-09-27 Thread namekuseijin
On 27 set, 05:46, TheFlyingDutchman zzbba...@aol.com wrote:
 On Sep 27, 12:58 am, p...@informatimago.com (Pascal J. Bourguignon)
 wrote:
  RG rnospa...@flownet.com writes:
   In article
   7df0eb06-9be1-4c9c-8057-e9fdb7f0b...@q16g2000prf.googlegroups.com,
    TheFlyingDutchman zzbba...@aol.com wrote:

   On Sep 22, 10:26 pm, Scott L. Burson sc...@ergy.com wrote:
This might have been mentioned here before, but I just came across it: 
a
2003 essay by Bruce Eckel on how reliable systems can get built in
dynamically-typed languages.  It echoes things we've all said here, but
I think it's interesting because it describes a conversion experience:
Eckel started out in the strong-typing camp and was won over.

   https://docs.google.com/View?id=dcsvntt2_25wpjvbbhk

-- Scott

   If you are writing a function to determine the maximum of two numbers
   passed as arguents in a dynamic typed language, what is the normal
   procedure used by Eckel and others to handle someone passing in
   invalid values - such as a file handle for one varible and an array
   for the other?

   The normal procedure is to hit such a person over the head with a stick
   and shout FOO.

  Moreover, the functions returning the maximum may be able to work on
  non-numbers, as long as they're comparable.  What's more, there are
  numbers that are NOT comparable by the operator you're thinking about!.

  So to implement your specifications, that function would have to be
  implemented for example as:

  (defmethod lessp ((x real) (y real)) ( x y))
  (defmethod lessp ((x complex) (y complex))
    (or ( (real-part x) (real-part y))
        (and (= (real-part x) (real-part y))
             ( (imag-part x) (imag-part y)

  (defun maximum (a b)
    (if (lessp a b) b a))

  And then the client of that function could very well add methods:

  (defmethod lessp ((x symbol) (y t)) (lessp (string x) y))
  (defmethod lessp ((x t) (y symbol)) (lessp x (string y)))
  (defmethod lessp ((x string) (y string)) (string x y))

  and call:

  (maximum 'hello WORLD) -- WORLD

  and who are you to forbid it!?

  --
  __Pascal Bourguignon__                    
  http://www.informatimago.com/-Hide quoted text -

  - Show quoted text -

 in C I can have a function maximum(int a, int b) that will always
 work. Never blow up, and never give an invalid answer. If someone
 tries to call it incorrectly it is a compile error.
 In a dynamic typed language maximum(a, b) can be called with incorrect
 datatypes. Even if I make it so it can handle many types as you did
 above, it could still be inadvertantly called with a file handle for a
 parameter or some other type not provided for. So does Eckel and
 others, when they are writing their dynamically typed code advocate
 just letting the function blow up or give a bogus answer, or do they
 check for valid types passed? If they are checking for valid types it
 would seem that any benefits gained by not specifying type are lost by
 checking for type. And if they don't check for type it would seem that
 their code's error handling is poor.

that is a lie.

Compilation only makes sure that values provided at compilation-time
are of the right datatype.

What happens though is that in the real world, pretty much all
computation depends on user provided values at runtime.  See where are
we heading?

this works at compilation time without warnings:
int m=numbermax( 2, 6 );

this too:
int a, b, m;
scanf( %d, a );
scanf( %d, b );
m=numbermax( a, b );

no compiler issues, but will not work just as much as in python if
user provides foo and bar for a and b... fail.

What you do if you're feeling insecure and paranoid?  Just what
dynamically typed languages do:  add runtime checks.  Unit tests are
great to assert those.

Fact is:  almost all user data from the external words comes into
programs as strings.  No typesystem or compiler handles this fact all
that graceful...
-- 
http://mail.python.org/mailman/listinfo/python-list


relative imports and sub-module execution

2010-09-27 Thread King
Hi,

After reading couple of docs and articles, I have implemented a simple
test package with nested modules.
When running main.py, everything is working fine. Some of my sub-
modules has some small test routines for debug purpose.
It's because I am using relative package imports at the top, I am not
able to run these sub modules individually.

For example, this works when running from main.py

Here is example structure

main.py
__init__.py
core/
__init__.py
   folder1
__init__.py
   f1a.py
   f1b.py
folder2
__init__.py
   f2a.py
   f2b.py

in folder2/f2b.py, I am importing

from core.folder1 import f1a
print f1a.myvar

Now I can't execute 'f2b.py' individually. It's giving an error:

ImportError: No module named core.folder2

Is this mean when you have created a package where modules are using
relative imports, they can't execute individually?

Another solution that I have discovered is using sys.path. Check this:

import sys
import os
sys.path.append(os.path.abspath(../../))
from core.folder1 import f1a
print f1a.myvar

This works fine and easier too. I can execute modules individually as
well as package is also working. Are there any disadvantages when
using above technique? Couple of articles suggests that this is a bad
practice and should not be used.

Need some clarifications.

Thanks

Prashant


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


Re: Introducing Kids to Programming: 2 or 3?

2010-09-27 Thread Terry Reedy

On 9/27/2010 11:48 AM, Marco Gallotta wrote:

Hi there

I'm sure you get a lot of 2 or 3 questions, but here's another.
Umonya [1] uses Python to introduce school kids to programming. The
initiative is only 15 months old and up till now we've been using
existing notes and exercises and thus Python 2. But we're at the stage
where we can either stick with 2 for the next few years, or go to 3
now.

We received a grant from Google to reach 1,000 kids in South Africa
with our course in 2011. People have also shown interest in running
the course in Croatia, Poland and Egypt. We're also eyeing developing
African countries in the long-term. As such, we're taking the time now
to write our very own specialised course notes and exercises, and we
this is why we need to decide *now* which path to take: 2 or 3? As we
will be translating the notes we'll probably stick with out choice for
the next few years.


I would absolutely, definitely, move to Python3, with the the intention 
of using 3.2 when it comes out in a few months. I suspect that most of 
your exercise code will need little change beyond what 2to3 does for you.



Since these are kids, we feel the nice changes in 3 such as removing
integer division will help in teaching.


There are several half-finished transitions in late 2.x. Removal of 
old-style classes, not only as the default, but completely, removes a 
source of confusion. The range/xrange confusion is gone. The 
input/raw_imput confusion is gome. I think most important for an 
international project is the shift to unicode as the default text type, 
including for identifiers. Kids who are not masters of English will want 
to write identifiers in their own language.


 It will also remove confusion

when they go to download Python and grab the latest version. Since
they're just starting, chances are almost none will be hit by the
limited library support for at least a year or two.


I personally consider this pretty irrelevant for teaching programming to 
kids. There is a *lot* in the stdlib to work with. And stdlib 
improvement is getting special emphasis for 3.2. Bug fixes may be 
backported, feature additions are not.


Even if one disagrees, 3rd-party library support is improving and will 
continue to improve especially after 3.2 is released. For instance, the 
recent release of numpy for 3.1 enables conversions that were blocked 
waiting for that.

http://sourceforge.net/projects/numpy/files/NumPy/1.5.0/numpy-1.5.0-win32-superpack-python3.1.exe/download

For another example, the web-sig appears to have agreed on a minimal, 
backward-compatible extension to PEP 333 to make wsgi work with Python3. 
This will be PEP . (It appears the problem was too many choices 
rather than no choice. Discussion continues on more extensive 
non-compatible changes.) This will allow existing wsgi tools to both 
work with Python3 *and* continue to be intercompatible. (The latter was 
the problem. If each tool made its own non-standard choice for Python3, 
that latter property would be lost.)


--
Terry Jan Reedy

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


Re: Python3: API Documentation generator

2010-09-27 Thread Terry Reedy

On 9/27/2010 1:15 PM, Tim Diels wrote:

On 27/09/2010 09:02, Chris Rebert wrote:

On Sun, Sep 26, 2010 at 11:56 PM, Tim Dielsfark...@gmail.com wrote:

Hi all

I've just switched to python3 and it turns out my current API
documentation
generator (epydoc) no longer works. I am looking for a tool that
reads the
docstrings of all classes, ... in my project and turns it into HTML
documentation.


Sphinx (http://sphinx.pocoo.org/ ) is the new gold standard. You'll
want to enable the `autodoc` extension:
http://sphinx.pocoo.org/ext/autodoc.html

Cheers,
Chris
--
http://blog.rebertia.com


I tried, but it fails to run through python code that's not backwards
compatible with older python versions.

It fails with: ...autodoc can't import/find module 'pytilities', it
reported error: invalid syntax (overload.py, line 55)...

This is line 55 (runs in python3, not in python):
def process_args(self, *args, kwargs={})


Unless the autodoc doc says that it does not work with all Python3 code, 
that strikes me as a bug (a new 3.x feature that was overlooked) that 
should be reported. The sphinx tracker is linked on the sphinx homepage

http://bitbucket.org/birkenfeld/sphinx/issues/
There is also a link to a google group for sphinx.


Does epydoc not work because is does not run on 3.1 or because it also 
chokes when fed the above code.


In the meanwhile, you could change the api ;-).

--
Terry Jan Reedy

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


Re: Python3: API Documentation generator

2010-09-27 Thread Ken Watford
On Mon, Sep 27, 2010 at 1:15 PM, Tim Diels limyr...@gmail.com wrote:
 On 27/09/2010 09:02, Chris Rebert wrote:

 On Sun, Sep 26, 2010 at 11:56 PM, Tim Dielsfark...@gmail.com  wrote:

  Hi all

 I've just switched to python3 and it turns out my current API
 documentation
 generator (epydoc) no longer works. I am looking for a tool that reads
 the
 docstrings of all classes, ... in my project and turns it into HTML
 documentation.

 Sphinx (http://sphinx.pocoo.org/ ) is the new gold standard. You'll
 want to enable the `autodoc` extension:
 http://sphinx.pocoo.org/ext/autodoc.html

 Cheers,
 Chris
 --
 http://blog.rebertia.com

 I tried, but it fails to run through python code that's not backwards
 compatible with older python versions.

 It fails with: ...autodoc can't import/find module 'pytilities', it reported
 error: invalid syntax (overload.py, line 55)...

 This is line 55 (runs in python3, not in python):
 def process_args(self, *args, kwargs={})


As far as I'm aware, autodoc works by importing the modules and then
reading doctext straight from the __doc__ attributes.
So the module in question has to import correctly in whatever
interpreter Sphinx is using. You probably need to install Sphinx with
python3 to get it to use the right interpreter. If you're using
easy_install or pip, check if you have an easy_install-3.1 or pip-3.1
(or similar) script installed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (and scheme lisp) x Python and modern langs [was Re: gossip, Guy Steel, Lojban, Racket]

2010-09-27 Thread Xah Lee
2010-09-27

 For instance, this is far more convenient:

 [x+1 for x in [1,2,3,4,5] if x%2==0]

 than this:

 map(lambda x:x+1,filter(lambda x:x%2==0,[1,2,3,4,5]))

How about this:

 LC(func, inputList, P)

compared to

 [func for myVar in inputList if P]

the functional form is:

• shorter
• not another idiysyncratic new syntax



now, a separate issue. Suppose we want some “list comprehension”
feature in a functional lang.
Normally, by default this can be done by

 filter( map(func, inputList), Predicate)

but perhaps this usage is so frequent that we want to create a new
fuction for it, to make it more convenient, and perhaps easier to make
the compiler to optimize more. e.g.

 LC(func, inputList, Predicate)

this is about whether a lang should create a new convenient function
that otherwise require 2 function combinations. Common Lisp vs Scheme
Lisp are the typical example of extreme opposites.

note, there's no new syntax involved.



Now, let's consider another separated issue related to so-called “list
comprehension”.
Suppose we decided that generating list by a filter is so frequently
used that it worth it to create a new func for it.

 LC(func, inputList, Predicate)

Now, in functional langs, in general a design principle is that you
want to reduce the number of function unless you really need. Because,
any combination of list related functions could potentionally be a new
function in your lang. So, if we really think LC is useful, we might
want to generalize it. e.g. in

 LC(func, inputList, Predicate)

is it worthwhile say to add a 4th param, that says return just the
first n? (here we presume the lang doesn't support list of infinite
elements) e.g.

 LC(func, inputList, Predicate, n)

what about partition the list to m sublists?

 LC(func, inputList, Predicate, n, m)

what about actualy more generalized partition, by m sublist then by m1
sublist then by m2 sublist?

 LC(func, inputList, Predicate, n, list(m,m1,m2,...))

what about sorting? maybe that's always used together when you need a
list?

 LC(func, inputList, Predicate, n, list(m,m1,m2,...), sortPredcate)

what if actually frequently we want LC to map parallel to branches?
e.g.

 LC(func, inputList, Predicate, n, list(m,m1,m2,...), sortPredcate,
mapBranch:True)

what if ...

you see, each of these or combination of these can be done by default
in the lang by sequenceing one or more functions (i.e. composition).
But when we create a new function, we really should think a lot about
its justification, because otherwise the lang becomes a bag of
functions that are non-essential, confusing.

In summary:

• “list comprehension” is a bad jargon.

• The concept of “list comprehension” is redundant. There's no
justification for the concept to exist except historical.

• The syntax of “list comprehension” in most lang is ad hoc syntax.

for those who find imperative lang good, then perhaps “list
comprehension” is good, because it adds another idiosyncratic syntax
to the lang, but such is with the tradition of imperative langs. The
ad hoc syntax aids in reading code by various syntactical forms and
hint words such as “[... for ... in ...]”.

 Xah ∑ xahlee.org ☄
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (and scheme lisp) x Python and modern langs [was Re: gossip, Guy Steel, Lojban, Racket]

2010-09-27 Thread namekuseijin
On 27 set, 16:06, Xah Lee xah...@gmail.com wrote:
 2010-09-27

  For instance, this is far more convenient:
  [x+1 for x in [1,2,3,4,5] if x%2==0]
  than this:
  map(lambda x:x+1,filter(lambda x:x%2==0,[1,2,3,4,5]))

 How about this:
[snip]

how about this:  read before replying.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Introducing Kids to Programming: Scratch

2010-09-27 Thread Kee Nethery
My son has been writing games using MIT's Scratch. It is visual and highly 
interactive. In an afternoon he can build something that looks cool to him, is 
interactive, and that he can share with others. It's not Python but he is 
learning how to make the tools do what he wants and he is getting results. He's 
8 years old.

http://scratch.mit.edu

For introducing kids to programming, I recommend Scratch.

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


Re: Strong typing vs. strong testing

2010-09-27 Thread Pascal J. Bourguignon
namekuseijin namekusei...@gmail.com writes:

 in C I can have a function maximum(int a, int b) that will always
 work. Never blow up, and never give an invalid answer. If someone
 tries to call it incorrectly it is a compile error.
 In a dynamic typed language maximum(a, b) can be called with incorrect
 datatypes. Even if I make it so it can handle many types as you did
 above, it could still be inadvertantly called with a file handle for a
 parameter or some other type not provided for. So does Eckel and
 others, when they are writing their dynamically typed code advocate
 just letting the function blow up or give a bogus answer, or do they
 check for valid types passed? If they are checking for valid types it
 would seem that any benefits gained by not specifying type are lost by
 checking for type. And if they don't check for type it would seem that
 their code's error handling is poor.

 that is a lie.

 Compilation only makes sure that values provided at compilation-time
 are of the right datatype.

 What happens though is that in the real world, pretty much all
 computation depends on user provided values at runtime.  See where are
 we heading?

 this works at compilation time without warnings:
 int m=numbermax( 2, 6 );

 this too:
 int a, b, m;
 scanf( %d, a );
 scanf( %d, b );
 m=numbermax( a, b );

 no compiler issues, but will not work just as much as in python if
 user provides foo and bar for a and b... fail.

 What you do if you're feeling insecure and paranoid?  Just what
 dynamically typed languages do:  add runtime checks.  Unit tests are
 great to assert those.

 Fact is:  almost all user data from the external words comes into
 programs as strings.  No typesystem or compiler handles this fact all
 that graceful...


I would even go further.

Types are only part of the story.  You may distinguish between integers
and floating points, fine.  But what about distinguishing between
floating points representing lengths and floating points representing
volumes?  Worse, what about distinguishing and converting floating
points representing lengths expressed in feets and floating points
representing lengths expressed in meters.

If you start with the mindset of static type checking, you will consider
that your types are checked and if the types at the interface of two
modules matches you'll think that everything's ok.  And six months later
you Mars mission will crash.

On the other hand, with the dynamic typing mindset, you might even wrap
your values (of whatever numerical type) in a symbolic expression
mentionning the unit and perhaps other meta data, so that when the other
module receives it, it may notice (dynamically) that two values are not
of the same unit, but if compatible, it could (dynamically) convert into
the expected unit.  Mission saved!


-- 
__Pascal Bourguignon__ http://www.informatimago.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strong typing vs. strong testing

2010-09-27 Thread Scott L. Burson

Pascal J. Bourguignon wrote:


On the other hand, with the dynamic typing mindset, you might even wrap
your values (of whatever numerical type) in a symbolic expression
mentionning the unit and perhaps other meta data, so that when the other
module receives it, it may notice (dynamically) that two values are not
of the same unit, but if compatible, it could (dynamically) convert into
the expected unit.  Mission saved!


In fairness, you could do this statically too, and without the consing 
required by the dynamic approach.


-- Scott

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


Re: Strong typing vs. strong testing

2010-09-27 Thread Pascal J. Bourguignon
Scott L. Burson sc...@ergy.com writes:

 Pascal J. Bourguignon wrote:

 On the other hand, with the dynamic typing mindset, you might even wrap
 your values (of whatever numerical type) in a symbolic expression
 mentionning the unit and perhaps other meta data, so that when the other
 module receives it, it may notice (dynamically) that two values are not
 of the same unit, but if compatible, it could (dynamically) convert into
 the expected unit.  Mission saved!

 In fairness, you could do this statically too, and without the consing
 required by the dynamic approach.

I don't deny it.  My point is that it's a question of mindset.

-- 
__Pascal Bourguignon__ http://www.informatimago.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: toy list processing problem: collect similar terms

2010-09-27 Thread ccc31807
On Sep 26, 12:05 am, Xah Lee xah...@gmail.com wrote:
 here's a interesting toy list processing problem.

 I have a list of lists, where each sublist is labelled by
 a number. I need to collect together the contents of all sublists
 sharing
 the same label. So if I have the list

 ((0 a b) (1 c d) (2 e f) (3 g h) (1 i j) (2 k l) (4 m n) (2 o p) (4 q
 r) (5 s t))

 where the first element of each sublist is the label, I need to
 produce:

 output:
 ((a b) (c d i j) (e f k l o p) (g h) (m n q r) (s t))

Here is a solution in Perl -- the verbose version. Please see my note
below.

SCRIPT:
use strict;
use warnings;
my %lists;

while (DATA)
{
chomp;
my ($k, @v) = split(/ /, $_);
push(@{$lists{$k}}, @v);
}

foreach my $k (sort keys %lists)
{
print $k - @{$lists{$k}}\n;
}

exit(0);

__DATA__
0 a b
1 c d
2 e f
3 g h
1 i j
2 k l
4 m n
2 o p
4 q r
5 s t

OUTPUT:
perl lists.plx
0 - a b
1 - c d i j
2 - e f k l o p
3 - g h
4 - m n q r
5 - s t

NOTE:
I assume that you want an idiomatic solution for the language. I have
therefore converted your data into a typical record oriented
structure. Perlistas don't use parenthesis. If you want a Lispy
solution, use Lisp. Further, Perl was made for exactly this kind of
problem, which is simple data munging, taking some input, transforming
it, and printing it out -- Practical Extraction and Reporting
Language. I know that some Lispers (R.G., are you reading?) will
object to a formulation like this: @{$lists{$k}}, but all this says
(in Perl) is to spit out the value contained in the hash element
$lists{$k} as an array, and is good idiomatic Perl, even if some
Lispers aren't quite up to the task of understanding it.

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


Re: [ctpug] Introducing Kids to Programming: 2 or 3?

2010-09-27 Thread Simon Cross
On Mon, Sep 27, 2010 at 5:48 PM, Marco Gallotta ma...@gallotta.co.za wrote:
 We received a grant from Google to reach 1,000 kids in South Africa
 with our course in 2011. People have also shown interest in running
 the course in Croatia, Poland and Egypt. We're also eyeing developing
 African countries in the long-term. As such, we're taking the time now
 to write our very own specialised course notes and exercises, and we
 this is why we need to decide *now* which path to take: 2 or 3? As we
 will be translating the notes we'll probably stick with out choice for
 the next few years.

If you were going to start running the course tomorrow I'd suggest
sticking with Python 2. Python 3 ports are rapidly becoming available
but few have had the bugs shaken out of them yet. In three or four
months I expect that the important bugs will have been dealt with.
Given that 2.x will not receive any new features, I think it is
effectively dead.

I would explicitly mention the existence of 2.7 and 3.2 [1] to
students (perhaps near the end of the first day or whenever they're
about to go off and download Python for themselves).

One caveat is that web applications may only start to migrate to 3.x
late next year. There are a number of reasons for this. First it's not
yet clear what form the WSGI standard will take under Python 3 (and if
3.2 is released before this decision is made it will effectively have
to wait for 3.3 to be included).  Secondly the software stack involved
is quite deep in some places. For example, database support might
require porting MySQLdb, then SQLAlchemy, then the web framework and
only after that the web application itself.

[1] Which should hopefully make it out before 2011. :)

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


Re: (and scheme lisp) x Python and modern langs [was Re: gossip, Guy Steel, Lojban, Racket]

2010-09-27 Thread Xah Lee
On Sep 27, 12:11 pm, namekuseijin namekusei...@gmail.com wrote:
 On 27 set, 16:06, Xah Lee xah...@gmail.com wrote: 2010-09-27

   For instance, this is far more convenient:
   [x+1 for x in [1,2,3,4,5] if x%2==0]
   than this:
   map(lambda x:x+1,filter(lambda x:x%2==0,[1,2,3,4,5]))

  How about this:

 [snip]

 how about this:  read before replying.

hum???

i read your post quite carefully, and rather thought i replied well.
In fact, i really wanted to tell you “read before replying” before but
refrained from making any of that expression.

here's 2 previous posts about list compre.
http://groups.google.com/group/comp.lang.lisp/msg/145f6ecf29ebbdaf
http://groups.google.com/group/comp.lang.lisp/msg/62ca84062c9fcdca

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


Re: program organization question for web development with python

2010-09-27 Thread Hans
On Sep 17, 2:36 am, Bruno Desthuilliers bruno.
42.desthuilli...@websiteburo.invalid wrote:
 Hans a écrit :
 (snip)

  Maybe I did not make my question clear. I never tried python web
  programing before, so I want to start from CGI.

 You can indeed learn quite a few things doing raw CGI - the most
 important one being why frameworks are a good idea !-)

  I read something about web framework like django, but seems it's a
  little bit complicated.

 Not that much IMHO, but being an early django user I'm probably a bit
 biased. Now Python is known as the language with more web frameworks
 than keywords, so you could probably check some lighter framework like
   web.py (http://webpy.org/) or flask (http://flask.pocoo.org/).

  my task is actually very simple: get search
  string from input, and then search database, print search result. I
  thought CGI should be good enough to do this.

 CGI is good enough to do any web stuff - just like assembler is good
 enough to write any application !-)



  I don't have any idea about how to organize those cgi codes, so what
  I'm asking is:

  1. do I have to have each single file for each hyper-link? Can I put
  them together? how?

  2. how can I pass a db_cursor to another file?   can I use db_cursor as
  a parameter?

 Obviously not. FWIW, both questions show a lack of understanding of the
 HTTP protocol, and you can't hope to do anything good in web programming
 if you don't understand at least the basics of the HTTP protocol,
 specially the request/response cycle.

 Now for a couple more practical answers:

 There are basically two ways to organize your url = code mapping:
 1/ have only one cgi script and use querystring params to tell which
 action should be executed.
 2/ have one cgi script per action.

 The choice is up to you. For a simple app like yours, the first solution
 is probably the most obvious : always display the seach form, if the
 user submitted the form also display the result list. That's how google
 works (wrt/ user interface I mean).

 Now if you still need / want to have distinct scripts and want to factor
 out some common code, you just put the common code in a module that you
 import from each script.

Thank you very much! I got your meaning. The choice 1 is definitely
what I want, I just cannot think about this idea by myself. Thank you
again!
-- 
http://mail.python.org/mailman/listinfo/python-list


Nautilus Python

2010-09-27 Thread Eduardo Ribeiro
I'm a python noob and wrote the following code for a nautilus extension:

#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import urllib
import gtk
import pygtk
import nautilus
import gconf 
import gtk.glade

class Slide (nautilus.MenuProvider):
f = None
def __init__(self):
self.client = gconf.client_get_default() 
self.f = gtk.glade.XML( papel.glade ) 
self.window = self.f.get_widget(window1)
gtk.main()

def oi (self):
self.window.show()

def menu_activate_cb(self, menu, file):
self.oi()

def get_file_items(self, window,files):
if len(files) != 1:
return
item = 
nautilus.MenuItem('NautilusPython::slide_file_item','Slide','Slide')
item.connect('activate', self.menu_activate_cb, files[0])
return item,

def get_background_items(self, window, file):
 item = nautilus.MenuItem('NautilusPython::slide_item','Slide','Slide')
 item.connect('activate', self.menu_background_activate_cb, file)
 return item, 

def menu_background_activate_cb(self, menu, file):
self.oi()

But it doesn't work. If I comment the lines:

self.f = gtk.glade.XML( papel.glade ) 
self.window = self.f.get_widget(window1)
gtk.main()

the code works but I can't see any problem in those lines. Any help?



  

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


vhttp://www.vipshops.org/ nike air jordan shoe for sale,nike , chanal, gucci, juicy, polo tshirt.adidas and so on.all are free shipping.

2010-09-27 Thread fcgffj
nike air jordan shoes
http://www.vipshops.org/
nike shoes
http://www.vipshops.org/
ed hardy
http://www.vipshops.org/
SUIT
ShortJ
ERSEY
Jean
Jacket
Hoody

http://www.vipshops.org/
T-ShirtT
http://www.vipshops.org/
-Shirt_W
http://www.vipshops.org/
Tracksuit_W
http://www.vipshops.org/
Skirt_W
http://www.vipshops.org/
Short_W
http://www.vipshops.org/
Jean
sunglass
http://www.vipshops.org/
more info
http://www.vipshops.org/
ED Hardy_menDG menCOACH_menLV menLacoste manKobe
http://www.vipshops.org/
manPuma
manTimberland
bootRift_man
Super
http://www.vipshops.org/Size(14_15)Prada_man
Nike_shox
Nike_Air_Jordan
Nike_Air_Force_1
Nike_Air_Dunk
Jordan Ring
Jordan Fusion
Jordan 23 Mixture
GucciFashion
BOOTBape
 shoesASCIS
Air_max_man
ADIDAS SHOE
http://www.vipshops.org/
Shoes For Female
http://www.vipshops.org/
Woman BootSandal
Nike_shox_woman
Nike_Air_Jordan_w
Jordan_Fusion_w
Gucci woman
Dunk_Shoe_woman
Air_max_woman
AF1_Shoe_woman
Timberland_WRift_W
Puma_WPrada_W
LV_W
Louboutin_W
juicy couture shoe_W
DG_WCOACH_W
christian louboutin
ASCIS_WADIDAS_W
Kid Apparel
http://www.vipshops.org/
Shoe For KidClothing For Kid
Handbag_Wallet
http://www.vipshops.org/
Wallet
Handbag
Other Product
http://www.vipshops.org/
Watch
Sunglass
Software
Jewerly
Hair Straigher
CapBelt
ED Hardy_men
DG menCOACH_men
LV men
Lacoste man
Kobe man
Puma_man   Timberland bootRift_man  Super
Size(14_15)Prada_manNike_shoxNike_Air_JordanNike_Air_Force_1Nike_Air_DunkJordan
RingJordan   FusionJordan 23 Mixture   GucciFashion BOOTBape shoes
ASCISAir_max_manADIDAS SHOE

more info
http://www.vipshops.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


strange results from sys.version

2010-09-27 Thread John Machin
I am trying to help a user of my xlrd package who says he is getting 
anomalous results on his work computer but not on his home computer.


Attempts to reproduce his alleged problem in a verifiable manner on his 
work computer have failed, so far ... the only meaning difference in 
script output is in sys.version


User (work): sys.version: 2.7 (r27:82500, Aug 23 2010, 17:18:21) etc
Me : sys.version: 2.7 (r27:82525, Jul  4 2010, 09:01:59) etc

I have just now downloaded the Windows x86 msi from www.python.org and 
reinstalled it on another computer. It gives the same result as on my 
primary computer (above).


User result looks whacked: lower patch number, later date. 
www.python.org says Python 2.7 was released on July 3rd, 2010.


Is it possible that the work computer is using an unofficial release? 
What other possibilities are there?


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


Re: strange results from sys.version

2010-09-27 Thread Robert Kern

On 9/27/10 6:01 PM, John Machin wrote:

I am trying to help a user of my xlrd package who says he is getting anomalous
results on his work computer but not on his home computer.

Attempts to reproduce his alleged problem in a verifiable manner on his work
computer have failed, so far ... the only meaning difference in script output
is in sys.version

User (work): sys.version: 2.7 (r27:82500, Aug 23 2010, 17:18:21) etc
Me : sys.version: 2.7 (r27:82525, Jul 4 2010, 09:01:59) etc

I have just now downloaded the Windows x86 msi from www.python.org and
reinstalled it on another computer. It gives the same result as on my primary
computer (above).

User result looks whacked: lower patch number, later date. www.python.org says
Python 2.7 was released on July 3rd, 2010.

Is it possible that the work computer is using an unofficial release? What
other possibilities are there?


ActivePython 2.7.0.2 was released on Aug 25:

http://downloads.activestate.com/ActivePython/releases/2.7.0.2/

--
Robert Kern

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

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


Re: strange results from sys.version

2010-09-27 Thread Sridhar Ratnakumar

On 2010-09-27, at 4:30 PM, Robert Kern wrote:

 On 9/27/10 6:01 PM, John Machin wrote:
 I am trying to help a user of my xlrd package who says he is getting 
 anomalous
 results on his work computer but not on his home computer.
 
 Attempts to reproduce his alleged problem in a verifiable manner on his work
 computer have failed, so far ... the only meaning difference in script 
 output
 is in sys.version
 
 User (work): sys.version: 2.7 (r27:82500, Aug 23 2010, 17:18:21) etc
 Me : sys.version: 2.7 (r27:82525, Jul 4 2010, 09:01:59) etc
 
 I have just now downloaded the Windows x86 msi from www.python.org and
 reinstalled it on another computer. It gives the same result as on my primary
 computer (above).
 
 User result looks whacked: lower patch number, later date. www.python.org 
 says
 Python 2.7 was released on July 3rd, 2010.
 
 Is it possible that the work computer is using an unofficial release? What
 other possibilities are there?
 
 ActivePython 2.7.0.2 was released on Aug 25:
 
 http://downloads.activestate.com/ActivePython/releases/2.7.0.2/

John,

If it is ActivePython, the first line of the interactive shell (in credits 
section) should print something like:

  ActivePython 2.7.0.2 (ActiveState Software Inc.) 

Also what is the output of python -m activestate?

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


Re: strange results from sys.version

2010-09-27 Thread Sridhar Ratnakumar

On 2010-09-27, at 4:01 PM, John Machin wrote:

 User (work): sys.version: 2.7 (r27:82500, Aug 23 2010, 17:18:21) etc
 Me : sys.version: 2.7 (r27:82525, Jul  4 2010, 09:01:59) etc
 
 [...] User result looks whacked: lower patch number, later date

Perusing http://svn.python.org/view/python/branches/release27-maint/?view=log - 
the difference in svn versions (there is no difference in patch number) seems 
insignificant. Both revisions are past the 2.7 final release. Perhaps, the 
python.org installer was created using a later revision.

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


Re: (and scheme lisp) x Python and modern langs [was Re: gossip, Guy Steel, Lojban, Racket]

2010-09-27 Thread namekuseijin
On 27 set, 18:39, Xah Lee xah...@gmail.com wrote:
 On Sep 27, 12:11 pm, namekuseijin namekusei...@gmail.com wrote:

  On 27 set, 16:06, Xah Lee xah...@gmail.com wrote: 2010-09-27

For instance, this is far more convenient:
[x+1 for x in [1,2,3,4,5] if x%2==0]
than this:
map(lambda x:x+1,filter(lambda x:x%2==0,[1,2,3,4,5]))

   How about this:

  [snip]

  how about this:  read before replying.

 hum???

 i read your post quite carefully, and rather thought i replied well.

I don't think so.  You completely missed the point where I agreed
about filter map being more convenient when calling predefined
functions and also the detailed explanation of why do in scheme is not
imperative at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugger - fails to continue with breakpoint set

2010-09-27 Thread Danny Levinson

 Does this describe the problem you are having?

http://bugs.python.org/issue5294

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


Re: Problems reading tif files

2010-09-27 Thread gujax
On Sep 26, 9:19 pm, Christian Heimes li...@cheimes.de wrote:
 Am 27.09.2010 02:31, schrieb gujax:

  Hi,
  I have read several related e-mails dating back as far as 2006. I am
  quite confused whether PIL can open tif images. Some posts seem to say
  there isn't yet any support for PIL while there are few posts where
  PIL has been able to open tif images. So I guess, I have to ask this
  probably trivial question again. I am just learning python and PIL. I
  have tiff images which are 8 bit and 16 bit gray scale images. I
  cannot open them. Here are the errors that I encounter.

 PIL only supports a limited subset of TIFF files. Several compression
 algorithms like G3 and G4 fax compression are not supported yet. PIL may
 have a problem with partly broken TIFF files, too.

  I have no idea why this happens.
  I will appreciate a resolution. The file opens with ImageJ and
  ImageMagick. It is a 8-bit RGB file. I have associated default viewer
  to be ImageMagick. I am on Lucid Linux, and other programs such as F-
  spot and Gimp cannot open those files either.
  I don't yet know how to attach image files to the post so please bear
  with me till I figure that out.

 Can you please post the output of tiffinfo for the specific file? It may
 give me a hint what's going wrong.

 There aren't a lot of good alternatives for image processing in Python.
 I've evaluated most of them and decided to write my own one for my
 employer. It's a Cython based library around FreeImage [1] and LCMS2 [2]
 and works very well. So far we have processed several million TIFF files
 with more than 100 TB of raw data smoothly. I've permission to release
 the software as open source but haven't found time to do a proper release.

 Christian Heimes

 [1]http://freeimage.sourceforge.net/
 [2]http://www.littlecms.com/

Thanks Christian,
Here is the tiffinfo:

TIFF Directory at offset 0x8 (8)
  Subfile Type: (0 = 0x0)
  Image Width: 640 Image Length: 480
  Bits/Sample: 32
  Sample Format: IEEE floating point
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Samples/Pixel: 1
  Rows/Strip: 480
  Planar Configuration: single image plane
  ImageDescription: ImageJ=1.44f
min=0.0
max=255.0

How do I use freeimage with python. Is there a backend?
Can these files be converted to something else such as bmp and then
read out? I should have tried it out before asking you,
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems reading tif files

2010-09-27 Thread gujax
Thanks Christian,
Here is the info:
TIFF Directory at offset 0x8 (8)
  Subfile Type: (0 = 0x0)
  Image Width: 640 Image Length: 480
  Bits/Sample: 32
  Sample Format: IEEE floating point
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Samples/Pixel: 1
  Rows/Strip: 480
  Planar Configuration: single image plane
  ImageDescription: ImageJ=1.44f
min=0.0
max=255.0

How can I use freeimage. Can I incorporate it with python? Any idea
what do ImageJ or Matlab use. Don't they have a robust imaging
toolbox. Unfortunately, I cannot afford Matlab and I am not good at
Java programing to be able to implement ImageJ with numerical analysis
software.

Thanks much,
gujax



On Sep 26, 9:19 pm, Christian Heimes li...@cheimes.de wrote:
 Am 27.09.2010 02:31, schrieb gujax:

  Hi,
  I have read several related e-mails dating back as far as 2006. I am
  quite confused whether PIL can open tif images. Some posts seem to say
  there isn't yet any support for PIL while there are few posts where
  PIL has been able to open tif images. So I guess, I have to ask this
  probably trivial question again. I am just learning python and PIL. I
  have tiff images which are 8 bit and 16 bit gray scale images. I
  cannot open them. Here are the errors that I encounter.

 PIL only supports a limited subset of TIFF files. Several compression
 algorithms like G3 and G4 fax compression are not supported yet. PIL may
 have a problem with partly broken TIFF files, too.

  I have no idea why this happens.
  I will appreciate a resolution. The file opens with ImageJ and
  ImageMagick. It is a 8-bit RGB file. I have associated default viewer
  to be ImageMagick. I am on Lucid Linux, and other programs such as F-
  spot and Gimp cannot open those files either.
  I don't yet know how to attach image files to the post so please bear
  with me till I figure that out.



 Can you please post the output of tiffinfo for the specific file? It may
 give me a hint what's going wrong.

 There aren't a lot of good alternatives for image processing in Python.
 I've evaluated most of them and decided to write my own one for my
 employer. It's a Cython based library around FreeImage [1] and LCMS2 [2]
 and works very well. So far we have processed several million TIFF files
 with more than 100 TB of raw data smoothly. I've permission to release
 the software as open source but haven't found time to do a proper release.

 Christian Heimes

 [1]http://freeimage.sourceforge.net/
 [2]http://www.littlecms.com/

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


Re: Strong typing vs. strong testing

2010-09-27 Thread John Nagle

On 9/27/2010 10:46 AM, namekuseijin wrote:

On 27 set, 05:46, TheFlyingDutchmanzzbba...@aol.com  wrote:

On Sep 27, 12:58 am, p...@informatimago.com (Pascal J. Bourguignon)
wrote:

RGrnospa...@flownet.com  writes:

In article
7df0eb06-9be1-4c9c-8057-e9fdb7f0b...@q16g2000prf.googlegroups.com,
  TheFlyingDutchmanzzbba...@aol.com  wrote:



On Sep 22, 10:26 pm, Scott L. Bursonsc...@ergy.com  wrote:

This might have been mentioned here before, but I just came across it: a
2003 essay by Bruce Eckel on how reliable systems can get built in
dynamically-typed languages.  It echoes things we've all said here, but
I think it's interesting because it describes a conversion experience:
Eckel started out in the strong-typing camp and was won over.



https://docs.google.com/View?id=dcsvntt2_25wpjvbbhk




   The trouble with that essay is that he's comparing with C++.
C++ stands alone as offering hiding without memory safety.
No language did that before C++, and no language has done it
since.

   The basic problem with C++ is that it take's C's rather lame
concept of array=pointer and wallpapers over it with
objects.  This never quite works.  Raw pointers keep seeping
out.  The mold always comes through the wallpaper.

   There have been better strongly typed languages.  Modula III
was quite good, but it was from DEC's RD operation, which was
closed down when Compaq bought DEC.

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


Re: Nautilus Python

2010-09-27 Thread Steven D'Aprano
On Mon, 27 Sep 2010 15:28:34 -0700, Eduardo Ribeiro wrote:

 But it doesn't work.

What do you mean doesn't work?

- It crashes the operating system;
- You get a core dump;
- You get an exception;
- It hangs forever, never doing anything;
- It does something unexpected;
- Something else?


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


Re: reduced-tagged (was Re: toy list processing problem: collect similar terms)

2010-09-27 Thread Steven D'Aprano
On Mon, 27 Sep 2010 08:18:22 -0700, Mirko wrote:

 Here is my Common Lisp (and I only care about Common Lisp answers)

Good for you. So why are you spamming other newsgroups with your CL 
solution? Not once, but three times.

Replies to /dev/null.

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


Re: toy list processing problem: collect similar terms

2010-09-27 Thread Seebs
On 2010-09-26, Xah Lee xah...@gmail.com wrote:
 On Sep 25, 11:17??pm, Paul Rubin no.em...@nospam.invalid wrote:
 Python solution follows (earlier one with an error cancelled). ??All
 crossposting removed since crossposting is a standard trolling tactic.

 btw, i disagree about your remark on crossposting.

You're wrong.  Crossposting is indeed a standard trolling tactic.

This does not prove that all crossposters are trolls, nor does it assert
that all crossposters are trolls, but it is absolutely factually correct
that it's a standard trolling tactic.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: toy list processing problem: collect similar terms

2010-09-27 Thread Seebs
On 2010-09-26, J?rgen Exner jurge...@hotmail.com wrote:
 It was livibetter who without any motivation or reasoning posted Python
 code in CLPM.

Not exactly; he posted it in a crossposted thread, which happened to include
CLPM and other groups, including comp.lang.python.

It is quite possible that he didn't know about the crossposting.  However,
while I would agree that this would constitute a form of ignorance, I'd think
that, especially with how well some newsreading interfaces hide that detail,
I don't think it's really worth getting angry over.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to Deal with Xah Lee Spam/Abuse (was: toy list processing problem: collect similar terms)

2010-09-27 Thread John Bokma
Seebs usenet-nos...@seebs.net writes:

 On 2010-09-26, Xah Lee xah...@gmail.com wrote:
 On Sep 25, 11:17??pm, Paul Rubin no.em...@nospam.invalid wrote:
 Python solution follows (earlier one with an error cancelled). ??All
 crossposting removed since crossposting is a standard trolling tactic.

 btw, i disagree about your remark on crossposting.

 You're wrong.

FYI: Xah Lee is well known for his abuse of cross posting. Be happy that
Google Groups limits the number of groups to crosspost to five.

Related: his spamming behaviour has already resulted in Xah Lee
having to look for another hosting provider [1]. Currently 1and1 provides
him shelter, most likely carefully selected by Xah (as Google Groups)
since 1and1 is not known for their spam fighting reputation nor clue.

But one can only hope, so if you want to do something about this Xah
thing, please report it with 1and1 and ab...@google.com. He won't learn
respect from it, but maybe you end up being honored [2] on his
collection of drivel [3].

In short:

 = don't reply to Xah Lee: at best it's a waste of time
 = if his post is abusive (crossposting to 5 groups just because you can
   is) report it with /and/ his hosting provider (since most of his
   posts are copy paste jobs of articles on his site just to drive
   traffic) and Google Groups (his Usenet provider of choice since they
   hardly do a thing about spam).


[1] http://www.mail-archive.com/python-list@python.org/msg91631.html
[2] http://www.google.com/search?q=site%3Axahlee.org%20bokma
[3] What's sad is that some of its stuff is actually good/not bad. 
But tainted: Xah Lee is a spammer and a Usenet abuser.

-- 
John Bokma   j3b

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


Re: toy list processing problem: collect similar terms

2010-09-27 Thread John Bokma
Seebs usenet-nos...@seebs.net writes:

 On 2010-09-26, J?rgen Exner jurge...@hotmail.com wrote:
 It was livibetter who without any motivation or reasoning posted Python
 code in CLPM.

 Not exactly; he posted it in a crossposted thread, which happened to include
 CLPM and other groups, including comp.lang.python.

 It is quite possible that he didn't know about the crossposting.

Oh, he does. It has been Xah's game for years.

 while I would agree that this would constitute a form of ignorance, I'd think
 that, especially with how well some newsreading interfaces hide that detail,
 I don't think it's really worth getting angry over.

You think wrong. And Jurgen should have known better than to reply several
times (but like too many people in cplm he posts for posting's sake, the
main reason why I don't follow that group anymore).

Xah has been doing this for many years and most of his posts are just
made to drive traffic to his site (hence they are copy paste of articles
on his site + link(s) to his site). It's Usenet abuse, on purpose.

The reason it pisses off people is that nearly weekly it causes a lot of
noise in newsgroups that are really better off without the noise
(IMNSHO).

See my other post on how to deal with this spammer. If you've missed it:
report him for spamming, since that's what he does. It already made him
have to move hosting providers once. While it's not going to stop him,
it will cost him money. See:
http://www.google.com/search?q=site%3Axahlee.org%20bokma

While I am named in that article be assured that I was not the only one
contacting dreamhost (+10 for doing this, btw). Quite some people
contacted me via email that they also talked with Dreamhost. Just keep
reporting this spammer, and maybe 1and1 will kick it out.

-- 
John Bokma   j3b

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


Example of exec_proxy

2010-09-27 Thread Prathibha G
Hi Team,

I am very new to this python world.

Below is my problem.

I have a Machine A where i want to execute some commands(dos commands from
command prompt), delete/create some files, delete/create some directories.
All this i need to do from my local host.

Is there a way which i can do? Can ayone help me in achieving this?

I tried using WMI module, but it only starts the processes. It is not
allowing me to execute commands/ work with files and directories.

I got to see this EXEC_PROXY module but i find no examples of it which is
used to connect to remote machine. Could any of you provide that?

-- 
Thank You,
Prathibha
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nautilus Python

2010-09-27 Thread Peter
On Sep 28, 12:31 pm, Steven D'Aprano steve-REMOVE-
t...@cybersource.com.au wrote:
 On Mon, 27 Sep 2010 15:28:34 -0700, Eduardo Ribeiro wrote:
  But it doesn't work.

 What do you mean doesn't work?

 - It crashes the operating system;
 - You get a core dump;
 - You get an exception;
 - It hangs forever, never doing anything;
 - It does something unexpected;
 - Something else?

 --
 Steven

It seems to be a fairly absolute statement - so I would assume all of
the above! :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: toy list processing problem: collect similar terms

2010-09-27 Thread Seebs
On 2010-09-28, John Bokma j...@castleamber.com wrote:
 Seebs usenet-nos...@seebs.net writes:
 On 2010-09-26, J?rgen Exner jurge...@hotmail.com wrote:
 It was livibetter who without any motivation or reasoning posted Python
 code in CLPM.

 Not exactly; he posted it in a crossposted thread, which happened to include
 CLPM and other groups, including comp.lang.python.

 It is quite possible that he didn't know about the crossposting.

 Oh, he does. It has been Xah's game for years.

But did livibetter know about it?  I wasn't defending Xah, who is indeed
at the very least clueless and disruptive.  But I was sort of defending
the poster who was accused of posting Python code in CLPM, because that
poster may not have understood the game.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ -- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) -- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: toy list processing problem: collect similar terms

2010-09-27 Thread John Bokma
Seebs usenet-nos...@seebs.net writes:

fup set to poster

 On 2010-09-28, John Bokma j...@castleamber.com wrote:
 Seebs usenet-nos...@seebs.net writes:
 On 2010-09-26, J?rgen Exner jurge...@hotmail.com wrote:
 It was livibetter who without any motivation or reasoning posted Python
 code in CLPM.

 Not exactly; he posted it in a crossposted thread, which happened to include
 CLPM and other groups, including comp.lang.python.

 It is quite possible that he didn't know about the crossposting.

 Oh, he does. It has been Xah's game for years.

 But did livibetter know about it?  I wasn't defending Xah, who is indeed
 at the very least clueless and disruptive.

Heh, he's not clueless, the problem is that he knows exactly what he's
doing. And like most spammers, very hard to get rid off.

 But I was sort of defending
 the poster who was accused of posting Python code in CLPM, because that
 poster may not have understood the game.

Ah, clear. Well, the problem is somewhat also in CLPM where people
somehow have to reply to messages like this :-(. And I am sure Xah
laughes his ass off each time it happens.

-- 
John Bokma   j3b

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


[issue9937] _winreg.EnumValue causes MemoryError

2010-09-27 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:


Removed file: http://bugs.python.org/file18999/py27_winreg_EnumValue.patch

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



[issue9937] _winreg.EnumValue causes MemoryError

2010-09-27 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:


Removed file: 
http://bugs.python.org/file19021/py27_fix_winreg_EnumValue_op1.patch

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



[issue9937] _winreg.EnumValue causes MemoryError

2010-09-27 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

I've withdrew my patch... It has still problem, and
I cannot fix it yet. I suppose option 2 is easy.
ANSI API's limitation makes it harder to implement
correctly.

--

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



[issue9937] _winreg.EnumValue causes MemoryError

2010-09-27 Thread STINNER Victor

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

Can't we use RegEnumValueW and RegQueryInfoKeyW?

--

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



[issue9958] (c)elementTree missing children

2010-09-27 Thread Valentin Kuznetsov

New submission from Valentin Kuznetsov vkuz...@gmail.com:

Hi, I found that parsing XML file with identical structure leads to missing 
children item at some point. In my test case which I attach it happens at 
id=183. Basically I have XML with bunch of elements of the following structure:

processed_dataset id='0'
path dataset_path='/aaa/0'/
/processed_dataset
processed_dataset id='1'
path dataset_path='/aaa/0'/
/processed_dataset


when I parse them recursively, all, except the one with id=183, are parsed 
identically. The one with id=183 does not contain children. I tried the code 
with python 2.6 and python 2.7 on Mac and Linux. Bug exists in both version of 
ElementTree and cElementTree. Code and testbed XML are attached. Please untar 
and run as python test_bug.py.
Thanks,
Valentin

--
files: em_bug.tar
messages: 117440
nosy: vkuznet
priority: normal
severity: normal
status: open
title: (c)elementTree missing children
type: behavior
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file19028/em_bug.tar

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



[issue9958] (c)elementTree missing children

2010-09-27 Thread Amaury Forgeot d'Arc

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

The given script yields an item on a start event; but the element may not be 
fully populated at this point. please read 
http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.iterparse

You should use the end events instead.

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

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



[issue2972] arguments and default path not set in site.py and sitecustomize.py

2010-09-27 Thread Geoffrey Bache

Geoffrey Bache gjb1...@users.sourceforge.net added the comment:

I also just ran into this. Is it likely that an enhancement request to provide 
access to the raw command line, as requested by the previous commenter, would 
be accepted? It's sometimes useful to have some idea about what kind of Python 
process is being started at this point.

--
nosy: +gjb1002

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



[issue2972] arguments and default path not set in site.py and sitecustomize.py

2010-09-27 Thread Tim Golden

Tim Golden m...@timgolden.me.uk added the comment:

Merely from a Windows point-of-view, you could get the full
command line fairly easily:

code

import ctypes
pstring = ctypes.windll.kernel32.GetCommandLineW ()
print (ctypes.c_wchar_p (pstring).value)

/code

TJG

--
nosy: +tim.golden

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



[issue9959] int(math.log(4,2)) == 1 instead of 2

2010-09-27 Thread akira

New submission from akira 4kir4...@gmail.com:

$ python3.1 -c'import math; f = math.log(4,2); print(int(f), 
f.as_integer_ratio())'
2 (2, 1)

$ python3.2 -c'import math; f = math.log(4,2); print(int(f), 
f.as_integer_ratio())'
1 (9007199254740991, 4503599627370496)

Python 3.2a2+ (py3k:85028, Sep 27 2010, 16:46:11) 
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
 import math
 f = math.log(32, 2)
 f
4.999
 int(f)
4
 f.as_integer_ratio()
(5629499534213119, 1125899906842624)

I'm not sure whether it is a bug, but it is an unexpected change in behavior 
between 3.1 and 3.2.

--
components: Library (Lib)
messages: 117444
nosy: akira
priority: normal
severity: normal
status: open
title: int(math.log(4,2)) == 1 instead of 2
type: behavior
versions: Python 3.2

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



[issue2972] arguments and default path not set in site.py and sitecustomize.py

2010-09-27 Thread Geoffrey Bache

Geoffrey Bache gjb1...@users.sourceforge.net added the comment:

Interesting. Any idea if something similar is possible on Linux?

--

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



[issue9955] multiprocessing.Pipe segmentation fault when recv of unpicklable object

2010-09-27 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
nosy: +asksol

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



[issue2972] arguments and default path not set in site.py and sitecustomize.py

2010-09-27 Thread Tim Golden

Tim Golden m...@timgolden.me.uk added the comment:

I'm afraid I don't know; might be worth asking that on the main python mailing 
list.

--

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



[issue9959] int(math.log(4,2)) == 1 instead of 2

2010-09-27 Thread Mark Dickinson

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

No, it's not really a bug:  math.log(x, 2) isn't an atomic operation: it's 
computed internally as something like log(x) / log(2), and since each of the 
three steps (computation of the logs, division) can introduce a small rounding 
error, you shouldn't be surprised if the result doesn't come out exactly.

The difference between 3.1 and 3.2 was a side-effect of a change to remove the 
dependence of the math module on the internal long integer representation.

Having said that, it would be possible to improve the algorithm that's used to 
compute log of an integer (see the loghelper function in Modules/mathmodule.c): 
currently, for positive k, log(2**k) ends up being computed as log(0.5) + 
(k+1)*log(2), which doesn't help;  it would be slightly better if it were 
computed directly as k*log(2) instead.  But you still can't (and shouldn't) 
rely on log(x, 2) giving exact results for powers of 2.

I'm not sure what you're using math.log(x, 2) for, but you may be interested in 
the int.bit_length method.

--
assignee:  - mark.dickinson
nosy: +mark.dickinson

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



[issue9960] test_structmembers fails on s390x (bigendian 64-bit): int/Py_ssize_t issue

2010-09-27 Thread Dave Malcolm

New submission from Dave Malcolm dmalc...@redhat.com:

test test_structmembers crashed -- type 'exceptions.ValueError':
string too long
Traceback (most recent call last):
  File /builddir/build/BUILD/Python-2.7/Lib/test/regrtest.py, line 863, in 
runtest_inner
the_package = __import__(abstest, globals(), locals(), [])
  File /builddir/build/BUILD/Python-2.7/Lib/test/test_structmembers.py, line 
12, in module
9.9, 10.1010101010, hi)
ValueError: string too long

_testcapimodule.c: test_structmembers_new's fmt has:
  s#
and these args:
  s, string_len

for grabbing this data:
const char *s = NULL;
Py_ssize_t string_len = 0;

However, the module doesn't define PY_SSIZE_T_CLEAN, which leads to string_len 
being treated as an (int*) rather than a (Py_ssize_t*) and thus written to with 
just the first 32-bits of the size, rather than the full size.

The PyArgs_ call without PY_SSIZE_T_CLEAN writes the size of the string (2) 
through (int*)string_len, writing 0x0002 to the first 4 bytes, setting the 
64-bit string_len value to 0x0002 i.e. 2^34, wildly too large for 
the iirc 5 byte buffer.

Confirmed in gdb:
  (gdb) p string_len
  $2 = 8589934592

  (gdb) p /x string_len
  $3 = 0x2

Am attaching a patch (against 2.7 maintenance branch) which defines 
PY_SSIZE_T_CLEAN; doing so requires updating another int to be a Py_ssize_t in 
that module, within test_u_code.


http://docs.python.org/c-api/arg.html lists u# (Unicode) [Py_UNICODE *, int] 
and has no reference to the effect of PY_SSIZE_T_CLEAN on the u# format 
specifier.  My reading of Python/getargs.c is that this macro does affect u# 
in a manner analogous to s#; does this documentation need clarifying?

--
components: Tests
files: python-test_structmembers.patch
keywords: easy, patch
messages: 117448
nosy: dmalcolm
priority: normal
severity: normal
stage: patch review
status: open
title: test_structmembers fails on s390x (bigendian 64-bit): int/Py_ssize_t 
issue
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file19029/python-test_structmembers.patch

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



[issue9960] test_structmembers fails on s390x (bigendian 64-bit): int/Py_ssize_t issue

2010-09-27 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue9961] Identity Crisis! variable assignment using strftime fails comparison test.

2010-09-27 Thread Bill Hawkes

New submission from Bill Hawkes williamhawke...@yahoo.com:

See below. When variable assignment is used with strftime for the day of the 
week, it fails comparison checks for the days of the week. Even when using the 
str() function it still fails. Manual entry of variable assignment is required 
for a successful comparison. This pretty well defeats the purpose of computer 
programming (automation). There seems to be a real identity crisis here!

$ python3
Python 3.0rc1+ (py3k, Oct 28 2008, 09:23:29) 
[GCC 4.3.2] on linux2
 import time
 from datetime import date
 today = date.today()
 print(This line will always print)
This line will always print
 myday = today.fromordinal(today.toordinal() - 31)
 printthis = myday.strftime(%m-%d-%y. %d %b %Y is a %A on the %d day of 
 %B.)
 print(%s % printthis)
08-27-10. 27 Aug 2010 is a Friday on the 27 day of August.
 # dow is Day Of Week variable
... dow = myday.strftime(%A)
 chkval = dow
 dow is chkval
True
 print(dow is %s % dow)
dow is Friday
 print(chkval is %s % chkval)
chkval is Friday
 print(%s % dow)
Friday
 print(%s % chkval)
Friday
 dow is chkval
True
 if dow is 'Sunday':
...cntbck = 0
... elif dow is 'Monday':
...cntbck = 1
... elif dow is 'Tuesday':
...cntbck = 2
... elif dow is 'Wednesday':
...cntbck = 3
... elif dow is 'Thursday':
...cntbck = 4
... elif dow is 'Friday':
...cntbck = 5
... elif dow is 'Saturday':
...cntbck = 6
... else:
...cntbck = 'undefined'
...print(What day is it? It is %s % dow)
... 
What day is it? It is Friday
 print('finished with script')
finished with script
 dow is 'Friday'
False
 dow = 'Friday'
 dow is 'Friday'
True
 chkval
'Friday'
 dow
'Friday'
 chkval is dow
False
  chkval is 'Friday'
False
 chkval
'Friday'
 chkval = str(chkval)
 chkval
'Friday'
 chkval is 'Friday'
False
 cntbck
'undefined'


--
components: Interpreter Core
messages: 117449
nosy: BillHawkes
priority: normal
severity: normal
status: open
title: Identity Crisis! variable assignment using strftime fails comparison 
test.
type: behavior
versions: Python 3.1

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



[issue9961] Identity Crisis! variable assignment using strftime fails comparison test.

2010-09-27 Thread Jean-Paul Calderone

Jean-Paul Calderone inva...@example.invalid added the comment:

You mistakenly used is for these comparisons, rather than ==.  The strftime 
involvement is a red herring.  The real problem is the use of an /identity/ 
comparison rather than an /equality/ comparison.

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

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9961
___
___
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

2010-09-27 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

___
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



[issue1652] subprocess should have an option to restore SIGPIPE to default action

2010-09-27 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

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



[issue9609] make cProfile multi-stack aware

2010-09-27 Thread Todd Whiteman

Changes by Todd Whiteman twhit...@yahoo.com.au:


--
nosy: +twhitema

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



[issue9941] Unify trace and profile interfaces

2010-09-27 Thread Alexander Belopolsky

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

I've ran into a problem adding context manager functionality to Profile/Trace 
objects.  When profile/trace function is set in __enter__ and removed in 
__exit__ it catches two spurious events: a return from __enter__ and a call to 
__exit__.  This is particularly problematic with Profile which is not prepared 
to handle a return event that does not follow a matching call.

--

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



[issue1634774] locale 1251 does not convert to upper case properly

2010-09-27 Thread Amaury Forgeot d'Arc

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

the OP is right: str.upper is supposed to be locale-dependent
http://docs.python.org/library/stdtypes.html#str.upper

But the implementation uses _toupper() which is a macro with Visual Studio, and 
obviously not locale-dependent:

#define _toupper(_Char)( (_Char)-'a'+'A' )

--
nosy: +amaury.forgeotdarc
stage: unit test needed - needs patch

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



[issue9950] socket.sendall() crash when receiving a signal

2010-09-27 Thread Antoine Pitrou

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

Patch committed in r85032. I'm gonna watch the buildbots a bit, in case the 
test fails on some platforms.

--
assignee:  - pitrou
resolution:  - fixed
stage:  - committed/rejected

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



[issue8521] Allow some winreg functions to accept named arguments

2010-09-27 Thread Brian Curtin

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

Committed in r85033.

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

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



[issue8158] documentation of 'optparse' module incomplete

2010-09-27 Thread Sandro Tosi

Sandro Tosi sandro.t...@gmail.com added the comment:

Hello,
since 2.7 optparse is deprecated in favor of argparse: is this bug still worth 
to be fixed? If so, I can work on a patch for the doc.

Regards,
Sandro

--
nosy: +sandro.tosi

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



[issue8158] documentation of 'optparse' module incomplete

2010-09-27 Thread Sandro Tosi

Sandro Tosi sandro.t...@gmail.com added the comment:

Sorry, I probably overlooked at the situation. After a quick chat with Antoine 
on IRC, it's clear optparse is here to stay for all the lifetime of 2.7 (quite 
a long and prosper, we hope :) so yes, it's worth work on its documentation, 
hence I'll start preparing a patch and I'll submit it asap.

Cheers,
Sandro

--

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



[issue9959] int(math.log(4,2)) == 1 instead of 2

2010-09-27 Thread akira

akira 4kir4...@gmail.com added the comment:

 No, it's not really a bug: math.log(x, 2) isn't an atomic operation:

It is not a bug, but values of math.log(4) differs between 3.1 and 3.2
i.e., math.log(4.0) in 3.2 returns value that is consistent with
math.log(4) in 3.1 but math.log(4) in 3.2 doesn't.

 I'm not sure what you're using math.log(x, 2) for, but you may be
interested in the int.bit_length method.

The docs for int.bit_length say: 

 if x is nonzero, then x.bit_length() is the unique positive integer
k such that 2**(k-1) = abs(x)  2**k. Equivalently, when abs(x) is
small enough to have a correctly rounded logarithm, then k = 1 +
int(log(abs(x), 2)).

It is expected that int(log(n,2)) produces correct result for small n.

 Having said that, it would be possible to improve the algorithm
 that's used to compute log of an integer (see the loghelper function
 in Modules/mathmodule.c): currently, for positive k, log(2**k) ends
 up being computed as log(0.5) + (k+1)*log(2), which doesn't help; it
 would be slightly better if it were computed directly as k*log(2)
 instead.  But you still can't (and shouldn't) rely on log(x, 2)
 giving exact results for powers of 2.

I've changed loghelper() to return improved result for power of 2

--
keywords: +patch
Added file: http://bugs.python.org/file19030/math_log_power_two.diff

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



[issue9441] increase logging handlers test coverage

2010-09-27 Thread Brian Curtin

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

It would be nice to see tests for NTEventLogHandler, as there are currently 
none.

I looked into implementing NTEventLogHandler's Win32 calls in a C extension 
rather than requiring a third-party module, but stopped once I realized there 
weren't any tests. I may get to it myself, but I thought I'd throw this out 
there.

--
nosy: +brian.curtin

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



[issue9959] int(math.log(4,2)) == 1 instead of 2

2010-09-27 Thread akira

Changes by akira 4kir4...@gmail.com:


Added file: http://bugs.python.org/file19031/test_log_power_two.py

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



[issue9950] socket.sendall() crash when receiving a signal

2010-09-27 Thread Antoine Pitrou

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

The patch passes at least on Linux, OS X and Solaris buildbots. Backported to 
3.1 (r85034) and 2.7 (r85035).

--
status: open - closed

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



[issue9959] int(math.log(4,2)) == 1 instead of 2

2010-09-27 Thread akira

Changes by akira 4kir4...@gmail.com:


--
type: behavior - feature request

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



[issue9929] subprocess.Popen unbuffered not work

2010-09-27 Thread R. David Murray

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

But if line buffering doesn't work, disabling buffering on stdout/stderr does 
have a functional consequence: it allows process output to appear as generated 
instead of coming in chunks when the buffer is full.  Of course, I could be 
completely misunderstanding what you are talking about :)

--
nosy: +r.david.murray

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



[issue9929] subprocess.Popen unbuffered not work

2010-09-27 Thread Antoine Pitrou

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

 But if line buffering doesn't work, disabling buffering on 
 stdout/stderr does have a functional consequence: it allows process 
 output to appear as generated instead of coming in chunks when the
 buffer is full

Yes, sorry, I had it backwards. It's buffering on stdin which doesn't make any 
functional difference (whether it's buffered or not, you always get data as 
soon as it arrives).

--

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



[issue8959] WINFUNCTYPE wrapped ctypes callbacks not functioning correctly in Python 2.7

2010-09-27 Thread Brian Curtin

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

This doesn't seem to be an issue anymore.

--
stage:  - committed/rejected
status: open - closed

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



[issue9934] Python Docs Typo

2010-09-27 Thread Éric Araujo

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

Ported to distutils2 in 2f460982b025, thanks!

--
components: +Distutils2
nosy: +eric.araujo

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



[issue9943] TypeError message became less helpful in Python 2.7

2010-09-27 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue9945] Improper locking in logging

2010-09-27 Thread Éric Araujo

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

Just to be sure: this does not apply to 3.1?

--
nosy: +eric.araujo

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



[issue9946] lock use in logging

2010-09-27 Thread Éric Araujo

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


--
superseder:  - Improper locking in logging

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



[issue3532] bytes.tohex method

2010-09-27 Thread Éric Araujo

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

See #9951 for a patch adding bytes.hex

--

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



  1   2   >