Re: can't start Apache on Mac OS X--no listening sockets available?

2007-06-26 Thread 7stud
On Jun 26, 12:52 am, kaens <[EMAIL PROTECTED]> wrote:
> If apache2 works on macs how it does on linux (it should, right?)
> there should be Apache2/sites-enabled and Apache2/sites-available
> directories - the "default" files in these will tell you what pages
> are being served, I believe.
>

There are no such directories in my new installation directory /
Library/Apache2

> Also, I think the processes are normal, but I'm not sure. Apache is a
> pretty heavyweight server.

Ok.


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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Giorgos Keramidas
On Fri, 22 Jun 2007 21:51:34 -, Twisted <[EMAIL PROTECTED]> wrote:
>> C-h i, C-x b RET is non-trivial?!?
[...]
> I'm sorry. I don't speak Chinese.
>
> I trust I've made my point. Not only does it insist you learn a whole
> other language (though I'm guessing it's not actually Chinese --
> Greek, maybe), even when you know that's a bunch of keystrokes and
> even what they are...
>
> HOW IN THE BLOODY HELL IS IT SUPPOSED TO OCCUR TO SOMEONE TO ENTER
> THEM, GIVEN THAT THEY HAVE TO DO SO TO REACH THE HELP THAT WOULD TELL
> THEM THOSE ARE THE KEYS TO REACH THE HELP?!

No it's not Greek.  I can assure you it isn't, because I *am* Greek.

Now, regarding your shouting about the keys, have you tried using a
recent GNU Emacs installation?  The first thing that pops up when a new
user runs Emacs looks like this:

,---
| Welcome to GNU Emacs, a part of the GNU operating system.
|
| Type C-l to begin editing.
|
| Get help   C-h  (Hold down CTRL and press h)
| Emacs manual   C-h r
| Emacs tutorial C-h t   Undo changes C-x u
| Buy manualsC-h C-m Exit Emacs   C-x C-c
| Browse manuals C-h i
| Activate menubar   F10  or  ESC `  or   M-`
| (`C-' means use the CTRL key.  `M-' means use the Meta (or Alt) key.
| If you have no Meta key, you may instead type ESC followed by the character.)
|
| GNU Emacs 22.1.50.2 (i386-unknown-freebsd7.0, X toolkit)
|  of 2007-05-29 on kobe
| Copyright (C) 2007 Free Software Foundation, Inc.
|
| GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
| Emacs is Free Software--Free as in Freedom--so you can redistribute copies
| of Emacs and modify it; type C-h C-c to see the conditions.
| Type C-h C-d for information on getting the latest version.
`---

Basic reading skills are necessary to parse this 'splash' screen, but it
shouldn't be too hard to read a few lines of text which guide you about
the proper key sequence to reach the tutorial, right?

> Of course, Notepad is so easy to use it doesn't even need help,
> despite which it's readily available. In case you forgot the bog-
> standard (and therefore it IS self-evident) "F1" there's even a "Help"
> menu in plain view as soon as you open a Notepad.

There's also a "Help" menu in plain sight when you fire up Emacs with an
X11 interface.  I don't see why Notepad is special in any way here.

> This is the lowly Notepad, which I'll freely admit is the rusty
> bicycle of text editors, and it's much easier to use (including the
> help) than the supposed Mercedes-Benz of editors.

Isn't this always the case?  The 'interface' of a tiny bicycle is
something which even very young kids can master pretty fast.  On the
other hand, I'm relatively sure there's at least one valid reason we
don't let pre-school aged children drive around Mercedes-Benz cars,
isn't there?

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Giorgos Keramidas
On Fri, 22 Jun 2007 23:08:02 -, [EMAIL PROTECTED] wrote:
>> lpr /usr/local/share/emacs/21.3/etc/refcard.ps
>> or your install-dir^^
>> or your version.^
>
> So now we're expected to go on a filesystem fishing expedition instead
> of just hit F1? One small step (backwards) for a man; one giant leap
> (backwards) for mankind. :P
>
>> But then again buying the GNU-book from 'O Reilly would have solved it
>> in the utmost nicest possible of ways anyway.
>
> So much for the "free" in "free software". If you can't actually use
> it without paying money, whether for the software or for some book, it
> isn't really free, is it?

Please do not confuse the term 'free' in 'free software' with 'gratis'.

'Gratis', i.e. 'lacking a monetary price tag' is something *very*
different from the meaning of 'free' in 'free software'.

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


Re: Python's "only one way to do it" philosophy isn't good?

2007-06-26 Thread Paul Rubin
Douglas Alan <[EMAIL PROTECTED]> writes:
> > In the Maclisp era functions like mapcar worked on lists, and
> > generated equally long lists in memory.
> 
> I'm aware, but there were various different mapping functions.  "map",
> as opposed to "mapcar" didn't return any values at all, and so you had
> to rely on side effects with it.

The thing is there was no standard way in Maclisp to write something
like Python's "count" function and map over it.  This could be done in
Scheme with streams, of course.

> Right -- I wrote "iterators", not "generators".

Python iterators (the __iter__ methods on classes) are written with
yield statements as often as not.

> > The point is that mapcar (as the name implies) advances down a list
> > using cdr, i.e. it only operates on lists, not general iterators or
> > streams or whatever.
> 
> Right, but each sequence type had it's own corresponding mapping fuctions.

Precisely, I think that's what Alexander was trying to get across, Lisp
didn't have a uniform interface for traversing different types of sequence.

> they had standardized such things.  This would not be particularly
> difficult to do, other than the getting everyone to agree on just what
> the interfaces should be.  But Lisp programmers, are of course, just
> as recalcitrant as Python programmers.

Python programmers tend to accept what the language gives them and use
it and not try to subvert it too much.  I don't say that is good or bad.

> And in Python's case, the reference manual is just an incomplete
> description of the features offered by the implementation, and people
> revel in features that are not yet in the reference manual.

No I don't think so, unless you count some things that are in accepted
PEP's and therefore can be considered part of the reference docs, even
though they haven't yet been merged into the manual.

> That's not ugly.  The fact that CPython has a reference-counting GC
> makes the lifetime of object predictable, which means that like in
> C++, and unlike in Java, you can use destructors to good effect.  This
> is one of the huge boons of C++.  The predictability of lifespan makes
> the language more expressive and powerful.  The move to deprecate
> relying on this feature in Python is a bad thing, if you ask me, and
> removes one of the advantages that Python had over Lisp.

No that's wrong, C++ has no GC at all, reference counting or
otherwise, so its destructors only run when the object is manually
released or goes out of scope.  The compiler normally doesn't attempt
lifetime analysis and it would probably be against the rules to free
an object as soon as it became inaccessible anyway.  Python (as of
2.5) does that using the new "with" statement, which finally makes it
possible to escape from that losing GC-dependent idiom.  The "with"
statement handles most cases that C++ destructors normally handle.

Python object lifetimes are in fact NOT predictable because the ref
counting doesn't (and can't) pick up cyclic structure.  Occasionally a
cyclic GC comes along and frees up cyclic garbage, so some destructors
don't get run til then.  Of course you can manually organize your code
so that stuff with destructors don't land in cyclic structures, but
now you don't really have automatic GC any more, you have (partially)
manual storage management.  And the refcounts are a performance pig in
multithreaded code, because of how often they have to be incremented
and updated.  That's why CPython has the notorious GIL (a giant lock
around the whole interpreter that stops more than one interpreter
thread from being active at a time), because putting locks on the
refcounts (someone tried in the late 90's) to allow multi-cpu
parallelism slows the interpreter to a crawl.

Meanwhile 4-core x86 cpu's are shipping on the desktop, and network
servers not dependent on the complex x86 architecture are using
16-core MIPS processors (www.movidis.com).  Python is taking a beating
all the time because of its inability to use parallel cpu's, and it's
only going to get worse unless/until PyPy fixes the situation.  And
that means serious GC instead of ref counting.

> And it's not bygone -- it's just nichified.  Lisp is forever -- you'll see.

Lisp may always be around in some tiny niche but its use as a
large-scale systems development language has stopped making sense.

If you want to see something really pathetic, hang out on
comp.lang.forth sometime.  It's just amazing how unaware the
inhabitants there are of how irrelevant their language has become.
Lisp isn't that far gone yet, but it's getting more and more like that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can't start Apache on Mac OS X--no listening sockets available?

2007-06-26 Thread 7stud
Well, I'm able to put html pages in /Library/Apache2/htdocs/ and
access them in Safari as I would expect:

http://localhost/test.htm

and I can access the index.html page in that directory:

http://localhost/index.html

and it displays:

It works! Apache 2.2.4

But, if I just use the address http://localhost/ in Safari, this is
displayed:

It works!

Where is that coming from?  Is the original index.html page(before I
changed it and added "Apache 2.2.4") cached by Safari somehow?  That
doesn't make any sense to me because when I explicitly request
index.html, I get the changed output.


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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Twisted
On Jun 25, 2:32 pm, Giorgos Keramidas <[EMAIL PROTECTED]>
wrote:
> > So much for the "free" in "free software". If you can't actually use
> > it without paying money, whether for the software or for some book, it
> > isn't really free, is it?
>
> Please do not confuse the term 'free' in 'free software' with 'gratis'.
>
> 'Gratis', i.e. 'lacking a monetary price tag' is something *very*
> different from the meaning of 'free' in 'free software'.

Having to pay for the documentation, presumably because it's
copyrighted, doesn't strike me as much more "free as in speech" than
it is "free as in beer". Also being dependent on a particular
publisher for access to required documentation violates "free as in no
vendor lock-in", to boot. So anyone saying some "free" software is
unusable without such-and-such an O'Reilly book can go peddle the
software and the book somewhere where spammers are welcome. Being
locked in to O'Reilly being just as bad as being locked in to
Microsoft or Adobe.


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


Re: can't start Apache on Mac OS X--no listening sockets available?

2007-06-26 Thread 7stud
On Jun 26, 1:34 am, 7stud <[EMAIL PROTECTED]> wrote:
> Where is that coming from?  Is the original index.html page(before I
> changed it and added "Apache 2.2.4") cached by Safari somehow?  That
> doesn't make any sense to me because when I explicitly request
> index.html, I get the changed output.

I looked around in Safari for a bit, and I found Empty Cache under the
Safari menu item.  So I emptied the cache and now when I use the
address http://localhost, I get the changed index.html page.  So
Safari was caching the original page.  I guess Safari associate the
address http://localhost with the original index.html page, and Safari
would not display the updated index.html page when I used that address
again.

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Twisted
On Jun 25, 2:28 pm, Giorgos Keramidas <[EMAIL PROTECTED]>
wrote:
> > This is the lowly Notepad, which I'll freely admit is the rusty
> > bicycle of text editors, and it's much easier to use (including the
> > help) than the supposed Mercedes-Benz of editors.
>
> Isn't this always the case?  The 'interface' of a tiny bicycle is
> something which even very young kids can master pretty fast.  On the
> other hand, I'm relatively sure there's at least one valid reason we
> don't let pre-school aged children drive around Mercedes-Benz cars,
> isn't there?

And the myth of the bicycle being easy to learn persists. Did you know
that kids learn better than adults do? Why do kids pick up at least
one language without any conscious effort, while adults trying to
learn one more often struggle in night school?

I know people who find all kinds of vehicles easy to learn but never
mastered a bicycle (despite trying). People, plural, as in more than
one of them.

Anyway, I know which comes with a fatter manual -- the Benz...

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


Dispatching a method using PyobjC Selectors/Methods

2007-06-26 Thread sapsi
Hi,
I am writing a SIMBL plugin for Mail.app, so far it loads and the
correct method has been swizzled. However, i would like to call the
original method and that is where the problem lies.

If you could see the code(below), in console.app, i get the following
error because of old(x)
"
2007-06-26 03:42:04.053 Mail[2600] *** NSRunLoop ignoring exception
'exceptions.TypeError: 'int' object is not callable' that raised
during posting of delayed perform with target 5bd1b10 and selector
'_finalSetup'
"



#saved as MailDump.py
import objc
from Foundation import *
from AppKit import *
WebMessageEditor = objc.lookUpClass('WebMessageEditor')
old=1
swizzled = {}
 #http://end.com/svn/BionicDOM/tags/1.0/
BionicDOMPalette.py
def swizzle(cls, SEL, func):
NSLog(cls)
oldIMP = cls.instanceMethodForSelector_(SEL)
oldMethod = objc.selector(oldIMP.__call__,
selector=oldIMP.selector, signature=oldIMP.signature)
newMethod = objc.selector(func, selector=oldIMP.selector,
signature=oldIMP.signature)
objc.classAddMethod(cls, 'OLD'+SEL, oldMethod)
objc.classAddMethod(cls, SEL, newMethod)
swizzled[(cls, SEL, func)] = (oldMethod, newMethod, oldIMP)
return(oldMethod)
def updateContentsToShowSignature_(self,x):
NSLog("OHMYGOD")
old(x)


class MWM(NSObject):
plugin = None # We will retain a pointer to the plugin to prevent
it being garbage-collected
@classmethod
def sharedInstance(cls): # not strictly necessary, but we only
need one instance of our object
if not cls.plugin:
cls.plugin = cls.alloc().init()
return cls.plugin

@classmethod
def initialize(cls):
old=swizzle(WebMessageEditor,
'updateContentsToShowSignature:', updateContentsToShowSignature_)


#setup.py
# from distutils.core import setup
# import py2app
# plist = dict(
# NSPrincipalClass='MWM',
# CFBundleName='MWM',
# SIMBLTargetApplications=[dict(BundleIdentifier='com.apple.mail',
MinBundleVersion='000', MaxBundleVersion='20')],
# )

# setup(
# plugin=['MailDump.py'],
# options=dict(py2app=dict(
# extension='.bundle',
# plist=plist,
# )),
# )
#Run the following
#python2.4 setup.py py2app -A
#and copy the dist/MailDump.bundle to ~/Library/Application Support/
SIMBL/Plugins/

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


Re: can't start Apache on Mac OS X--no listening sockets available?

2007-06-26 Thread half . italian
On Jun 25, 11:09 pm, 7stud <[EMAIL PROTECTED]> wrote:
> > On Jun 25, 7:23 pm, 7stud <[EMAIL PROTECTED]> wrote:
>
> > > I'm trying to get Apache set up on my system so I can use mod_python.
> > > I installed Apache 2.2.4 according to the following instructions:
>
> > >http://switch.richard5.net/isp-in-a-box-v2/installing-apache-on-mac-o...
>
> > > and everything seemed to install correctly, but I can't start Apache.
> > > I typed in the following command:
>
> > > $ sudo /Library/Apache2/bin/apachectl start
> > > Password:
>
> > > and I got this error message:
>
> > > httpd: Could not reliably determine the server's fully qualified
> > > domain name, using tms-computer.local for ServerName
> > > (48)Address already in use: make_sock: could not bind to address
> > > 0.0.0.0:80
> > > no listening sockets available, shutting down
> > > Unable to open logs
>
> > > Any ideas?
>
> > Do you have "Web Sharing" in the prefs on as well?  
>
> I checked and to my surprise Personal Web Sharing was turned on.  I
> was messing around with it yesterday because I thought that might have
> something to do with my problems, but I couldn't get Personal Web
> Sharing to start--it just said "Web Sharing starting up...", and it
> never did.
>
> Anyway, I turned Personal Web Sharing off, and then the error message
> changed to this:
>
> $ sudo /Library/Apache2/bin/apachectl start
> Password:
> httpd: Could not reliably determine the server's fully qualified
> domain name, using tms-computer.local for ServerName
>
> However, I checked the All Processes page in the Activity Monitor, and
> it said httpd was running.  So I tested my apache installation by
> typing http:/localhost in Safari's address bar, and a page displayed
> saying "It works!".  But I wondered if that page was being served up
> by the pre-installed version of Apache or my new installation.  So, I
> went into my new installation's directory and looked at the file:
>
> /Library/Apache2/htdocs/index.html
>
> and changed the text from "It works!" to "Apache 2.2.4", but when I
> retyped http:/localhost in Safari's address bar, I still got a page
> saying "It works!", so that page is not being served by my new
> installation.

Console and the system logs are an invaluable debugging tool on Macs.
Bet you have some errors there saying why apache couldnt stop/start.

Glad you got it working.

~Sean

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


Tkinter: different results from the same tcl script

2007-06-26 Thread Fabrizio Pollastri
Hello,
in mixed python-tcl programming I found the following different 
behaviours of the same tcl script.

If I type manually in the python interpreter the following lines

 >>> from Tkinter import *
 >>> w = Tk()
 >>> w.tk.evalfile('my_tcl_script.tcl')

where my_tcl_script.tcl is

#!/bin/sh
package require Tk
wm withdraw .
toplevel .root
wm title .root "My title"

I obtain one toplevel window with title "My title", as expected.


The same result is obtained with the tcl shell command

% wish my_tcl_script.tcl


Now, I wish to run the same instructions from a python script. So, I 
written the following script

from time import *
from Tkinter import *
w = Tk()
w.tk.evalfile('my_tcl_script.tcl')
sleep(3)

I expected to see the same toplevel window for 3 seconds, but the result 
of this python script is nothing, no window appears.

If anybody can explain the different behaviour and how to normalize it 
with the correct one, I will be very glad. Thank you in advance.


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


Re: Installing python under the linux

2007-06-26 Thread vedrandekovic

Danyelle Gragsone je napisao/la:
> Hi,
>
> Yeah .. if its ubuntu then you have python already installed.  I would
> suggest that you start reading the documentation on your distro.  How
> did you get your distro if you don't know what it is?  That concerns
> me a bit.  Ubuntu has alot of documentation as well as a help channel
> on irc.  irc.freenode.net #ubuntu.  You can pull up alot of
> documentation by just typing "ubuntu documentation" or "ubuntu guides"
> in google.
>
> good luck!
> Danyelle
>
> On 6/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > Danyelle Gragsone je napisao/la:
> > > Greetings,
> > >
> > > Python is usally already installed on most distros.  In a terminal
> > > window type "python" to see if something happens.  Also please provide
> > > what distro you are running.
> > >
> > > Danyelle
> > >
> > > On 6/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > > Hello,
> > > >
> > > > I have problem with installing Python on the Linux platform.Can you
> > > > tell me step by step how can I install
> > > > python on linux  ( please detailed ) , because I don't know anything
> > > > about linux and I really don't understand
> > > > python documentation about installing python on linux.
> > > >
> > > >
> > > >
> > > > Thanks!!!
> > > >
> > > > --
> > > > http://mail.python.org/mailman/listinfo/python-list
> > > >
> >
> > Helo,
> >
> > Probably my distro is "ubuntu"  <--- I don't what is it, and ' want
> > install/build python from source
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >

Hi again,

This previously was very useful THANKS. I just want ask you is there,
is there any folder with that basic Python
on ubuntu linux where can I find file "Grammar" and change the names
of python keywords.
 
THANKS AGAIN!

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


Re: Tkinter: different results from the same tcl script

2007-06-26 Thread half . italian
On Jun 26, 1:06 am, Fabrizio Pollastri <[EMAIL PROTECTED]> wrote:
> Hello,
> in mixed python-tcl programming I found the following different
> behaviours of the same tcl script.
>
> If I type manually in the python interpreter the following lines
>
>  >>> from Tkinter import *
>  >>> w = Tk()
>  >>> w.tk.evalfile('my_tcl_script.tcl')
>
> where my_tcl_script.tcl is
>
> #!/bin/sh
> package require Tk
> wm withdraw .
> toplevel .root
> wm title .root "My title"
>
> I obtain one toplevel window with title "My title", as expected.
>
> The same result is obtained with the tcl shell command
>
> % wish my_tcl_script.tcl
>
> Now, I wish to run the same instructions from a python script. So, I
> written the following script
>
> from time import *
> from Tkinter import *
> w = Tk()
> w.tk.evalfile('my_tcl_script.tcl')
> sleep(3)
>
> I expected to see the same toplevel window for 3 seconds, but the result
> of this python script is nothing, no window appears.
>
> If anybody can explain the different behaviour and how to normalize it
> with the correct one, I will be very glad. Thank you in advance.
>
> F. Pollastri

You need a call to `w.mainloop()`

w=Tk()
w.after(3000, lambda: w.quit())
w.mainloop()

~Sean

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Giorgos Keramidas
On Tue, 26 Jun 2007 07:40:55 -, Twisted <[EMAIL PROTECTED]> wrote:
>On Jun 25, 2:32 pm, Giorgos Keramidas <[EMAIL PROTECTED]>
>wrote:
>>> So much for the "free" in "free software". If you can't actually use
>>> it without paying money, whether for the software or for some book,
>>> it isn't really free, is it?
>>
>> Please do not confuse the term 'free' in 'free software' with 'gratis'.
>>
>> 'Gratis', i.e. 'lacking a monetary price tag' is something *very*
>> different from the meaning of 'free' in 'free software'.
>
> Having to pay for the documentation, presumably because it's
> copyrighted, doesn't strike me as much more "free as in speech" than
> it is "free as in beer".

You don't have to "pay for the documentation because it is copyrighted".
You can _download_ the Emacs manual in any format you are more
comfortable with.

See for example:

  http://www.gnu.org/manual/manual.html

This page lists downloadable documentation in nicely formatted HTML or
PDF formats, which is available without any sort of monetary charge.

> Also being dependent on a particular publisher for access to required
> documentation violates "free as in no vendor lock-in", to boot. So
> anyone saying some "free" software is unusable without such-and-such
> an O'Reilly book can go peddle the software and the book somewhere
> where spammers are welcome. Being locked in to O'Reilly being just as
> bad as being locked in to Microsoft or Adobe.

Since you are not obliged to _pay_ for the O'Reilly version, this entire
paragraph is both meaningless and moot.  Feel free to grab an online
copy of the manual, or install the documentation of Emacs using your
favorite distribution's packaging tools.  There is absolutely no
"lock-in" anywhere near Emacs.

- Giorgos

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


Re: Face Recognition

2007-06-26 Thread Diez B. Roggisch
Henrik Lied wrote:

> Hi there!
> 
> Has anyone made effort to try to create a python binding to a facial
> recognition software [1]?
> 
> For those of you with some experience - would this be very hard?


OpenCV has a python-binding. And a ctypes-binding.

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


Re: can't start Apache on Mac OS X--no listening sockets available?

2007-06-26 Thread 7stud
> Console and the system logs are an invaluable debugging tool on Macs.
> Bet you have some errors there saying why apache couldnt stop/start.
>

What/where is Console and how do I look at the system logs?

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


Re: [OT] can't start Apache on Mac OS X--no listening sockets available?

2007-06-26 Thread Bruno Desthuilliers
7stud a écrit :
> I'm trying to get Apache set up on my system so I can use mod_python.
> I installed Apache 2.2.4 according to the following instructions:
> 
> http://switch.richard5.net/isp-in-a-box-v2/installing-apache-on-mac-os-x/#comment-30704
> 
> and everything seemed to install correctly, but I can't start Apache.
> I typed in the following command:
> 
> $ sudo /Library/Apache2/bin/apachectl start
> Password:
> 
> and I got this error message:
> 
> httpd: Could not reliably determine the server's fully qualified
> domain name, using tms-computer.local for ServerName
> (48)Address already in use: make_sock: could not bind to address
> 0.0.0.0:80
> no listening sockets available, shutting down
> Unable to open logs
> 
> Any ideas?
> 

yes : please post on a Mac newsgroup. This has nothing to do with Python.

This group is highly tolerant[1], but you'll probably find the best 
answers on a mac-related newsgroup, because that's where the Mac expert 
are (or at least are supposed to be).

[1] as a matter of fact, you got some answers to a totally OT post not 
even labelled as such - on some ng you would have been shot down in 
flames instead...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Gian Uberto Lauri
> "n" == nebulous99  <[EMAIL PROTECTED]> writes:

n> On Jun 22, 6:32 pm, Cor Gest <[EMAIL PROTECTED]> wrote:
>> > HOW IN THE BLOODY HELL IS IT SUPPOSED TO OCCUR TO SOMEONE TO
>> ENTER > THEM, GIVEN THAT THEY HAVE TO DO SO TO REACH THE HELP THAT
>> WOULD TELL > THEM THOSE ARE THE KEYS TO REACH THE HELP?!
>> 
>> What's your problem ?
>> 
>> Ofcourse a mere program-consumer would not look what was being
>> installed on his/her system in the first place ...  So after some
>> trivial perusing what was installed and where : WOW Look, MA !
>>  it's all there!
>> 
>> lpr /usr/local/share/emacs/21.3/etc/refcard.ps or your
>> install-dir^ ^ or your
>> version.^

n> So now we're expected to go on a filesystem fishing expedition
n> instead of just hit F1? One small step (backwards) for a man; one
n> giant leap (backwards) for mankind. :P

Waring, possible ID TEN T detected!

There's a program called find, not this intuitive but worth learning

It could solve the problem from the root with something like

find / -name refcard.ps -exec lpr {} \; 2> /dev/null

This  line  requires some  brain  and  some  learning, true,  but  the
documents should be on your  HD, unless you avoided installing the man
to save space. 

About the brain, you should have received like me a standard issue one
at least (or maybe a better one).

>> But then again buying the GNU-book from 'O Reilly would have solved
>> it in the utmost nicest possible of ways anyway.

n> So much for the "free" in "free software". If you can't actually
n> use it without paying money, whether for the software or for some
n> book, it isn't really free, is it?

GNU books ARE free, and come in both printed and electronic form.

No excuses. 

BTW, buing a GNU book is a good way to finance FSF.

And from your too-lazy (ID TEN T like) point of view even freedom
itself is not free, since its defence has a cost.

-- 
 /\   ___
/___/\_|_|\_|__|___Gian Uberto Lauri_
  //--\| | \|  |   Integralista GNUslamico
\/ e coltivatore diretto di Software

A Cesare avrei detto di scrivermi a [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-26 Thread tony . theodore
On Jun 21, 4:53 am, Stephen R Laniel <[EMAIL PROTECTED]> wrote:
> Before I ask anything, let me note that this is surely an
> old question that has inspired its share of flame wars; I'm
> new to Python, but not new to how Internet discussions work.
> So if there's a canonical thread or web page that documents
> the whole battle, feel free to point me to it.
>
> Reading [1], I wonder: why isn't the compiler making better
> use of (purely optional) type labeling? Why not make a compiler
> directive so that
>
> a) it will check the types of all my arguments and return
>values, and maybe even
> b) do some type inference up the call stack?
>

You might like to look at traits http://code.enthought.com/traits/

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Gian Uberto Lauri
> Long count = 12.19.14.7.15; tzolkin = 1 Men; haab = 3 Tzec.
> I get words from the Allmighty Great Gnus that
> "T" == Twisted  <[EMAIL PROTECTED]> writes:

T> And the myth of the bicycle being easy to learn persists. Did you
T> know that kids learn better than adults do? Why do kids pick up at
T> least one language without any conscious effort, while adults
T> trying to learn one more often struggle in night school?

Mostly because  they block themselves  with strange fears and  due bad
teaching, the "fear"  of a test, the lack  of fun, the "constriction",
all block  adults learning new  language. 

Pick an  over 30, overloaded  with (often) frustrating work,  and give
her  an university  level  course in  languages  with grammars  and/or
alphabets  completly  different  from  those  she uses  (yesss,  I  am
thinking of a woman, my wife...) like Arab (alphabet and some grammar)
and  Turkish (its grammar  sound lispish  to my  ears), and  she'll go
ahead without "fatigue" and with flying colours.

Children pick  up other language without any  conscious effort because
either they learn  it by using with parents,  relatives and friends or
they are involved in a game-like style of learning.

Why else hacker prize fun this much ? :) :)

T> I know people who find all kinds of vehicles easy to learn but
T> never mastered a bicycle (despite trying). People, plural, as in
T> more than one of them.

Again, fear, or maybe, some  malfunction in the balancing organs.  But
fear mainly. You do not see what keeps a bike upright and running, you
have to trust that you can.

You can walk on a 4 inch  wide stripe on a floor without problems, but
when it is a 4 inch wide bar some feet over the floor...

-- 
 /\   ___
/___/\_|_|\_|__|___Gian Uberto Lauri_
  //--\| | \|  |   Integralista GNUslamico
\/ e coltivatore diretto di Software

A Cesare avrei detto di scrivermi a [EMAIL PROTECTED]

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


text-mode tree viewer?

2007-06-26 Thread Torsten Bronger
Hallöchen!

I'm looking for a package/routine that can convert

[["Peter",
   ["Ian", 
  [["Randy",
 ["Clara"],
  "Paul", 
 ["Mary",
   ["Arthur"]]]

into

  +---> Peter
  |   |
  |   +---> Ian
  |   |
  |   +---> Randy
  |   |
  |   +---> Clara
  |
  +---> Paul
  |
  +---> Mary
  |
  +---> Arthur

Neither the input data structure nor the output must be exactly like
here but probably you got the idea.  Thank you for any hints!

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
  (See http://ime.webhop.org for ICQ, MSN, etc.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite newbie questions

2007-06-26 Thread Carsten Haese
On Tue, 26 Jun 2007 08:38:29 GMT, Dennis Lee Bieber wrote:
>   In both cases, the whole idea behind letting the adapter do
> parameter substitution is that the adapter will add the appropriate
> delimiters (quote marks, for the most part) needed for the data type.

That's only the case if the adapter is dumb enough to stuff the parameter into
the query as a literal value. Most adapters aren't that dumb.

--
Carsten Haese
http://informixdb.sourceforge.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing python under the linux

2007-06-26 Thread Paul Boddie
On 25 Jun, 22:50, Grant Edwards <[EMAIL PROTECTED]> wrote:
>
> I really do not recommend installing from source for somebody
> like you who knows nothing about Python or Linux.  Can explain
> why you think you want to install Python from source instead of
> using the Python that's already installed on your computer?

The inquirer has previously shown an interest in changing Python's
keywords, so although recommending that someone use the installed
Python remains sound advice for most situations, I think compilation
from source is the only way to go here, at least for Python 2.4 and
earlier - I don't know what grammar tricks were added to Python 2.5
and later, but I imagine that you'd still need to compile everything
after modifying any grammar description file that may be provided.

To compile from source, the inquirer should read the README file
provided in the source distribution, paying attention at the very
least to the section entitled "If you don't read instructions". The
source distribution is found here:

http://www.python.org/download/

Paul

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


Re: simplifying algebraic expressions

2007-06-26 Thread Robin Becker
> Hi,
> 
> Are there any libraries for manipulating algebraic expression trees?
> In particular, take an expression tree and simplify it down.
> 
> I'm working up the next release of PyGene, the genetic programming and
> genetic algorithms library.
> 
> Part of PyGene works with trees holding algebraic expressions. For
> example, the expression:
>   f = x**2 + sqrt(y) + 7
> is represented as the tree:
> 
>   +
>  **
>  x
>  2
>  +
>  sqrt
>  y
>  7
> 
> My GP code is successfully evolving expression trees to solve problems,
> however they're often full of redundancies, eg adding y in one part then
> subtracting y later on.

I have seen this sort of evolution strategy in the past and it's very wrong to 
attempt to simplify outside the genetic framework. The implication is that you 
know better than the overall fitness requirement. The additional expressions 
and 
redundancies allow for extra mutation and combination possibilities which is a 
good thing for the whole population. If you must, add the requirement to the 
target ie give extra fitness points to organisms which perform efficiently.
-- 
Robin Becker

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


Customizable GUI package for Win$?

2007-06-26 Thread Alex Sentry
I want to know which GUI package should I turn to if I want to make something 
resembling MS OneNote.

A lot of packages have "Notebook" style widgets or tabbed stuff, but wxPython's 
are not really customizable from what I know, and neither are TKs. I'm not sure 
about pyGTK and it's primarily a Linux GUI package. I'd like to color 
them(gradients), make them have a custom shape, and other shiny not-so-native 
stuff. 
Yes, to some olde-schoole hackers it might seem shallow, but in all honesty, a 
slick good comfortable AND good looking interface is like a modern car. Sure, 
to get from point A to B you could use a lawnmower, but we're not doing that, 
and for a reason, right? :)

   
-
Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, 
when. -- 
http://mail.python.org/mailman/listinfo/python-list

Re: simplifying algebraic expressions

2007-06-26 Thread DavidM
On Tue, 26 Jun 2007 11:11:39 +0100, Robin Becker wrote:

> I have seen this sort of evolution strategy in the past and it's very wrong 
> to 
> attempt to simplify outside the genetic framework. The implication is that 
> you 
> know better than the overall fitness requirement. The additional expressions 
> and 
> redundancies allow for extra mutation and combination possibilities which is 
> a 
> good thing for the whole population. If you must, add the requirement to the 
> target ie give extra fitness points to organisms which perform efficiently.

I'm sorry, but there's something important I forgot to mention - I only
want to do the simplification *after* a winning successful organism has
evolved and satisfied the fitness function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing python under the linux

2007-06-26 Thread Stefan Behnel
[EMAIL PROTECTED] wrote:
> is there any folder with that basic Python
> on ubuntu linux where can I find file "Grammar" and change the names
> of python keywords.

AFAICT, the Grammar file is not part of the binary installation.

So, download the Python source distribution from python.org and unpack it if
you want to play with it.

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


Re: simplifying algebraic expressions

2007-06-26 Thread Mark Westwood
Hi David

It seems that all you are asking for are the capabilities of
Mathematica or Maple or some other CAS.  A quick Google reveals that
there is a CAS written in Python, called SAGE.  That might be a good
place to start; but I'll admit that I know nothing about it.

I'm with Robin Becker on this one, if GP is good enough for your
problem, then the answers it produces should be good enough.  Set the
fitness criteria in favour of shorter rather than longer expressions
and let you system run a little longer.  Not only do you avoid having
to integrate into your system a novel library, you avoid a world of
pain trying to decide whether or not x**2 is 'simpler' than x*x, (is
x**4 'simpler' than (x**2)*(x**2) ?) and making sure that you don't
define any circular simplification rules.

If you don't like the computer algebra approach, you could google for
'program transformation' and follow some of the links.

Good luck !

Mark Westwood

On 26 Jun, 12:06, DavidM <[EMAIL PROTECTED]> wrote:
> On Tue, 26 Jun 2007 11:11:39 +0100, Robin Becker wrote:
> > I have seen this sort of evolution strategy in the past and it's very wrong 
> > to
> > attempt to simplify outside the genetic framework. The implication is that 
> > you
> > know better than the overall fitness requirement. The additional 
> > expressions and
> > redundancies allow for extra mutation and combination possibilities which 
> > is a
> > good thing for the whole population. If you must, add the requirement to the
> > target ie give extra fitness points to organisms which perform efficiently.
>
> I'm sorry, but there's something important I forgot to mention - I only
> want to do the simplification *after* a winning successful organism has
> evolved and satisfied the fitness function.


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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-26 Thread harri

Bruno Desthuilliers wrote:
[...]
>
> It seems obvious from this that static typecheking would require
> dropping all dynamism from Python - then turning it into another, very
> different (and mostly useless as far as I'm concerned) language. IOW :
> you can't have Python *and* static typechecks - both are mutually
> exclusive. Hence my answer : if you want static typecheking, you'll have
> to use another language - one way or another.

Well, static typing for me is usually the way to get the last speed
required once the
algorithmic improvements are exhausted.

The language Pyrex uses combines dynamic and static typing in a very
useful manner.

"Practicality beats purity"

Harri

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Martin Gregorie
Twisted wrote:
> 
> First, I didn't claim the ideal WP was necessarily perfectly WYSIWYG.
 >
Maybe I should have clarified my viewpoint. When it comes to programs 
that operate on the content of textual documents a word processor is 
WYSIWYG by definition. Anything else is a text editor. You may have a 
different view but that's mine.

> Your quiet change from discussing word processing to discussing
> WYSIWYG is interesting.
 >
See above. We were actually discussing text editors whose formatting 
capabilities (unless they are syntax-sensitive) are generally limited to 
line wrapping and auto-indentation. You introduced more complex document 
reformatting - something that I regard as a capability of word 
processors rather than text editors.

> Programming in role-playing game? And I meant my roguelike-filesystem-
> interface suggestion at least partly in jest...
>
RPG is "Report Generating Program" in the context of programming 
languages. The RPG language is horrid: its a bastardized, fixed column 
assembler derivative that's been shoehorned into a typical report 
generator's processing loop. Even PL/1 and COBOL shine as paragons of 
programming language design by comparison.

> If it's so great, why hasn't it, and why hasn't OS/400 managed to
> escape from persistent obscurity?
>
A fair question. I don't know, but it probably has a lot to do with AIX 
and the UNIX command shell with its great power but lack of consistency 
in naming, etc.

> In other words, the implementation was a dog. That doesn't refute the
> basic concept's validity.
 >
True, but doing better would be really hard because of all the 
information and context that would need to be associated with every 
mouse click in case it was needed to record a macro. At best it might 
make macro recording tedious. At worst it could make the whole GUI 
unresponsive.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org   |
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text-mode tree viewer?

2007-06-26 Thread Martin Skou
Not quite, but almost:


data=[["Peter",
["Ian",
   [["Randy",
  ["Clara"],
   "Paul",
  ["Mary",
["Arthur"]]]


def show(data,level):
for i in data:
if i.__class__.__name__=='list':
show(i,level+1)
else:
print '%s->%s' % ('-'*level,i)


show(data,0)


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


Re: Python Info.

2007-06-26 Thread Joe Riopel
On 6/26/07, kaens <[EMAIL PROTECTED]> wrote:
> It was like being slapped with the mid-90s
That was awesome.

> On 6/26/07, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> > Brandon wrote:
> > > Check it out: www.BrandonsMansion.com
That is horrible.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Portable general timestamp format, not 2038-limited

2007-06-26 Thread Martin Gregorie
Paul Rubin wrote:
> Martin Gregorie <[EMAIL PROTECTED]> writes:
 pretend the leap seconds never happened, just as Java does.
>>> Which leaves you about 30 seconds out by now - smelly.
>> Easy solution: always read Zulu time directly from a recognized
>> real-time clock
> 
> That's no good, it doesn't let you accurately compute the difference
> between timestamps.
 >
I don't recall the OP mentioning time interval computability - just a 
requirement for sub second accuracy timestamps.

> If you want a precise timestamp and you don't
> want to deal with leap seconds, TAI is one approach.
 >
TAI? Care to provide a reference?

> There is
> currently some political pressure to get rid of leap seconds to ease
> computer synchronization, but (at least some of) the astronomy
> community is opposed; see
> 
Yes, that's just silly, especially because if you're trying to do 
date-time calculations across historic time or non-western calendars 
(e.g. Islamic) the minuscule accumulated leap second error is dwarfed by 
  all the other uncertainties.

> No do NOT use stratum 1 sources for something like this.
 >
Fair comment. I was thinking about network delays and jitter and should 
not have forgotten Stratum 1 congestion. Of course, you could always run 
your own local Stratum 1 clock if accuracy is that important.

IIRC the major American interbank networks use GPS as their time 
standard because its about the only system that can avoid jitter and 
propagation delays over continental areas without introducing smoothing 
  engines, e.g. ntpd.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org   |
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text-mode tree viewer?

2007-06-26 Thread Torsten Bronger
Hallöchen!

Martin Skou writes:

> Not quite, but almost:
>
>
> data=[["Peter",
>["Ian",
>   [["Randy",
>  ["Clara"],
>   "Paul",
>  ["Mary",
>["Arthur"]]]

This was flawed, there were two brackets too much:

data=[["Peter",
   ["Ian",
   ["Randy",
 ["Clara",
  "Paul",
 ["Mary",
   ["Arthur"]]]

> def show(data,level):
>   for i in data:
>   if i.__class__.__name__=='list':
>   show(i,level+1)
>   else:
>   print '%s->%s' % ('-'*level,i)
>   
>   
> show(data,0)

It doesn't show Paul and Mary on the same level.  I (think I) solved
the problem with this:

def print_tree(tree, line_columns=[0]):
for i, item in enumerate(tree):
current_line = u""
for j, pos in enumerate(line_columns):
current_line += (pos - j) * " " + "|"
print current_line
if isinstance(item, list):
print current_line[:-1] + "+---> " + item[0]
new_line_columns = line_columns + [line_columns[-1] + 6 + 
len(item[0]) // 2]
if i == len(tree) - 1:
del new_line_columns[-2]
print_tree(item[1], new_line_columns)
elif isinstance(item, basestring):
print current_line[:-1] + "+---> " + item

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
  (See http://ime.webhop.org for ICQ, MSN, etc.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Collections of non-arbitrary objects ?

2007-06-26 Thread walterbyrd
> > On Jun 24, 10:31 pm, Bruno Desthuilliers
> > <[EMAIL PROTECTED]> wrote:
>
> You perhaps don't know this, but most statically typed languages have
> the notion of either pointers or references, that can cause similar -
> and usually worse - problems.
>

Yes, but those languages also have the notion of structures that do
not allow arbitrary collections. That is what I was wondering about
when I started the thread. It's fine that python has four different
ways of creating collections of arbitrary data types, but I thought it
might be helpful if python had, at least, one way of a creating a
collection of non-arbitrary data.

>
> You do program carefully, don't you ?-)
>

I try. But things like typos are a normal part a life.

>
> Now did you actually had any effective problem with Python's dynamism ?
> Or are you just scared ?
>

Just scared.

 > You know, Python is now something like 17 years old, and is used by
a
> *lot* of peoples for a *lot* of programs - some of them far from
> trivial. I think you can be confident in this experience. IOW, just
> write your code, and you'll find out that the kind of problems you seem
> to fear so much will not happens that often.
>

Of course, BASIC is over 40 years old, also used by a *lot* of people.
A lot of non-trivial apps have been written in BASIC. But, BASIC is
often criticized for it's lack of structure. A language's longevity,
and/or popularity, don't mean there isn't room for improvement. Guido
must think python has a lot of room for improvement since he's
completely throwing out backward compatibility with python 3000.

>
> You don't use tuples "instead of" lists. Lists are collections, tuples
> are structured data.
>

It seems to me that tuple are essentially immutable lists. So why
impose that immutability restriction on a data collection? Why not
just have lists and not tuples? What can a tuple do that a list can
not do? Why was python designed so that tuples could be used for
dictionary indexes, but not lists? Could it be because imposing that
restriction on a data collection insures a certain degree of
integrity? My point is: sometimes imposing some restrictions can give
a degree in built-in integrity. Maybe you don't need that integrity
insurance, if you code carefully enough, but can you always count on
that?

BTW: I'm not assuming that it will always be me running my own app.
Sure, if an exception occureed while I was running my own app, I'd
probably know what to do. But if somebody else (who - god forbid -
didn't know python was running the app, things might be more difficult.

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


Problem with wxPython

2007-06-26 Thread Ali
Hi

I'm not sure if this is the right place to post, pardon me if it's not.
I'm having a problem with an application written with wxpython. The frame
seems only to refresh when moving my mouse of it, though i frequently call:
frame.Refresh(True). In fact, that line is called by another thread, right
after having modified some of the frames attributes.

here are some snippets of code :
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
self.queue=Queue.Queue(0)
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
iconFile = "gnobots2.xpm"
icon1 = wx.Icon(iconFile, wx.BITMAP_TYPE_XPM)
self.SetIcon(icon1)
self.panel_1 = wx.Panel(self, -1)
self.panel_1.Bind(wx.EVT_PAINT, self.on_paint) 
self.static_line_1 = wx.StaticLine(self, -1)
self.text_ctrl_1 = 
wx.TextCtrl(self, -1, 
"",style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP)

self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("Simulation")
self.SetSize((600, 400))
self.static_line_1.SetBackgroundColour(wx.Colour(0, 0, 0))
self.text_ctrl_1.SetMinSize((600, 100))
# end wxGlade

self.blues = []

def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
sizer_1.Add(self.static_line_1, 0, wx.EXPAND, 0)
sizer_1.Add(self.text_ctrl_1, 0, wx.ADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade

def on_paint(self, event):
dim = self.panel_1.GetSize()
dc = wx.PaintDC(self.panel_1)
total_types = len(Parameters.DEMANDERS_NUMBERS)
large = dim[1] / (total_types + 3)
long = dim[0] / Parameters.NUMBER_OF_BLUES - 1
for type in range(total_types):
counter = long
for blue in self.blues:
green = (int(blue.biais[type])) * 20
red = - green
if red<0:
red=0
if green<0:
green=0
color = wx.Colour(red, green, 75)
dc.SetPen(wx.Pen(color,long))
dc.DrawLine(counter,50 + (type * (20 +
large)),counter, 50 + large + (ty
pe * (20 + large)))
counter += long
while(not self.queue.empty()):
self.text_ctrl_1.AppendText(str(self.queue.get()) + "\n")


# end of class MyFrame

class MyApp( wx.App):
def OnInit(self):
self.text = ""
self.frame = MyFrame(None , -1, 'Frame Window Demo') 
self.frame.Show(True) 
self.SetTopWindow(self.frame) 
return True
#this is called by an external thread
def paint(self, blues):
self.frame.blues = blues
self.frame.Refresh(True)



I don't know if that is enough information, feel free to ask for more.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: eggs considered harmful

2007-06-26 Thread Harry George
[EMAIL PROTECTED] (John J. Lee) writes:

> Harry George <[EMAIL PROTECTED]> writes:
>> [EMAIL PROTECTED] (John J. Lee) writes:
> [...]
>>> 2. You can run your own private egg repository.  IIRC, it's as simple
>>> as a directory of eggs and a plain old web server with directory
>>> listings turned on.  You then run easy_install -f URL package_name
>>> instead of easy_install package_name .  The distutils-sig archives
>>> will have more on this.
>>
>> Again, not speaking for anyone else: With 500 OSS packages, all of
>> which play by the same tarball rules, we don't have resources to
>> handle eggs differently.
>
> You said earlier:
>
>> The rules are that a) a very few authorized downloaders obtain
>> tarballs and put them in a depot and b) other users get tarballs from
>> the depot and build from source.
>
> Not sure how this differs significantly "from running a repository",
> in the sense I use it above.
>
>
> John

Significant differences:

"depot": Place(s) where tarballs can be stored, and can then be
reached via http.  

"private egg repository": Tuned to the needs of Python eggs.  E.g.,
not scattered over several directories or several versions.

Thus a depot of self-contained packages can handle:

1. Multiple "releases" of the depot live at the same time.

2. Packages factored into CD-sized directories (not all in one "-f" location)

3. Multiple versions of Python, without having a new egg for each.


4. Multiple target platforms.  Various *NIX and MS Win and Mac systems
-- each at their own OS versions and own compiler versions.  All
without having platform-specific and compiler-specific eggs.

5. Different package version selections based on compatibility with
other (non-Python) packages.  E.g., to tune for GIS systems vs 3D
animation systems vs numerical analysis systems vs web server systems.

6. Refresh process which does not need to fiddle with egg-ness, or
even know about Python.  Everything is a tarball.


-- 
Harry George
PLM Engineering Architecture
-- 
http://mail.python.org/mailman/listinfo/python-list


Change Geany Syntax Highlighting

2007-06-26 Thread Scott
Hi,

 I think I may have finally found a IDE/text editor that I like,
but, it still haves one problem.  Geany haves syntax highlighting, but
it is not very good for Python.  It only seems to have a couple
different colours.  One for text and another for modules/classes/
functions.  Is it possible to change the syntax highlighting for
Python, so it highlights more and uses more different colours?  I
really liked the syntax highlighting for Python in kwrite/kate, but
did not like the bugs.

Your friend,
Scott

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


_hashlib portability issue

2007-06-26 Thread Olivier Feys
Hi all,

I build python 2.5 on linux-x86-64 (centos).
Why is lib-dynload/_hashlib.so dynamically linked with libssl.so.0.9.7 
and not with libssl.so that points on it (same thing for libcrypto.so)?
This causes problems when copying all the python distribution and 
running it on a different os, where the theses lib versions are not 
allways the same.
Is it possible to configure that ?

thanks,

Olivier

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


Re: text-mode tree viewer?

2007-06-26 Thread Martin Skou
Torsten Bronger wrote:
> 
> It doesn't show Paul and Mary on the same level.  I (think I) solved
> the problem with this:
> 

I could do so if Poul was in a list of his own, like "Arthur" and "Clara".

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


Leo 4.4.3 final released

2007-06-26 Thread Edward K Ream
Leo 4.4.3 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://webpages.charter.net/edreamleo/intro.html

The highlights of Leo 4.4.3:

- Added support for chapters in Leo's core.
- Added support for zipped .leo files.
- Added a leoBridge module that allows full access to all of Leo's
capabilities
  from programs running outside of Leo.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Added support for @enabled-plugins nodes in settings files.
- Added support for @open-with nodes in settings files.
- Added support for @bool write_strips_blank_lines setting.
- The__wx_gui plugin is now functional.
- Leo can use aspell on Linux when using Python 2.5 or later.
- @test nodes can now be run from any .leo file.
- Many minor improvements, new settings, commands and bug fixes.

Links:
--
Leo:  http://webpages.charter.net/edreamleo/front.html
Home: http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:  http://leo.tigris.org/source/browse/leo/
Quotes:   http://webpages.charter.net/edreamleo/testimonials.html

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: Installing python under the linux

2007-06-26 Thread vedrandekovic
Hello,

>No.  The only way to change the keywords would be to edit the
>Python source and re-compile it.

This was very helpful information , I already know that but I don't
know how
to that.PLEASE HELP ME ABOUT THIS, I WILL BE VERY GRATEFUL TO YOU.

( IF you can please step by step how to I install that source )

 
THANKS

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Matthias Buelow
Twisted wrote:

[...]

Hey dude,

get back to selling used cars and leave us computer geeks alone, will ya?

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


Re: Collections of non-arbitrary objects ?

2007-06-26 Thread Bruno Desthuilliers
walterbyrd a écrit :
>>> On Jun 24, 10:31 pm, Bruno Desthuilliers
>>> <[EMAIL PROTECTED]> wrote:
>> You perhaps don't know this, but most statically typed languages have
>> the notion of either pointers or references, that can cause similar -
>> and usually worse - problems.
>>
> 
> Yes, but those languages also have the notion of structures that do
> not allow arbitrary collections. 

Ever played with casting in C ?

> That is what I was wondering about
> when I started the thread. It's fine that python has four different
> ways of creating collections of arbitrary data types, but I thought it
> might be helpful if python had, at least, one way of a creating a
> collection of non-arbitrary data.

As I explained, while technically possible (and not specially 
difficult), this is a waste of time given Python's dynamism.

>> You do program carefully, don't you ?-)
>>
> 
> I try. But things like typos are a normal part a life.

So are they in any language. I fail to see much difference here.

>> Now did you actually had any effective problem with Python's dynamism ?
>> Or are you just scared ?
>>
> Just scared.

So take a deep breath and try to just do the simplest thing (in this 
case: using builtin collection types). Usually, it JustWorks(tm).

>  > You know, Python is now something like 17 years old, and is used by
> a
>> *lot* of peoples for a *lot* of programs - some of them far from
>> trivial. I think you can be confident in this experience. IOW, just
>> write your code, and you'll find out that the kind of problems you seem
>> to fear so much will not happens that often.
> 
> Of course, BASIC is over 40 years old, also used by a *lot* of people.

Not the same kind of people I'd say !-)

> A lot of non-trivial apps have been written in BASIC. But, BASIC is
> often criticized for it's lack of structure.

Old time basic effectively lacks of "structure", since it uses goto's 
instead of functions, loops and conditionals (google for "structured 
programming").

What I meant here is that one of the lessons of this collective 
experience is that 'typed' containers are more often harmful than useful.

> A language's longevity,
> and/or popularity, don't mean there isn't room for improvement. 

Indeed. But declarative static typechecking wouldn't be an improvement.

> Guido
> must think python has a lot of room for improvement since he's
> completely throwing out backward compatibility with python 3000.

Not "completely throwing out". Just allowing *some* major breakages - 
the kind you usually get with each major release of other languages, but 
that Python managed to avoid as much as possible so far.

>> You don't use tuples "instead of" lists. Lists are collections, tuples
>> are structured data.
>>
> 
> It seems to me that tuple are essentially immutable lists.

They are not (even if you can use them that way too). FWIW and IIRC, 
this is a FAQ.

> So why
> impose that immutability restriction on a data collection?

Because tuples are *not* collections. They are *structured data*. The 
canonical tuple is a SQL database row.

> Why not
> just have lists and not tuples?

because tuples are not lists.

> What can a tuple do that a list can
> not do?

Be immutable.

> Why was python designed so that tuples could be used for
> dictionary indexes, but not lists?

How would you compute a hash from a generic mutable collection ?

> Could it be because imposing that
> restriction on a data collection insures a certain degree of
> integrity? 

Once again: tuples are *not* collections. Would you define a string as a 
collection ?

> My point is: sometimes imposing some restrictions can give
> a degree in built-in integrity.

Yes. But the kind of restriction you're talking about won't buy you 
much, as I already explained, and, in practice, happens to be mostly 
useless.

> Maybe you don't need that integrity
> insurance, if you code carefully enough,

Maybe you don't need that "integrity insurance", period ?-)

> but can you always count on
> that?

It seems that tens of thousands of Python users are doing fine without this.

> BTW: I'm not assuming that it will always be me running my own app.
> Sure, if an exception occureed while I was running my own app, I'd
> probably know what to do. But if somebody else (who - god forbid -
> didn't know python was running the app, things might be more difficult.
> 
The canonical solution is to have an application-level error handler 
that logs uncaught exceptions (so the developper can get at them), 
display a user-friendly error message (eventually giving the user a way 
to submit a bug report to the developper), and try to crash as cleanly 
as possible.

However careful and serious you are wrt/ programming and testing, your 
program *will* have bugs (unless it's some kind of hello world). Better 
learn to live with it.

Let's suppose you implement a restrictedList. It of course raises an 
exception when trying to add a 'non-compliant' item. All this happening 
at runtime, of

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread David Kastrup
Matthias Buelow <[EMAIL PROTECTED]> writes:

> Twisted wrote:
>
> [...]
>
> Hey dude,
>
> get back to selling used cars and leave us computer geeks alone,
> will ya?

Well, how will his customers react to the stories about avoiding
Mercedes cars because of people getting hit in the face by the crank
start?

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread notbob
On 2007-06-25, Giorgos Keramidas <[EMAIL PROTECTED]> wrote:

> X11 interface.  I don't see why Notepad is special in any way here.

It's not.  I discovered, quite by accident, wordpad is the superior
text editor in windows.  It even properly formats those cryptic brag
pages crackers put in cracked software.

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Bjorn Borud
[Robert Uhl <[EMAIL PROTECTED]>]
| 
| Once again I am forced to wonder if you have _ever_ actually used
| emacs.  find-file has tab completion: hit tab without anything typed, and
| it displays _everything_ in the directory; type a few characters to
| narrow it down; hit tab to complete the filename and be done with
| it.

...and of course, in addition you have access to history so you can
easily find previous parameters and edit them.  this makes it very
efficient when you need to fiddle about in deep directory trees in a
way no GUI can yet offer.

...and then there's bookmarking, which is very good for keeping a set
of files (and locations) handy for quick access. 

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


Help needed in Handling HTML file

2007-06-26 Thread senthil arasu

Hi,
Right now Iam handling HTML files using Python.
Is there any modules to support HTML parsing and rendering ?
or suggest me any other way to support HTML.

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

Converting Diff Output to XML?

2007-06-26 Thread Debajit Adhikary

What would be the best way to convert the regular (unix) diff output into
XML?
Are there any libraries at all which might help?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Bjorn Borud
[Twisted <[EMAIL PROTECTED]>]
| 
| Really? None of this happens if you just do the straightforward file-
| open command, which should obviously at least provide a navigable
| directory tree, but definitely does not.

well, if you insist on using Emacs in the most clumsy way possible,
then of course, not it won't be easy.  it is very obvious to any Emacs
user that you haven't bothered learning Emacs at all.  go away, troll.

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help needed in Handling HTML file

2007-06-26 Thread Stephen R Laniel
On Tue, Jun 26, 2007 at 09:42:37AM -0500, senthil arasu wrote:
> Right now Iam handling HTML files using Python.
> Is there any modules to support HTML parsing and rendering ?
> or suggest me any other way to support HTML.

Parsing: BeautifulSoup
http://www.crummy.com/software/BeautifulSoup/

Rendering: not sure. If worse came to worst, you could
always call out to 'w3m -dump' using system(). How
sophisticated do you want your rendering to be? Other people
on this last may well know of ways to fully render a page,
including graphics and JavaScript and whatever else, using a
scriptable Python object; I do not.

-- 
Stephen R. Laniel
[EMAIL PROTECTED]
Cell: +(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing python under the linux

2007-06-26 Thread Diez B. Roggisch
 [EMAIL PROTECTED] wrote:

> Hello,
> 
>>No.  The only way to change the keywords would be to edit the
>>Python source and re-compile it.
> 
> This was very helpful information , I already know that but I don't
> know how
> to that.PLEASE HELP ME ABOUT THIS, I WILL BE VERY GRATEFUL TO YOU.
> 
> ( IF you can please step by step how to I install that source )

Stop shouting. Start reading this:

http://www.catb.org/~esr/faqs/smart-questions.html

And for god's sake, follow the suggestions you got  when asking the same
question over and over: Stop trying to do what you want to do - altering
python. That is _NOT_ the way to go. Especially not if someone is obviously
not skilled enough to really dig into the guts of the interpreter.

Instead, tell us what you really want. Write a preprocessor to alter your
user's code to become python code. 

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


logging anomaly

2007-06-26 Thread Jesse James

I have some fairly simply code in a turbogears controller that uploads
files. In this code, I inserted a 'start uploading' and a 'done
uploading' log record like this:

logger.info('- start uploading file: '+Filename)
# copy file to specified location.
while 1:
# Read blocks of 8KB at a time to avoid memory problems
with large files.
data = Filedata.file.read(1024 * 8)
if not data:
break
fp.write(data)
logger.info('- done uploading file: '+Filename)
fp.close()

It is nice to occasionally see the upload time for a large file...but
what I am seeing is that the 'start' message is not being logged until
just immediately before the 'done' message:

2007-06-26 07:59:38,192 vor.uploader INFO - start uploading file:
7_Canyons_Clip_1.flv
2007-06-26 07:59:38,206 vor.uploader INFO - done uploading file:
7_Canyons_Clip_1.flv

I know this is wrong because this is a large file that took almost a
minute to upload.

Seems like, with my experience with log4j, upon which I believe the
python logging module was modeled, this should just work as expected.

What am I missing here?

Jesse.

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Bjorn Borud
[Robert Uhl <[EMAIL PROTECTED]>]
| 
| Agreed.  Stallman got sidetracked by Scheme, which IMHO was a
| dead-end.

too many people buying SICP and believing what they heard about it
being an important book.  I too spent some time exploring Scheme, or
should I say, wasted some time, years ago, and nothing came of it
other than a profound irritation.  these people seemed to be
completely disconnected from reality.

Scheme, and thus Guile, might have been a viable path if these people
had only been practical instead of stubbornly insisting on being odd.

| A Common Lisp emacs would be pretty sweet.  There's a Climacs project,
| but they're just focused on providing an editor, not on providing a
| full-fledged emacs.

if nothing else, a proper Emacs in Common Lisp might give me a reason
to learn Lisp properly.

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Bjorn Borud
[Twisted <[EMAIL PROTECTED]>]
| On Jun 23, 2:04 am, Robert Uhl <[EMAIL PROTECTED]> wrote:
| > Of course, emacs doesn't take years of mastery.  It takes 30, 40
| > minutes.
| 
| I gave it twice that, and it failed to grow on me in that amount of
| time.

then it just wasn't meant to be.  stick to Notepad.

| If I haven't, it must be the case that finding this tutorial (or even
| discovering that it exists) was nontrivial, or it wasn't built into
| emacs, one or the other.

when Emacs on my machine starts it says the following:
  
  Welcome to GNU Emacs, one component of a Linux-based GNU system.
  
  Get help   C-h  (Hold down CTRL and press h)
  Undo changes   C-x u   Exit Emacs   C-x C-c
  Get a tutorial C-h t   Use Info to read docsC-h i
  Ordering manuals   C-h RET
  Activate menubar   F10  or  ESC `  or   M-`
  (`C-' means use the CTRL key.  `M-' means use the Meta (or Alt) key.
  If you have no Meta key, you may instead type ESC followed by the
  character.)
  
if you haven't found the tutorial, you haven't really tried very hard.

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


Help needed with translating perl to python

2007-06-26 Thread vj
I have a perl script which connect to network stream using sockets.
The scripts first logins in to the server and then parses the data
comming from the socket.

Statement 1:
  my $today = sprintf("%4s%02s%02s", [localtime()]->[5]+1900,
[localtime()]->[4]+1, [localtime()]->[3]) ;


Statement 2:
  my $password = md5_hex("$today$username") ;

Statement group 3:

$msglen = bcdlen(length($msg)) ;

sub bcdlen {
  my $strlen = sprintf("%04s", shift) ;
  my $firstval = substr($strlen, 2, 1)*16 + substr($strlen, 3, 1) ;
  my $lastval  = substr($strlen, 0, 1)*16 + substr($strlen, 1, 1) ;
  return chr($firstval) . chr($lastval) ;
}

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


Re: Output XML buffer?

2007-06-26 Thread Jan Danielsson
Stefan Behnel wrote:
[---]
> lxml.etree already implements that, BTW.
> 
> http://codespeak.net/lxml

   Ok, thanks. I'll take a look at it.

[---]
> Some people propose just that if you really *want* a declaration. No need to
> have it, though, as ET will create well-formed XML anyway.

   Yeah, I checked the specs, and found a '?' there (but not where I
expected it to be). I just checked the first mention of the "header",
and didn't see it marked as optional.

   However, I want it to be there, simply because it feels better. I'll
check lxml out.

-- 
Kind regards,
Jan Danielsson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Bjorn Borud
[Twisted <[EMAIL PROTECTED]>]
| 
| and you said that depended on the definition of "expert". Apparently
| you believe there is a type of "expert" for whom beginner-friendly
| software is intrinsically less usable than beginner-hostile
| software.

no, I was alluding to you thinking that posession of knowledge which
is considered rudimentary basics for Emacs somehow elevates the person
in question to an "expert".  just because you have not, by your own
admission, been able to even locate the built-in tutorial, I don't
think your definition of "expert" is very relevant.

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


popen and a long running process in a wx.python application

2007-06-26 Thread Doru Moisa
Hello,

How can I capture the output of a long runnning process which I open
with popen() ?
I tried reading line by line, char by char, but the result always
comes when the process finishes.
(I am trying to make a wx.python program that opens some "make ..."
with popen). How can I receive the output of the program immediatly,
so that I can show a progressbar  in my application ?
I always get the program's output after it finished executing.
Is this the right place, or should I post this to wx.python ?

Thank you in advance.

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


Re: Help needed with translating perl to python

2007-06-26 Thread vj
I posted too soon:

> Statement 1:
>   my $today = sprintf("%4s%02s%02s", [localtime()]->[5]+1900,
> [localtime()]->[4]+1, [localtime()]->[3]) ;

1. is localtime the same as time in python?
2. What does -> ? do in perl?
3. What is 'my'

> Statement 2:
>   my $password = md5_hex("$today$username") ;

is md5_hex the same as md5.new(key).hexdigest() in python?

> $msglen = bcdlen(length($msg)) ;

1. here the funciton is being called with the length of variable msg.
However the function def below does not have any args

> sub bcdlen {
>   my $strlen = sprintf("%04s", shift) ;
>   my $firstval = substr($strlen, 2, 1)*16 + substr($strlen, 3, 1) ;
>   my $lastval  = substr($strlen, 0, 1)*16 + substr($strlen, 1, 1) ;
>   return chr($firstval) . chr($lastval) ;
>
> }

2. What does shift do above?
3. is the '.' operator just + in python?

Thanks,

Vineet



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


RE: Collections of non-arbitrary objects ?

2007-06-26 Thread Hamilton, William
> From: walterbyrd
> 
> 
> Yes, but those languages also have the notion of structures that do
> not allow arbitrary collections. That is what I was wondering about
> when I started the thread. It's fine that python has four different
> ways of creating collections of arbitrary data types, but I thought it
> might be helpful if python had, at least, one way of a creating a
> collection of non-arbitrary data.

The thing is, in python all data is arbitrary.  The differences between
the data types float, int, string, etc. are unimportant.  What is
important is the _behavior_ of those types.  

If it is really necessary to check data when putting it into your
collection (user input, processing side-effects will cause damage,
etc.), test that it behaves the way you need it to behave rather than
requiring a specific type.


> It seems to me that tuple are essentially immutable lists. So why
> impose that immutability restriction on a data collection? Why not
> just have lists and not tuples? What can a tuple do that a list can
> not do? Why was python designed so that tuples could be used for
> dictionary indexes, but not lists? Could it be because imposing that
> restriction on a data collection insures a certain degree of
> integrity? My point is: sometimes imposing some restrictions can give
> a degree in built-in integrity. Maybe you don't need that integrity
> insurance, if you code carefully enough, but can you always count on
> that?

Tuples are more like structs in C.  They are collections of data in a
particular order.  Lists, on the other hand, are ordered collections of
data that all exhibit the same behavior.  You don't have to use them
like that, but those are the uses they were developed for as I
understand it.

Function arguments are the obvious example of a tuple.  The position of
an argument in the argument tuple defines how it is used in the
function; get the position wrong, and the function will act unexpectedly
and probably raise an exception.  Iterating over a set of function
arguments doesn't make much sense in the general case.

Lists, are generally intended to be iterated over.  You may take a list
of items that are addable, and add them.  You may take a list of
file-like objects and concatenate them into one file-like object.  (And,
note the "-like" part of that.  They don't have to be files, they just
have to be things that _behave_ like files for the file-like functions
you'll be using.)


> BTW: I'm not assuming that it will always be me running my own app.
> Sure, if an exception occureed while I was running my own app, I'd
> probably know what to do. But if somebody else (who - god forbid -
> didn't know python was running the app, things might be more
difficult.

So, what happens when this user tries to put something into your
restricted list that isn't allowed?  I expect they'll produce an
exception of some sort, and the app will crash if you don't handle that
exception.  Which is exactly what will happen if you don't restrict the
list data and it gets processed.  


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


Re: Problem with wxPython

2007-06-26 Thread Chris Mellon
On 6/26/07, Ali <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm not sure if this is the right place to post, pardon me if it's not.
> I'm having a problem with an application written with wxpython. The frame
> seems only to refresh when moving my mouse of it, though i frequently call:
> frame.Refresh(True). In fact, that line is called by another thread, right
> after having modified some of the frames attributes.
>

In general, the wxpython-users list is a better source of wxPython
answers than c.l.p.

wxPython gui elements are not threadsafe unless otherwise indicated.
Don't make calls against gui objects from other threads. This includes
Refresh().

You can make this call in a threadsafe manner using wx.CallAfter like so:
wx.CallAfter(frame.Refresh, True)


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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread David Kastrup
Bjorn Borud <[EMAIL PROTECTED]> writes:

> [Twisted <[EMAIL PROTECTED]>]
> | 
> | and you said that depended on the definition of "expert". Apparently
> | you believe there is a type of "expert" for whom beginner-friendly
> | software is intrinsically less usable than beginner-hostile
> | software.
>
> no, I was alluding to you thinking that posession of knowledge which
> is considered rudimentary basics for Emacs somehow elevates the person
> in question to an "expert".  just because you have not, by your own
> admission, been able to even locate the built-in tutorial, I don't
> think your definition of "expert" is very relevant.

Since he did not ever download a copy of Emacs in the last 10 years
(and won't according to his own statements download anything or look
at any web page because his computer incompetency makes him incapable
of avoiding or detecting viruses) one can hardly blame him for not
finding the tutorial in software he did not download.

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


Re: Help needed with translating perl to python

2007-06-26 Thread Jay Loden

vj wrote:
> I posted too soon:
> 
>> Statement 1:
>>   my $today = sprintf("%4s%02s%02s", [localtime()]->[5]+1900,
>> [localtime()]->[4]+1, [localtime()]->[3]) ;
> 
> 1. is localtime the same as time in python?

http://perldoc.perl.org/functions/localtime.html

It's more like time.localtime()

One key thing you'll notice here is the adding of 1900 - the year returned by 
Perl's localtime is 'number of years since 1900' so in order to convert it to 
the actual year you have to add 1900.

> 2. What does -> ? do in perl?

In this case, it's accessing localtime similar to something like localtime[5]. 
-> can basically be considered similar to dotted notation in Python, used to 
access items in a container object.

> 3. What is 'my'

http://perldoc.perl.org/functions/my.html

It's a way of declaring a local variable in Perl. 

>> Statement 2:
>>   my $password = md5_hex("$today$username") ;
> 
> is md5_hex the same as md5.new(key).hexdigest() in python?

http://www.xav.com/perl/site/lib/Digest/MD5.html#functions

>> $msglen = bcdlen(length($msg)) ;
> 
> 1. here the funciton is being called with the length of variable msg.
> However the function def below does not have any args
> 
>> sub bcdlen {
>>   my $strlen = sprintf("%04s", shift) ;
>>   my $firstval = substr($strlen, 2, 1)*16 + substr($strlen, 3, 1) ;
>>   my $lastval  = substr($strlen, 0, 1)*16 + substr($strlen, 1, 1) ;
>>   return chr($firstval) . chr($lastval) ;
>>
>> }

Perl subroutines (functions) can be declared without any arguments if desired, 
and then you can use 'shift' to access any arguments. So:

sub printMe {
  my $arg = shift;
  print $arg;
}

would print the first argument passed to it, e.g. printMe("foo"); would output 
foo. 

> 
> 2. What does shift do above?

http://perldoc.perl.org/functions/shift.html

See above, it's used for accessing the first value of an array, in this case an 
arry of arguments to a subroutine.

> 3. is the '.' operator just + in python?

'.' operator is used for string concatenation in Perl, so + would be the 
equivalent in Python, yes. 

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-26 Thread paul
Bruno Desthuilliers schrieb:
> Stephen R Laniel a écrit :
>> On Wed, Jun 20, 2007 at 09:41:09PM +0100, Michael Hoffman wrote:
>>> If you asked Java programmers why you couldn't turn *off* Java's static 
>>> type checking if you wanted to, you'd probably get a similar response.
>> Perhaps it would help for me to explain what I'd like.
>>
>> Under both Perl and Python, I've found myself
>> having/wanting to write things like so:
>>
>> def my_func( int_arg, str_arg ):
>> try:
>> int_arg = int( int_arg )
>> str_arg = str( str_arg )
>> except ValueError:
>> sys.stderr.write( "Args are not of the right type\n" )
>> sys.exit(1)
>>
> 
> Just a question : what will happen if you get rid of the try/except 
> block ?-)
> 
The error will remain unnoticed and the argument might survive another 
few function calls but eventually fails deep down somewhere with:

TypeError: cannot concatenate 'str' and 'list' objects

then you have to examine the traceback and hope the real error is 
visible somewhere (an argument not conforming to the specification of 
the function prototype, or the lack thereof).

cheers
  Paul

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


Re: Python's "only one way to do it" philosophy isn't good?

2007-06-26 Thread Andy Freeman
On Jun 26, 12:26 am, Paul Rubin  wrote:
> Precisely, I think that's what Alexander was trying to get across, Lisp
> didn't have a uniform interface for traversing different types of sequence.

And he's wrong, at least as far as common lisp is concerned - map does
exactly that.

http://www.lispworks.com/documentation/HyperSpec/Body/f_map.htm

Map doesn't work on generators or iterators because they're not part
of the common lisp spec, but if someone implemented them as a library,
said library could easily include a map that handled them as well.

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


Return name of caller function?

2007-06-26 Thread Matthew Peter
For example, how do I get this to work?

def func():
print "This is", __?__
return __caller__

def echo():
print "This is ", __?__
return func()


>>> print echo()
This is echo
This is func
echo



   

Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
-- 
http://mail.python.org/mailman/listinfo/python-list


Hi How to implement switch case statement.

2007-06-26 Thread parasuram.nooranianand

Hi 
 
  My requirement is to check a variable with a set of constant values
and call a particular function depending on the value of the variable. A
C-language  implementation might look something like :
 
switch (a) {
 
case 1 : func1();
case 2 : func2() ;
default : func3();
}
 
How to do it in Python ? 
 
Ofcourse an if-elif construct can also be used to do the job, which is
indeed my last option. However i would like to know if a 'switch-case'
option is available.
 
I found some implementations involving dictionaries and lambdas but i
don't know how suitable they might be for this kind of an
implementation.
 
Any suggestions and ideas welcome
 
 
 
Thanks and regards
Parasuram N.A.
I know the answers to all the questions
But its just that i don't find some of them worth answering
 
 
 
 



The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.
 
www.wipro.com-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-26 Thread Chris Mellon
On 6/26/07, paul <[EMAIL PROTECTED]> wrote:
> Bruno Desthuilliers schrieb:
> > Stephen R Laniel a écrit :
> >> On Wed, Jun 20, 2007 at 09:41:09PM +0100, Michael Hoffman wrote:
> >>> If you asked Java programmers why you couldn't turn *off* Java's static
> >>> type checking if you wanted to, you'd probably get a similar response.
> >> Perhaps it would help for me to explain what I'd like.
> >>
> >> Under both Perl and Python, I've found myself
> >> having/wanting to write things like so:
> >>
> >> def my_func( int_arg, str_arg ):
> >> try:
> >> int_arg = int( int_arg )
> >> str_arg = str( str_arg )
> >> except ValueError:
> >> sys.stderr.write( "Args are not of the right type\n" )
> >> sys.exit(1)
> >>
> >
> > Just a question : what will happen if you get rid of the try/except
> > block ?-)
> >
> The error will remain unnoticed and the argument might survive another
> few function calls but eventually fails deep down somewhere with:
>
> TypeError: cannot concatenate 'str' and 'list' objects
>
> then you have to examine the traceback and hope the real error is
> visible somewhere (an argument not conforming to the specification of
> the function prototype, or the lack thereof).
>

In the example given, not catching the example will provide *more*
information than the terrible exception handling performed. If you're
going to write thick boilerplate to log the values of your locals and
arguments around all your functions, I suggest that you not do that
and instead make use of the ehanced tracebacks in the cgitb module,
which will give you a stack trace with the values of the locals in
each stack frame.

The only reason to trap an exception is either to redirect the
exception (for example, I have a call in a thread which can't be
permitted to throw, so exceptions are caught and transfered elsewhere
for logging), or to correct the error that caused the exception.
Boilerplate like this is at best useless, and in the case of the
example given actively worse than simply not catching it at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Return name of caller function?

2007-06-26 Thread Stephen R Laniel
On Mon, Jun 25, 2007 at 06:27:29PM -0700, Matthew Peter wrote:
> For example, how do I get this to work?
> 
> def func():
> print "This is", __?__
> return __caller__
> 
> def echo():
> print "This is ", __?__
> return func()

inspect is your friend:
http://docs.python.org/lib/inspect-stack.html

-- 
Stephen R. Laniel
[EMAIL PROTECTED]
Cell: +(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's "only one way to do it" philosophy isn't good?

2007-06-26 Thread Andy Freeman
On Jun 26, 8:49 am, Andy Freeman <[EMAIL PROTECTED]> wrote:
> Map doesn't work on generators or iterators because they're not part
> of the common lisp spec, but if someone implemented them as a library,
> said library could easily include a map that handled them as well.

Note that this is is a consequence of something that Python does
better than lisp.  Far more parts of python are defined in terms of
named operations which are data-type independent.  As a result, they
work on things that the implementor (or spec) never considered.

That said, it's no big deal for a lisp program that needed an enhanced
map that also understands iterators and generators to use it.

Compare that with what a programmer using Python 2.4 has to do if
she'd like the functionality provided by 2.5's with statement.  Yes,
with is "just syntax", but it's extremely useful syntax, syntax that
can be easily implemented with lisp-style macros.





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


Re: Help needed with translating perl to python

2007-06-26 Thread attn . steven . kuo
On Jun 26, 8:04 am, vj <[EMAIL PROTECTED]> wrote:
> I have a perl script which connect to network stream using sockets.
> The scripts first logins in to the server and then parses the data
> comming from the socket.
>
> Statement 1:
>   my $today = sprintf("%4s%02s%02s", [localtime()]->[5]+1900,
> [localtime()]->[4]+1, [localtime()]->[3]) ;


Perl has "Do What I Mean" features that allow you to
treat strings and number interchangeably.  Python's
time.localtime returns a tuple of integers so you'll
have to use the proper format conversion characters:

import time
today = "%04d%02d%02d" % time.localtime()[0:3]

# No need to add offsets of 1900 and 1 because Python
# does this for you



>
> Statement 2:
>   my $password = md5_hex("$today$username") ;


You should have added that md5_hex is comes from
Digest::MD5, not a core Perl module.  Regardless:


import md5
password = md5.new("%s%s" % (today, username)).hexdigest()

# seems to be what you wanted



> Statement group 3:
>
> $msglen = bcdlen(length($msg)) ;
>
> sub bcdlen {
>   my $strlen = sprintf("%04s", shift) ;
>   my $firstval = substr($strlen, 2, 1)*16 + substr($strlen, 3, 1) ;
>   my $lastval  = substr($strlen, 0, 1)*16 + substr($strlen, 1, 1) ;
>   return chr($firstval) . chr($lastval) ;
>
> }




You can have a variadic function in Python but the parameters
are passed via a tuple.  Because a tuple is immutable, one cannot
"shift" elements out of a tuple.  Here I've used the first parameter
via selection by index.  Perl's substr is replaced by slice notation;
chr is, well, chr.  Concatenation (Perl's '.' operator) is replaced
by string formatting:

>>> def bcdlen(*args):
... strlen = "%04s" % str(args[0])
... firstval = int(strlen[2:3]) * 16 + int(strlen[3:4])
... lastval  = int(strlen[0:1]) * 16 + int(strlen[1:2])
... return "%s%s" % (chr(firstval), chr(lastval))
...
>>> bcdlen(4546)
'FE'


--
Hope this helps,
Steven

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


Re: Help needed with translating perl to python

2007-06-26 Thread Greg Armer
On Tue, Jun 26, 2007 at 08:17:06AM -0700, vj wrote:
>I posted too soon:
>
>> Statement 1:
>>   my $today = sprintf("%4s%02s%02s", [localtime()]->[5]+1900,
>> [localtime()]->[4]+1, [localtime()]->[3]) ;
>
>1. is localtime the same as time in python?
You could use this instead

-
from time import localtime
today = localtime()
-

'today' would then contain a tuple:

(2007, 6, 26, 17, 41, 27, 327829)

which you could access in a similar way as above (eg: today[0] == 2007)
obviously the order of the values is different from the perl
counterpart.

>2. What does -> ? do in perl?
'->' references a hash (or dict in python) key. In python it would be 
localtime()[4]

>3. What is 'my'
'my' declares local data structures (scalars, arrays or hashes) when 'use 
strict;' 
is defined in the perl script.

>
>> Statement 2:
>>   my $password = md5_hex("$today$username") ;
>
>is md5_hex the same as md5.new(key).hexdigest() in python?
Yes it is.

>
>> $msglen = bcdlen(length($msg)) ;
>
>1. here the funciton is being called with the length of variable msg.
>However the function def below does not have any args
>
>> sub bcdlen {
>>   my $strlen = sprintf("%04s", shift) ;
>>   my $firstval = substr($strlen, 2, 1)*16 + substr($strlen, 3, 1) ;
>>   my $lastval  = substr($strlen, 0, 1)*16 + substr($strlen, 1, 1) ;
>>   return chr($firstval) . chr($lastval) ;
>>
>> }
>
>2. What does shift do above?
'shift' accesses the first argument passed to the function, in this case
the value of length($msg)

>3. is the '.' operator just + in python?
In principle yes.

-- 
Greg Armer
[EMAIL PROTECTED]
http://www.codelounge.org

If it would be cheaper to repair the old one, the
company will insist on the latest model.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python changing keywords name

2007-06-26 Thread Sion Arrowsmith
Gabriel Genellina  <[EMAIL PROTECTED]> wrote:
>(I hope nobody will abuse this technique... Y perd=F3n a los
>hispanoparlantes por lo horrible de la traducci=F3n).

Ah, I only spotted this when I came to post a response. And the
reason I was going to post a response was that these:

>'assert': 'afirmar',
>'exec': 'ejecutar',
>'import': 'importar',
>'pass': 'pasar',
>'print': 'imprimir',
>'raise': 'lanzar',
>'return': 'retornar',
>'try': 'intentar',
>'yield': 'producir',

look rather odd to this non-native Spanish speaker (or at least
reader), and I was going to ask if they sounded more idiomatically
correct if it's not your nth language. I guess they don't 8-)

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: logging anomaly

2007-06-26 Thread Vinay Sajip
On Jun 26, 3:48 pm, Jesse James <[EMAIL PROTECTED]> wrote:
>
> 2007-06-26 07:59:38,192 vor.uploader INFO - start uploading file:
> 7_Canyons_Clip_1.flv
> 2007-06-26 07:59:38,206 vor.uploader INFO - done uploading file:
> 7_Canyons_Clip_1.flv
>
> I know this is wrong because this is a large file that took almost a
> minute to upload.
>
> Seems like, with my experience with log4j, upon which I believe the
> pythonloggingmodule was modeled, this should just work as expected.
>
> What am I missing here?

Not sure...it depends on your logging configuration. Ordinarily, the
event would be processed straight away...delays in seeing output could
be because of e.g. unflushed I/O buffers or buffering via
MemoryHandler (however, this would not affect the time printed for the
event, which is determined at the time the event is logged). Does this
same behaviour occur if the message is logged to a console handler?
(StreamHandler with sys.stderr as the stream, which is not redirected
to a file).

Regards,

Vinay Sajip

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


Re: eggs considered harmful

2007-06-26 Thread Robert Kern
Harry George wrote:
> [EMAIL PROTECTED] (John J. Lee) writes:

>> Not sure how this differs significantly "from running a repository",
>> in the sense I use it above.
>>
>>
>> John
> 
> Significant differences:
> 
> "depot": Place(s) where tarballs can be stored, and can then be
> reached via http.  
> 
> "private egg repository": Tuned to the needs of Python eggs.  E.g.,
> not scattered over several directories or several versions.

Please note that easy_install can use source tarballs, too.

> Thus a depot of self-contained packages can handle:
> 
> 1. Multiple "releases" of the depot live at the same time.

I'm not sure how this is relevant.

> 2. Packages factored into CD-sized directories (not all in one "-f" location)

Of course, you can specify multiple locations for easy_install to find packages.
You can store these in your ~/.pydistutils.cfg file so you never have to type
them on the command line.

> 3. Multiple versions of Python, without having a new egg for each.
> 
> 4. Multiple target platforms.  Various *NIX and MS Win and Mac systems
> -- each at their own OS versions and own compiler versions.  All
> without having platform-specific and compiler-specific eggs.
> 
> 5. Different package version selections based on compatibility with
> other (non-Python) packages.  E.g., to tune for GIS systems vs 3D
> animation systems vs numerical analysis systems vs web server systems.
> 
> 6. Refresh process which does not need to fiddle with egg-ness, or
> even know about Python.  Everything is a tarball.

And all of these are obviated by the fact that easy_install can find and build
source tarballs, too.

-- 
Robert Kern

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

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


Re: Installing python under the linux

2007-06-26 Thread Grant Edwards
On 2007-06-26, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:

>>>No.  The only way to change the keywords would be to edit the
>>>Python source and re-compile it.
>> 
>> This was very helpful information , I already know that but I
>> don't know how to that.PLEASE HELP ME ABOUT THIS, I WILL BE
>> VERY GRATEFUL TO YOU.
>> 
>> (IF you can please step by step how to I install that source)
>
> Stop shouting. Start reading this:
>
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> And for god's sake, follow the suggestions you got when asking
> the same question over and over: Stop trying to do what you
> want to do - altering python. That is _NOT_ the way to go.

He's also already been told where to download the source and
pointed towards instructions on building and installing it.  He
seems rather impervious to help.

-- 
Grant Edwards   grante Yow! Now I understand the
  at   meaning of "THE MOD SQUAD"!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing python under the linux

2007-06-26 Thread Evan Klitzke
On 6/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> >No.  The only way to change the keywords would be to edit the
> >Python source and re-compile it.
>
> This was very helpful information , I already know that but I don't
> know how
> to that.PLEASE HELP ME ABOUT THIS, I WILL BE VERY GRATEFUL TO YOU.
>
> ( IF you can please step by step how to I install that source )

You need to execute the following commands:

apt-get install build-essential fakeroot
apt-get source python
apt-get build-dep python
cd python-some-more-stuff-here-and-a-version-number
(make the changes you want to make)
sudo dpkg-buildpackage -rfakeroot -b

If you need more help building the deb, you should ask on the Ubuntu
mailing lists.

-- 
Evan Klitzke <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: _hashlib portability issue

2007-06-26 Thread Robert Kern
Olivier Feys wrote:
> Hi all,
> 
> I build python 2.5 on linux-x86-64 (centos).
> Why is lib-dynload/_hashlib.so dynamically linked with libssl.so.0.9.7 
> and not with libssl.so that points on it (same thing for libcrypto.so)?
> This causes problems when copying all the python distribution and 
> running it on a different os, where the theses lib versions are not 
> allways the same.
> Is it possible to configure that ?

I don't think so. I think that ld simply follows the symbolic links down to the
actual file. I'm a bit hazy on this, though. `info ld` has not enlightened me,
either.

-- 
Robert Kern

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

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


Re: Python's "only one way to do it" philosophy isn't good?

2007-06-26 Thread Paul Rubin
Andy Freeman <[EMAIL PROTECTED]> writes:
> And he's wrong, at least as far as common lisp is concerned - map does
> exactly that.
> 
> http://www.lispworks.com/documentation/HyperSpec/Body/f_map.htm

"sequence" there just means vectors and lists.

> Map doesn't work on generators or iterators because they're not part
> of the common lisp spec, but if someone implemented them as a library,
> said library could easily include a map that handled them as well.

Right, more scattered special purpose kludges instead of a powerful
uniform interface.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: popen and a long running process in a wx.python application

2007-06-26 Thread kyosohma
On Jun 26, 10:16 am, Doru Moisa <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How can I capture the output of a long runnning process which I open
> with popen() ?
> I tried reading line by line, char by char, but the result always
> comes when the process finishes.
> (I am trying to make a wx.python program that opens some "make ..."
> with popen). How can I receive the output of the program immediatly,
> so that I can show a progressbar  in my application ?
> I always get the program's output after it finished executing.
> Is this the right place, or should I post this to wx.python ?
>
> Thank you in advance.

When talking about anything advanced with wxPython, you usually want
to submit it to the wxPython user's group. Lots of advanced users
(including the author of wxPython) answer questions there.

I would recommend looking at the following link as this will probably
be one of the first suggestions:
http://wiki.wxpython.org/index.cgi/LongRunningTasks?highlight=%28task%29%7C%28longrunning%29

wxPython mailing list: http://www.wxpython.org/maillist.php

I used a variation of one of the threading example in the
LongRunningTasks page to send output to a text widget, through stdout
redirection.

Good luck!

Mike

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


Re: Hi How to implement switch case statement.

2007-06-26 Thread Evan Klitzke
Read this thread, which was discussed on the list a few days ago:
http://www.mail-archive.com/python-list@python.org/msg150704.html

On 6/25/07, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
>
> Hi
>
>   My requirement is to check a  variable with a set of constant values and 
> call a particular  function depending on the value of the variable. A 
> C-language   implementation might look something like :
>
> switch (a) {
>
> case 1 :  func1();
> case 2 :  func2() ;
> default :  func3();
> }
>
> How to do it in Python ?
>
> Ofcourse an if-elif construct can also be  used to do the job, which is 
> indeed my last option. However i would like to know  if a 'switch-case' 
> option is available.
>
> I found some implementations involving  dictionaries and lambdas but i don't 
> know how suitable they might be for this  kind of an implementation.
>
> Any suggestions and  ideas welcome
>
>
>
> Thanks and regards
> Parasuram  N.A.
> I know the answers to all the  questions
> But its just that i don't find some of  them worth answering
>
>
>
>
>
>  The information contained in this electronic message and any attachments to 
> this message are intended for the exclusive use of the addressee(s) and may 
> contain proprietary, confidential or privileged information. If you are not 
> the intended recipient, you should not disseminate, distribute or copy this 
> e-mail. Please notify the sender immediately and destroy all copies of this 
> message and any attachments.
>
>  WARNING: Computer viruses can be transmitted via email. The recipient should 
> check this email and any attachments for the presence of viruses. The company 
> accepts no liability for any damage caused by any virus transmitted by this 
> email.
>
>  www.wipro.com
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Evan Klitzke <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's "only one way to do it" philosophy isn't good?

2007-06-26 Thread Paul Rubin
Andy Freeman <[EMAIL PROTECTED]> writes:
> Compare that with what a programmer using Python 2.4 has to do if
> she'd like the functionality provided by 2.5's with statement.  Yes,
> with is "just syntax", but it's extremely useful syntax, syntax that
> can be easily implemented with lisp-style macros.

Not really.  The with statement's binding targets all have to support
the protocol, which means a lot of different libraries need redesign.
You can't do that with macros.  Macros can handle some narrow special
cases such as file-like objects, handled in Python with
contextlib.closing.

That said, the with statement was missing from Python for much too
long, since users were happy to rely on reference counting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Portable general timestamp format, not 2038-limited

2007-06-26 Thread Paul Rubin
Martin Gregorie <[EMAIL PROTECTED]> writes:
> I don't recall the OP mentioning time interval computability - just a
> requirement for sub second accuracy timestamps.

That Y2038 is an issue suggests the OP wants a timestamp format that
is future-proof and that means it should be good for all plausible
applications.  That would include computing intervals.

> > If you want a precise timestamp and you don't
> > want to deal with leap seconds, TAI is one approach.
>  >
> TAI? Care to provide a reference?

Same one already given: http://cr.yp.to/proto/utctai.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Return name of caller function?

2007-06-26 Thread Jay Loden

Matthew Peter wrote:
> For example, how do I get this to work?
> 
> def func():
> print "This is", __?__
> return __caller__
> 
> def echo():
> print "This is ", __?__
> return func()
> 
> 
 print echo()
> This is echo
> This is func
> echo

This may not be what you're looking for but here's the solution I ended up with 
after some help from the list. It's designed for getting the name of an 
instance method, but in case it applies to your particular situation: 

#!/usr/bin/python

import functools

class TestClass:
  def __init__(self):
pass

  def __getattr__(self, name):
try:
  return getattr(self.__class__, name)
except AttributeError:
  return functools.partial(self.foo, name)

  def foo(self, name, **args):
print "This is", name

test = TestClass()
test.someMethod()
test.anotherMethod()

Otherwise the inspect module may be the way to go, as Stephen already pointed 
out (though I must admit it seems a very inelegant route, especially compared 
to Python's usually clean and clear style). 

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


Re: Help needed with translating perl to python

2007-06-26 Thread attn . steven . kuo
On Jun 26, 8:59 am, [EMAIL PROTECTED] wrote:

(snipped)

>
> >>> def bcdlen(*args):
>
> ... strlen = "%04s" % str(args[0])
> ... firstval = int(strlen[2:3]) * 16 + int(strlen[3:4])
> ... lastval  = int(strlen[0:1]) * 16 + int(strlen[1:2])
> ... return "%s%s" % (chr(firstval), chr(lastval))
> ...>>> bcdlen(4546)
>
> 'FE'


Let me add that instead of an an-close-as-possible translation
from the  original Perl code, one can rewrite this as:

>>> def bcdlen(length):
... strlen = "%04s" % length
... return chr(int(strlen[2:4], 16)) + chr(int(strlen[0:2], 16))


which is more "Pythonic" to me.

--
Hope this helps,
Steven

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


Re: Internals and complexity of types, containers and algorithms

2007-06-26 Thread Harald Luessen
On Mon, 25 Jun 2007 James Stroud wrote:

>Harald Luessen wrote:
>> Hi, I am new to python and I miss some understanding of the internals 
>> of some types and containers. With my C/C++ background I hope to get 
>> some hints to chose the best data structure for my programs. Here are 
>> some questions:
>
>This depends on how you define "best". If you want speed and 
>optimization, you can use the numpy package built with ATLAS tuned for a 
>specific machine.

Are there arrays in numpy that can efficiently be used for 
other things than matrix arithmetic? Are they faster than lists 
but still easy to use?

no_piece = 0
wpawn = 1
...
board[square] = no_piece
board[square+8] = pawn
...

could be a typical pawn move.

>Beyond speed, "best" in the python community usually means "most suited" 
>from an idiomatic perspective and from the perspective of structure that 
>lends itself to long term maintainability because [C]python data 
>structures seem to undergo optimizations in their implementation at each 
>revision.

I like the python way of "best" code. But in this particular 
question the emphasis was on performance and speed.

>Your best bet is probably to forget about implementation and write code 
>that makes sense. For example, some have suggested a tuple-keyed 
>dictionary to represent a chess board:
>
>board = ((c,r) for r in xrange(1, 9) for c in 'abcdefgh')
>starting = 'RNBQKBNR' + 'P' * 8 + ' ' * 32 + 'p' * 8 + 'rnbqkbnr'
>position = dict(zip(board, starting))

I am not new to board game programming and I am used to 
an array approach or even bitboards. Therefore the dictionary 
looks a little bit strange to me.

Harald

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


Re: Internals and complexity of types, containers and algorithms

2007-06-26 Thread Harald Luessen
On Mon, 25 Jun 2007 Martin v. Löwis wrote:

>Sure, see below:
>
>- tuples are represented as arrays, with a single block for the
>  entire objects (object header, tuple size, and data)
>- list are represented as arrays, with two memory blocks:
>  one for object header and sizes, and the other one for the
>  "guts", i.e. the actual data. The list uses over-allocation,
>  to avoid resizing on each addition.
>- strings are implemented as arrays, with a single block for
>  the entire string. In addition to header, size, and data,
>  it also contains a cached hash and a pointer to the interned
>  version of the string (if any).
>- dicts are implemented as hash tables, with open addressing.
... and more interesting things ...

Thank you. That was the information I was looking for. 
I just forgot to ask for sets.

Harald

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


problem mixing gettext and properties

2007-06-26 Thread André
I've encountered a problem using gettext with properties while using a
Python interpreter.

Here's a simple program that illustrate the problem.
==
# i18n_test.py: test of gettext & properties

import gettext

fr = gettext.translation('i18n_test', './translations',
languages=['fr'])
fr.install()

help = _("Help me!")

class Test_i18n(object):
def get(self):
__help = _("HELP!")
return __help
help_prop = property(get, None, None, 'help')

test = Test_i18n()

print help
print test.help_prop
 end of file

To run the above program, you need to have the strings translated and
the proper ".po" and ".mo" files created.  (for those interested, I
can send the whole lot in a zip file)

If I run the program as is, the output is:
Aidez-moi!
AIDE!!!

Ok, let's try with the Python interpreter:

ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
Python 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import i18n_test
Aidez-moi!
AIDE!!!

#  No surprise there so far.

>>> print i18n_test.help
Aidez-moi!
>>> print i18n_test.test.help_prop
AIDE!!!
>>> i18n_test.help
'Aidez-moi!'

# all of the above are as expected; now for the first surprise

>>> i18n_test.test.help_prop
Traceback (most recent call last):
  File "", line 1, in ?
  File "i18n_test.py", line 12, in get
__help = _("HELP!")
TypeError: 'str' object is not callable

# and a second surprise where we try to repeat something that used to
work

>>> print i18n_test.test.help_prop
Traceback (most recent call last):
  File "", line 1, in ?
  File "i18n_test.py", line 12, in get
__help = _("HELP!")
TypeError: 'str' object is not callable

#=

Dare I say: "Help!"   I really need to use the above at the
interpreter prompt.

André

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


Re: Indenting in Emacs

2007-06-26 Thread Rustom Mody
Ive been struggling with this same question -- which python mode --
for a while but not getting anywhere!

I understand (from the emacs list) that the new python mode has better
support for debugging (pdbtrack in addition to pdb) but dont know much
more.


On 6/26/07, John J. Lee <[EMAIL PROTECTED]> wrote:
> Michael Hoffman <[EMAIL PROTECTED]> writes:
>
> > John J. Lee wrote:
> >> Eugene Morozov <[EMAIL PROTECTED]> writes:
> >>
> >>> Steven W. Orr пишет:
> >>>  > Ok. I'm not stupid but I do not see a 4.78 anywhere even though I
> >>> see refs
>  from google. I have 4.75 The SVN tree doesn't seem to even have
>  that.
> 
>  I checked the latest copy out from sourceforge and that was 4.75 too.
> 
>  Can someone please tell me where to find the latest?
> 
> >>> It's from Emacs 22.
> >>
> >> Note that's a different python-mode to the old one that lives on SF.
> >> Yes, there are now two of them.
> >
> > Which one is better?
>
> I've not noticed a big difference in usability.
>
> I find indentation with the new mode very mildly more annoying than
> the old mode.  YMMV on that.  There are probably annoyances with the
> old mode that I've now forgotten about.
>
> I'm told by an emacs developer at work that the new mode is more
> emacsy in its implementation -- I don't know in what ways exactly, but
> presumably that, plus the fact that the new mode is included with
> emacs 22, will mean that it's likely to work better with other emacs
> code (not that I ever had much problem with the old mode -- but then I
> didn't push it very far).
>
>
> John
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: problem mixing gettext and properties

2007-06-26 Thread Matimus
On Jun 26, 10:52 am, André <[EMAIL PROTECTED]> wrote:
> I've encountered a problem using gettext with properties while using a
> Python interpreter.
>
> Here's a simple program that illustrate the problem.
> ==
> # i18n_test.py: test of gettext & properties
>
> import gettext
>
> fr = gettext.translation('i18n_test', './translations',
> languages=['fr'])
> fr.install()
>
> help = _("Help me!")
>
> class Test_i18n(object):
> def get(self):
> __help = _("HELP!")
> return __help
> help_prop = property(get, None, None, 'help')
>
> test = Test_i18n()
>
> print help
> print test.help_prop
>  end of file
>
> To run the above program, you need to have the strings translated and
> the proper ".po" and ".mo" files created.  (for those interested, I
> can send the whole lot in a zip file)
>
> If I run the program as is, the output is:
> Aidez-moi!
> AIDE!!!
>
> Ok, let's try with the Python interpreter:
>
> ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
> Python 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> import i18n_test
>
> Aidez-moi!
> AIDE!!!
>
> #  No surprise there so far.
>
> >>> print i18n_test.help
> Aidez-moi!
> >>> print i18n_test.test.help_prop
> AIDE!!!
> >>> i18n_test.help
>
> 'Aidez-moi!'
>
> # all of the above are as expected; now for the first surprise
>
> >>> i18n_test.test.help_prop
>
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "i18n_test.py", line 12, in get
> __help = _("HELP!")
> TypeError: 'str' object is not callable
>
> # and a second surprise where we try to repeat something that used to
> work
>
> >>> print i18n_test.test.help_prop
>
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "i18n_test.py", line 12, in get
> __help = _("HELP!")
> TypeError: 'str' object is not callable
>
> #=
>
> Dare I say: "Help!"   I really need to use the above at the
> interpreter prompt.
>
> André

In the interpreter "_" is used to store the return value of the last
statement executed. So when this line is run:

>>> i18n_test.help

"_" is set to  'Aidez-moi!'.

A possible fix, which I have not tested in your context, would be to
explicitly set _ to _ after your module is loaded.

So, try this:

>>> import i18n_test
>>> _ = i18n_test._
... The rest of your code here

I don't know for sure that this will work. From what I have tried
though, assigning to _ seems to disable that feature of the
interpreter.

Matt

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


Re: problem mixing gettext and properties

2007-06-26 Thread Peter Otten
André wrote:

> I've encountered a problem using gettext with properties while using a
> Python interpreter.
> 
> Here's a simple program that illustrate the problem.
> ==
> # i18n_test.py: test of gettext & properties
> 
> import gettext
> 
> fr = gettext.translation('i18n_test', './translations',
> languages=['fr'])

_ = fr.gettext # untested

> help = _("Help me!")
> 
> class Test_i18n(object):
> def get(self):
> __help = _("HELP!")
> return __help
> help_prop = property(get, None, None, 'help')
> 
> test = Test_i18n()
> 
> print help
> print test.help_prop
>  end of file
> 
> To run the above program, you need to have the strings translated and
> the proper ".po" and ".mo" files created.  (for those interested, I
> can send the whole lot in a zip file)
> 
> If I run the program as is, the output is:
> Aidez-moi!
> AIDE!!!
> 
> Ok, let's try with the Python interpreter:
> 
> ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
> Python 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
 import i18n_test
> Aidez-moi!
> AIDE!!!
> 
> #  No surprise there so far.
> 
 print i18n_test.help
> Aidez-moi!
 print i18n_test.test.help_prop
> AIDE!!!
 i18n_test.help
> 'Aidez-moi!'
> 
> # all of the above are as expected; now for the first surprise
> 
 i18n_test.test.help_prop
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "i18n_test.py", line 12, in get
> __help = _("HELP!")
> TypeError: 'str' object is not callable
> 
> # and a second surprise where we try to repeat something that used to
> work
> 
 print i18n_test.test.help_prop
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "i18n_test.py", line 12, in get
> __help = _("HELP!")
> TypeError: 'str' object is not callable
> 
> #=
> 
> Dare I say: "Help!"   I really need to use the above at the
> interpreter prompt.
> 
> André

The _ builtin is set to the result of the last expression evaluated by the
interpreter:

>>> for i in range(3):
... i
...
0
1
2
>>> _
2
>>> import __builtin__
>>> __builtin__._
2

Therefore you get a name clash with _() as an alias for gettext(). Use
module-global aliases instead, e. g.

_ = fr.gettext

in the above code.

Peter

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


Re: Internals and complexity of types, containers and algorithms

2007-06-26 Thread Paul Rubin
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:
> Amortized O(1) for inserting into lists.

I think you mean amortized O(1) for appending to lists.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem mixing gettext and properties

2007-06-26 Thread André
On Jun 26, 3:56 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> André wrote:
> > I've encountered a problem using gettext with properties while using a
> > Python interpreter.
>
> > Here's a simple program that illustrate the problem.
> > ==
> > # i18n_test.py: test of gettext & properties
>
> > import gettext
>
> > fr = gettext.translation('i18n_test', './translations',
> > languages=['fr'])
>
> _ = fr.gettext # untested
>
>
>
> > help = _("Help me!")
>
> > class Test_i18n(object):
> > def get(self):
> > __help = _("HELP!")
> > return __help
> > help_prop = property(get, None, None, 'help')
>
> > test = Test_i18n()
>
> > print help
> > print test.help_prop
> >  end of file
>
> > To run the above program, you need to have the strings translated and
> > the proper ".po" and ".mo" files created.  (for those interested, I
> > can send the whole lot in a zip file)
>
> > If I run the program as is, the output is:
> > Aidez-moi!
> > AIDE!!!
>
> > Ok, let's try with the Python interpreter:
>
> > ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
> > Python 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)]
> > on win32
> > Type "help", "copyright", "credits" or "license" for more information.
>  import i18n_test
> > Aidez-moi!
> > AIDE!!!
>
> > #  No surprise there so far.
>
>  print i18n_test.help
> > Aidez-moi!
>  print i18n_test.test.help_prop
> > AIDE!!!
>  i18n_test.help
> > 'Aidez-moi!'
>
> > # all of the above are as expected; now for the first surprise
>
>  i18n_test.test.help_prop
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> >   File "i18n_test.py", line 12, in get
> > __help = _("HELP!")
> > TypeError: 'str' object is not callable
>
> > # and a second surprise where we try to repeat something that used to
> > work
>
>  print i18n_test.test.help_prop
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> >   File "i18n_test.py", line 12, in get
> > __help = _("HELP!")
> > TypeError: 'str' object is not callable
>
> > #=
>
> > Dare I say: "Help!"   I really need to use the above at the
> > interpreter prompt.
>
> > André
>
> The _ builtin is set to the result of the last expression evaluated by the
> interpreter:
>
> >>> for i in range(3):
>
> ... i
> ...
> 0
> 1
> 2>>> _
> 2
> >>> import __builtin__
> >>> __builtin__._
>
> 2
>
> Therefore you get a name clash with _() as an alias for gettext(). Use
> module-global aliases instead, e. g.
>
> _ = fr.gettext
>
> in the above code.
>
> Peter

Thanks, that works ... but, it brings many other "complications".   I
have multiple modules, and I want to be able to switch languages
easily.   Unless I am mistaken, if I do it with module-global aliases
instead, I will need to have something like

lang = {}
for code in ['en', 'fr', ...]:
   lang[code] = gettext.translation('i18n_test', './translations',
languages=[code])

def switch_language(code):
   ...
   import module1
   import module2
   ...
   module1._ = lang[code].gettext
   module2._ = lang[code].gettext
   ...

And I will need to make sure to keep track of all the modules that
require translation...  Is there an easier, less tedious way to do
this?

Am I missing something?

André

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-26 Thread Kjetil S. Matheussen


On Tue, 26 Jun 2007, Bjorn Borud wrote:

> [Robert Uhl <[EMAIL PROTECTED]>]
> |
> | Agreed.  Stallman got sidetracked by Scheme, which IMHO was a
> | dead-end.
>
> too many people buying SICP and believing what they heard about it
> being an important book.  I too spent some time exploring Scheme, or
> should I say, wasted some time, years ago, and nothing came of it
> other than a profound irritation.
>

Did you expect something specific before starting to read that 
book? Thats a failure. SICP is a book you should read just for pure 
pleasure.



>  these people seemed to be
> completely disconnected from reality.

Please don't write things like that without backing it up with some 
reason.

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


Re: popen and a long running process in a wx.python application

2007-06-26 Thread Ratko
On Jun 26, 10:16 am, Doru Moisa <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How can I capture the output of a long runnning process which I open
> with popen() ?
> I tried reading line by line, char by char, but the result always
> comes when the process finishes.
> (I am trying to make a wx.python program that opens some "make ..."
> with popen). How can I receive the output of the program immediatly,
> so that I can show a progressbar  in my application ?
> I always get the program's output after it finished executing.
> Is this the right place, or should I post this to wx.python ?
>
> Thank you in advance.



I think this is the right list to post this in since it's independent
of wxPython.
I just recently went through this and got it working properly. Your
problem is that the output is buffered and is only flushed upon exit
(and that's when you read() it)
Here's a piece of code:

doRead = True
p = subprocess.Popen(["ls"], stdout=sp.PIPE, stderr=sp.STDOUT,
bufsize=1)
while doRead:
 txt = os.read(p.stdout.fileno(), 2048)
 time.sleep(0.5)   # read at most x times / sec

A few things to note:
(1) you must use os.read and not the builtin read() for unbuffered
read.
(2) you probably want to run this while loop in a thread because read
will block until there's some text available
(3) this is a polling method where I read at most 2 a second in the
above example
(4) this works on Mac, Windows and Linux the same (besides the "ls"
command of course)
(5) after you read this text you can send it to a TextCtrl or
something

Hope that helps.

Ratko

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


Re: Python plain-text database or library that supports joins?

2007-06-26 Thread Joshua J. Kugler
On Friday 22 June 2007 09:18, felciano wrote:

> Hello --
> 
> Is there a convention, library or Pythonic idiom for performing
> lightweight relational operations on flatfiles? I frequently find
> myself writing code to do simple SQL-like operations between flat
> files, such as appending columns from one file to another, linked
> through a common id. For example, take a list of addresses and append
> a 'district' field by looking up a congressional district from a
> second file that maps zip codes to districts.

Two pointers, but maybe not a complete solution:

http://search.cpan.org/dist/DBD-Sprite/
Perl library that uses CSV files and supports simple joins.  Maybe a port of
this?

http://www.biostat.wisc.edu/~annis/creations/pseudb.html
Functional interface for CSV files inspired by Sprite, but does not support
joins.  Possibly could be extended?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: problem mixing gettext and properties

2007-06-26 Thread Peter Otten
André wrote:

> On Jun 26, 3:56 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
>> André wrote:
>> > I've encountered a problem using gettext with properties while using a
>> > Python interpreter.
>>
>> > Here's a simple program that illustrate the problem.
>> > ==
>> > # i18n_test.py: test of gettext & properties
>>
>> > import gettext
>>
>> > fr = gettext.translation('i18n_test', './translations',
>> > languages=['fr'])
>>
>> _ = fr.gettext # untested
>>
>>
>>
>> > help = _("Help me!")
>>
>> > class Test_i18n(object):
>> > def get(self):
>> > __help = _("HELP!")
>> > return __help
>> > help_prop = property(get, None, None, 'help')
>>
>> > test = Test_i18n()
>>
>> > print help
>> > print test.help_prop
>> >  end of file
>>
>> > To run the above program, you need to have the strings translated and
>> > the proper ".po" and ".mo" files created.  (for those interested, I
>> > can send the whole lot in a zip file)
>>
>> > If I run the program as is, the output is:
>> > Aidez-moi!
>> > AIDE!!!
>>
>> > Ok, let's try with the Python interpreter:
>>
>> > ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
>> > Python 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)]
>> > on win32
>> > Type "help", "copyright", "credits" or "license" for more information.
>>  import i18n_test
>> > Aidez-moi!
>> > AIDE!!!
>>
>> > #  No surprise there so far.
>>
>>  print i18n_test.help
>> > Aidez-moi!
>>  print i18n_test.test.help_prop
>> > AIDE!!!
>>  i18n_test.help
>> > 'Aidez-moi!'
>>
>> > # all of the above are as expected; now for the first surprise
>>
>>  i18n_test.test.help_prop
>> > Traceback (most recent call last):
>> >   File "", line 1, in ?
>> >   File "i18n_test.py", line 12, in get
>> > __help = _("HELP!")
>> > TypeError: 'str' object is not callable
>>
>> > # and a second surprise where we try to repeat something that used to
>> > work
>>
>>  print i18n_test.test.help_prop
>> > Traceback (most recent call last):
>> >   File "", line 1, in ?
>> >   File "i18n_test.py", line 12, in get
>> > __help = _("HELP!")
>> > TypeError: 'str' object is not callable
>>
>> > #=
>>
>> > Dare I say: "Help!"   I really need to use the above at the
>> > interpreter prompt.
>>
>> > André
>>
>> The _ builtin is set to the result of the last expression evaluated by
>> the interpreter:
>>
>> >>> for i in range(3):
>>
>> ... i
>> ...
>> 0
>> 1
>> 2>>> _
>> 2
>> >>> import __builtin__
>> >>> __builtin__._
>>
>> 2
>>
>> Therefore you get a name clash with _() as an alias for gettext(). Use
>> module-global aliases instead, e. g.
>>
>> _ = fr.gettext
>>
>> in the above code.
>>
>> Peter
> 
> Thanks, that works ... but, it brings many other "complications".   I
> have multiple modules, and I want to be able to switch languages
> easily.   Unless I am mistaken, if I do it with module-global aliases
> instead, I will need to have something like
> 
> lang = {}
> for code in ['en', 'fr', ...]:
>lang[code] = gettext.translation('i18n_test', './translations',
> languages=[code])
> 
> def switch_language(code):
>...
>import module1
>import module2
>...
>module1._ = lang[code].gettext
>module2._ = lang[code].gettext
>...
> 

If you need to change the language while the program is running you can put

def _(s):
   return gettext(s)

into one "master" module and have the other modules import that:

from master import _

This comes at the cost of one extra indirection.

> And I will need to make sure to keep track of all the modules that
> require translation...  Is there an easier, less tedious way to do
> this?

If your users don't rely on _ in the interpreter, you can write a custom
sys.displayhook that doesn't set __builtin__._

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


ironpython exception line number

2007-06-26 Thread Troels Thomsen

Hello ,

When an exeption occurs in a IronPython executet script, and I print the 
sys.exc , i get something ugly like the example below.
How can I get the fileName and line number?

Thx in advance
Troels


26-06-2007 13:19:04 : IronPython.Runtime.Exceptions.PythonIndentationError: 
unexpected token def
   ved IronPython.Compiler.SimpleParserSink.AddError(String path, String 
message, String lineText, CodeSpan span, Int32 errorCode, Severity severity)

   ved IronPython.Compiler.CompilerContext.AddError(String message, String 
lineText, Int32 startLine, Int32 startColumn, Int32 endLine, Int32 
endColumn, Int32 errorCode, Severity severity)

   ved IronPython.Compiler.Parser.ReportSyntaxError(Location start, Location 
end, String message, Int32 errorCode)
   ved IronPython.Compiler.Parser.ReportSyntaxError(Token t, Int32 
errorCode, Boolean allowIncomplete)
   ved IronPython.Compiler.Parser.ParseSuite()
   ved IronPython.Compiler.Parser.ParseFuncDef()
   ved IronPython.Compiler.Parser.ParseStmt()
   ved IronPython.Compiler.Parser.ParseSuite()
   ved IronPython.Compiler.Parser.ParseClassDef()
   ved IronPython.Compiler.Parser.ParseStmt()
   ved IronPython.Compiler.Parser.ParseFileInput()
   ved IronPython.Hosting.PythonEngine.Compile(Parser p, Boolean 
debuggingPossible)
   ved IronPython.Hosting.PythonEngine.CompileFile(String fileName)
   ved IronPython.Hosting.PythonEngine.ExecuteFile(String fileName)



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


Re: bicycle repair man help

2007-06-26 Thread Kathryn Van Stone

On Jun 23, 2007, at 2:24 PM, Rustom Mody wrote:

> Does someone know that when using bicycle repair man to refactor  
> python code what exactly extract local variable means?

I don't know about bicycle repair main, but in general 'extract local  
variable' means to make a change like this:

self.method_call(1, )

to

value = 
self.method_call(1, value)

i.e, it takes an expression, assigns it to a variable name (which is  
specified by the user) and then uses that variable name in place of  
the expression.

I would expect that you need to select the expression to be  
substituted for the refactoring to work.

I hope this helps,

Kathy Van Stone
[EMAIL PROTECTED]

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


  1   2   >