Re: xrange issue 7721

2010-05-30 Thread Steven D'Aprano
On Sat, 29 May 2010 19:46:28 +0100, Mark Lawrence wrote:

> I've had an OverflowError using xrange with Python 2.6.5 on Windows.
> Googling got me to the subject line.

It is considered best practice (or at least sensible practice) to include 
a relevant URL in your post. This will maximise the number of people who 
click through to the bug tracker while minimising the number who say "if 
the poster can't be bothered to copy and paste a URL, he obviously 
doesn't care that much about the issue, so why should I google for it?".

http://bugs.python.org/issue7721

 
[...]
> Assuming that I am correct, can I create myself a login on the bugs
> tracker and re-open the issue to get this sorted?

You can try, but I don't think that a code snippet is meant as a full-
blown replacement for xrange, just as a, well, snippet to get you started.

If you need a full replacement, you'll end up with something like this:

_xrange = xrange
def xrange(a, b=None, step=1):
try:
return _xrange(a, b, step)
except OverflowError:
if b is None:
start, end = 0, a
else:
start, end = a, b
if step > 0:
from operator import lt as cmp
elif step < 0:
from operator import gt as cmp
else:
raise ValueError("xrange() arg 3 must not be zero")
from itertools import count, takewhile
return takewhile(
lambda n: cmp(n, end),
(start + i*step for i in count()))

This should give you a larger range while still avoiding any significant 
overhead when you don't need it.



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


How to use dbstore in google app engine

2010-05-30 Thread Ou Chao
Hi all:
I have a question. How GEA save a file as simulates the App Engine
datastore in local computer? where is the file?
thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI programs

2010-05-30 Thread Detlev Offenbach
I would recommend PyQt. I've done a lot of programming with it 
(http://eric-ide.python-projects.org) and am amazed about the platform 
neutrality it offers.

Regards,
Detlev

[email protected] wrote:

> Just curious if anyone would be willing to share their thoughts
> about different Python GUI programming modules.  I've been
> doing a bit of research and am trying to find something that:
> 
> 1.  Is portable.  Would like to be able to send the module along
> with the main python file that would be able to run a GUI
> window.  Would be sending this to multiple machines.
> Currently I'd like it to work on OS X machines, but it'd be nice
> if it worked on Windows machines, etc.  Probably be using
> Python 2.5 or 2.6.
> 
> 2.  Can show an image (that is zoomable) as well as add GUI
> controls like text fields, popup menues, etc. as well as send
> information back to the program from the text fields, etc.
> For now, I'm really looking for something that can display
> EPS (postscript) and PDF images.
> 
> In my research, here's some GUI modules/programs I've been
> looking at.  I haven't gone real in-depth with these, but did
> just a little testing:
> 
> 1.  wxPython - This looks very good, although I'm not sure
> how to set up portability with this.  Other machines that would
> run the Python code probably wouldn't have the Developer
> Tools or wxPython installed.  I think I could use Py2App for
> OS X to create a Package App but I'm not real familiar with
> how that would all work.
> 
> 2.  Pyglet - This is a pretty cool program.  I was able to display
> a window with an image… but I don't think it has GUI controls
> like text fields, drop down menues, etc.
> 
> 3.  ImageMagick - This one looks cool but I can't figure out how
> to install it correctly on OS X (Snow Leopard).  Not sure if it would
> give me the GUI tools either.
> 
> 4.  PyGui - This one looks very interesting.  Just found it last night
> so haven't looked at it too closely.  Looks like it needs PyObjC on
> the machine for OS X.  I'm assuming that comes pre-installed on
> Snow Leopard machines, but not sure about Leopard or Tiger
> machines.  Anyone have more info about this?
> 
> 5.  NodeBox - This is an incredible application!  Don't think I can
> use it's libraries for what I'm wanting to do, but what a cool
> program!  I will definitely spend some time working with this!
> 
> 6.  TkInter - Does this module come standard on all machines
> that have Python?  Haven't worked with this one much, but if I
> send Python code to other machines would TkInter work?
> 
> Would love to hear anyones thoughts about GUI programming
> and what they use.  Would also like to hear pros/cons with the
> different modules/apps.
> 
> Thanks for looking at my questions.
> 
> Jay

-- 
Detlev Offenbach
[email protected]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py_single_input and the side-effects...

2010-05-30 Thread moerchendiser2k3
Hi, any idea?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Antoine Pitrou

Really, this shouldn't happen if you really are using a
non-root version of Python:

>  [Errno 2] No such file or directory: 
> '/usr/local/lib/python2.6/site-packages/test-easy-install-22015.write-test'

I don't think setuptools is dumb enough to hardcode things like
"/usr/local/lib/python2.6/", so the error is probably yours here.
Perhaps you should double-check you did everything fine before posting
such a rant.

Of course, if by "freshly-built version of Python", you mean you didn't
run "make install" in any way, then it's your problem. Give
"./configure" an appropriate non-root prefix and don't forget to run
"make install" at the end.


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


Re: GUI programs

2010-05-30 Thread Philip Semanchuk


On May 29, 2010, at 9:13 PM,
wrote:



Just curious if anyone would be willing to share their thoughts
about different Python GUI programming modules.  I've been
doing a bit of research and am trying to find something that:

1.  Is portable.  Would like to be able to send the module along
with the main python file that would be able to run a GUI
window.  Would be sending this to multiple machines.
Currently I'd like it to work on OS X machines, but it'd be nice
if it worked on Windows machines, etc.  Probably be using
Python 2.5 or 2.6.


Hi Jay,
wxPython, pyQT and Tkinter are all portable in that they'll run under  
OS X, Windows, Gnome and KDE. Getting them installed there in some  
sane fashion is another matter. There are programs like py2exe and  
py2app that you've found, but Python doesn't lend itself to being  
bundled this way. It can work, but may be a fair amount of trouble  
depending on what modules you're trying to use and how diverse your  
target machines are.



6.  TkInter - Does this module come standard on all machines
that have Python?  Haven't worked with this one much, but if I
send Python code to other machines would TkInter work?


That's my understanding. I haven't used it. I gather that Tkinter is  
useful in a pinch, but that it isn't appropriate for applications with  
much more than a minimalist GUI.



Would love to hear anyones thoughts about GUI programming
and what they use.  Would also like to hear pros/cons with the
different modules/apps.


There's lots of discussion on this topic in the archives of this  
mailing list and others. These modules haven't changed dramatically  
over the past few years, so any recent-ish conversation is relevant.



Good luck
Philip

PS - we use wxPython
--
http://mail.python.org/mailman/listinfo/python-list


$Wholesale Sports Shoes Clear Air Force One AAA++quality

2010-05-30 Thread yan
$Wholesale Sports Shoes Clear Air Force One AAA++quality
please kindly visite our website: http://www.8000trade.com
supply sports shoes. The brand Sports shoes basketball shoes, Boot,
walling shoes, Athletic shoes, Jogging shoes, running shoes, leather
shoes, football, shoe sports shoe Footwear Sneaker, Shox Max Rift T-
shirts, womens t-shirts, Clothing womens clothing, wear hats Caps
Jersey jeans Sock Jacks, Watches, wallet, handbags, and Jeans Lady
Clothing and so on. Please contact us by email to get more
information.

our price $33shoes,$15tshirt,15sunglasess, $13cap,$33jean,$35bag
please kindly visite our website: http://www.8000trade.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI programs

2010-05-30 Thread Grant Edwards
On 2010-05-30,   wrote:

> 1.  wxPython - This looks very good, although I'm not sure 
> how to set up portability with this.

I'm not sure what you mean by "set up portability".  If you follow the
wxPython API documentation, then wxPython code is fairly portable.

> Other machines that would run the Python code probably wouldn't have
> the Developer Tools or wxPython installed.  I think I could use
> Py2App for OS X to create a Package App but I'm not real familiar
> with how that would all work.

I've used py2exe with success.  It's fairly simple to use for simple
programs, but can require some configuration tweaking if you use a log
of libraries (wxPython numeric Python, scientific Python, etc.).

> 6.  TkInter - Does this module come standard on all machines
> that have Python?

Not all, but it's a lot more common than wxPython.

> Haven't worked with this one much, but if I send Python code to other
> machines would TkInter work?

Generally yes, if the machines have TkInter installed.

> Would love to hear anyones thoughts about GUI programming and what
> they use.  Would also like to hear pros/cons with the different
> modules/apps.  

This question comes up about once a week, so Google should be able
to find plenty of recent threads.

-- 
Grant

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


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread David Cournapeau
On Sun, May 30, 2010 at 3:56 PM, John Nagle  wrote:
>   MySQLdb won't install as non-root on Python 2.6 because
> its "setup.py" file requires "setuptools".  "setuptools",
> unlike "distutils", isn't part of the Python 2.6 distribution.
>
>   IMPORTANT PACKAGES SHOULD NOT USE "setuptools".  Use the
> standard "distutils".  "setuptools" and "eggs" create more
> problems than they solve.  "setuptools" has many built-in
> assumptions about where things are supposed to be, and they're
> usually wrong.

Yes, setuptools is often a pain.

The magic incantation you want is something like python setup.py
install --prefix=someprefix --single-version-externally-managed
--record=/dev/null. I myself have a small script which detects whether
setup.py uses setuptools or not, and add the necessary options in
setuptools case for a sane behavior.

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


Re: GUI programs

2010-05-30 Thread Alf P. Steinbach

* [email protected], on 30.05.2010 03:13:

Just curious if anyone would be willing to share their thoughts
about different Python GUI programming modules.  I've been
doing a bit of research and am trying to find something that:

1.  Is portable.  Would like to be able to send the module along
with the main python file that would be able to run a GUI
window.  Would be sending this to multiple machines.
Currently I'd like it to work on OS X machines, but it'd be nice
if it worked on Windows machines, etc.  Probably be using
Python 2.5 or 2.6.

2.  Can show an image (that is zoomable) as well as add GUI
controls like text fields, popup menues, etc. as well as send
information back to the program from the text fields, etc.
For now, I'm really looking for something that can display
EPS (postscript) and PDF images.


A GUI library may contain such functionality, but it's more properly the domain 
of a special purpose library.


The question then boils down to which GUI libraries your image/rich text library 
is compatible with.


Perhaps if someone else has handled that combination they'll chime in.


Cheers & hth.,

- Alf

PS: Tkinter on its own does not provide image resizing and does not on its own 
support common image formats like JPEG or PNG (it does support GIF). For Tkinter 
I think you can do that by adding the PIL library, if I remember the name 
correctly. But as far as I know PIL doesn't yet support Python 3.x, and doesn't 
support EPS or PDF, which are not image formats but rich text formats.


--
blog at http://alfps.wordpress.com>
--
http://mail.python.org/mailman/listinfo/python-list


strptime dilemma with Python 2.5

2010-05-30 Thread pythonista
Hello,
I have a date string looking like the following:

 "Sun May 30 07:25:17 2010"

With Python 2.6, the %f is supported (it parses the microseconds), so
that this statement works:

dt = datetime.strptime(s, "%a %b %d %H:%M:%f %Y")

However, with Python 2.5, (which is supported on the live Webfaction
server I'm using), %f is not supported.

 Is there a straightforward way to simply ignore the :17 microseconds
in the original string?

Maybe force it to "00" ? -  but without having to actually change the
original string by removing the ":17" ?

If I simply leave out the ":%f" in the strptime call, I get back a "
 ValueError: time data did not match format:  data=Sun May 30
19:33:54 2010  fmt=%a %b %d %H:%M %Y


Hoping for a simple solution that someone is familiar with
Thanks
Steve
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread John Nagle

David Cournapeau wrote:

On Sun, May 30, 2010 at 3:56 PM, John Nagle  wrote:

  MySQLdb won't install as non-root on Python 2.6 because
its "setup.py" file requires "setuptools".  "setuptools",
unlike "distutils", isn't part of the Python 2.6 distribution.

  IMPORTANT PACKAGES SHOULD NOT USE "setuptools".  Use the
standard "distutils".  "setuptools" and "eggs" create more
problems than they solve.  "setuptools" has many built-in
assumptions about where things are supposed to be, and they're
usually wrong.


Yes, setuptools is often a pain.

The magic incantation you want is something like python setup.py
install --prefix=someprefix --single-version-externally-managed
--record=/dev/null. I myself have a small script which detects whether
setup.py uses setuptools or not, and add the necessary options in
setuptools case for a sane behavior.

David


The "setup.py" file for MySQLdb has, as its first Python
line, "from setuptools import ...".  No combination of options will
get around that.

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


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread John Nagle

Antoine Pitrou wrote:

Really, this shouldn't happen if you really are using a
non-root version of Python:

 [Errno 2] No such file or directory: 
'/usr/local/lib/python2.6/site-packages/test-easy-install-22015.write-test'


I don't think setuptools is dumb enough to hardcode things like
"/usr/local/lib/python2.6/", so the error is probably yours here.
Perhaps you should double-check you did everything fine before posting
such a rant.

Of course, if by "freshly-built version of Python", you mean you didn't
run "make install" in any way, then it's your problem. Give
"./configure" an appropriate non-root prefix and don't forget to run
"make install" at the end.


Actually, a "built" but "uninstalled" Python works fine.  If it
didn't, "make test" wouldn't work. "sys.path" correctly points to the
library directories created during "build".

On the other hand, options to "./configure" apparently don't work
right in Python 2.6 through 3.x.  "--libdir" and "--bindir" don't actually
do anything.  See "http://bugs.python.org/issue858809"; (an open bug).  So custom
"configure" is currently broken.

The real problem here remains the unnecessary use of "setuptools".
It's Debian distro policy not to use "setuptools":

http://www.debian.org/doc/packaging-manuals/python-policy/ap-packaging_tools.html

 Also read  "Setuptools is not a decent software package management".

http://workaround.org/easy-install-debian

The fundamental problem is that "setuptools" is more than an installer but
less than a widely-supported system-wide package manager like "yum".

 Now, how to get the dependency on "setuptools" out of MySQLdb?

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


Re: strptime dilemma with Python 2.5

2010-05-30 Thread MRAB

pythonista wrote:

Hello,
I have a date string looking like the following:

 "Sun May 30 07:25:17 2010"

With Python 2.6, the %f is supported (it parses the microseconds), so
that this statement works:

dt = datetime.strptime(s, "%a %b %d %H:%M:%f %Y")

However, with Python 2.5, (which is supported on the live Webfaction
server I'm using), %f is not supported.

 Is there a straightforward way to simply ignore the :17 microseconds
in the original string?

Maybe force it to "00" ? -  but without having to actually change the
original string by removing the ":17" ?

If I simply leave out the ":%f" in the strptime call, I get back a "
 ValueError: time data did not match format:  data=Sun May 30
19:33:54 2010  fmt=%a %b %d %H:%M %Y


Hoping for a simple solution that someone is familiar with


The date string looks like it has hours, minutes and seconds, not hours,
minutes and microseconds.
--
http://mail.python.org/mailman/listinfo/python-list


Address of an immutable object

2010-05-30 Thread candide
Suppose a Python program defines an integer object with value 42. The 
object has an "address" we can capture with the built-in function id() :


>>> a=42
>>> id(a)
152263540
>>>

Now I was wondering if any integer object with value 42 will be refered 
at the same adress with the above id.


Some experiments tend to show that it may be the case, for instance :

>>> a=42
>>> id(a)
152263540
>>> id(42)
152263540
>>> b=2*21
>>> id(b)
152263540
>>> c=0b101010
>>> id(c)
152263540 


>>> d={"foo":42, "bar":"foo"}
>>> id(d["foo"])
152263540
>>> L=["foo",(51,([14,42],5)),"bar"]
>>> id(L[1][1][0][1])
152263540
>>> del a
>>> id(L[1][1][0][1]) 

152263540 


>>> zzz=range(1000)
>>> id(zzz[42])
152263540
>>>

Even you can't make a deep copy :


>>> from copy import deepcopy
>>> a=42
>>> from copy import deepcopy
>>> z=deepcopy(a)
>>> id(a), id(z)
(152263540, 152263540)
>>>

So is the following true :

Two non mutable objects with the same value shall be allocated at a 
constant and unique address ?

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


Re: Address of an immutable object

2010-05-30 Thread Alf P. Steinbach

* candide, on 30.05.2010 19:38:

Suppose a Python program defines an integer object with value 42. The
object has an "address" we can capture with the built-in function id() :

 >>> a=42
 >>> id(a)
152263540
 >>>

Now I was wondering if any integer object with value 42 will be refered
at the same adress with the above id.

Some experiments tend to show that it may be the case, for instance :

 >>> a=42
 >>> id(a)
152263540
 >>> id(42)
152263540
 >>> b=2*21
 >>> id(b)
152263540
 >>> c=0b101010
 >>> id(c)
152263540
 >>> d={"foo":42, "bar":"foo"}
 >>> id(d["foo"])
152263540
 >>> L=["foo",(51,([14,42],5)),"bar"]
 >>> id(L[1][1][0][1])
152263540
 >>> del a
 >>> id(L[1][1][0][1])
152263540
 >>> zzz=range(1000)
 >>> id(zzz[42])
152263540
 >>>

Even you can't make a deep copy :


 >>> from copy import deepcopy
 >>> a=42
 >>> from copy import deepcopy
 >>> z=deepcopy(a)
 >>> id(a), id(z)
(152263540, 152263540)
 >>>

So is the following true :

Two non mutable objects with the same value shall be allocated at a
constant and unique address ?


No.

First, id() doesn't generally provide an address. It does that in CPython, but 
more generally it just provides a unique integer identifying the reference. You 
can think of it as the "reference value" if you want; it's what's copied by an 
assignment to a variable.


Second, the reason that you get the same id for various 42 objects is that 
CPython uses a cache of "small integer" objects. As I recall the cache ranges 
from -5 to some 127 or so (or perhaps it was double that). Any value outside 
that cached range you'll see different id's for the same value.



Cheers & hth.,

- Alf

--
blog at http://alfps.wordpress.com>
--
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread John Nagle

John Nagle wrote:

David Cournapeau wrote:

On Sun, May 30, 2010 at 3:56 PM, John Nagle  wrote:

  MySQLdb won't install as non-root on Python 2.6 because
its "setup.py" file requires "setuptools".  "setuptools",
unlike "distutils", isn't part of the Python 2.6 distribution.

  IMPORTANT PACKAGES SHOULD NOT USE "setuptools".  Use the
standard "distutils".  "setuptools" and "eggs" create more
problems than they solve.  "setuptools" has many built-in
assumptions about where things are supposed to be, and they're
usually wrong.


   I tried this change on MySQLdb's "setup.py":

diff setup.py setup-nodistutils.py
5c5
< from setuptools import setup, Extension
---
> from distutils.core import setup, Extension

The build then runs.  The resulting MySQLdb runs under the uninstalled
Python and connects to the database properly.

There's no need for "setuptools" here at all.  It just gets in the way.

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


Re: Address of an immutable object

2010-05-30 Thread Simon Brunning
On 30 May 2010 18:38:23 UTC+1, candide  wrote:
> Two non mutable objects with the same value shall be allocated at a constant 
> and unique address ?

Nope.

>>> a = 999
>>> b = 999
>>> id(a) == id(b)
False

Your statement will be the case for small integers, but this in an
implementation detail. Indeed, this used to be the case for integers
up to 100 (IIRC) or thereabouts, but it's now the case up to 256:

>>> a = 256
>>> b = 256
>>> id(a) == id(b)
True
>>> a = 257
>>> a = 257
>>> id(a) == id(b)
False

Some identifier-like strings are also interned like this:

>>> a = 'foo'
>>> b = 'foo'
>>> id(a) == id(b)
True
>>> a = 'two words'
>>> b = 'two words'
>>> id(a) == id(b)
False

But again, it's an implementation detail, and shouldn't be relied upon.

This same issue also comes up with people noticing that they can
compare small integers with the 'is' operator, and getting a surprise
when bigger numbers come along:

>>> a = 256
>>> b = 256
>>> a is b
True
>>> a = 257
>>> b = 257
>>> a is b
False

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


Threads with Cmd and socket server combination

2010-05-30 Thread [email protected]
hi,
I have implement a command line app using Python's cmd library module
and it works fine.
I 've also create a simple threaded socket server. How can i merge the
two ones, so that the
console app, is also a listening server? How can i achieve that with
threads?
I'm trying for days and i can't make it work! I know it can be done
with Twisted but i want
 to understand how thread works.

The console:

class BM(CmdBase):
"""Simple custom command processor"""

def do_acmd(self):
pass

if __name__ == '__main__':
BM().cmdloop()

and the Server:

class MyClientHandler(SocketServer.BaseRequestHandler):
def handle(self):
pass


server = SocketServer.ThreadingTCPServer(myaddr, MyClientHandler)
server.serve_forever( )

Thanks in advance
Threads can be so difficult
A.K.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: if, continuation and indentation

2010-05-30 Thread Colin J. Williams

On 30-May-10 01:50 AM, Nathan Rice wrote:

I prefer to just break such things into multiple lines.  You're doing
that already anyhow, it's not much of a speed hit, and it makes exactly
what you're testing explicit.  If I break a statement onto multiple
lines I only use parenthesis, and that is as a last resort.  In my
opinion there's almost always some combination of variable assignments
and lambda expressions that uses fewer lines and is clearer.

is_correct_style = width == 0 and height == 0 and color == 'red'
if (is_correct_style and emphasis == 'strong') or highlight > 100:


On Sat, May 29, 2010 at 8:59 PM, Mark Lawrence mailto:[email protected]>> wrote:

On 30/05/2010 01:23, john wrote:

On May 28, 10:37 am, "Colin J. Williams"mailto:[email protected]>>
wrote:

On 28-May-10 05:54 AM, Jonathan Hartley wrote:

On May 27, 1:57 pm, Jean-Michel
Pichavantmailto:[email protected]>>
wrote:

HH wrote:

I have a question about best practices when it
comes to line wrapping/
continuation and indentation, specifically in
the case of an if
statement.


When I write an if statement with many
conditions, I prefer to use a
parenthesis around the whole block and get the
implicit continuation,
rather than ending each line with an escape
character.  Thus, using
the example from the style guide
(http://www.python.org/dev/peps/
pep-0008/) I would write:


  if (width == 0 and
  height == 0 and
  color == 'red' and
  emphasis == 'strong' or
  highlight>100):
  raise ValueError("sorry, you lose")


The problem should be obvious -- it's not easy
to see where the
conditional ends and the statement begins since
they have the same
indentation.  Part of the problem, I suppose, is
that Emacs indents
'height' and the other lines in the conditional
to 4 spaces (because
of the parenthesis).  How do people deal with
this situation?


Thanks,
Henrik


One possible solution


  if (
  width == 0 and
  height == 0 and
  color == 'red' and
  emphasis == 'strong' or
  highlight>100
 ):
  raise ValueError("sorry, you lose")


JM


I've always liked this, or even:


if (
width == 0 and
height == 0 and
color == 'red' and
emphasis == 'strong' or
highlight>100
):
raise ValueError("sorry, you lose")


but my co-workers have uniformly gone bananas whenever I
try it.


I liked:

On 27-May-10 08:48 AM, Xavier Ho wrote:
 >  On 27 May 2010 22:22, HHmailto:[email protected]>> >>  wrote:

 >
 >   if (width == 0 and
 >   height == 0 and
 >   color == 'red' and
 >   emphasis == 'strong' or
 >   highlight>  100):
 >   raise ValueError("sorry, you lose")
 >
 >
 >  I've gotta say - I've bumped into this problem before,
and I'm sure many
 >  other have - this is a valid question. It just hasn't
bothered me enough
 >  to ask...
 >
 >  Correct me if I'm wrong, but I think the following is
equivalent, and
 >  looks better. Although this won't fix all ugly cases in
that problem..
 >
 >  if (width, height, color, emphasis) == (0, 0, 'red',
'strong') or
 >  highlight>  100:
 >raise ValueError("sorry, you lose")
 >
 >  Cheers,
 >  Xav

  

Returning value from home made unit - how to?

2010-05-30 Thread Martin Hvidberg
Dear 

A may-bee beginner’s question

I have a Python program, which has until now, been running in command line mode 
only. I wish to add a GUI.

I would like to develop (and maintain) the GUI part in a separate module, i.e. 
in its own .py file, and then ‘import’ that into the old main program.

I jumped into wxPython, as it seems to be the right GUI for me, and downloaded 
some examples that I took apart and joined. Now the basic GUI is running, 
though neither beautiful nor complete.

The main task for my GUI is to allow the user to point to an input file. 
It can now obtain a filename from a file selection dialog, but I can’t figure 
out how to get the filename, i.e. the string variable containing the file name, 
send back to the main program…

I attach the two .py files hereunder.

My question is:
How do I get the information from variable strSequenceFile, back to the main 
module in file jacxl.py ?

Best Regards
Martin Hvidberg

# == File jacxl.py =
import jacXlgui

if __name__ == "__main__":
print "Hello World - from Main";

result = jacXlgui.app.MainLoop()

print 'Result:',result
# == End of jacxl.py =

# == File jacXlgui.py =
#--
# A very simple wxPython GUI.
# To go with JakXl.py
#--

import wx, os

class JacXlFrame(wx.Frame):
"""
This is a Frame.  It just shows a few controls on a wxPanel,
and has a simple menu.
"""
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title, pos=(150, 150), size=(350, 
350))

# Create the menubar
menuBar = wx.MenuBar()
# and some menus
filemenu = wx.Menu()
helpmenu = wx.Menu()
# add an item to the menu
filemenu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Leave without running 
anything ...")
helpmenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
# bind the menu event to an event handler
self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=wx.ID_EXIT)
self.Bind(wx.EVT_MENU, self.OnShowAbout, id=wx.ID_ABOUT)
# and put the menu on the menubar
menuBar.Append(filemenu, "&File")
menuBar.Append(helpmenu, "&Help")
self.SetMenuBar(menuBar)

# Status bar
self.CreateStatusBar()

# Now create the Panel to put the other controls on.
panel = wx.Panel(self)
# A text...
text = wx.StaticText(panel, -1, "Please select a \"Sequence\" file")
text.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL)) # , wx.BOLD
text.SetSize(text.GetBestSize())
# Where is the Sequence file ?
self.txcI = wx.TextCtrl(panel, -1, "", size=(300, -1))

# Some buttons
btnFileFind = wx.Button(panel, -1, "Browse for file")
btnClose = wx.Button(panel, -1, "Exit")
btnRun = wx.Button(panel, -1, "Run")
# bind the button events to handlers
self.Bind(wx.EVT_BUTTON, self.OnFindFileButton, btnFileFind)
self.Bind(wx.EVT_BUTTON, self.OnRunButton, btnRun)
self.Bind(wx.EVT_BUTTON, self.OnTimeToClose, btnClose)
# Use a sizer to layout the controls, stacked vertically and with
# a 10 pixel border around each
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(text, 0, wx.ALL, 10)
sizer.Add(self.txcI, 0, wx.ALL, 10)
sizer.Add(btnFileFind, 0, wx.ALL, 10)
sizer.Add(btnRun, 0, wx.ALL, 10)
sizer.Add(btnClose, 0, wx.ALL, 10)
panel.SetSizer(sizer)
panel.Layout()

def OnFindFileButton(self, evt):  
strReturn = ''
wildcard = "Sequence Log (*.LOG)|*.LOG|" \
"All files (*.*)|*.*"
dialog = wx.FileDialog(None, "Choose a file", os.getcwd(), "", 
wildcard, wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
strSequenceFile = dialog.GetPath()
self.txcI.ChangeValue(strSequenceFile) # Copying filename to text 
box
dialog.Destroy()
print 'Found file:',strSequenceFile
return strSequenceFile

def OnShowAbout(self, evt):
print "About this program ..."

def OnRunButton(self, evt):
"""Event handler for the button click."""
print 'Run   :',self.txcI.GetValue()
return self.txcI.GetValue()

def OnTimeToClose(self, evt):
"""Event handler for the button click."""
print "See ya later!"
self.Close()

class JacXlApp(wx.App):
def OnInit(self):
frame = JacXlFrame(None, "JacXl - converting ... to eXcel")
self.SetTopWindow(frame)
print "Print statements go to this stdout window by default."
frame.Show(True)
return True

app = JacXlApp(redirect=False)
# == End of jacXlgui.py =

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


Re: GUI programs

2010-05-30 Thread Colin J. Williams

On 30-May-10 08:22 AM, Philip Semanchuk wrote:


On May 29, 2010, at 9:13 PM,  
wrote:


Just curious if anyone would be willing to share their thoughts
about different Python GUI programming modules. I've been
doing a bit of research and am trying to find something that:

1. Is portable. Would like to be able to send the module along
with the main python file that would be able to run a GUI
window. Would be sending this to multiple machines.
Currently I'd like it to work on OS X machines, but it'd be nice
if it worked on Windows machines, etc. Probably be using
Python 2.5 or 2.6.


Hi Jay,
wxPython, pyQT and Tkinter are all portable in that they'll run under OS
X, Windows, Gnome and KDE. Getting them installed there in some sane
fashion is another matter. There are programs like py2exe and py2app
that you've found, but Python doesn't lend itself to being bundled this
way. It can work, but may be a fair amount of trouble depending on what
modules you're trying to use and how diverse your target machines are.


6. TkInter - Does this module come standard on all machines
that have Python? Haven't worked with this one much, but if I
send Python code to other machines would TkInter work?


That's my understanding. I haven't used it. I gather that Tkinter is
useful in a pinch, but that it isn't appropriate for applications with
much more than a minimalist GUI.


Would love to hear anyones thoughts about GUI programming
and what they use. Would also like to hear pros/cons with the
different modules/apps.


There's lots of discussion on this topic in the archives of this mailing
list and others. These modules haven't changed dramatically over the
past few years, so any recent-ish conversation is relevant.


Good luck
Philip

PS - we use wxPython


I am just starting with PyQt4.  It has an IDE, Eric4, which seems 
flexible and is about to be fully geared up for Windows.  There is also 
a Screen Designer, that I haven't used yet.


Colin W.

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


Re: strptime dilemma with Python 2.5

2010-05-30 Thread pythonista
You know why it looks like it has seconds and not microseconds?

Because it does, and I'm on something.

Thank you


>
> The date string looks like it has hours, minutes and seconds, not hours,
> minutes and microseconds.

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


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Antoine Pitrou
On Sun, 30 May 2010 10:10:00 -0700
John Nagle  wrote:
> 
>  Actually, a "built" but "uninstalled" Python works fine.
>  If it
> didn't, "make test" wouldn't work.

That's a completely unrelated thing. The main reason "make test" works
with an uninstalled Python is simply so that the core developers' life
is easier. It doesn't mean all Python functionalities work in that
context.

>  On the other hand, options to "./configure" apparently don't work
> right in Python 2.6 through 3.x.  "--libdir" and "--bindir" don't actually
> do anything.

You can use "--prefix" instead, it works.

>  The real problem here remains the unnecessary use of "setuptools".

No, again, the real problem is just that you are trying to install
modules for an uninstalled Python.
You may hate setuptools with a passion, but it's unconstructive and
useless to put the blame on it without any solid argument.
Do yourself a favour: pass the proper options to "./configure", and
install Python.

Regards

Antoine.


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


Re: Address of an immutable object

2010-05-30 Thread candide

Thanks for your responses,  I should do more experiments !
--
http://mail.python.org/mailman/listinfo/python-list


Re: Address of an immutable object

2010-05-30 Thread candide

Alf P. Steinbach a écrit :

* candide, on 30.05.2010 19:38:

Suppose a Python program defines an integer object with value 42. The
object has an "address" we can capture with the built-in function id() :


First, id() doesn't generally provide an address. 


I talked about a quote unquote "address" ;)
but according to "The Python Language Reference" it's not very far from 
the truth  :



3.1 Objects, values and types
(...)
An object’s identity never changes
once it has been created; you may think of it as the object’s _address_ 
in memory. The ‘is‘ operator compares the
identity of two objects; the id() function returns an integer 
representing its identity (currently implemented as

its _address_).


(emphasizing is mine)
--
http://mail.python.org/mailman/listinfo/python-list


Re: xrange issue 7721

2010-05-30 Thread Martin Manns
On Sun, 30 May 2010 00:49:11 +0100
Mark Lawrence  wrote:
 
>  From http://docs.python.org/dev/library/itertools.html
> "Unlike regular slicing, islice()  does not support negative values
> for start, stop, or step."
> 
> Rule 1 of programming never assume anything, particularly wrt
> testing. I assume that you are ok with this. :) Dreadful I know :)

Right, never post before reading the fine manual :)

> > I found the msg97928 code pretty obvious when seeing the snippet.
> > If you disagree you may consider re-opening the issue.
> I trust that you get my point regarding the failure to raise a 
> ValueError :)  Or am I wearing my extremely stupid hat today?

Since you seem to find this issue important, are you going to re-open
the issue?

Cheers

Martin

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


Re: GUI programs

2010-05-30 Thread prezjordan
How does GTK compare to Qt?
-- 
http://mail.python.org/mailman/listinfo/python-list


What's the largest python/django powered website in the world?

2010-05-30 Thread est
Hi list,

just curious, what's the largest python powered website in the world?

and what's the largest django powered website in the world? Is it
disqus.com?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread John Nagle

Antoine Pitrou wrote:

On Sun, 30 May 2010 10:10:00 -0700
John Nagle  wrote:

 Actually, a "built" but "uninstalled" Python works fine.
 If it
didn't, "make test" wouldn't work.


That's a completely unrelated thing. The main reason "make test" works
with an uninstalled Python is simply so that the core developers' life
is easier. It doesn't mean all Python functionalities work in that
context.

>

 On the other hand, options to "./configure" apparently don't work
right in Python 2.6 through 3.x.  "--libdir" and "--bindir" don't actually
do anything.


You can use "--prefix" instead, it works.


It's nice that some of the options work.  Note that someone who
used "--bindir", expecting it to work, might end up overwriting their
existing Python installation unintentionally, which would break system
administration tools like cPanel and "yum".

cPanel support recommends against installing a new Python other
than through "yum".

http://forums.cpanel.net/f5/mailman-breaks-stable-upcp-due-python-upgrade-126453.html
http://forums.cpanel.net/f5/upgrade-python-whm-113593.html

They don't trust other install mechanisms.  With good cause.


 The real problem here remains the unnecessary use of "setuptools".


No, again, the real problem is just that you are trying to install
modules for an uninstalled Python.
You may hate setuptools with a passion, but it's unconstructive and
useless to put the blame on it without any solid argument.
Do yourself a favour: pass the proper options to "./configure", and
install Python.

Regardssetu

Antoine.


   Having demonstrated in a previous post that 1) the use of "setuptools"
was completely unnecessary, and 2) it's quite possible to load and use
MySQLdb in an "uninstalled" Python, we can dismiss the above argument.

   The ongoing low quality of Python distribution mechanisms, and the
denial of that fact, is a major part of why Python, after 20 years, is far
less available than Perl.  The latest production versions of Red Hat
Enterprise Linux and CentOS, the major server distributions, still ship
with Python 2.4.3, a five year old version of Python.

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


Re: What's the largest python/django powered website in the world?

2010-05-30 Thread Daniel Fetchinson
> just curious, what's the largest python powered website in the world?

I'm afraid you'll need to define what you mean by "python powered". If
the server side of a web application is written in 3 or more languages
and one of them is python, does that count? If yes, then probably
google and youtube are the "largest python powered websites".

Daniel


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


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Antoine Pitrou
On Sun, 30 May 2010 15:16:42 -0700
John Nagle  wrote:
> 
>  It's nice that some of the options work.  Note that someone who
> used "--bindir", expecting it to work, might end up overwriting their
> existing Python installation unintentionally, which would break system
> administration tools like cPanel and "yum".

Well, usually you don't type "sudo" unintentionally...

> The ongoing low quality of Python distribution mechanisms, and the
> denial of that fact, is a major part of why Python, after 20 years, is far
> less available than Perl.

"Far less available"? How so?

>  The latest production versions of Red Hat
> Enterprise Linux and CentOS, the major server distributions, still ship
> with Python 2.4.3, a five year old version of Python.

And of course nothing in this is Python's or setuptools' fault, since
it's just Redhat's policy, so I wonder what you're trying to tell us.

(not to mention that it doesn't have anything to do with the original
topic anymore, either)


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


Re: Returning value from home made unit - how to?

2010-05-30 Thread Mel
Martin Hvidberg wrote:
> I have a Python program, which has until now, been running in command line
> mode only. I wish to add a GUI.
> 
> I would like to develop (and maintain) the GUI part in a separate module,
> i.e. in its own .py file, and then ‘import’ that into the old main
> program.
> 
> I jumped into wxPython, as it seems to be the right GUI for me, and
> downloaded some examples that I took apart and joined. Now the basic GUI
> is running, though neither beautiful nor complete.
> 
> The main task for my GUI is to allow the user to point to an input file.
> It can now obtain a filename from a file selection dialog, but I can’t
> figure out how to get the filename, i.e. the string variable containing
> the file name, send back to the main program…
> 
> I attach the two .py files hereunder.
> 
> My question is:
> How do I get the information from variable strSequenceFile, back to the
> main module in file jacxl.py ?

AFAIK, typically, you don't -- the way it is here.  Returning a value from a 
Button handler, or any event handler generally, won't have any effect.  The 
event handlers are called from deep in wx code by routines that don't deal 
with anything specific to the data-processing side of the program.

What I think you might do is to make strSequenceFile an attribute of your 
Frame, so that OnFindFile button does ``self.strSequenceFile = 
dialog.GetPath()'' rather than returning that value.

Then your main level can do ``jacXlgui.app.GetTopWindow().strSequenceFile'' 
.

There are probably refinements to be added to this, but I think it's a good 
beginning strategy.  The first new place I would take the whole program 
would be to remove the command-line controls from the command line program, 
so you're left with a sort of "business model" that contains only the data 
processing.  Then you can write a new GUI program based on jacXlgui that 
imports the  data processing module and calls computations and reports 
results from the model.


Mel.


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


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread David Cournapeau
On Mon, May 31, 2010 at 7:16 AM, John Nagle  wrote:

>    It's nice that some of the options work.  Note that someone who
> used "--bindir", expecting it to work, might end up overwriting their
> existing Python installation unintentionally, which would break system
> administration tools like cPanel and "yum".
>
>    cPanel support recommends against installing a new Python other
> than through "yum".
>
> http://forums.cpanel.net/f5/mailman-breaks-stable-upcp-due-python-upgrade-126453.html
> http://forums.cpanel.net/f5/upgrade-python-whm-113593.html
>
>    They don't trust other install mechanisms.  With good cause.

This has absolutely nothing to do with how python is installed. It is
common sense that you should upgrade an installed package through the
package manager mechanism (here yum), and is true for any software,
python or not.

> The latest production versions of Red Hat
> Enterprise Linux and CentOS, the major server distributions, still ship
> with Python 2.4.3, a five year old version of Python.

Yes, by definition RHEL ships softwares that does not change for a
long time. By your argument, the linux kernel and gcc are broken
because they are 4 years old on RHEL 5 (linux 2.6.18. gcc 4.0.*). That
does not make any sense.

cheers,

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


Re: xrange issue 7721

2010-05-30 Thread Martin v. Loewis

Assuming that I am correct, can I create myself a login on the bugs
tracker and re-open the issue to get this sorted?


Definitely not. The issue you are looking at has been fixed; whatever 
your issue is (you didn't state it clearly), it must be a different

one. So if you are going to report anything, please submit a new bug
report instead.

For the record, the issue you were looking at was a complaint that the 
documentation is incorrect. This had been fixed by correcting the 
documentation.


Please structure bug reports as follows:
1. this is what you did
2. this is what happened
3. this is what you had expected/wanted to happen instead

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


Re: MySQLdb install vs. "setuptools"

2010-05-30 Thread Benjamin Kaplan
On Sun, May 30, 2010 at 3:16 PM, John Nagle  wrote:

> Antoine Pitrou wrote:
>
>> On Sun, 30 May 2010 10:10:00 -0700
>> John Nagle  wrote:
>>
>>> Actually, a "built" but "uninstalled" Python works fine.
>>>  If it
>>> didn't, "make test" wouldn't work.
>>>
>>
>> That's a completely unrelated thing. The main reason "make test" works
>> with an uninstalled Python is simply so that the core developers' life
>> is easier. It doesn't mean all Python functionalities work in that
>> context.
>>
> >
>
>> On the other hand, options to "./configure" apparently don't work
>>> right in Python 2.6 through 3.x.  "--libdir" and "--bindir" don't
>>> actually
>>> do anything.
>>>
>>
>> You can use "--prefix" instead, it works.
>>
>
>It's nice that some of the options work.  Note that someone who
> used "--bindir", expecting it to work, might end up overwriting their
> existing Python installation unintentionally, which would break system
> administration tools like cPanel and "yum".
>
>cPanel support recommends against installing a new Python other
> than through "yum".
>
>
> http://forums.cpanel.net/f5/mailman-breaks-stable-upcp-due-python-upgrade-126453.html
> http://forums.cpanel.net/f5/upgrade-python-whm-113593.html
>
>They don't trust other install mechanisms.  With good cause.
>
>  The real problem here remains the unnecessary use of "setuptools".
>>>
>>
>> No, again, the real problem is just that you are trying to install
>> modules for an uninstalled Python.
>> You may hate setuptools with a passion, but it's unconstructive and
>> useless to put the blame on it without any solid argument.
>> Do yourself a favour: pass the proper options to "./configure", and
>> install Python.
>>
>> Regardssetu
>>
>> Antoine.
>>
>
>   Having demonstrated in a previous post that 1) the use of "setuptools"
> was completely unnecessary, and 2) it's quite possible to load and use
> MySQLdb in an "uninstalled" Python, we can dismiss the above argument.
>
>   The ongoing low quality of Python distribution mechanisms, and the
> denial of that fact, is a major part of why Python, after 20 years, is far
> less available than Perl.  The latest production versions of Red Hat
> Enterprise Linux and CentOS, the major server distributions, still ship
> with Python 2.4.3, a five year old version of Python.
>
>John Nagle
>
>
Based on a quick search, CentOS 5.5 ships with Perl 5.8.8. I would assume
that it uses the same version as RHEL. Based on another quick search, Perl
5.8.8 shipped in February 2006, one month before Python 2.4.3.

What does this have to do with distribution mechanisms again?

And last time I checked, Python is now preinstalled on every OS worth
speaking of except for Windows. Last time I checked, Perl was preinstalled
on every OS worth speaking of except for Windows. With IronPython putting
Python on the .NET Framework, one could argue that, if anything, Python is
more available than Perl. Particularly if Microsoft ever gets around to
giving IronPython and IronRuby first class status in Visual Studio.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Address of an immutable object

2010-05-30 Thread Steven D'Aprano
On Sun, 30 May 2010 22:08:49 +0200, candide wrote:

> Alf P. Steinbach a écrit :
>> * candide, on 30.05.2010 19:38:
>>> Suppose a Python program defines an integer object with value 42. The
>>> object has an "address" we can capture with the built-in function id()
>>> :
> 
>> First, id() doesn't generally provide an address.
> 
> I talked about a quote unquote "address" ;) but according to "The Python
> Language Reference" it's not very far from the truth  :
> 
> 
> 3.1 Objects, values and types
> (...)
> An object’s identity never changes
> once it has been created; you may think of it as the object’s _address_
> in memory. The ‘is‘ operator compares the identity of two objects; the
> id() function returns an integer representing its identity (currently
> implemented as its _address_).
> 
> 
> (emphasizing is mine)


Which is a weakness of the documentation, since in Jython object ids are 
1, 2, 3, 4, ... rather than addresses in memory. Of course, if you want 
to think of 1, 2, 3, 4, ... as addresses, who's going to stop you? :-)


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


Re: What's the largest python/django powered website in the world?

2010-05-30 Thread est
> I'm afraid you'll need to define what you mean by "python powered".

Except database, presentation layer, major business logic is done by
python.

Except Google/youtube, what's next?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xrange issue 7721

2010-05-30 Thread Steven D'Aprano
On Mon, 31 May 2010 00:54:16 +0200, Martin v. Loewis wrote:

>> Assuming that I am correct, can I create myself a login on the bugs
>> tracker and re-open the issue to get this sorted?
> 
> Definitely not. The issue you are looking at has been fixed; whatever
> your issue is (you didn't state it clearly), it must be a different one.
> So if you are going to report anything, please submit a new bug report
> instead.
> 
> For the record, the issue you were looking at was a complaint that the
> documentation is incorrect. This had been fixed by correcting the
> documentation.

I think Mark's point is that the code snippet given isn't a full 
replacement for xrange, since it doesn't support negative step sizes, nor 
does it raise an exception on step=0.

I can see why somebody might argue that the documentation is wrong. The 
given snippet *isn't* a replacement for xrange, but merely an example of 
how you might get xrange-like behaviour over a restricted domain.

Since the docs are read by people with vastly different levels of 
experience, skill and nous, I think it's a reasonable complaint to make. 
I am sure that there will be plenty of people who will take the docs 
literally and be surprised when their code fails because the xrange 
replacement fails.

I'd suggest fixing the docs to make it clear that the snippet is a 
simplified example rather than a replacement, rather than trying to 
complicate the snippet to cover all cases xrange deals with.

In my opinion, all it takes is the addition of two words:

If a larger range is needed, an alternate version can be crafted using 
the itertools module, for example: takewhile(lambda x: xhttp://mail.python.org/mailman/listinfo/python-list


Re: What's the largest python/django powered website in the world?

2010-05-30 Thread James Mills
On Mon, May 31, 2010 at 9:27 AM, est  wrote:
> Except Google/youtube, what's next?

bitbucket (1) is mostly implemented in Python

cheers
James

1. http://bitbucket.org/

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


Re: What's the largest python/django powered website in the world?

2010-05-30 Thread Benjamin Kaplan
On Sun, May 30, 2010 at 4:27 PM, est  wrote:
>
> > I'm afraid you'll need to define what you mean by "python powered".
>
> Except database, presentation layer, major business logic is done by
> python.
>
> Except Google/youtube, what's next?
> --
> http://mail.python.org/mailman/listinfo/python-list

http://www.reddit.com
http://github.com/reddit/reddit

I believe they recently said that they're at 7.5 million users and 270
million page views per month. And the repo is 71% Python with most of
the rest as Javascript.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py_single_input and the side-effects...

2010-05-30 Thread Carl Banks
On May 30, 3:17 am, moerchendiser2k3  wrote:
> Hi, any idea?

Python doesn't guarantee that objects will be deleted at a specific
time.  There are different reasons why an object might not be deleted.

In command line mode Python keeps a reference to the most recent
result.  I don't know if it happens in general for any
Py_single_input, but you could try to execute a few dummy commands
with Py_single_input to see if it helps.  But if you're relying on
that behavior you really need to consider rethinking your problem.

The only foolproof way to ensure that an object has been finalized is
to do it manually (i.e., provide a finalize method to releases
resources).


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


RE:GUI programs

2010-05-30 Thread jyoung79
Just want to say thank you to all those who responded with their 
thoughts so far.  Really appreciate you taking the time to share.  
This list has always been incredibly helpful and insightful!

I do have another quick question.  Has anyone had any luck getting 
PyGUI working on Snow Leopard?  I can't seem to get the blobedit 
example to work.

--

>> 1.  wxPython - This looks very good, although I'm not sure 
>> how to set up portability with this.

> I'm not sure what you mean by "set up portability".  If you follow the
> wxPython API documentation, then wxPython code is fairly portable.

By portable, I mean I want to send code out to other machines (right 
now just OS X machines) that don't already have wxPython.  It'd be 
nice to be able to package the appropriate module/library with my 
Python script.  For example, I include the xlrd module and Python 
file inside of an AppleScript droplet which works perfect as a 
stand-alone droplet on numerous machines.

--

>> Would love to hear anyones thoughts about GUI programming and what
>> they use.  Would also like to hear pros/cons with the different
>> modules/apps.  

> This question comes up about once a week, so Google should be able
> to find plenty of recent threads.

I've been googling this subject for quite some time.  Have found a lot 
of good results but would like to find more detail - especially more 
specific to displaying zoomable images like EPS, etc.


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