Re: regarding the dimensions in gui

2010-06-10 Thread Shashwat Anand
Do you realize you are spamming the list. You generally fire one question
and wait rather than supplying us a bunch of questions. And please stop
using 'sir' for heaven's sake. I realize you are from India and it is a
culture there but people don't use it in mailing lists.

Thanks.

On Thu, Jun 10, 2010 at 11:47 AM, madhuri vio  wrote:

> sir ,,
>  i wanted to knw how to decide on the dimensions
> mentioned in the gui development..all i know  is the
> top left corner is considered as the origin ...
> then how are we having all the dimensions positive.???
>
>
> --
> madhuri :)
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-10 Thread Ian Kelly
On Wed, Jun 9, 2010 at 11:54 PM, Benjamin Kaplan
 wrote:
> On Wed, Jun 9, 2010 at 10:25 PM, Qijing Li  wrote:
>> Thanks for your reply.
>> I'm trying to understand python language deeply and  use it efficiently.
>> For example: How the operator "in" works on list? the running time is
>> be O(n)?  if my list is sorted, what the running time would be?
>>
>>
>
> Still O(n). Python doesn't know that your list is sorted, so nothing
> changes. And the check to make sure it is sorted would be O(n) anyway.

However, if the programmer knows that the list is sorted, then the
following would be O(log n):

from bisect import bisect_left

index = bisect_left(the_list, item)
item_in_list = index < len(the_list) and the_list[index] == item

But in general, if you want the "in" operator to be efficient, then
you probably want to use a set or a dict, not a list.

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


Re: grep command

2010-06-10 Thread Simon Brunning
On 10 June 2010 07:38, madhuri vio  wrote:
>
> i was wondering bout the usage and syntax of
> grep command..can u tall me its syntax so that
> i can use it and proceed...pls

That's really not on topic for this list.

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


Re: capitalize() NOT the same as var[0].upper _ var[1:]

2010-06-10 Thread geremy condra
On Wed, Jun 9, 2010 at 2:10 PM, Dan Stromberg  wrote:
>
>
> On Tue, Jun 8, 2010 at 7:09 PM, alex23  wrote:
>>
>> I'm amazed at the endless willingness of this group to help Victor
>> write his contracted project for free.
>>
> I don't get it.  What's wrong with helping people?  And what's it to you if
> others do?

Its not the helping. Its the asking for help.

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Gregory Ewing

Ethan Furman wrote:

*Alert*  Potentially dumb question following:  On the MS Windows 
platform, Gtk is not required, just win32?


That's correct. The current version of PyGUI includes
a pywin32-based implementation.

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


Re: regarding the dimensions in gui

2010-06-10 Thread Simon Brunning
On 10 June 2010 08:19, Shashwat Anand  wrote:
> And please stop using 'sir' for heaven's sake.

Not least because list list isn't male only.

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


gui doubt

2010-06-10 Thread madhuri vio
how do i get the buttons at the bottom
of the tool i create???
what is the command for side i need to mention???
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter doubt

2010-06-10 Thread Thomas Jollans
On 06/10/2010 08:50 AM, madhuri vio wrote:
> # File: hello2.py
> 
> from Tkinter import *
> 
> class App:
> 
> def __init__(self, master):
> 
> frame = Frame(master)
> frame.pack()
> 
> self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
> 
> self.button.pack(side=LEFT)
> 
> self.hi_there = Button(frame, text="Hello", command=self.say_hi)
> self.hi_there.pack(side=LEFT)
> 
> def say_hi(self):
> print "hi there, everyone!"
> 
> 
> root = Tk()
> 
> app = App(root)
> 
> root.mainloop()
> 
> in this program i wanted to  get a clear idea about this
> 
> 
> def __init__(self, master):
> 
> frame = Frame(master)
> 
> frame.pack()
> 
> self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
> self.button.pack(side=LEFT)
> 
> self.hi_there = Button(frame, text="Hello", command=self.say_hi)
> 
> self.hi_there.pack(side=LEFT)
> 
> what is _init_...self and master...
read up on object-orientation with Python

> where did frame and button come from...
frame and self.button were set. Frame and Button were probably imported.

> kindly reply...awaiting
Please read
  http://www.catb.org/~esr/faqs/smart-questions.html
Even if you didn't mean to send this to the mailing list (in which case,
you shouldn't have...), you should *still* read it. Whoever you were
addressing would *certainly* appreciate it if you took this to heart.

I repeat: Please read
  http://www.catb.org/~esr/faqs/smart-questions.html
You have been asked to do so before and I cannot believe that you did it.

> -- 
> madhuri :)
> 

PS: you addressed [email protected] as well. That's the
address of the software that takes care of subscribing and unsubscribing
people. No use writing questions there.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-10 Thread Thomas Jollans
On 06/10/2010 07:25 AM, Qijing Li wrote:
> Thanks for your reply.
> I'm trying to understand python language deeply and  use it efficiently.
> For example: How the operator "in" works on list? the running time is
> be O(n)?  if my list is sorted, what the running time would be?

There is excellent documentation of the language and standard library at
http://docs.python.org/ .

Otherwise, just download the Python source code! You know it's free. I
think it's pretty well organised, though I haven't worked with it a lot
yet myself. Just poke around!

Have fun,
Thomas

> 
> 
> 
> On Wed, Jun 9, 2010 at 5:59 PM, geremy condra  > wrote:
> 
> On Wed, Jun 9, 2010 at 5:28 PM, Leon  @gmail.com > wrote:
> > Hi, there,
> > I'm trying to read the source code of python.
> > I read around, and am kind of lost, so where to start?
> >
> > Any comments are welcomed, thanks in advance.
> 
> Are you trying to find out more about python-the-language,
> or the interpreter, or the stdlib, or trying to make some
> specific change, or...?
> 
> Geremy Condra
> 
> 

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


ANN: eGenix pyOpenSSL Distribution 0.10.0-1.0.0a

2010-06-10 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

   eGenix.com pyOpenSSL Distribution

  Version 0.10.0-1.0.0a


 An easy-to-install and easy-to-use distribution
 of the pyOpenSSL Python interface for OpenSSL -
available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.10.0-1.0.0a-1.html



INTRODUCTION

The eGenix.com pyOpenSSL Distribution includes everything you need to
get started with SSL in Python.

It comes with an easy-to-use installer that includes the most recent
OpenSSL library versions in pre-compiled form, making your application
independent of OS provided OpenSSL libraries:

http://www.egenix.com/products/python/pyOpenSSL/

pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS-
aware network applications as well as certificate management tools:

https://launchpad.net/pyopenssl/

OpenSSL is an open-source implementation of the SSL/TLS protocol:

http://www.openssl.org/



NEWS

This new release of the eGenix.com pyOpenSSL Distribution updates the
included pyOpenSSL version to 0.10.0 and the included OpenSSL version
to 1.0.0a.


Main new features in pyOpenSSL 0.10.0 (from the announcement)
-

* pyOpenSSL 0.10 exposes several more OpenSSL APIs, including
  support for running TLS connections over in-memory BIOs, access
  to the OpenSSL random number generator, the ability to pass
  subject and issuer parameters when creating an X509Extension
  instance, more control over PKCS12 creation and an API for
  exporting PKCS12 objects, and APIs for controlling the client CA
  list servers send to clients.

* Several bugs have also been fixed, including a crash when
  certain X509Extension instances are deallocated, a mis-handling
  of the OpenSSL error queue in the X509Name implementation,
  Windows build issues, and a possible double free when using a
  debug build.

See Jean-Paul Calderone's full announcement for all details:

https://launchpad.net/pyopenssl/+announcement/4318


New features in OpenSSL 1.0.0a since our last release
-

The main new features in OpenSSL 0.9.8m is the new support for RFC
5746, which addresses the SSL renegotiation problem found in earlier
OpenSSL versions.

* RFC 5746 - Transport Layer Security (TLS) Renegotiation
  Indication Extension: http://tools.ietf.org/html/rfc5746

* For a complete list of changes see:
  http://www.openssl.org/news/news.html

Version 0.9.8n fixes this vulnerability (see
http://www.openssl.org/news/secadv_20100324.txt):

* "Record of death" vulnerability in OpenSSL 0.9.8f through
  0.9.8m

Version 1.0.0 adds many new features, including (see
http://www.openssl.org/news/news.html):

* Support for Whirlpool hash algorithm
* Support for GOST cipher

Version 1.0.0a fixes two security issues (see
http://www.openssl.org/news/secadv_20100601.txt):

* Invalid ASN1 module definition for CMS.
* Invalid Return value check in pkey_rsa_verifyrecover


New features in the eGenix pyOpenSSL Distribution
-

* The embedded OpenSSL libs will now look for certificates in
  /etc/ssl on Unix platforms and /System/Library/OpenSSL on
  Mac OS X

  Note that it's usually better to explicitly tell OpenSSL where
  to look for trusted certificates via
  .load_verify_locations(None, certs_dir) than to rely on the
  above defaults using context.set_default_verify_paths()

* Added support for Win64 and precompiled Python 2.6 compatible
  binaries for that platform (you can find the OpenSSL libs in
  openssl-win64/vc9)

* Added support for Mac OS X 10.6 on Intel x64.

* Added .egg Distributions for Python 2.4 as well (in order to
  support Plone 3).


As always, we provide binaries that include both pyOpenSSL and the
necessary OpenSSL libraries for all supported platforms: Windows x86
and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64.

Due to popular demand, we've also added .egg-file format versions of
our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X
to the available download options.

These makes setups using e.g. zc.buildout and other egg-file based
installers a lot easier.



DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/pyOpenSSL/

__

Re: GUIs - A Modest Proposal

2010-06-10 Thread Martin v. Loewis

Is the Tkinter GUI also the basic way that Python handles a graphics
display? (I've never tried it.)


No. Python, in itself, does not "handle" graphics displays at all. For
any output to the graphics display, it uses some kind of library,
whether it's console output, or a GUI application. One specific GUI
library is Tkinter. A standard "print" command (which eventually also
outputs to the graphics display) instead uses the terminal emulation of
the operating system.

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Gregory Ewing

Brian Blais wrote:

I wonder if that sort of philosophy would work: a really nice and  
clear, pythonic wrapper around a sophisticated, complex, and complete  
GUI framework. ...  Depending on how it is designed, it might even  be 
possible to have a multi-framework wrapping, so that someone could  have 
a Qt-based wrapper, and another using the same module choose to  have it 
wrap wx.


That's more or less what PyGUI is meant to be, except that the
frameworks currently wrapped are Cocoa, Gtk and pywin32. There's
also a slight difference in emphasis, since PyGUI aims to leverage
platform functionality as much as possible, rather than rely on
a large third-party library that duplicates much of that functionality.

> It should be thin enough that the underlying GUI
> library can be called directly, however, or its usefulness will be
> greatly diminished.

Hmmm... you probably *could* do that with PyGUI if you wanted, but
it would require delving under the covers and dealing with some
stuff that's a bit on the hairy side and wasn't meant to be seen
by ordinary mortals. Also the resulting app would no longer be
cross-platform, and might be tied to details of a particular
version of PyGUI. Possibly some hooks could be added to the API
to make this sort of thing cleaner, though.

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Martin v. Loewis

That said, PerlTk didn't use Tcl did it?


If you are referring to http://search.cpan.org/~srezic/Tk-804.028/ -
this also has a full Tcl interpreter, in pTk/mTk, and uses Tcl_Interp
and Tcl_Obj throughout. From the Perl/Tk FAQ (*):

"However, from a Perl perspective, Perl/Tk does not require any 
familiarity with Tcl, nor does its installation depend on any Tcl code 
apart from that packaged within Perl/Tk."


They also explain

"The pTk code proper is an externally callable Tk toolkit (i.e. a 
re-write of the Tk 8.0 code that allows easier external linking & 
calling, especially by perl)."


I couldn't quite understand what they mean by that: the sources for 
tcl/generic (for example) look fairly unmodified.


Regards,
Martin

(*) http://www.lns.cornell.edu/~pvhp/ptk/ptkFAQ.htm
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-10 Thread News123
Leon wrote:
> Hi, there,
> I'm trying to read the source code of python.dd
> I read around, and am kind of lost, so where to start?
> 
> Any comments are welcomed, thanks in advance.


I use my favourite text editor with syntax highlighting.

Next to it I use a web browser with pydoc and google.

If uou're looking for an IDE that will help you a little more navigating
in python code, then you could look at

Eclipse
or
Netbeans
both support python

both are rather heavy weapons though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-10 Thread Gregory Ewing

Brian Blais wrote:

In this whole discussion, I haven't seen anyone mention wax (http:// 
zephyrfalcon.org/labs/wax_primer.html)


Just had a quick look at that. In the third example code box:

  def Body(self):
  
self.textbox = TextBox(self, multiline=1, wrap=0)
self.AddComponent(self.textbox)
 

Here's something unpythonic already: a couple of non-pep-8-compliant
method names.

And a bit further down:

self.textbox.SetFont(FIXED_FONT)
 ^^^

Using a setter method instead of a property.

So while it's quite likely better than raw wxPython, it fails the
pythonicity test for me.

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


Re: tkinter doubt

2010-06-10 Thread Chris Rebert
On Thu, Jun 10, 2010 at 12:48 AM, Thomas Jollans  wrote:
> On 06/10/2010 08:50 AM, madhuri vio wrote:
>> # File: hello2.py
>>
>> from Tkinter import *
>>
>> class App:
>>
>>     def __init__(self, master):
>>
>>         frame = Frame(master)
>>         frame.pack()
>>
>>         self.button = Button(frame, text="QUIT", fg="red", 
>> command=frame.quit)
>>
>>         self.button.pack(side=LEFT)
>>
>>         self.hi_there = Button(frame, text="Hello", command=self.say_hi)
>>         self.hi_there.pack(side=LEFT)
>>
>>     def say_hi(self):
>>         print "hi there, everyone!"
>>
>>
>> root = Tk()
>>
>> app = App(root)
>>
>> root.mainloop()
>>
>> in this program i wanted to  get a clear idea about this
>>
>>
>> def __init__(self, master):
>>
>>         frame = Frame(master)
>>
>>         frame.pack()
>>
>>         self.button = Button(frame, text="QUIT", fg="red", 
>> command=frame.quit)
>>         self.button.pack(side=LEFT)
>>
>>         self.hi_there = Button(frame, text="Hello", command=self.say_hi)
>>
>>         self.hi_there.pack(side=LEFT)
>>
>> what is _init_...self and master...
> read up on object-orientation with Python

In particular, see the official tutorial's section on objects & classes:
http://docs.python.org/tutorial/classes.html

Read it after you're done with
http://www.catb.org/~esr/faqs/smart-questions.html

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


Re: regarding the dimensions in gui

2010-06-10 Thread Andreas Waldenburger
On Thu, 10 Jun 2010 08:37:21 +0100 Simon Brunning
 wrote:

> On 10 June 2010 08:19, Shashwat Anand 
> wrote:
> > And please stop using 'sir' for heaven's sake.
> 
> Not least because list list isn't male only.
> 

Not that I know a lot about Indian English, but I think the Indian mind
tends to use "Sir" as a general respectful address. Or such.

/W

-- 
INVALID? DE!

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


Re: using reverse in list of tuples

2010-06-10 Thread Marco Nawijn
On Jun 10, 2:39 am, james_027  wrote:
> hi,
>
> I am trying to reverse the order of my list of tuples and its is
> returning a None to me. Is the reverse() function not allow on list
> containing tuples?
>
> Thanks,
> James

As the others already mentioned list.reverse() is in-place, just as
for
example list.sort(). Alternatively, use the builtin reversed() or
sorted()
functions to get a return value (they will leave the original list
unmodified.

Example:
>>> a = range(3)
>>> b = reversed(a)
>>> for item in b:
  ...print item
This will produce:
  2
  1
  0

Note that reversed returns an iterator.

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Gregory Ewing

Martin v. Loewis wrote:

or PyGui would need to be implemented in terms of ctypes (which then 
would prevent its inclusion, because there is a policy that ctypes must 
not be used in the standard library).


Is there? I wasn't aware of that. What's the reason?

If it's because ctypes doesn't work on all platforms, then
I don't think that applies in this case, because the only
platform where it would be needed is Windows, where ctypes
does work.

I think that the separation of pywin32 into modules is 

> somewhat arbitrary

Pywin32 does seem to have grown rather haphazardly. Some
functionality is wrapped in two different ways in different
modules, for no apparently good reason, and some other
things are wrapped incompletely or not at all. A well
thought out replacement suitable for stdlib inclusion
wouldn't go amiss.

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


Re: regarding the dimensions in gui

2010-06-10 Thread Chris Rebert
On Thu, Jun 10, 2010 at 1:27 AM, Andreas Waldenburger
 wrote:
> On Thu, 10 Jun 2010 08:37:21 +0100 Simon Brunning
>  wrote:
>> On 10 June 2010 08:19, Shashwat Anand 
>> wrote:
>> > And please stop using 'sir' for heaven's sake.
>>
>> Not least because list list isn't male only.
>
> Not that I know a lot about Indian English, but I think the Indian mind
> tends to use "Sir" as a general respectful address. Or such.

In any case, if one is using an address, it needs to be plural since
mailinglists/usenet involve communicating with a multitude.

Cheers,
Chris
--
The language specification for English leaves much to be desired.
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with libxml2/libxlst

2010-06-10 Thread CinnamonDonkey
Hi All,

I could not find a dedicated libxml2/libxlst group so I thought I
would see if anyone here could help.

I have a system which captures the stdout from various sources and
writes it into a generic xml file. This file then needs to be
transformed to get the correct html format for rendering in a
webserver.

I am using the following code to perform the translation:

  styledoc = libxml2.parseFile('stdout.xsl')
  style = libxslt.parseStylesheetDoc(styledoc)

  doc = libxml2.parseFile('stdout.xml')
  result = style.applyStylesheet(doc, None)

  style.saveResultToFilename('stdout.html'), result, 0)

  style.freeStylesheet()
  doc.freeDoc()
  result.freeDoc()

Given the following stdout.xml sample:


  some app spew...
  laa laaa laa...
  something interesting 


It seems that the resultant 'stdout.html' file shows the final stdout
message translated too:

  something interesting 

which of course results in a badly formed file with a missing tag :(

How do I get libxml2/libxlst to not touch the '<' and '>'

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


gui related

2010-06-10 Thread madhuri vio
in this program i tried..i am getting a name error...

from Tkinter import*
import Tkinter

a = Tk()
a.title ("TOOL")
entry = Tkinter.Canvas(a)#creating the canvas
under the root
entry.pack() #to call the packer
geometry
entry.create_rectangle(40,30,300,150,fill="white")
b = Button(frame,text = "upload",fg="black",command = "browse")
b.pack()
c = Button(frame,text = "translate",fg="red",command = "still in progress")
c.pack()
d = Button(frame,text="exit",fg="green",command="bye")
d.pack()

a.mainloop()




$ python newtool.py
Traceback (most recent call last):
  File "newtool.py", line 14, in 
b = Button(frame,text = "upload",fg="black",command = "browse")
NameError: name 'frame' is not defined


i didnt understand hw do i instantiate frame
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regarding the dimensions in gui

2010-06-10 Thread Jean-Michel Pichavant

Chris Rebert wrote:

On Thu, Jun 10, 2010 at 1:27 AM, Andreas Waldenburger
 wrote:
  

On Thu, 10 Jun 2010 08:37:21 +0100 Simon Brunning
 wrote:


On 10 June 2010 08:19, Shashwat Anand 
wrote:
  

And please stop using 'sir' for heaven's sake.


Not least because list list isn't male only.
  

Not that I know a lot about Indian English, but I think the Indian mind
tends to use "Sir" as a general respectful address. Or such.



In any case, if one is using an address, it needs to be plural since
mailinglists/usenet involve communicating with a multitude.

Cheers,
Chris
--
The language specification for English leaves much to be desired.
http://blog.rebertia.com
  

Internet rule, number 30:

"There are no girls on the internet"

:)

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


Re: gui related

2010-06-10 Thread Chris Rebert
On Thu, Jun 10, 2010 at 2:38 AM, madhuri vio  wrote:
> in this program i tried..i am getting a name error...
>
> from Tkinter import*
> import Tkinter
>
> a = Tk()
> a.title ("TOOL")
> entry = Tkinter.Canvas(a)    #creating the canvas
> under the root
> entry.pack() #to call the packer
> geometry
> entry.create_rectangle(40,30,300,150,fill="white")
> b = Button(frame,text = "upload",fg="black",command = "browse")
> b.pack()
> c = Button(frame,text = "translate",fg="red",command = "still in progress")
> c.pack()
> d = Button(frame,text="exit",fg="green",command="bye")
> d.pack()
>
> a.mainloop()
>
>
>
>
> $ python newtool.py
> Traceback (most recent call last):
>   File "newtool.py", line 14, in 
>     b = Button(frame,text = "upload",fg="black",command = "browse")
> NameError: name 'frame' is not defined
>
>
> i didnt understand hw do i instantiate frame

Read A Fine Tutorial:
http://www.pythonware.com/library/tkinter/introduction/x4822-patterns.htm

(After you're finished with "How To Ask Questions The Smart Way" of course)

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


Re: How to read source code of python?

2010-06-10 Thread pradeepbpin
On Jun 10, 1:15 pm, News123  wrote:
> Leon wrote:
> > Hi, there,
> > I'm trying to read the source code of python.dd
> > I read around, and am kind of lost, so where to start?
>
> > Any comments are welcomed, thanks in advance.
>
> I use my favourite text editor with syntax highlighting.
>
> Next to it I use a web browser with pydoc and google.
>
> If uou're looking for an IDE that will help you a little more navigating
> in python code, then you could look at
>
> Eclipse
> or
> Netbeans
> both support python
>
> both are rather heavy weapons though.


In my opinion, pydoc would be a good choice. I am a fan of it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-10 Thread Emin.shopper Martinian.shopper
Dear Dmitry, Bryan and Philip,

Thanks for the suggestions. I poked around the dictionary descriptions
and fiddled some more but couldn't find any obvious error. I agree it
does seem odd that a 50 kb dict should fail. Eventually, I tried
Dmitry suggestion of moving over to python 2.6. This took a while
since I had to upgrade a bunch of libraries like numpy and scipy along
the way but once I got everything over to 2.6 it succeeded.

My bet is that it was still some kind of weird memory issue but
considering that it does not seem to exist in python 2.6 I'm guessing
it's not worth the effort to continue to track down.

Thanks again for all your help. I learned a lot more about
dictionaries along the way.

Best,
-Emin

On Fri, Jun 4, 2010 at 4:40 PM, Bryan
 wrote:
> Philip Semanchuk wrote:
>> At PyCon 2010, Brandon Craig Rhodes presented about how dictionaries
>> work under the 
>> hood:http://python.mirocommunity.org/video/1591/pycon-2010-the-mighty-dict...
>>
>> I found that very informative.
>
> That's a fine presentation of hash tables in general and Python's
> choices in particular. Also highly informative, while easily readable,
> is the Objects/dictnotes.txt file in the Python source.
>
> Fine as those resources may be, the issue here stands. Most of my own
> Python issues turn out to be stupid mistakes, and the problem here
> might be on that level, but Emin seems to have worked his problem and
> gotten a bunch of stuff right. There is no good reason why
> constructing a 50 kilobyte dict should fail with a MemoryError while
> constructing 50 megabyte lists succeeds.
>
>
> --
> --Bryan Olson
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


xml-rpc UnicodeDecodeError

2010-06-10 Thread timothee cezard

Hi all,
I'm starting to use xml-rpc module to check and potentially modify a 
confluence wiki

but I'm getting and error on a page containing the pound (£) sign

here is the code I'm using

server = xmlrpclib.ServerProxy('my_server',  verbose=True)
token = server.confluence1.login('username','password)
page = server.confluence1.getPage(token, spacekey, pagetitle)
print page['content']
I'm getting:
   page = server.confluence1.getPage(token, spacekey, pagetitle)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1387, in _parse_response
p.feed(response)
  File "/usr/lib/python2.6/xmlrpclib.py", line 868, in end
return f(self, join(self._data, ""))
  File "/usr/lib/python2.6/xmlrpclib.py", line 959, in end_value
self.end_string(data)
  File "/usr/lib/python2.6/xmlrpclib.py", line 916, in end_string
data = _decode(data, self._encoding)
  File "/usr/lib/python2.6/xmlrpclib.py", line 164, in _decode
data = unicode(data, encoding)
  UnicodeDecodeError: 'utf8' codec can't decode byte 0xa3 in position 
811: unexpected code byte



I tried changing the encoding to iso-8859-1
server = xmlrpclib.ServerProxy('my_server', encoding='iso-8859-1', 
verbose=True)

token = server.confluence1.login('username','password)
page = server.confluence1.getPage(token, spacekey, pagetitle)
print page['content']
I'm getting the same exception

Does any of you have an idea of what I'm doing wrong?
I'm using Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55) and xmlrpclib 
version 1.0.1


Thanks

Tim


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-10 Thread Nobody
On Wed, 09 Jun 2010 21:15:48 -0700, Chris Seberino wrote:

> How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

The same way that the shell does it, e.g.:

  from subprocess import Popen, PIPE
  p1 = Popen("ls", stdout=PIPE)
  p2 = Popen(["grep", "foo"], stdin=p1.stdout, stdout = PIPE)
  p1.stdout.close()
  result = p2.communicate()[0]
  p1.wait()

Notes:

Without the p1.stdout.close(), if the reader (grep) terminates before
consuming all of its input, the writer (ls) won't terminate so long as
Python retains the descriptor corresponding to p1.stdout. In this
situation, the p1.wait() will deadlock.

The communicate() method wait()s for the process to terminate. Other
processes need to be wait()ed on explicitly, otherwise you end up with
"zombies" (labelled "" in the output from "ps").

> Does complex commands with "|" in them mandate shell=True?

No.

Also, "ls | grep" may provide a useful tutorial for the subprocess module,
but if you actually need to enumerate files, use e.g. os.listdir/os.walk()
and re.search/fnmatch, or glob. Spawning child processes to perform tasks
which can easily be performed in Python is inefficient (and often creates
unnecessary portability issues).

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Brian Blais

On Jun 10, 2010, at 4:28 , Gregory Ewing wrote:


Brian Blais wrote:


In this whole discussion, I haven't seen anyone mention wax (http://
zephyrfalcon.org/labs/wax_primer.html)


Just had a quick look at that. In the third example code box:

   def Body(self):
   
 self.textbox = TextBox(self, multiline=1, wrap=0)
 self.AddComponent(self.textbox)
  

Here's something unpythonic already: a couple of non-pep-8-compliant
method names.

And a bit further down:

 self.textbox.SetFont(FIXED_FONT)
  ^^^

Using a setter method instead of a property.

So while it's quite likely better than raw wxPython, it fails the
pythonicity test for me.


I hope I didn't imply that it was perfect.  :)  It's definitely much  
easier than raw wx, and I think it is a reasonable starting point.   
Some of the things that you pointed out are very easily fixed, and  
are there because of some wx quirks.  AddComponent could easily be  
renamed to append, for the same meaning.  Many other wx getters/ 
setters are done with properties or attributes, so it is in the right  
direction.



I wonder if that sort of philosophy would work: a really nice and
clear, pythonic wrapper around a sophisticated, complex, and complete
GUI framework. ...  Depending on how it is designed, it might  
even  be
possible to have a multi-framework wrapping, so that someone  
could  have
a Qt-based wrapper, and another using the same module choose to   
have it

wrap wx.



That's more or less what PyGUI is meant to be, except that the
frameworks currently wrapped are Cocoa, Gtk and pywin32. There's
also a slight difference in emphasis, since PyGUI aims to leverage
platform functionality as much as possible, rather than rely on
a large third-party library that duplicates much of that  
functionality.



I've tried PyGUI about 6 months ago, and it seemed like a good start,  
but missing a lot of what I would need.  I also am not very fluent in  
MVC (having developed all my bad GUI habits from years of matlab  
programming), so the structure wasn't particularly intuitive.  I just  
tried it again a few days ago, and couldn't get it running on my  
system, which is a bit old (OS X Tiger).


Since many seem to be married to a particular GUI framework, I was  
just suggesting that a thin wrapper around the framework might be  
fruitful, with wax as a working proof-of-concept. That way, when  
there is a limitation, one can fall back on the underlying framework  
easily.  Wrapping an already cross-platform framework would seem to  
get the most bang for the buck.



bb
--
Brian Blais
[email protected]
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/



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


Re: help!!

2010-06-10 Thread z00z
On Jun 10, 1:33 am, Steven D'Aprano  wrote:
> On Wed, 09 Jun 2010 16:44:10 -0700, z00z wrote:
> > ok when my code is like this everything works well
>
> > #/usr/bin/python
> > input = raw_input(">> ").replace(',','\n')
> > a=open("file","w")
> > a.write(input)
> > a.close()
> > import sys,os,time,subprocess,threading,readline,socket,ifc
>
> Your hash-bang line is broken, missing the exclamation mark.
>
> What is "ifc" module?
>
> > but the problem is i have to import the libraries before the code so my
> > code should be like this
>
> > #/usr/bin/python
> > import sys,os,time,subprocess,threading,readline,socket,interfaces
> > input = raw_input(">> ").replace(',','\n')
> > a=open("file","w")
> > a.write(input)
> > a.close()
>
> The hash-bang line is still broken, and the import ifc is replaced by
> interfaces. What is interfaces?
>
> > when i execute the above code no error message is given but no file is
> > written.
>
> Apart from not having the interfaces module, it works for me. Are you
> sure that's the code you're actually running?
>
> --
> Steven
yeah sorry about that
interfaces is ifc and its a module (written by me) to detect the
network interface.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: grep command

2010-06-10 Thread D'Arcy J.M. Cain
On Thu, 10 Jun 2010 08:26:58 +0100
Simon Brunning  wrote:
> On 10 June 2010 07:38, madhuri vio  wrote:
> > i was wondering bout the usage and syntax of
> > grep command..can u tall me its syntax so that
> > i can use it and proceed...pls
> 
> That's really not on topic for this list.

I'm surprised that there is anyone left who hasn't killfiled this guy.
He/she hasn't made any effort to understand the group.  Why bother even
answering him?  Just filter him and enjoy the silence.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help!!

2010-06-10 Thread z00z
On Jun 10, 1:33 am, Steven D'Aprano  wrote:
> On Wed, 09 Jun 2010 16:44:10 -0700, z00z wrote:
> > ok when my code is like this everything works well
>
> > #/usr/bin/python
> > input = raw_input(">> ").replace(',','\n')
> > a=open("file","w")
> > a.write(input)
> > a.close()
> > import sys,os,time,subprocess,threading,readline,socket,ifc
>
> Your hash-bang line is broken, missing the exclamation mark.
>
> What is "ifc" module?
>
> > but the problem is i have to import the libraries before the code so my
> > code should be like this
>
> > #/usr/bin/python
> > import sys,os,time,subprocess,threading,readline,socket,interfaces
> > input = raw_input(">> ").replace(',','\n')
> > a=open("file","w")
> > a.write(input)
> > a.close()
>
> The hash-bang line is still broken, and the import ifc is replaced by
> interfaces. What is interfaces?
>
> > when i execute the above code no error message is given but no file is
> > written.
>
> Apart from not having the interfaces module, it works for me. Are you
> sure that's the code you're actually running?
>
> --
> Steven

yeah i have some mistakes there sorry about that
ifc is interfaces and its a module (written by me) to detect network
interfaces.
but its ok now i sixed the problem
thanks for your response anyway
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Jobs

2010-06-10 Thread Michael Chambliss
On Wed, Jun 9, 2010 at 8:58 PM, Vincent Davis wrote:
>
>
> You might take a look at Front Range pythoneers. The is a mailing list
> an I think monthly meetups.  I see some job post coma across the list
> now and then.
> http://www.meetup.com/frpythoneers/
>
> I am also in the Denver area and have been meaning to go to one of the
> meetups.
>
> Vincent
>

Thanks for that, Vincent.  I've signed up for the group.  Perhaps Python is
enough of a niche amongst the Java and .NET shops that employers go straight
to these SIGs instead of the normal job boards.

Thanks to all for the input thus far.  It'll be interesting to see more
responses if they come in, but my assumption is that for most of you, the
development you're doing is either internal or hosted.  My company is
particularly phobic of releasing our products, which are typically "shrink
wrapped" and customer hosted, in anything but an obfuscated and compiled
package.

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


Simple hack to get $500 to your home

2010-06-10 Thread free money
Simple hack to get $500 to your home at http://ukfullenjoy.co.cc

Due to high security risks,i have hidden the cheque link in an
image.  in that website on left side below search box, click on image
and enter your name and address where you want to receive your
cheque.please dont tell to anyone.
-- 
http://mail.python.org/mailman/listinfo/python-list


numpy arrays to python compatible arrays

2010-06-10 Thread Javier Montoya
Dear all,

I'm new to python and have been working with the numpy package. I have
some numpy float arrays (obtained from np.fromfile and np.cov
functions) and would like to convert them to simple python arrays.
I was wondering which is the best way to do that? Is there any
function to do that?

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


Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-10 Thread Grant Edwards
On 2010-06-10, Chris Seberino  wrote:

> How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

You'll have to build your own pipeline with multiple calls to subprocess

> Does complex commands with "|" in them mandate shell=True?

Yes.

Hey, I've got a novel idea!

Read the documentation for the subprocess module:

http://docs.python.org/library/subprocess.html#replacing-shell-pipeline

-- 
Grant Edwards   grant.b.edwardsYow! ... My pants just went
  at   on a wild rampage through a
  gmail.comLong Island Bowling Alley!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-10 Thread python
Brian,

> Since many seem to be married to a particular GUI framework, I was just 
> suggesting that a thin wrapper around the framework might be fruitful,

The guys on the Dabo project have created such a wrapper.
www.dabodev.org.

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


Deformed Form

2010-06-10 Thread Victor Subervi
Hi;
I have a script that calls values from the form that calls it. This script
imports another script:

from New_Passenger import New_Passenger

def create_edit_passengers3():
  ...
  new_passengers_curr_customers = New_Passengers_Curr_Customers(customers,
flights)
  if new_passengers_curr_customers > 0:
print ""

All this works. What puzzles me, however, is that the value of
new_passengers_curr_customers has to be called using cgi from the imported
script (New_Passenger). It cannot be called from the calling script. I would
have thought it would have been the other way around. Please help me
understand why.
TIA,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regarding the dimensions in gui

2010-06-10 Thread Jon Clements
On 10 June, 10:40, Jean-Michel Pichavant 
wrote:
> Chris Rebert wrote:
> > On Thu, Jun 10, 2010 at 1:27 AM, Andreas Waldenburger
> >  wrote:
>
> >> On Thu, 10 Jun 2010 08:37:21 +0100 Simon Brunning
> >>  wrote:
>
> >>> On 10 June 2010 08:19, Shashwat Anand 
> >>> wrote:
>
>  And please stop using 'sir' for heaven's sake.
>
> >>> Not least because list list isn't male only.
>
> >> Not that I know a lot about Indian English, but I think the Indian mind
> >> tends to use "Sir" as a general respectful address. Or such.
>
> > In any case, if one is using an address, it needs to be plural since
> > mailinglists/usenet involve communicating with a multitude.
>
> > Cheers,
> > Chris
> > --
> > The language specification for English leaves much to be desired.
> >http://blog.rebertia.com
>
> Internet rule, number 30:
>
> "There are no girls on the internet"
>
> :)
>
> JM

Ahh, you're forgetting the sub-clause of that rule: "(well actually
there are, they just happen to be in .gif and .jpg format)".

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


Re: Deformed Form

2010-06-10 Thread Stephen Hansen (L/P)
On 6/10/10 7:14 AM, Victor Subervi wrote:
> Hi;
> I have a script that calls values from the form that calls it. This script
> imports another script:
> 
> from New_Passenger import New_Passenger
> 
> def create_edit_passengers3():
>   ...
>   new_passengers_curr_customers = New_Passengers_Curr_Customers(customers,
> flights)
>   if new_passengers_curr_customers > 0:
> print ""
> 
> All this works. What puzzles me, however, is that the value of
> new_passengers_curr_customers has to be called using cgi from the imported
> script (New_Passenger). It cannot be called from the calling script. I would
> have thought it would have been the other way around. Please help me
> understand why.

I can't quite figure out what you're asking.
new_passengers_curr_customers is a variable local to
create_edit_passengers3; you have something that differs only in case
called New_Passengers_Curr_Customers which -- I assume is defined,
somewhere. Then you haev New_Passenger, and I'm not sure I see what it
has to do with anything.

But what does "cannot be called" mean? "Cannot" usually means "an error
happened" -- in which case you shouldn't really even mention it unless
you're gonna back it up with a traceback.

The former is a value, you don't call it. You access it. And it being
local, you can surely only access it within that function (unless you
pass it somewhere). The latter is -- a class? A function? No idea, as
you haven't shown us. Nor shown any errors or any tracebacks or
*anything* to indicate what is possibly going on, let alone what is
going wrong when you, I presume, attempt to "call .. something .. from
the calling script". (???)

So either way... cannot be called?

+1 for "absolutely worst framed question of the day" :)

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: function that counts...

2010-06-10 Thread Lie Ryan
On 06/10/10 09:03, Bryan wrote:
> Lie Ryan wrote:
>> I went through the mathematical foundation of using
>> partition/distribution and inclusion-exclusion, and have written some
>> code that solves a subset of the problem, feel free if you or superpollo
>> are interested in continuing my answer (I won't be able to continue it
>> until next week, have been a little bit busy here)
>>
>> copying the code here for convenience:
>>
>> # memoization would be very useful here
>> def fact(n):
>> """ factorial function (i.e. n! = n * (n-1) * ... * 2 * 1) """
>> return n * fact(n - 1) if n != 0 else 1
>>
>> def C(n, r):
>> """ regular Combination (nCr) """
>> return fact(n) / (fact(n - r) * fact(r))
>>
>> def D(M, N):
>> """ Distribution aka Partitioning """
>> return C(M + N - 1, M)
>>
>> def partition10(M, i):
>> """ Count how many integer < N sums to M where N = 10**int(i) """
>> s = 0
>> sign = 1
>> for j in range(i + 1):
>> s += sign * D(M, i) * C(i, j)
>>
>> # flip the sign for inclusion-exclusion
>> sign *= -1
>>
>> # if M = 32, then 32, 22, 12, 2, -8
>> M -= 10
>> return s
> 
> It doesn't seem to work. I get no answer at all, because it recursion-
> loops out when it calls fact() with a negative integer.

Why of course you're right! In my original post in comp.programming, I
used this definition of factorial:

def fact(n):
""" factorial function (i.e. n! = n * (n-1) * ... * 2 * 1) """
p = 1
for i in range(1,n+1):
p *= i
return p

when I reposted it here, I substituted that factorial to the recursive
definition which fails when n is negative without much testing and that
causes things to fails miserably. Sorry about that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with libxml2/libxlst

2010-06-10 Thread CinnamonDonkey
My mistake! *doh*

I had an 'disable-output-escape="YES"' when it should have been "NO".

-Shaun

On 10 June, 10:17, CinnamonDonkey 
wrote:
> Hi All,
>
> I could not find a dedicated libxml2/libxlst group so I thought I
> would see if anyone here could help.
>
> I have a system which captures the stdout from various sources and
> writes it into a generic xml file. This file then needs to be
> transformed to get the correct html format for rendering in a
> webserver.
>
> I am using the following code to perform the translation:
>
>   styledoc = libxml2.parseFile('stdout.xsl')
>   style = libxslt.parseStylesheetDoc(styledoc)
>
>   doc = libxml2.parseFile('stdout.xml')
>   result = style.applyStylesheet(doc, None)
>
>   style.saveResultToFilename('stdout.html'), result, 0)
>
>   style.freeStylesheet()
>   doc.freeDoc()
>   result.freeDoc()
>
> Given the following stdout.xml sample:
>
> 
>   some app spew...
>   laa laaa laa...
>   something interesting 
> 
>
> It seems that the resultant 'stdout.html' file shows the final stdout
> message translated too:
>
>   something interesting 
>
> which of course results in a badly formed file with a missing tag :(
>
> How do I get libxml2/libxlst to not touch the '<' and '>'
>
> Cheers
> -Shaun

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


Re: How to read source code of python?

2010-06-10 Thread Floris Bruynooghe
On Jun 10, 8:55 am, Thomas Jollans  wrote:
> On 06/10/2010 07:25 AM, Qijing Li wrote:
>
> > Thanks for your reply.
> > I'm trying to understand python language deeply and  use it efficiently.
> > For example: How the operator "in" works on list? the running time is
> > be O(n)?  if my list is sorted, what the running time would be?

Taking this example, you know you want the "in" operator.  Which you
somehow need to know is implemented by the "__contains__" protocol
(you can find this in the "expressions" section of the "Language
Reference").

Now you can either know how objects look like in C (follow the
"Extending and Embedding" tutorial, specifically the "Defining New
Types" section) and therefore know you need to look at the sq_contains
slot of the PySequenceMethods sturcture.  Or you could just locate the
list object in Objects/listobjects.c (which you can easily find by
looking at the source tree) and search for "contains".  Both ways
will lead you pretty quickly to the list_contains() function in
Objects/listobject.c.  And now you just need to know the C-API (again
in the docs) to be able to read it (even if you don't that's a pretty
straightforward function to read).

Hope that helps
Floris
-- 
http://mail.python.org/mailman/listinfo/python-list


Py++, boost and python type mismatch error

2010-06-10 Thread Murrgon
I have a simple C++ library (from a dll) I am attempting to make accessible 
through bindings to python.  I used Py++ to generate some boost code for the 
library that I compiled into a pyd.  I can import the pyd no problem into 
python, but I can't seem to call the functions.


struct MM_Api
{
  void* pData;
};

int declspec(dllimport) MM_Initialize( MM_Api* pApi );

I made a PyMM.pyd that has this in it.

import PyMM
api = PyMM.MM_Api
ret = PyMM.MM_Initialize(api)

Traceback (most recent call last):
  File "", line 1, in 
Boost.Python.ArgumentError: Python argument types in
PyMM.MM_Initialize(Boost.Python.class)
did not match C++ signature:
MM_Initialize(struct MM_Api * pApi)

The docs for Py++ leave a lot guess work up to the user, so I don't know if I 
forgot a step, or messed something up.  Is there some glue I need to 
write/generate that will translate an instance of PyMM.MM_Api to the C++ 
version of MM_Api, and if so, is this python glue, or C/C++ glue?


Thank you
Murrgon
--
http://mail.python.org/mailman/listinfo/python-list


including pygments code_block directive in rst2* from docutils

2010-06-10 Thread Sean Davis
I would like to simply extend the rst2* scripts bundled with docutils
to include a code_block directive.  I have found a number of sites
that discuss the topic, but I guess I am new enough to docutils to
still be wondering how to make it actually happen.  I'm looking to
convert a single .rst file to bother html and pdf (via latex).  Any
suggestions?

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


Re: Deformed Form

2010-06-10 Thread Bruno Desthuilliers

Stephen Hansen (L/P) a écrit :

On 6/10/10 7:14 AM, Victor Subervi wrote:

(snip)


+1 for "absolutely worst framed question of the day" :)


IMHO you're wasting your time. Some guys never learn, and I guess we do 
have a world-class all-times champion here.



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


Re: Problem with libxml2/libxlst

2010-06-10 Thread Stephen Hansen
On 6/10/10 7:47 AM, CinnamonDonkey wrote:
> My mistake! *doh*
> 
> I had an 'disable-output-escape="YES"' when it should have been "NO".
> 
> -Shaun
> 

Eeeeven though you figured out your problem: have you checked out lxml?
Its extremely capable and ISTM much easier to use then whatever direct
wrapper you seem to be using.

Check out: http://codespeak.net/lxml/xpathxslt.html#xslt

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-10 Thread Chris Seberino
On Jun 10, 6:52 am, Nobody  wrote:
> Without the p1.stdout.close(), if the reader (grep) terminates before
> consuming all of its input, the writer (ls) won't terminate so long as
> Python retains the descriptor corresponding to p1.stdout. In this
> situation, the p1.wait() will deadlock.
>
> The communicate() method wait()s for the process to terminate. Other
> processes need to be wait()ed on explicitly, otherwise you end up with
> "zombies" (labelled "" in the output from "ps").

You are obviously very wise on such things.  I'm curious if this
deadlock issue is a rare event since I'm grep (hopefully) would rarely
terminate before consuming all its input.

Even if zombies are created, they will eventually get dealt with my OS
w/o any user intervention needed right?

I'm just trying to verify the naive solution of not worrying about
these deadlock will still be ok and handled adequately by os. :)

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


Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-10 Thread Lie Ryan
On 06/10/10 21:52, Nobody wrote:
> Spawning child processes to perform tasks
> which can easily be performed in Python is inefficient

Not necessarily so, recently I wrote a script which takes a blink of an
eye when I pipe through cat/grep to prefilter the lines before doing
further complex filtering in python; however when I eliminated the
cat/grep subprocess and rewrite it in pure python, what was done in a
blink of an eye turns into ~8 seconds (not much to fetter around, but it
shows that using subprocess can be faster). I eventually optimized a
couple of things and reduced it to ~1.5 seconds, up to which, I stopped
since to go even faster would require reading by larger chunks,
something which I don't really want to do.

The task was to take a directory of ~10 files, each containing thousands
of short lines (~5-10 chars per line on average) and count the number of
lines which match a certain criteria, a very typical script job, however
the overhead of reading the files line-by-line in pure python can be
straining (you can read in larger chunks, but that's not the point,
eliminating grep may not come for free).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py++, boost and python type mismatch error

2010-06-10 Thread Thomas Jollans
On 06/10/2010 05:15 PM, Murrgon wrote:
> I have a simple C++ library (from a dll) I am attempting to make
> accessible through bindings to python.  I used Py++ to generate some
> boost code for the library that I compiled into a pyd.  I can import the
> pyd no problem into python, but I can't seem to call the functions.
> 
> struct MM_Api
> {
>   void* pData;
> };
> 
> int declspec(dllimport) MM_Initialize( MM_Api* pApi );
> 
> I made a PyMM.pyd that has this in it.
> 
> import PyMM
> api = PyMM.MM_Api
> ret = PyMM.MM_Initialize(api)
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> Boost.Python.ArgumentError: Python argument types in
> PyMM.MM_Initialize(Boost.Python.class)
> did not match C++ signature:
> MM_Initialize(struct MM_Api * pApi)

Just guessing here: maybe you meant to type

import PyMM
api = PyMM.MM_Api()
ret = PyMM.MM_Initialize(api)

(initializing the MM_Api and passing the object instead of the class)

> 
> The docs for Py++ leave a lot guess work up to the user, so I don't know
> if I forgot a step, or messed something up.  Is there some glue I need
> to write/generate that will translate an instance of PyMM.MM_Api to the
> C++ version of MM_Api, and if so, is this python glue, or C/C++ glue?
> 
> Thank you
> Murrgon

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


Re: using reverse in list of tuples

2010-06-10 Thread Steven W. Orr
On 06/10/10 04:41, quoth Marco Nawijn:
> On Jun 10, 2:39 am, james_027  wrote:
>> hi,
>>
>> I am trying to reverse the order of my list of tuples and its is
>> returning a None to me. Is the reverse() function not allow on list
>> containing tuples?
>>
>> Thanks,
>> James
> 
> As the others already mentioned list.reverse() is in-place, just as
> for
> example list.sort(). Alternatively, use the builtin reversed() or
> sorted()
> functions to get a return value (they will leave the original list
> unmodified.
> 
> Example:
 a = range(3)
 b = reversed(a)
 for item in b:
>   ...print item
> This will produce:
>   2
>   1
>   0
> 
> Note that reversed returns an iterator.
> 
> Marco

How about just doing it the old fashioned way via slicing.

>>> foo = (4,5,8,2,9,1,6)
>>> foo[::-1]
(6, 1, 9, 2, 8, 5, 4)
>>>

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



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


Re: GUIs - A Modest Proposal

2010-06-10 Thread rantingrick
On Jun 10, 3:28 am, Gregory Ewing  wrote:
> Brian Blais wrote:
> > In this whole discussion, I haven't seen anyone mention wax (http://
> > zephyrfalcon.org/labs/wax_primer.html)
>
> Just had a quick look at that. In the third example code box:
>
>    def Body(self):
>        
>      self.textbox = TextBox(self, multiline=1, wrap=0)
>      self.AddComponent(self.textbox)
>           
>
> Here's something unpythonic already: a couple of non-pep-8-compliant
> method names.
>
> And a bit further down:
>
>      self.textbox.SetFont(FIXED_FONT)
>                   ^^^
>
> Using a setter method instead of a property.
>
> So while it's quite likely better than raw wxPython, it fails the
> pythonicity test for me.
>
> --
> Greg

Yes, i'll agree the syntax it not what we would want for Python.
Although it could be re-written in a Pythonic fashion but then again
scaling to the real Wx library would not be as "clean". However wax
does have one very likable quality -- it "is" a small part of a well
established GUI and very large library. But again, not what any of
"us" would consider to be Pythonic "enough".

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread rantingrick
On Jun 10, 3:52 am, Gregory Ewing  wrote:

> Pywin32 does seem to have grown rather haphazardly. Some
> functionality is wrapped in two different ways in different
> modules, for no apparently good reason, and some other
> things are wrapped incompletely or not at all. A well
> thought out replacement suitable for stdlib inclusion
> wouldn't go amiss.

You summed up in a most elegant way what i was unable to do earlier.
But i want to add more...

I think PyWin32, like Tkinter, was another gift we have failed to
maintain on our end. The great Mark Hammond brought us the much need
functionality of PyWin32 and even today it has not be seized upon and
made better by the Python community? Do we expect Mark to just keep
maintaining and supporting what REALLY should be a stdlib module
forever?

Like it not (And i'm talking directly to all the Unix hackers here!)
Win32 is here to stay! You should have realized that years ago! And
likewise, like it or not, GUI is here to stay. You should have also
realized that years ago (although we may be supporting web interfaces
soon...same thing really). If you wish to hide your head in the sand
and ignore these facts hoping that the "old days" of command line and
no windows platform will return, well thats not going to happen. The
rest of us are going to move forward and hope that eventually you will
see the light and tag along.

Tkinter and TclTk are dead! I use Tkinter and i can happily say that.
And the ONLY reason i even use Tkinter is the fact that it's there in
the stdlib! Remove the module and i will move on to something better.
Tkinter is legacy software built on legacy software. It was the best
choice way back when Guido forged the path. But now Tkinter has fallen
into obscurity. Sure it's useful, i use it all the time. But it's too
large, too slow, and just too damn ugly to be part of "our" Python
stdlib. Embedded interpretor, YUCK! If people want to use Tkinter they
can download it as a 3rd party module, no harm done! But Tkinter is
harming Python by disgracing Python's stdlib and slowing Python down.

PyGUI is still the front runner and has my vote until someone can show
me a better option. I think if PyGUI where around circa 1995 Guido
would have pounced on it like a hungry tiger on a wildebeest. Ask
yourself what a Python GUI should look like, and what it should feel
like. Then go and use PyGUI. The choice will be obvious.



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


Re: historic grail python browser "semi-recovered"

2010-06-10 Thread lkcl
On Jun 9, 11:03 pm, rantingrick  wrote:
> On Jun 9, 4:29 pm, lkcl  wrote:
>
> > um, please don't ask me why but i foundgrail, the python-based web
> >browser, and have managed to hack it into submission sufficiently to
> > view e.g.http://www.google.co.uk.  out of sheer apathy i happened to
> > have python2.4 still installed which was the only way i could get it
> > to run without having to rewrite regex expressions (which i don't
> > understand).
>
> > if anyone else would be interested in resurrecting this historic web
> >browser, just for fits and giggles, please let me know.
>
> Hi lkcl,
>
> My current conquest to bring a new (or fix the current GUI) in
> Python's stdlib is receiving much resistance. I many need a project to
> convince my opponents of my worth. Tell you what i do, send me a text
> file with a pathname and all the line numbers that have broken regexs
> using a common sep --space is fine for me-- and i'll fix them for you.

 yegods - i'm going to have to create a python script to do that :)
 shouldn't take me  30 mins.  i'll also upload the source of grail
 to github.com or summink, first.

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


Re: historic grail python browser "semi-recovered"

2010-06-10 Thread lkcl
On Jun 9, 10:58 pm, Thomas Jollans  wrote:

> give us a copy then, just for the laughs. ^^ Post it on bitbucket,
> maybe? (or send me a copy and I'll do it)

 http://github.com/lkcl/grailbrowser

 remember it only works on python2.4 or less right now!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regarding the dimensions in gui

2010-06-10 Thread rantingrick
On Jun 10, 4:40 am, Jean-Michel Pichavant 
wrote:

> Internet rule, number 30:
>
> "There are no girls on the internet"


Well i hope at least your bedroom door does not still have that sign
hanging...

 #
 #* *#
 #   NO GIRLS ALLOWED!   #
 #* *#
 #

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


Re: historic grail python browser "semi-recovered"

2010-06-10 Thread lkcl
On Jun 9, 11:03 pm, rantingrick  wrote:
> On Jun 9, 4:29 pm, lkcl  wrote:
>
> > um, please don't ask me why but i foundgrail, the python-based web
> >browser, and have managed to hack it into submission sufficiently to
> > view e.g.http://www.google.co.uk.  out of sheer apathy i happened to
> > have python2.4 still installed which was the only way i could get it
> > to run without having to rewrite regex expressions (which i don't
> > understand).
>
> > if anyone else would be interested in resurrecting this historic web
> >browser, just for fits and giggles, please let me know.
>
> Hi lkcl,
>
> My current conquest to bring a new (or fix the current GUI) in
> Python's stdlib is receiving much resistance. I many need a project to
> convince my opponents of my worth. Tell you what i do, send me a text
> file with a pathname and all the line numbers that have broken regexs
> using a common sep --space is fine for me-- and i'll fix them for you.
> Here is a sample...

 ok i've committed a file REGEX.CONVERSIONS.REQUIRED into the git
repository,
http://github.com/lkcl/grailbrowser
git://github.com/lkcl/grailbrowser.git

 i used "grep -n" so it's filename:lineno:  {ignore the actual stuff}

 unfortunately, SGMLLexer.py contains some _vast_ regexs spanning 5-6
lines, which means that a simple grep ain't gonna cut it.  there's a
batch of regex's spanning from line 650 to line 699 and a few more
besides.

 of course, it has to be borne in mind that this code was written for
python 1.5 initially, at a time when python xml/sax/dom/sgml code
probably didn't exist.

 but leaving aside the fact that it all needs to be ripped up and
modernised i'm more concerned about getting these 35,000 lines of code
operational, doing as small transitions as possible.

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


Re: Deformed Form

2010-06-10 Thread Victor Subervi
On Thu, Jun 10, 2010 at 10:30 AM, Stephen Hansen (L/P)  wrote:

> On 6/10/10 7:14 AM, Victor Subervi wrote:
> > Hi;
> > I have a script that calls values from the form that calls it. This
> script
> > imports another script:
> >
> > from New_Passenger import New_Passenger
> >
> > def create_edit_passengers3():
> >   ...
> >   new_passengers_curr_customers =
> New_Passengers_Curr_Customers(customers,
> > flights)
> >   if new_passengers_curr_customers > 0:
> > print ""
> >
> > All this works. What puzzles me, however, is that the value of
> > new_passengers_curr_customers has to be called using cgi from the
> imported
> > script (New_Passenger). It cannot be called from the calling script. I
> would
> > have thought it would have been the other way around. Please help me
> > understand why.
>
> I can't quite figure out what you're asking.
> new_passengers_curr_customers is a variable local to
> create_edit_passengers3;


correct


> you have something that differs only in case
> called New_Passengers_Curr_Customers which -- I assume is defined,
> somewhere.


correct


> Then you haev New_Passenger, and I'm not sure I see what it
> has to do with anything.
>

My bad. This is another script that is called by the script I have partially
quoted here ("main script"). It is in that script that I am able to access
the variable in question (as cited by you below).

>
> But what does "cannot be called" mean? "Cannot" usually means "an error
> happened" -- in which case you shouldn't really even mention it unless
> you're gonna back it up with a traceback.
>

That is correct. It throws an error if I try and access the variable from
the main script, because I try and use the value of that variable and for
some reason I can't retrieve it.

>
> The former is a value, you don't call it. You access it. And it being
> local, you can surely only access it within that function (unless you
> pass it somewhere). The latter is -- a class? A function?


fn, a script. I hope that cleared things up. Please advise.
TIA,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-10 Thread Giampaolo Rodolà
2010/6/10 Leon :
> Hi, there,
> I'm trying to read the source code of python.
> I read around, and am kind of lost, so where to start?
>
> Any comments are welcomed, thanks in advance.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

If you're interested in understanding Python internals you might want
to take a look at this:
http://tech.blog.aknin.name/category/my-projects/pythons-innards/


--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deformed Form

2010-06-10 Thread Stephen Hansen
On 6/10/10 10:11 AM, Victor Subervi wrote:
> On Thu, Jun 10, 2010 at 10:30 AM, Stephen Hansen (L/P)  [email protected]> wrote:
>>
>> But what does "cannot be called" mean? "Cannot" usually means "an error
>> happened" -- in which case you shouldn't really even mention it unless
>> you're gonna back it up with a traceback.
>>
> 
> That is correct. It throws an error if I try and access the variable from
> the main script, because I try and use the value of that variable and for
> some reason I can't retrieve it.

I think you don't fully understand namespaces at the moment.

Every file is a module; think of it like a big box with a name on it.
Inside that box there are tags which have names written on them,
attached to some smaller boxes.

The variable in question, "new_passengers_curr_customers", is one such
tag. It is connected to a box, which is an object or value of some sort.

Let's assume you have approximately this code in a certain file, which
we shall name "creating.py" for example purposes:

  def create_edit_passengers3():
new_passengers_curr_customers = ...

You have to picture this as a series of boxes, one within another. Once
this module is imported, and everything's loaded, your namespace looks
vaguely like this (this is a demonstration only, not a real thing):

{"creating":
{"create_edit_passengers3":
{"new_passengers_curr_customers": ...}
}
}

I drew that out as nested dictionaries just to try to illustrate what's
going on.

new_passengers_curr_customers is a name that is *local* to the function.
It exists solely inside that function. If you want to use it anywhere
"else", you have to either a) call the else, passing it, b) if the else
called this function, then simply return it, or b) in some other
*explicit* way set or store the variable in a place that is accessible
to else.

I'm not sure what your "else" is here to tell you which is best, a, b,
or c. If you want this variable to be accessible to the "main script"
(its not clear to me exactly which is 'main' in your scenario), which in
my above example is the module named 'creating', then a global variable
may work for you (I'm not going to harp on the danger of globals to you,
you're not to the skill set of object oriented stuff yet), as in:

  new_passengers_curr_customers = None

  def create_edit_passengers3():
global new_passengers_curr_customers

new_passengers_curr_customers = ...

What this chunk of code does is establish, in the top-level of your
module, a new variable. Inside your function, you then explicitly state,
"When I assign to new_passengers_curr_customers, I want to assign to the
existing module-level variable, and NOT create a new local with the same
name." That's what the global statement does: but note, 'global' really
means /module level/, and not /universal/ -- it won't be accessible in
another module.

If you have certain variables you need to access in more then one
module/file, what you can do is create a separate module that both
import separately, and share.

As in, a file called "state.py", which would say like:

  new_passengers_curr_customers = None

Then in your creating.py:
  import state

  def create_edit_passengers3():
state.new_passengers_curr_customers = ...

Then anywhere you want to access that variable, you do 'state.blah'
instead of 'blah'.

Note: I'm entirely unsure if its wise to use -either- of these methods
in the context of a web application, unless this application is
single-threaded, and this state information is entirely temporary:
meaning that when you are done with it, and before a new request hits,
you are sure to clear it out so you don't get two requests corrupting
each-other.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: Deformed Form

2010-06-10 Thread Victor Subervi
No, I think you've misunderstood because while I thought I was being clear I
probably was not. So here is the complete code of
create_edit_passengers3.py:

#!/usr/bin/python

import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())
import MySQLdb
from login import login
import fpformat
from New_Passengers_Curr_Customers import New_Passengers_Curr_Customers
from New_Passengers_Addl_Customers import New_Passengers_Addl_Customers
from New_Passenger import New_Passenger

form = cgi.FieldStorage()

def sortedDictValues(adict):
  items = adict.items()
  items.sort()
  return [value for key, value in items]

def create_edit_passengers3():
  print "Content-Type: text/html"
  print
  print '''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";>
http://www.w3.org/1999/xhtml";>


'''
  user, passwd, db, host = login()
  database = MySQLdb.connect(host, user, passwd, db)
  cursor = database.cursor()
  cursor.execute('select id from Flights;')
  flights = [itm[0] for itm in cursor]
  cursor.execute('select id, first_name, middle_name, last_name, suffix from
Customers;')
  customers = cursor.fetchall()
  try:
cursor.execute('select p.id, c.first_name, c.middle_name, c.last_name,
c.suffix, c.discount, p.flights_id, p.name, f.price, c.id from Customers c
join Passengers p on c.id=p.customer_id join Flights f on p.flights_id=f.id
;')
passengers = cursor.fetchall()
print '\n'
start_html = "\n  \n
Delete?\nFlight\n
Name\nDiscount\n
Price\n  \n"
passengers_html = []
ids = []
i = 0
for passenger in passengers:
  do_delete = form.getfirst('%s:delete' % passenger[0])
  New_Passenger(passenger, do_delete)
printHTML = sortedDictValues(dict(zip(ids, passengers_html)))
if len(printHTML) > 0:
  print start_html
for html in printHTML:
  print html
print ""
  except MySQLdb.ProgrammingError:
pass
  New_Passengers_Curr_Customers(customers, flights,
new_passengers_curr_customers)
  new_passengers_addl_customers =
int(form.getfirst('new_passengers_addl_customers', 0))
  New_Passengers_Addl_Customers(customers, flights,
new_passengers_addl_customers)
  if (new_passengers_addl_customers > 0) or (new_passengers_curr_customers >
0):
print ""
  print '\n'
  cursor.close()

create_edit_passengers3()



Now, create_edit_passengers3() is called by the form/submit button in (you
guessed it) create_edit_passengers2.py, the latter containing a var in it
which *should* be accessible to create_edit_passengers3.py, one would think.
*However*, if I put the following line in create_edit_passengers3.py (even
in the beginning outside the fn of the same name):

  new_passengers_curr_customers =
int(form.getfirst('new_passengers_curr_customers', 0))

the value will *always* be 0. *However*, if I put that *same_line* of code
in New_Passengers.py (and fn of same name). it will give me the correct
value, which I can then pass back to the calling script
(create_edit_passengers3.py). Can you explain to me why it would behave like
that? I've never had a problem like this before and I've worked with
accessing variables by this manner in many a script.
TIA,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deformed Form

2010-06-10 Thread Stephen Hansen
On 6/10/10 10:48 AM, Victor Subervi wrote:
> Now, create_edit_passengers3() is called by the form/submit button in (you
> guessed it) create_edit_passengers2.py, the latter containing a var in it
> which *should* be accessible to create_edit_passengers3.py, one would think.

Wait, wait, wait.

If a user is browsing to, say,
http://example.com/create_edit_passengers2.py; that script will be run,
and once -done-, print out a form which the user sees.

At that point, create_edit_passengers2.py is dead. Gone. Over.

Once a person then clicks Submit, and the form is sent to
http://example.com/create_edit_passengers3.py; its a whole new
environment (assuming you're using CGI, which it appears you are).

The *only* way for state or data to get from one script to another is
not importing, or shared variables, or anything like that: you *have* to
pass it into that form, and extract it from the resulting form. You can
pass the actual variables as a , and then extract
it like any of the user-fields. Or, you can write out your state to a
local file with some unique ID, and just write out into the form that
unique ID. Or use a cookie session. Etc.

You *can't* pass variables around script-to-script among separate CGI
sessions. It just totally doesn't work like that. Any success you think
you have had is false; it works by mere accident or illusion. Each CGI
script stands alone. It starts, runs, executes, then closes. No state is
preserved unless you *explicitly* preserve it.


*However*, if I put that *same_line* of code
> in New_Passengers.py (and fn of same name). it will give me the correct
> value, which I can then pass back to the calling script
> (create_edit_passengers3.py). 

There is no passing going on. You're just tricking yourself into
thinking you're passing. The only way to pass variables between CGI
scripts is to explicitly write them out to the form, and read them in
from the form. You can't pass them around pythonically.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: historic grail python browser "semi-recovered"

2010-06-10 Thread MRAB

lkcl wrote:

On Jun 9, 11:03 pm, rantingrick  wrote:

On Jun 9, 4:29 pm, lkcl  wrote:


um, please don't ask me why but i foundgrail, the python-based web
browser, and have managed to hack it into submission sufficiently to
view e.g.http://www.google.co.uk.  out of sheer apathy i happened to
have python2.4 still installed which was the only way i could get it
to run without having to rewrite regex expressions (which i don't
understand).
if anyone else would be interested in resurrecting this historic web
browser, just for fits and giggles, please let me know.

Hi lkcl,

My current conquest to bring a new (or fix the current GUI) in
Python's stdlib is receiving much resistance. I many need a project to
convince my opponents of my worth. Tell you what i do, send me a text
file with a pathname and all the line numbers that have broken regexs
using a common sep --space is fine for me-- and i'll fix them for you.
Here is a sample...


 ok i've committed a file REGEX.CONVERSIONS.REQUIRED into the git
repository,
http://github.com/lkcl/grailbrowser
git://github.com/lkcl/grailbrowser.git

 i used "grep -n" so it's filename:lineno:  {ignore the actual stuff}

 unfortunately, SGMLLexer.py contains some _vast_ regexs spanning 5-6
lines, which means that a simple grep ain't gonna cut it.  there's a
batch of regex's spanning from line 650 to line 699 and a few more
besides.

 of course, it has to be borne in mind that this code was written for
python 1.5 initially, at a time when python xml/sax/dom/sgml code
probably didn't exist.

 but leaving aside the fact that it all needs to be ripped up and
modernised i'm more concerned about getting these 35,000 lines of code
operational, doing as small transitions as possible.


The regex module was called 'regex'. I see that the name 're' is used as
a name in the code.

As for the regexes themselves, the equivalents for the current 're'
module are:

regexre
\(   (
\)   )
\|   |
(\(
)\)
|\)
casefold IGNORECASE
regex.match(...) >= 0re.match(...)
--
http://mail.python.org/mailman/listinfo/python-list


SQLite3 - How to set page size?

2010-06-10 Thread durumdara
Hi!

I tried with this:

import sqlite3
pdb = sqlite3.connect("./copied4.sqlite")
pcur = pdb.cursor()
pcur.execute("PRAGMA page_size = 65536;")
pdb.commit()
pcur.execute('VACUUM;')
pdb.commit()
pcur.execute("PRAGMA page_size")
rec = pcur.fetchone()
print rec
pdb.close()

But never I got bigger page size.

What I do wrong?

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Martin v. Loewis

or PyGui would need to be implemented in terms of ctypes (which then
would prevent its inclusion, because there is a policy that ctypes
must not be used in the standard library).


Is there? I wasn't aware of that. What's the reason?


ctypes is inherently unsafe. It must be possible to remove it
from a Python installation, and still have the standard library work.

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


Re: SQLite3 - How to set page size?

2010-06-10 Thread Ian Kelly
On Thu, Jun 10, 2010 at 12:25 PM, durumdara  wrote:
> Hi!
>
> I tried with this:
>
> import sqlite3
> pdb = sqlite3.connect("./copied4.sqlite")
> pcur = pdb.cursor()
> pcur.execute("PRAGMA page_size = 65536;")
> pdb.commit()
> pcur.execute('VACUUM;')
> pdb.commit()
> pcur.execute("PRAGMA page_size")
> rec = pcur.fetchone()
> print rec
> pdb.close()
>
> But never I got bigger page size.
>
> What I do wrong?

According to the documentation, "The page size must be a power of two
greater than or equal to 512 and less than or equal to
SQLITE_MAX_PAGE_SIZE. The maximum value for SQLITE_MAX_PAGE_SIZE  is
32768."

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Emile van Sebille

On 6/10/2010 9:34 AM rantingrick said...


Like it not (And i'm talking directly to all the Unix hackers here!)
Win32 is here to stay! You should have realized that years ago!


Frankly, I'm dropping clients that insist on windows only and am 
actively migrating clients to ubuntu/openoffice/firefox/thunderbird/etc.


After 15 years, I don't see that MS has gotten it right yet and I'm 
tired of fixing stupid windows boxes.  Talk about time sinks!


Emile


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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Stephen Hansen
On 6/10/10 9:34 AM, rantingrick wrote:
> Like it not (And i'm talking directly to all the Unix hackers here!)
> Win32 is here to stay! You should have realized that years ago! And
> likewise, like it or not, GUI is here to stay. You should have also
> realized that years ago (although we may be supporting web interfaces
> soon...same thing really). If you wish to hide your head in the sand
> and ignore these facts hoping that the "old days" of command line and
> no windows platform will return, well thats not going to happen. The
> rest of us are going to move forward and hope that eventually you will
> see the light and tag along.

You're bordering very near "silly" now. Drop the rhetoric, it doesn't
actually help your case, argument, or position in the least. No one
thinks GUI's are going away. No one thinks win32 is going away.

Everytime you make a statement like this, you just sound daft.

Its not a question of those things going away. Its a question of what
exactly belongs in the standard library and what doesn't. Everything in
the world that is modern, current, or not "going away" does not need to
be in the standard library.

Why not include pywin32? Well the first question is: does Mark Hammond
even *want* it included? He has to offer it before the question can even
be considered, and assign copyright to the PSF. And after that
willingness is determined: its huge, and despite all of my *windows*
programming-- its what I get *paid* for in my day job-- I never needed
it except once.

So... uh, why again are we including it? Those people who need it, have
ready access.

Why not include wxPython and a very-easy-wrapper around it? Because
wxPython is also *huge* -- and also directly tied to the development and
release cycle of a third-party product (wxWidgets) which is *huge* in
and of itself-- you're now asking python-dev to effectively support
hundreds of thousands of lines of more code-- and a lot of it in a
language (C++) they may not be experts at (Python is C)! Not to mention
the only 'very-easy-wrapper' needs work, and there's no clear indication
anyone's willing to do the work

Why not include PyQT? Licensing makes it impossible.

Why not include PyGUI? Currently, its dependencies make it unsuitable,
but there's a question as to if its mature enough yet or not. I dunno,
I've never used it: it is *useless* to me. No offense to Greg meant.

Again: it has nothing at all to do with people not liking GUI's or
thinking GUI's are going the way of the dodo. It has to do with people's
ideas of what should or should not go in the standard library. Generally
speaking? Stuff that everyone or most people can make ready use of...
and while yes, doing GUI development is very, very common -- "GUI
development" is not a single monolithic thing. Different people have
some *very* different needs for what they get out of their GUI development.

For example: if you want to embed a CSS-capable web-browser into your
app? PyQT is actually your best option-- albeit a commercial one if
you're not open source.. wx/Python haven't yet finished WebKit
integration(*).

If you need some flexible or configuration-based user interfaces,
wxPython actually is a very solid solution, with its XML-based GUI
creation.

Neither of these things are very rare or even too terribly advanced.

The reason we do not embed any 'better' GUI then Tkinter into the
stdlib? There's several tools available for the job: and there is no
clear indication or agreement that one is better or more qualified for
inclusion over the others. At least, IMHO. I do not speak for python-dev.

> Tkinter and TclTk are dead! I use Tkinter and i can happily say that.
> And the ONLY reason i even use Tkinter is the fact that it's there in
> the stdlib! Remove the module and i will move on to something better.
> Tkinter is legacy software built on legacy software. It was the best
> choice way back when Guido forged the path. But now Tkinter has fallen
> into obscurity. Sure it's useful, i use it all the time. 

Rhetoric.

> But it's too
> large, too slow, and just too damn ugly to be part of "our" Python
> stdlib. 

It is fortunate that my Python is not ruled by the judgements of what
you think belongs in your Python.

There is clearly no "our" Python.

> Embedded interpretor, YUCK! If people want to use Tkinter they
> can download it as a 3rd party module, no harm done! But Tkinter is
> harming Python by disgracing Python's stdlib and slowing Python down.

Not just rhetoric, but silly rhetoric.

> PyGUI is still the front runner and has my vote until someone can show
> me a better option. I think if PyGUI where around circa 1995 Guido
> would have pounced on it like a hungry tiger on a wildebeest. Ask
> yourself what a Python GUI should look like, and what it should feel
> like. Then go and use PyGUI. The choice will be obvious.

PyGUI is indeed a solid project, and perhaps-- eventually-- a contender
for replacing Tkinter, once it works the kinks out and matures. Maybe 

Re: Java Developer with Chordiant, Hyderabad

2010-06-10 Thread Evan Plaice
You do realize that this is a python and not Java usenet group right?

You'd be better off checking out comp.lang.python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-10 Thread Mark Lawrence

On 10/06/2010 23:24, Stephen Hansen wrote:
[snip]


P.S. Considering I almost never use tkinter, I'm confused how I somehow
suddenly became a Champion of Tkinter Inclusiveness.


FWIW I've never used any GUI in Python.  I'd see your involvement on 
this thread as being more like a Champion of Common Sense.  This appears 
to be sadly lacking from some other participants.


Kindest regards.

Mark Lawrence.

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread geremy condra
On Thu, Jun 10, 2010 at 3:24 PM, Stephen Hansen
 wrote:
> On 6/10/10 3:17 PM, geremy condra wrote:
>> I mostly agree with you, but as Stephen points out you can't exactly
>> count on it being present now either, which more or less renders any
>> guarantee of backwards compatibility moot IMO. Whats the practical
>> difference between telling somebody that either tkinter works out of
>> the box or they'll have to satisfy an extra dependency and just telling
>> them that they'll have to satisfy an additional dependency in the first
>> place?
>
> Although that is true in theory, in reality-- In my experience-- You
> *can* count on it being there, except on Linux distributions which may
> choose to cut it out into an optional install, and where its also
> extremely trivial to add back in.

Sure, and that's why I said I mostly agree. Having said that,
it seems important to me to place the arguments against
projects like pygui in the context of the the arguments for
tkinter. The fact is that tkinter is not ubiquitous, and will on
some platforms require an additional dependency, forcing
those who aim for portability to take that into account. This
is exactly the same situation in which pygui finds itself, with
the exception that applications developed with pygui look
professional, while those made in tkinter generally look like
refugees from the Isle of Misfit UIs, although I'm told this
has improved markedly in recent years.

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread rantingrick
On Jun 10, 5:17 pm, geremy condra  wrote:

> Whats the practical
> difference between telling somebody that either tkinter works out of
> the box or they'll have to satisfy an extra dependency and just telling
> them that they'll have to satisfy an additional dependency in the first
> place?

BIG +1

It seems that removing Tkinter from the stdlib will not only benefit
Python, but also Tkinter; due to the fact that Tkinter will not be
confined to Python's release schedules. As we've witnessed so far
almost nothing has changed since Tkinter's addition many years ago.
Heck they only just recently (py30) added a ComboBox widget! This
development cycle is not working for Tkinter, something must change.
Tkinter is just a dead weight we're lugging around for no good
reason.

- lib-tk 755KB
- idlelib 1.18MB
- Tcl 6.57MB (+togl 51.2KB)

All that footprint with such a small capability! There must be a
better option out there!

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


Re: numpy arrays to python compatible arrays

2010-06-10 Thread Philip Semanchuk


On Jun 10, 2010, at 9:58 AM, Javier Montoya wrote:


Dear all,

I'm new to python and have been working with the numpy package. I have
some numpy float arrays (obtained from np.fromfile and np.cov
functions) and would like to convert them to simple python arrays.
I was wondering which is the best way to do that? Is there any
function to do that?


Hi Javier,
Since you are new to Python I'll ask whether you want to convert Numpy  
arrays to Python arrays (as you stated) or Python lists. Python lists  
are used very frequently; Python arrays see very little use outside of  
numpy.


If you can use a Python list, the .tolist() member of the numpy array  
object should do the trick.


bye
P

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Stephen Hansen
On 6/10/10 1:14 PM, Ethan Furman wrote:
> Stephen Hansen wrote:
>> Another thing you can look at is QT/PyQT. If you're doing GPL'd
>> software, that might be a very good solution for you-- you can design
>> your whole app in the beautiful QTDesigner, and the .ui files can be
>> used in any language with a QT binding, PyQT included. But you gotta be
>> GPL'd to use Python. (Although QT is now LGPL, the PyQT bindings
>> continue the GPL/commercial split... and PySide isn't cross platform yet)
> 
> Correction:  But you gotta be GPL'd to use PyQT.  Python doesn't care.

Er, yes. I meant Python's PyQT bindings, without a commercial license. Oops!

Python's all <3 about any sort of use anyone wants to use it for.   

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Benjamin Kaplan
On Thu, Jun 10, 2010 at 9:34 AM, rantingrick  wrote:
> On Jun 10, 3:52 am, Gregory Ewing  wrote:
>
>> Pywin32 does seem to have grown rather haphazardly. Some
>> functionality is wrapped in two different ways in different
>> modules, for no apparently good reason, and some other
>> things are wrapped incompletely or not at all. A well
>> thought out replacement suitable for stdlib inclusion
>> wouldn't go amiss.
>
> You summed up in a most elegant way what i was unable to do earlier.
> But i want to add more...
>
> I think PyWin32, like Tkinter, was another gift we have failed to
> maintain on our end. The great Mark Hammond brought us the much need
> functionality of PyWin32 and even today it has not be seized upon and
> made better by the Python community? Do we expect Mark to just keep
> maintaining and supporting what REALLY should be a stdlib module
> forever?
>
> Like it not (And i'm talking directly to all the Unix hackers here!)
> Win32 is here to stay! You should have realized that years ago! And
> likewise, like it or not, GUI is here to stay. You should have also
> realized that years ago (although we may be supporting web interfaces
> soon...same thing really). If you wish to hide your head in the sand
> and ignore these facts hoping that the "old days" of command line and
> no windows platform will return, well thats not going to happen. The
> rest of us are going to move forward and hope that eventually you will
> see the light and tag along.
>

It probably doesn't have as much staying power as you think. The only
reason that having PyWin32 is a big deal and having PyObj-C, PyGTK, or
PyQT is not is because the operating systems that use the other 3 come
with Python pre-installed. If Microsoft ever decides to pre-install
Python on Windows, it's going to be IronPython, where PyWin32 becomes
a non-issue (unless you really really hate yourself).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regarding the dimensions in gui

2010-06-10 Thread Phlip
On Jun 10, 10:00 am, rantingrick  wrote:
> On Jun 10, 4:40 am, Jean-Michel Pichavant 
> wrote:
>
> > Internet rule, number 30:
>
> > "There are no girls on the internet"
>
> Well i hope at least your bedroom door does not still have that sign
> hanging...
>
>  #
>  #*                     *#
>  #   NO GIRLS ALLOWED!   #
>  #*                     *#
>  #
>
> ;-)

I clicked on this thread, thinking to announce the latest answer seems
to be "CSS Pixels" (HTML5), but...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-10 Thread geremy condra
On Thu, Jun 10, 2010 at 3:57 PM, rantingrick  wrote:
> On Jun 10, 5:17 pm, geremy condra  wrote:
>
>> Whats the practical
>> difference between telling somebody that either tkinter works out of
>> the box or they'll have to satisfy an extra dependency and just telling
>> them that they'll have to satisfy an additional dependency in the first
>> place?
>
> BIG +1

Please don't agree with me, its almost enough to convince me I'm
wrong.

> It seems that removing Tkinter from the stdlib will not only benefit
> Python, but also Tkinter; due to the fact that Tkinter will not be
> confined to Python's release schedules. As we've witnessed so far
> almost nothing has changed since Tkinter's addition many years ago.
> Heck they only just recently (py30) added a ComboBox widget! This
> development cycle is not working for Tkinter, something must change.
> Tkinter is just a dead weight we're lugging around for no good
> reason.

Did you actually read what I wrote? I said nothing at all about
removing tkinter and in fact oppose doing so.

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


Re: Deformed Form

2010-06-10 Thread Stephen Hansen
On 6/10/10 8:35 AM, Bruno Desthuilliers wrote:
> Stephen Hansen (L/P) a écrit :
>> On 6/10/10 7:14 AM, Victor Subervi wrote:
> (snip)
>>
>> +1 for "absolutely worst framed question of the day" :)
> 
> IMHO you're wasting your time. Some guys never learn, and I guess we do
> have a world-class all-times champion here.
> 
> 

Well, he eventually learned about bare excepts and using string
formatting in SQL. It took a long time, but he finally believed us.

He just sort of needs to give us the benefit of the doubt when we say,
"umm, its bad to do that" :)

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-10 Thread Mark Lawrence

On 10/06/2010 22:51, Pascal J. Bourguignon wrote:

bolega  writes:


Which is the best implementation of LISP family of languages for real
world programming ?


What's the real world?
What's real world programming?



What's this doing on c.l.py?

Regards.

Mark Lawrence.

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


simple chat server

2010-06-10 Thread Burakk
Hi,

I am using ubuntu lucid and i have started to learn python(vrs 3.1). I
am trying to make a tutorial code(see below) work but when i run the
code, open a terminal window and connect as client with telnet and
type somethings and hit enter, give me error below...(the terminal
says connection closed by foreign host)

if someone can help i will be glad...

thanx

-- error: uncaptured python exception, closing channel
<__main__.ChatSession connected 127.0.0.1:46654 at 0xb71cce8c> (:expected an object with the buffer interface [/usr/lib/
python3.1/asyncore.py|read|75] [/usr/lib/python3.1/asyncore.py|
handle_read_event|420] [/usr/lib/python3.1/asynchat.py|handle_read|
170]) --

code

from asyncore import dispatcher
from asynchat import async_chat
import asyncore
import socket

PORT = 5005
NAME = 'TestChat'

class ChatSession(async_chat):

 def __init__(self, sock):
 async_chat.__init__(self, sock)
 self.set_terminator("xx")
 self.data = []


 def collect_incoming_data(self, data):
 self.data.append(data)


 def found_terminator(self):
 line = ''.join(self.data)
 self.data = []
 self.push(line)

class ChatServer(dispatcher):
  def __init__(self, port):
  dispatcher.__init__(self)
  self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
  self.set_reuse_addr()
  self.bind(('', PORT))
  self.listen(5)
  self.sessions = []


  def handle_accept(self):
  conn, addr = self.accept()
  self.sessions.append(ChatSession(conn))

if __name__== '__main__':
s = ChatServer(PORT)
try: asyncore.loop()
except KeyboardInterrupt : print

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


Re: historic grail python browser "semi-recovered"

2010-06-10 Thread lkcl
On Jun 10, 6:17 pm, MRAB  wrote:
> lkcl wrote:
> > On Jun 9, 11:03 pm, rantingrick  wrote:
> >> On Jun 9, 4:29 pm, lkcl  wrote:
>
> >>> um, please don't ask me why but i foundgrail, the python-based web
> >>>browser, and have managed to hack it into submission sufficiently to
> >>> view e.g.http://www.google.co.uk.  out of sheer apathy i happened to
> >>> have python2.4 still installed which was the only way i could get it
> >>> to run without having to rewrite regex expressions (which i don't
> >>> understand).
> >>> if anyone else would be interested in resurrecting this historic web
> >>>browser, just for fits and giggles, please let me know.
> >> Hi lkcl,
>
> >> My current conquest to bring a new (or fix the current GUI) in
> >> Python's stdlib is receiving much resistance. I many need a project to
> >> convince my opponents of my worth. Tell you what i do, send me a text
> >> file with a pathname and all the line numbers that have broken regexs
> >> using a common sep --space is fine for me-- and i'll fix them for you.
> >> Here is a sample...
>
> >  ok i've committed a file REGEX.CONVERSIONS.REQUIRED into the git
> > repository,
> >http://github.com/lkcl/grailbrowser
> > git://github.com/lkcl/grailbrowser.git
>
> >  i used "grep -n" so it's filename:lineno:  {ignore the actual stuff}
>
> >  unfortunately, SGMLLexer.py contains some _vast_ regexs spanning 5-6
> > lines, which means that a simple grep ain't gonna cut it.  there's a
> > batch of regex's spanning from line 650 to line 699 and a few more
> > besides.
>
> >  of course, it has to be borne in mind that this code was written for
> > python 1.5 initially, at a time when python xml/sax/dom/sgml code
> > probably didn't exist.
>
> >  but leaving aside the fact that it all needs to be ripped up and
> > modernised i'm more concerned about getting these 35,000 lines of code
> > operational, doing as small transitions as possible.
>
> The regex module was called 'regex'.

 yes.  there's a python module in 2.4 called reconvert.py which can
"understand" and convert _most_ regex expressions to re.

> I see that the name 're' is used as
> a name in the code.

 bizarre, isn't it?

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread rantingrick
On Jun 10, 1:52 pm, Emile van Sebille  wrote:
> After 15 years, I don't see that MS has gotten it right yet and I'm
> tired of fixing stupid windows boxes.  Talk about time sinks!

And i 100% agree Emille. Just for the record i hate windows, I hate
win32 programming, i hate MS office, and I hate VB. I could rant for
hours about how Windows sucks but for the sake of this thread I will
stop it at that. Unfortunately the mindless masses use Windows
extensively so we are forced to support it...

"""It's not going away just because we put our heads in the sand

... that was my point about win32.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-10 Thread rantingrick
On Jun 10, 1:56 pm, Stephen Hansen  wrote:

> So... uh, why again are we including it? Those people who need it, have
> ready access.

But what if Mark decided one day he no longer wants to support Python
or Win32? How many years will it be before someone writes another?

> Why not include wxPython 
> Why not include PyQT? 

Both are not-starters for many reasons already discussed in this
thread. Maybe wax would have a chance if we made it more Pythonic as
Greg pointed out. All others are a non-starter due to the zen (import
this).

> Again: it has nothing at all to do with people not liking GUI's or
> thinking GUI's are going the way of the dodo. It has to do with people's
> ideas of what should or should not go in the standard library. Generally
> speaking? Stuff that everyone or most people can make ready use of...
> and while yes, doing GUI development is very, very common -- "GUI
> development" is not a single monolithic thing. Different people have
> some *very* different needs for what they get out of their GUI development.

And again the opponents miss the whole point. It's not about including
a GUI that would make everyone happy. Its about including a GUI that
is complimentary to Python's stated goals. Not for you, Not for me,
Not for the x&lee... remember? ;-)

> The reason we do not embed any 'better' GUI then Tkinter into the
> stdlib? There's several tools available for the job: and there is no
> clear indication or agreement that one is better or more qualified for
> inclusion over the others. At least, IMHO. I do not speak for python-dev.

So i guess then the question becomes... Why keep supporting it? It's
time to say Bye-Bye to Tkinter.

> There is clearly no "our" Python.

i beg to differ my friend.

> PyGUI is indeed a solid project, and perhaps-- eventually-- a contender
> for replacing Tkinter, once it works the kinks out and matures. Maybe it
> is almost mature enough now? Maybe it needs more help? If so-- your time
> would be better spent downloading it, using it, and offering some
> patches

I am in the process of that right now!

> Things don't go into the stdlib to mature.

Agreed! And likewise "things" should not be left to clutter the stdlib
needlessly only to wither and die a slow death just because no one has
the vision (or the motivation) to fix them or remove them for the sake
of Python's evolution.

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


Re: What's the difference?

2010-06-10 Thread Ethan Furman

Anthony Papillion wrote:

Someone helped me with some code yesterday and I'm trying to
understand it. The way they wrote it was

subjects = (info[2] for info in items)

Perhaps I'm not truly understanding what this does. Does this do
anything different than if I wrote

for info[2] in items
   subject = info[2]


Close -- the correct form is

for info in items:
subject = info[2]

Basically, python goes through the elements of items, assigning each one 
to the name 'info' during that loop; then in the body of the loop, you 
can access the attributes/elements/methods/whatever of the info object.


Hope this helps!

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Stephen Hansen
On 6/10/10 12:34 PM, Evan Plaice wrote:
> This is my first foray into usenet and f*** the signal to crap
> ratio in here is ridiculous. I can't believe that there are 150+
> answers and little or no useful information yet

That's because the question wasn't really a question. Its a political
rallying cry to try to get us all to Do Something we don't really want
to do.

That said:

> I was wondering the same thing since the subject of cross platform GUI
> dev makes me cringe. I was wondering if there was a cross-platform
> language-agnostic XML-based declarative language. Basically, what HTML/
> CSS is to web browsers for the desktop.
> 
> Microsoft's WPF and more specifically XAML format accomplish the cross-
> platform cross-language part but the technology is owned by Microsoft.
> 
> Here are my findings:
> http://stackoverflow.com/questions/2962874/what-are-the-open-
> source-alternatives-to-wpf">
> 
> GTK+ & Glade
> Glade is the actual XML format. It can be used on any platform or
> language as long as GTK+ running on that system is adapted to it.
> 
> wxWidgets & XRC
> XRC is the format. Libraries that use it vary on the language (ex.
> wx.NET for C#, VB, and Managed C++).
> 
> If you want a desktop GUI that is cross-platform, language-agnostic,
> and open source. Use and contribute to these projects.

I'm only familiar with wxWidgets, and I have used XRC though not
terribly extensively. Its useful in certain contexts, but at least the
toolchains are a bit more 'dialog-focused' then 'design entire apps'.
Its still usable though. I usually design all my UI's by hand, just
because at this point, I use too many custom components and can do it
without thinking. But for certain 'custom' forms that I do make heavy
use of XRC.

Another thing you can look at is QT/PyQT. If you're doing GPL'd
software, that might be a very good solution for you-- you can design
your whole app in the beautiful QTDesigner, and the .ui files can be
used in any language with a QT binding, PyQT included. But you gotta be
GPL'd to use Python. (Although QT is now LGPL, the PyQT bindings
continue the GPL/commercial split... and PySide isn't cross platform yet)

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Decimal problem

2010-06-10 Thread durumdara
Hi!

In the prev. week I tested my home Python projects with KinterBasDB
embedded, PsyCOPG, and SQLite.

All of them worked well, and everything was good.

But the database blob table deletion was slow in SQLite, so I thought
I will try this with FireBird and PGSQL.

Today I tried to copy the SQLite DataBase into FireBird, and PGSQL.

Psycopg drop this error:

import psycopg2
pdb = psycopg2.connect("dbname=testx user=postgres password=x")

C:\Python26\lib\site-packages\psycopg2\__init__.py:62: RuntimeWarning:
can't import decimal module probably needed by _psycopg
RuntimeWarning)

I wondered, because this was working before...

Then I tried to start KinterBasDB:

  File "C:\Python26\lib\site-packages\kinterbasdb\__init__.py", line
478, in con
nect
return Connection(*args, **keywords_args)
  File "C:\Python26\lib\site-packages\kinterbasdb\__init__.py", line
644, in __i
nit__
self._normalize_type_trans()
  File "C:\Python26\lib\site-packages\kinterbasdb\__init__.py", line
1047, in _n
ormalize_type_trans
self.set_type_trans_out(_NORMAL_TYPE_TRANS_OUT)
  File "C:\Python26\lib\site-packages\kinterbasdb\__init__.py", line
1073, in se
t_type_trans_out
return _k.set_Connection_type_trans_out(self._C_con, trans_dict)
  File "C:\Python26\lib\site-packages\kinterbasdb\__init__.py", line
1907, in _m
ake_output_translator_return_type_dict_from_trans_dict
return_val = translator(sample_arg)
  File "C:\Python26\lib\site-packages\kinterbasdb
\typeconv_fixed_decimal.py", li
ne 91, in fixed_conv_out_precise
from decimal import Decimal
ImportError: cannot import name Decimal

I deleted my complete Python with all packages, and I reinstalled it.
But the problem also appeared...

What is this? And what the hell happened in this machine that
destroyed my working python apps...?

Thanks:
   dd


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


Re: SQLite3 - How to set page size?

2010-06-10 Thread durumdara
On jún. 10, 20:39, Ian Kelly  wrote:
> On Thu, Jun 10, 2010 at 12:25 PM, durumdara  wrote:
> > Hi!
>
> > I tried with this:
>
> > import sqlite3
> > pdb = sqlite3.connect("./copied4.sqlite")
> > pcur = pdb.cursor()
> > pcur.execute("PRAGMA page_size = 65536;")
> > pdb.commit()
> > pcur.execute('VACUUM;')
> > pdb.commit()
> > pcur.execute("PRAGMA page_size")
> > rec = pcur.fetchone()
> > print rec
> > pdb.close()
>
> > But never I got bigger page size.
>
> > What I do wrong?
>
> According to the documentation, "The page size must be a power of two
> greater than or equal to 512 and less than or equal to
> SQLITE_MAX_PAGE_SIZE. The maximum value for SQLITE_MAX_PAGE_SIZE  is
> 32768."
>
> Cheers,
> Ian

Thanks! This was!!!

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Stephen Hansen
On 6/10/10 12:36 PM, rantingrick wrote:
> On Jun 10, 1:56 pm, Stephen Hansen  wrote:
> 
>> So... uh, why again are we including it? Those people who need it, have
>> ready access.
> 
> But what if Mark decided one day he no longer wants to support Python
> or Win32? How many years will it be before someone writes another?

Very few, I suspect.

There's very little you can do with pywin32 that you can't do with
ctypes. PyWin32 served a pretty important role once upon a time when you
might need to do certain low level win32 api's. These days, I just use
ctypes.

The primary purpose I use pywin32 for is documentation or to see how
someone solved a problem *using* pywin32: I then rewrite it in ctypes.

But, should some mythical occasion come and Mark decides not to support
either anymore-- we'll be in the exact same position now as to then.
Someone'll need to step up and maintain it.

Something being in the stdlib doesn't mean its maintained: in fact,
that's a very dangerous part about inclusion. There's a number of
modules already in the stdlib which don't have anyone responsible for
them, and its really, really hard to get bugfixes into them unless
someone is very interested or its a serious bug.

>> Why not include wxPython 
>> Why not include PyQT? 
> 
> Both are not-starters for many reasons already discussed in this
> thread. Maybe wax would have a chance if we made it more Pythonic as
> Greg pointed out. All others are a non-starter due to the zen (import
> this).

I like how you left out all my talk of dependencies. That's very
important when you're talking about stdlib inclusion: wax depends on
wxPython. Thus, non-includable, as wxPython is non-includable and so
something dependent upon it is as well.

> 
>> Again: it has nothing at all to do with people not liking GUI's or
>> thinking GUI's are going the way of the dodo. It has to do with people's
>> ideas of what should or should not go in the standard library. Generally
>> speaking? Stuff that everyone or most people can make ready use of...
>> and while yes, doing GUI development is very, very common -- "GUI
>> development" is not a single monolithic thing. Different people have
>> some *very* different needs for what they get out of their GUI development.
> 
> And again the opponents miss the whole point. It's not about including
> a GUI that would make everyone happy. Its about including a GUI that
> is complimentary to Python's stated goals. Not for you, Not for me,
> Not for the x&lee... remember? ;-)

You make a statement about GUI's not going away, and how all of us GUI
haters need to get on board-- then leave that statement out-- and say I
miss the whole point when I say its got nothing to do with that. Okay, well.

You want to include a GUI that's not for, well, anyone. But
ideologically sound. Okay, well.

Tkinter is complimentary to Python's stated goals. The method by which
that compliment happens (with TCL in the middle) is a bit strange, and
the syntax leaves something to be desired-- but its really not that bad,
and there's other modules in the stdlib more unpythonic.

Its easy to use, reasonably powerful, and if you use the new themed
widgets (which isn't terribly hard to do), not even too ugly.

>> The reason we do not embed any 'better' GUI then Tkinter into the
>> stdlib? There's several tools available for the job: and there is no
>> clear indication or agreement that one is better or more qualified for
>> inclusion over the others. At least, IMHO. I do not speak for python-dev.
> 
> So i guess then the question becomes... Why keep supporting it? It's
> time to say Bye-Bye to Tkinter.

Because there is no clearly superior alternative available. Didn't I
just say that? I swear I did.

Until there is, Tkinter is "good enough".

>> Things don't go into the stdlib to mature.
> 
> Agreed! And likewise "things" should not be left to clutter the stdlib
> needlessly only to wither and die a slow death just because no one has
> the vision (or the motivation) to fix them or remove them for the sake
> of Python's evolution.

Tkinter is maintained, works, and is updated continually to make
available the latest things that become available in Tk.

And actually: things do go to the stdlib to die. Its actually a very apt
description of exactly how things work. Once a module gets added to the
stdlib, its sort of dead. Static. It might change, in this
excruciatingly slow pace, with strict rules for compatibility over
consistency. It takes years and years before you can fix a design error
-- you have to wait until the next major release to put a new option in,
do some deprecation (be it pending or regular, it depends), and then a
whole new major release before you can finally be fixed.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Which is the best implementation of LISP family of languages for real world programming ?

2010-06-10 Thread bolega
Which is the best implementation of LISP family of languages for real
world programming ?

http://wiki.alu.org/Implementation

Kindly pick one from commercial and one from open-source .

The criteria is :

libraries, gui interface and builder, libraries for TCP, and evolving
needs.

Please compare LISP and its virtues with other languages such as
javascript, python etc.

I put javascript in the context that it is very similar in its
architecture (homoiconic ie same representation for data-structures
and operations, ie hierarchical, which means nested-lists <=> n-ary
tree <=> binary tree <=> linked-list <=> dictionary <=> task-subtask,
and implicitly based on what C calls pointers, and at machine level
the indirect addressing of memory) to lisp family.

I put python in the context that it has the most extensive libraries
and shares the build-fix virtue of lisp highlighted by Paul Graham in
his books. Python is touted for its rapid prototyping of guis. It
syntax enforces stable format which guards against programmer malice
or sloppiness - so that there is a certain level of legacy code
readability.

Both have eval but not clear what is the implementation efficiency to
justify the habit of excessively using it.

Certainly, lisp/scheme are excellent for learning the concepts of
programming languages due to its multi-paradigm nature and readily
available code of the elementary interpreter.

Is there an IDE for these lispish-scheming languages ? Is there
quality implementation for Eclipse ? Emacs pre-supposes some knowledge
of these so that newbie can get stuck. Also, emacs help is not very
good.

Is there a project whereby the internal help of emacs (analogous to
its man pages) are being continuously being updated AND shared ? I
have never seen updates to the help. Perhaps, the commercial people
are doing it, even from the posts of the newsgroups, but the public
distros or these newsgroups have NEVER made such an announcement.

Explanations integrated into the help are more important than the
books - its like the wikipedia incorporated into emacs.

Is there support for the color highlighting of the code by hovering as
on this page ?

http://community.schemewiki.org/?lexical-scope

Which book/paper has the briefest minimal example of gui design along
XML nested/hiearchical elements with event-listeners for lisp/scheme ?

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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-10 Thread Pascal Costanza

On 10/06/2010 23:51, Pascal J. Bourguignon wrote:

bolega  writes:


Which is the best implementation of LISP family of languages for real
world programming ?


What's the real world?
What's real world programming?


I guess somebody's just enjoying flame wars too much.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-10 Thread geremy condra
On Thu, Jun 10, 2010 at 3:02 PM, Mark Lawrence  wrote:
> On 10/06/2010 22:20, rantingrick wrote:
> [snip most of it]
>
>> Free up pydev and send Tkinter to the bitbucket!
>
> Great idea, but lets take this further.  I don't personally like module xyz,
> so let's free up pydev and send xyz to the bitbucket because I say so.  To
> hell with anyone elses' views, and trivial little issues like keeping
> backwards compatibility.
>
> Mark Lawrence.

I mostly agree with you, but as Stephen points out you can't exactly
count on it being present now either, which more or less renders any
guarantee of backwards compatibility moot IMO. Whats the practical
difference between telling somebody that either tkinter works out of
the box or they'll have to satisfy an extra dependency and just telling
them that they'll have to satisfy an additional dependency in the first
place?

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


Re: What's the difference?

2010-06-10 Thread Martin
On Jun 10, 11:13 pm, Anthony Papillion  wrote:
> Thank you Emile and Thomas! I appreciate the help. MUCH clearer now.

Also at a guess I think perhaps you wrote the syntax slightly wrong
(square brackets)...you might want to look up "list comprehension"

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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-10 Thread Kenneth Tilton

bolega wrote:

Which is the best implementation of LISP family of languages for real
world programming ?

http://wiki.alu.org/Implementation

Kindly pick one from commercial and one from open-source .


ACL and SBCL



The criteria is :

libraries, gui interface and builder, libraries for TCP, and evolving
needs.

Please compare LISP and its virtues with other languages such as
javascript, python etc.


It's better.

kt



I put javascript in the context that it is very similar in its
architecture (homoiconic ie same representation for data-structures
and operations, ie hierarchical, which means nested-lists <=> n-ary
tree <=> binary tree <=> linked-list <=> dictionary <=> task-subtask,
and implicitly based on what C calls pointers, and at machine level
the indirect addressing of memory) to lisp family.

I put python in the context that it has the most extensive libraries
and shares the build-fix virtue of lisp highlighted by Paul Graham in
his books. Python is touted for its rapid prototyping of guis. It
syntax enforces stable format which guards against programmer malice
or sloppiness - so that there is a certain level of legacy code
readability.

Both have eval but not clear what is the implementation efficiency to
justify the habit of excessively using it.

Certainly, lisp/scheme are excellent for learning the concepts of
programming languages due to its multi-paradigm nature and readily
available code of the elementary interpreter.

Is there an IDE for these lispish-scheming languages ? Is there
quality implementation for Eclipse ? Emacs pre-supposes some knowledge
of these so that newbie can get stuck. Also, emacs help is not very
good.

Is there a project whereby the internal help of emacs (analogous to
its man pages) are being continuously being updated AND shared ? I
have never seen updates to the help. Perhaps, the commercial people
are doing it, even from the posts of the newsgroups, but the public
distros or these newsgroups have NEVER made such an announcement.

Explanations integrated into the help are more important than the
books - its like the wikipedia incorporated into emacs.

Is there support for the color highlighting of the code by hovering as
on this page ?

http://community.schemewiki.org/?lexical-scope

Which book/paper has the briefest minimal example of gui design along
XML nested/hiearchical elements with event-listeners for lisp/scheme ?

Thanks



--
http://www.stuckonalgebra.com
"The best Algebra tutorial program I have seen... in a class by itself." 
Macworld

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Mark Lawrence

On 10/06/2010 22:20, rantingrick wrote:
[snip most of it]


Free up pydev and send Tkinter to the bitbucket!


Great idea, but lets take this further.  I don't personally like module 
xyz, so let's free up pydev and send xyz to the bitbucket because I say 
so.  To hell with anyone elses' views, and trivial little issues like 
keeping backwards compatibility.


Mark Lawrence.


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


Re: What's the difference?

2010-06-10 Thread Emile van Sebille

On 6/10/2010 1:47 PM Anthony Papillion said...

Someone helped me with some code yesterday and I'm trying to
understand it. The way they wrote it was

subjects = (info[2] for info in items)

Perhaps I'm not truly understanding what this does. Does this do
anything different than if I wrote

for info[2] in items
subject = info[2]



more like:

result = []
for info in items:
  result.append(info[2])

subjects =iter(result)

Emile

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


Re: numpy arrays to python compatible arrays

2010-06-10 Thread Martin
On Jun 10, 9:02 pm, Philip Semanchuk  wrote:
> On Jun 10, 2010, at 9:58 AM, Javier Montoya wrote:
>
> > Dear all,
>
> > I'm new to python and have been working with the numpy package. I have
> > some numpy float arrays (obtained from np.fromfile and np.cov
> > functions) and would like to convert them to simple python arrays.
> > I was wondering which is the best way to do that? Is there any
> > function to do that?
>
> Hi Javier,
> Since you are new to Python I'll ask whether you want to convert Numpy  
> arrays to Python arrays (as you stated) or Python lists. Python lists  
> are used very frequently; Python arrays see very little use outside of  
> numpy.
>
> If you can use a Python list, the .tolist() member of the numpy array  
> object should do the trick.
>
> bye
> P

as Philip said...though I very much doubt you really want to do this?
Why wouldn't you just keep it in a numpy array?
-- 
http://mail.python.org/mailman/listinfo/python-list


MySQLdb problems with named pipe connection on Windows 7?

2010-06-10 Thread John Nagle

   MySQLdb won't connect to my MySQL 5.1 on on Windows 7.
This worked on Windows 2000, but of course I've had to
reinstall everything.

   The MySQL command line client, "mysql", connects
to the database without problems.

Installed:

 ActiveState Python 2.6 (Win32)
 "mysql-essential-5.1.47.win32.msi"
 "MySQL-python-1.2.2.win32.py2.6.exe"

MySQL is configured for connections over named pipes only; it's
not running as a TCP server.  Is MySQLdb trying to use TCP for a local 
connection?  The MySQLdb documentation says that connections to

"localhost" on Windows will be made over named pipes.  Does that
not work?

my.cnf reads

skip-networking
enable-named-pipe

# The Pipe the MySQL Server will use
socket=mysql

Error messages:

\python26\python
ActivePython 2.6.5.12 (ActiveState Software Inc.) based on
Python 2.6.5 (r265:79063, Mar 20 2010, 14:22:52) [MSC v.1500 32 bit 
(Intel)] on

win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
C:\python26\lib\site-packages\MySQLdb\__init__.py:34: 
DeprecationWarning: the sets module is deprecated

  from sets import ImmutableSet
>>> db = MySQLdb.connect("localhost","root","","???")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\python26\lib\site-packages\MySQLdb\__init__.py", line 74, in 
Connect

return Connection(*args, **kwargs)
  File "C:\python26\lib\site-packages\MySQLdb\connections.py", line 170,
in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError:
(2003, "Can't connect to MySQL server on 'localhost' (10061)")
>>>

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


Re: Decimal problem

2010-06-10 Thread Mark Dickinson
On Jun 10, 8:45 pm, durumdara  wrote:
> ne 91, in fixed_conv_out_precise
>     from decimal import Decimal
> ImportError: cannot import name Decimal

Is it possible that you've got another file called decimal.py
somewhere in Python's path?  What happens if you start Python manually
and type 'from decimal import Decimal' at the prompt?

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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-10 Thread Pascal J. Bourguignon
bolega  writes:

> Which is the best implementation of LISP family of languages for real
> world programming ?

What's the real world?
What's real world programming?

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


Re: GUIs - A Modest Proposal

2010-06-10 Thread Stephen Hansen
On 6/10/10 3:17 PM, geremy condra wrote:
> I mostly agree with you, but as Stephen points out you can't exactly
> count on it being present now either, which more or less renders any
> guarantee of backwards compatibility moot IMO. Whats the practical
> difference between telling somebody that either tkinter works out of
> the box or they'll have to satisfy an extra dependency and just telling
> them that they'll have to satisfy an additional dependency in the first
> place?

Although that is true in theory, in reality-- In my experience-- You
*can* count on it being there, except on Linux distributions which may
choose to cut it out into an optional install, and where its also
extremely trivial to add back in.

For both Mac and Windows, its basically always there. (Unless you go out
of your way to uncheck it in the windows installer...)

Linux distros may choose to cut up the standard Python library; that's
their business if they wanna do it. But they also make it really easy to
add back in.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io

P.S. Considering I almost never use tkinter, I'm confused how I somehow
suddenly became a Champion of Tkinter Inclusiveness.



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


  1   2   >