[ANN] rpncalc-2.2 RPN Calculator for Python

2005-12-04 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN)
interpreter to Python.  This interpreter allows the use of Python as
an RPN calculator.  You can easily switch between the RPN interpreter
and the standard Python interpreter.

Home page:  http://calcrpnpy.sourceforge.net/

Changes in 2.2

* Display only 12 digits of a mpf or cmpf value.

* Added stats function.

* Added chebyshev module.

* Added solve command.

* Simplified installing user functions into the calculator.

* Added on-line help.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


PyCon 2006 registration now open

2005-12-04 Thread A.M. Kuchling
Registration for PyCon 2006 is now open; go to the registration form
at http://www.python.org/pycon/2006/register.html
to register for the conference and for tutorials.

At this time the planned events for PyCon have all been announced:

* Talks: http://wiki.python.org/moin/PyCon2006/Talks
* Tutorials: http://wiki.python.org/moin/PyCon2006/Tutorials
* Sprints: http://wiki.python.org/moin/PyCon2006/Sprints

Also remember to book your flight, and to book your hotel room using
the hotel's PyCon event page at http://www.stayatmarriott.com/Pycon2006/ .

We look forward to seeing all of you at PyCon 2006.

A.M. Kuchling
Chair, PyCon 2006
[EMAIL PROTECTED]

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

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


Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2005-12-04 Thread Cameron Laird
QOTW:  Python makes it easy to implement algorithms. - casevh

Most of the discussion of immutables here seems to be caused by
newcomers wanting to copy an idiom from another language which doesn't
have immutable variables. Their real problem is usually with binding,
not immutability. - Mike Meyer


Among the treasures available in The Wiki is the current
copy of the Sorting min-howto:
http://www.amk.ca/python/howto/sorting/sorting.html

Dabo is way cool--at least as of release 0.5:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/becf84a4f8b3d34/

Tim Golden illustrates that wmi is *not* the only way to
access win32 functionality, and in fact that Python can
mimic VisualBasicScript quite handily.  It's only mimicry,
though; VBS remains better suited for this specific class
of tasks:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/fa84850666488500/

Claudio Grondi explains ActiveX componentry--OCXs, the
registry, apartments, ...--for a Python audience:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/471306f2d6f6927/

Dao is a novel high-level language which advertises strong
multi-threading, Unicode, and particularly comfortable C++ 
interfacing.  Limin Fu provides details:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4418fac8dda696d9/

Donn Cave leads at least a score of others in comparing
lists and tuples:
http://groups.google.com/group/comp.lang.python/msg/dd6ba8df451d57e0?


Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all
The old Python To-Do List now lives principally in a
SourceForge reincarnation.

Re: Trouble with idle from python 2.4.2 on SUSE linux 9.3

2005-12-04 Thread Peter Otten
Alasdair wrote:

 I've just installed python 2.4.2 from source - it works fine from the
 command line.  But when I attempt to start idle, I am told:
 
 ** IDLE can't import Tkinter.  Your Python may not be configured for
 Tk. **
 
 I have tcl 8.4 and tk 8.4 on my system; can anybody provide me with
 some advice?

I think you need to install the tcl-devel and tk-devel packages, too.

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


Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-04 Thread Dan Bishop
[EMAIL PROTECTED] wrote:
 I am trying to run an exe within a python script, but I'm having
 trouble with spaces in the directory name.
...
 So, it looks to me like the space in the path for the argument is
 causing it to fail.  Does anyone have any suggestions that could help
 me out?

Does C:\progra~1\somedi~1\engine\theexe.exe still work?

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Ed Leafe
On Dec 3, 2005, at 3:37 PM, Scott David Daniels wrote:

 They appear in different positions on different terminals (older hard-
 copy),

 Is anyone still using such devices to program Python?

 do different things on different OS's,

 Such as? I use OS X, Windows and Linux daily, and tabs work just  
fine on all of those. Which OS is it that is aberrant, and how  
exactly does it pose a problem?

 and in general do not behave nicely.

 Again, specifics would be welcome. I've been using tabs for  
indentation for over a decade, and have not once run into the horror  
stories that everyone who hates tabs says will happen, but who never  
give specifics as to how they cause problems.

 If you want to use spaces, great. I'm certainly not going to  
make up reasons why spaces are bad, just to make me feel better about  
my preference. Just don't make general damning comments without any  
specifics to back them up.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Ed Leafe
On Dec 3, 2005, at 5:55 PM, Sybren Stuvel wrote:

 That depends on your editor. Mine (vim) can be instructed to insert
 the appropriate amount of spaces on a tab, and remove them on a
 backspace.

 So let's say that you are using 4 spaces as your standard, but  
by accident type 5. You hit backspace, which deletes 4 spaces, and  
you now have to mentally compute the difference in order to keep  
things aligned.

 See, I can make up bizarre scenarios where spaces cause  
problems, too.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



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


Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)

2005-12-04 Thread Björn Lindström
Ed Leafe [EMAIL PROTECTED] writes:

 Again, specifics would be welcome. I've been using tabs for
 indentation for over a decade, and have not once run into the horror
 stories that everyone who hates tabs says will happen, but who never
 give specifics as to how they cause problems.

This article should explain it:

http://www.jwz.org/doc/tabs-vs-spaces.html

-- 
Björn Lindström [EMAIL PROTECTED]
Student of computational linguistics, Uppsala University, Sweden
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Trouble with idle from python 2.4.2 on SUSE linux 9.3

2005-12-04 Thread Alasdair
Thanks - that did the trick!  I wonder why it's not mentioned in the
README, or (so far as I can tell) anywhere else?

-Alasdair

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


Problem build python bindings to lasso with swig on mac os x

2005-12-04 Thread Roland Hedberg
Hi!

This involves quite a lot of different system, so I'm not really sure  
who which would be the right list to query.

So, I'm trying a couple, this list being one of them.

I'm trying to build the lasso (http://lasso.entrouvert.org/)  
libraries and what I really want to get at is the Python bindings.
Those binding are done with the help of swig and it fails with the  
following output:

gcc  -o .libs/_lasso.so -bundle  .libs/_lasso_la-lasso_wrap.o  -L/sw/ 
lib -L/Users
/rolandhedberg/src/libxml2-2.6.22 -L/usr/local/lib -L/lib ../ 
lasso/.libs/liblasso
.dylib /usr/lib/libiconv.dylib /usr/lib/libpthread.dylib /usr/lib/ 
libz.dylib /usr
/lib/libm.dylib /usr/lib/libssl.dylib /usr/lib/libcrypto.dylib /usr/ 
local/lib/lib
dl.dylib /usr/lib/libresolv.dylib /usr/local/lib/ 
libgobject-2.0.dylib /usr/lib/li
bc.dylib /usr/local/lib/libglib-2.0.dylib /usr/local/lib/ 
libintl.dylib /usr/local
/lib/libxmlsec1-openssl.dylib /usr/local/lib/libxmlsec1.dylib -ldl / 
usr/local/lib
/libxslt.dylib /usr/local/lib/libxml2.dylib -lpthread -lz /sw/lib/ 
libiconv.dylib
-lm -lssl -lcrypto /usr/local/lib/libsasl2.dylib -Wl,-F. -Wl,-F.
/usr/bin/ld: Undefined symbols:
_PyArg_ParseTuple
_PyCObject_AsVoidPtr
_PyCObject_FromVoidPtrAndDesc
_PyCObject_GetDesc
_PyCObject_Type
_PyDict_SetItemString
_PyErr_NewException
_PyErr_Occurred
_PyErr_SetObject
_PyErr_SetString
_PyExc_IOError
_PyExc_IndexError
_PyExc_MemoryError
_PyExc_NameError
_PyExc_OverflowError
_PyExc_RuntimeError
_PyExc_SyntaxError
_PyExc_SystemError
_PyExc_TypeError
_PyExc_ValueError
_PyExc_ZeroDivisionError
_PyFloat_FromDouble
_PyInt_AsLong
_PyInt_FromLong
_PyModule_AddObject
_PyModule_GetDict
_PyObject_CallObject
_PyObject_GetAttr
_PyObject_SetAttrString
_PyString_FromString
_PyType_Type
_Py_BuildValue
_Py_InitModule4
__Py_NoneStruct
collect2: ld returned 1 exit status
make[1]: *** [_lasso.la] Error 1
make: *** [all-recursive] Error 1

To me it looks like there is a missing library somewhere, but then I  
might be wrong.

I've tried with different versions of swig 1.3.21 - 1.3.27 with the  
same result.
It's the 0.6.3 version of lasso I'm trying to build.

Comments ?

-- Roland

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


enter and event

2005-12-04 Thread Ben Bush
When I read python Manuel, I got confused by the following code:
def turnRed(self, event):
event.widget[activeforeground] = red

self.button.bind(Enter, self.turnRed)
I can not understand it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Instances behaviour

2005-12-04 Thread Giovanni Bajo
Mr.Rech wrote:

 and so on. The problem I'm worried about is that an unaware user may
 create an instance of A supposing that it has any real use, while it
 is only a sort of prototype. However, I can't see (from my limited
 point of view) any other way to rearrange things and still get a
 similar behaviour.


1) Document your class is not intended for public use.
2) Make your A class private of the module that defines it. A simple way is
putting an underscore in front of its name.
3) Make your A class non-functional. I assume B and C have methods that A
doesn't. Then, add those methods to A too, but not implement them:

 def foo(self):
   Foo this and that. Must be implemented in subclasses.
   raise NotImplementedError

-- 
Giovanni Bajo


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


want to get the pointer of any python object in C++, but I Failed.

2005-12-04 Thread lg2779
Hello all
I am trying to call the method of python object. But I dont know
how to transfer the pointer of the python object into c++  .

the C++ method to receive python object pointer :

static PyObject*
ReceivePythonPointer(PyObject* self, PyObject* args)
{
   PyObject* temp=NULL ;

  //translate into C++ pointer, but Failed, the temp is null
   if ( PyArg_ParseTuple(args, 0, tmp) )
   {
 //tmp
   }
}

to call c method in the following python script:
class foo:
  def __init__(self):
  ReceivePythonPointer(self)
  def Func(self):
   print 'Func'
f1 foo

Is it impossible to get the pointer of C object when
ReceviePythonPointer is Called?
I want to get the pointer of f1 object, Can you give me some advice ?

Best wishes.

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


oval

2005-12-04 Thread Ben Bush
I tested the following code and wanted to get the message of oval2
got hit if I click the red one. But I always got oval1 got hit.
from Tkinter import *
root=Tk()
canvas=Canvas(root,width=100,height=100)
canvas.pack()
a=canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
b=canvas.create_oval(50,50,80,80,tags='oval2',fill='red')
def myEvent(event):
if a:
print oval1 got hit!
else:
print oval2 got hit
canvas.tag_bind('oval1','Button',func=myEvent)
canvas.tag_bind('oval2','Button',func=myEvent)
root.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urllib on windows machines

2005-12-04 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 I've got a strange problem on windows (not very familiar with that OS).
 
 I can ping a host, but cannot get it via urllib (see here under).
 I can even telnet the host on port 80.
 
 Thus network seems good, but not for python ;-(.
 
 Does any windows specialist can guide me (a poor linux user) to get
 Network functionalitiies with python on windows ?
 
 I'm runnning on Windows XP (sorry to not give more, I don't know the
 equivalent of uname).
 I'm using standard (msi) python-2.4.2
 
 Thanks.
 
 
 
 test.py contains the following lines:
 
 import urllib
 g=urllib.urlopen('http://www.google.com')
 
 
 
 C:\Temppython test.py
 Traceback (most recent call last):
   File test.py, line 2, in ?
 g=urllib.urlopen('http://www.google.com')
   File c:\william\tools\python24\lib\urllib.py, line 77, in urlopen
 return opener.open(url)
   File c:\william\tools\python24\lib\urllib.py, line 185, in open
 return getattr(self, name)(url)
   File c:\william\tools\python24\lib\urllib.py, line 308, in
 open_http
 h.endheaders()
   File c:\william\tools\python24\lib\httplib.py, line 795, in
 endheaders
 self._send_output()
   File c:\william\tools\python24\lib\httplib.py, line 676, in
 _send_output
 self.send(msg)
   File c:\william\tools\python24\lib\httplib.py, line 643, in send
 self.connect()
   File c:\william\tools\python24\lib\httplib.py, line 627, in connect
 raise socket.error, msg
 IOError: [Errno socket error] (10053, 'Software caused connection
 abort')
 
 C:\Tempping www.google.com
 
 Pinging www.l.google.com [66.249.93.104] with 32 bytes of data:
 
 Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
 Reply from 66.249.93.104: bytes=32 time=23ms TTL=246
 Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
 Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
 
 Ping statistics for 66.249.93.104:
 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
 Approximate round trip times in milli-seconds:
 Minimum = 22ms, Maximum = 23ms, Average = 22ms
 
Something is clearly wrong. here's *my* XP system connecting to Google:

C:\Stevepython
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
  import urllib
  f = urllib.urlopen('http://www.google.com')
  len(f.read())
2690
 

I suspect you may have a firewall problem: you could need to tell your 
(XP Service Pack 2 personal) firewall it's OK for Python to make 
outbound network connections.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Colorize expanded tabs

2005-12-04 Thread qwweeeit
Hi all,
from a string embedding tabs I want to colorize them when expanded:

# Starting from a string:
a= '1234\t5678\t\t90\nqwerty\nasdfg'
# which embeds both tabs and lfs

# printing it you obtain:
print a
# 1234567890
# qwerty
# asdfg

# print automatically expands tabs and interprets the NL.

# to colorize the expanded tabs, I tried:
print a.replace('\t',\033[41m\t\033[0m) # 41 = red color
# instead it works (in Linux) for the \n (substituted with a red
space):
print a.replace('\n',\033[41m \033[0m\n)

Can you help me?
Bye.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Roel Schroeven
Dave Hansen wrote:
 It's far more interesting to me _why_ people think indentation scoping
 is a bad thing.  The answer I get back fall into two general
 categories: 1) I've heard/read/been told it's a bad thing, and 2) It
 causes portability problems.

I can tell you why it freightened me at first: it made me think of the
rigid formatting of Fortran 77 and to a lesser extent BASIC. But when I
started working my way trough the tutorial, that fear very rapidly vanished.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: regexp non-greedy matching bug?

2005-12-04 Thread Fredrik Lundh
Mike Meyer wrote:

 ^ must match the beginning of the string (BTW, you can get the same
 behavior by leaving off the ^ and using search instead of match).

that's backwards, isn't it?  using ^ with match is usually pointless (since
match only looks at the first position anyway), and using ^ with search
is also usually pointless...

(the only time you really need ^ is in certain multiline searches; depending
on what flags you use, ^ can match not only at the beginning of a string,
but also after each newline character in the target string)

/F



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


Re: oval

2005-12-04 Thread Diez B. Roggisch
Ben Bush wrote:
 I tested the following code and wanted to get the message of oval2
 got hit if I click the red one. But I always got oval1 got hit.
 from Tkinter import *
 root=Tk()
 canvas=Canvas(root,width=100,height=100)
 canvas.pack()
 a=canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
 b=canvas.create_oval(50,50,80,80,tags='oval2',fill='red')
 def myEvent(event):
 if a:

Here is your problem. a is a name, bound to some value. So - it is true, 
as python semantics are that way. It would not be true if it was e.g.

False, [], {}, None, 


What you want instead is something like

if event.source == a:
 ...

Please note that I don't know what event actually looks like in Tkinter, 
so check the docs what actually gets passed to you.


Regards,

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


Re: regexp non-greedy matching bug?

2005-12-04 Thread Mike Meyer
John Hazen [EMAIL PROTECTED] writes:
 To do what you said you want to do, you want to use the split method:
 
 foo = re.compile('foo')
 if 2 = len(foo.split(s)) = 3:
print We had one or two 'foo's

 Well, this would solve my dumbed down example, but each foo in the
 original expression was a stand-in for a more complex term. 

That actually doesn't matter. Just replace 'foo' with your more
complex term.

 foo2 = re.compile(r'foo(\d+)bar')

 I was using
 match groups to extract the parts of the match that I wanted.  Here's an
 example (using Tim's correction) that actually demonstrates what I'm
 doing:
 s = 'zzzfoo123barxxxfoo456baryyy'
 s2 = 'zzzfoo123barxxxfooyyy'
 foobar2 = re.compile(r'^.*?foo(\d+)bar(.*foo(\d+)bar)?.*$')
 print foobar2.match(s).group(1)
 123
 print foobar2.match(s).group(3)
 456

 foo2.split('zzzfoo123barxxxfoo456baryyy')
['zzz', '123', 'xxx', '456', 'yyy']
 

 print foobar2.match(s2).group(1)
 123
 print foobar2.match(s2).group(3)
 None
 

 foo2.split('zzzfoo123barxxxfooyyy')
['zzz', '123', 'xxxfooyyy']

 Looking at re.split, it doesn't look like it returns the actual matching
 text, so I don't think that fits my need.

split() returns the text matched by groups in the pattern used to do
the split, and is documented as doing so. The solution you gave
doesn't return the actual matching text for the instances, but just
the text in the groups inside that text - which is exactly what
split() returns.

While on that topic, I'll note that the solution Tim gave you doesn't
solve the problem as I originally understood it, either. You said you
wanted to match one or two instances, which I read as only one or two
instances, so that more than two instances would be treated as a
failure. On rereading it, I can see where I was wrong.

 As the founder of SPARE...
 Hmm, not a very effective name.  A google search didn't fing any obvious
 hits (even after adding the python qualifier, and removing spare time
 and spare parts hits).  (I couldn't find it off your homepage,
 either.)

That's the Society for the Prevention of Abuse of Regular
Expressions. One of these days, my proof-reader will get back to me
and I'll add a link about it to my home page.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: want to get the pointer of any python object in C++, but I Failed.

2005-12-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 I am trying to call the method of python object. But I dont know
 how to transfer the pointer of the python object into c++  .

 the C++ method to receive python object pointer :

 static PyObject*
 ReceivePythonPointer(PyObject* self, PyObject* args)
 {
PyObject* temp=NULL ;

   //translate into C++ pointer, but Failed, the temp is null
if ( PyArg_ParseTuple(args, 0, tmp) )
{
  //tmp
}
 }

use the letter O (for object), not the digit 0.

adding some error checking would also be a good idea. if PyArg_ParseTuple
returns false, Python's exception state is set.  you can use the PyErr_Print
function to print the exception traceback (this is very useful during debugging,
at least).

/F



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


Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-04 Thread Leif K-Brooks
Leif K-Brooks wrote:
 It's perfectly reasonable behavior, and it also applies to Linux. The
 shell uses spaces to separate arguments; how do you expect it to know
 that you want a space to be part of the program's name unless you escape it?

I'm sorry, disregard my message. I failed to read the OP properly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-04 Thread Leif K-Brooks
[EMAIL PROTECTED] wrote:
 This comes up from time to time.  The brain damage is all Windows', 
 not Python's.

It's perfectly reasonable behavior, and it also applies to Linux. The
shell uses spaces to separate arguments; how do you expect it to know
that you want a space to be part of the program's name unless you escape it?

 Here's one thread which seems to suggest a bizarre doubling of the 
 initial quote of the commandline.

A better solution would be to use subprocess:
http://python.org/doc/current/lib/module-subprocess.html.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)

2005-12-04 Thread Sybren Stuvel
Björn Lindström enlightened us with:
 This article should explain it:

 http://www.jwz.org/doc/tabs-vs-spaces.html

To me it doesn't. I use a single tab character for a single indent
levell. That is unambiguous, and also ensures the file is indented as
the reader likes it. People who have their tab size set to 'n' will
see n-space sized indents,

No matter what setting, the order of the indents is kept. This is not
the case if tabs and spaces are intermixed, as some style guides
suggest.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Most SHAMEFUL one-liner:

2005-12-04 Thread Jeremy Moles
I was looking through some code of my today and noticed this little gem
I wrote a few days back that I had totally forgot about:

fill = [(%%-%ds\n % (columns - 1)) %   for i in range(yoffset - 2)]

...and then I went on to do:

.join(fill)

Talk about using the wrong tool for the job... :(

All I needed was:

  * (columns - 1) * (yoffset - 2)

Anyone else remember any shameful one-liners like this? :) I'm just
curious to see what kinda mistakes people make you think about a
solution WAY TO HARD... :)

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread JohnBMudd
This is amazing.

Python could take over the programming world except one of it's best
features (scope by indent) is a primary reason why it never will.  It's
not flexible enough.  A large percentage of programmers won't even try
the language.

And even amongst Python enthusiast who appreciate the feature (me
included) we can't agree on how to use it.  Python is too flexible.

And nobody else sees the need for change?  Oh, except those who think
Tabs are evil and should no longer be allowed.

How about (1) add some more flexibility for optional braces and (2) add
a formatting tool so I can reformat Python code to the correct style?
 Python is just a  program, not a religion.  Unless... Tabs really are
evil.

John

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


Re: Scientific Notation

2005-12-04 Thread Fredrik Lundh
   You mean something like:
  
print '%e' % (1e50)
   1.00e+50
  
   ...?

  No, I mean given a big number, such as
  1000, convert it into
  scientific notation.

 It's the same.

  print %e % 1000
 1.00e+51

one would have assumed that someone who *prefers* to use scientific notation
for large numbers would in fact know that, but the usenet never ceases to sur-
prise me...

/F



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


Re: regexp non-greedy matching bug?

2005-12-04 Thread Mike Meyer
Fredrik Lundh [EMAIL PROTECTED] writes:
 Mike Meyer wrote:
 ^ must match the beginning of the string (BTW, you can get the same
 behavior by leaving off the ^ and using search instead of match).
 that's backwards, isn't it?  using ^ with match is usually pointless (since
 match only looks at the first position anyway), and using ^ with search
 is also usually pointless...

Yup, you're right. The '^' was redundant in the OP's post.

 mike 
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Detect character encoding

2005-12-04 Thread Michal
Hello,
is there any way how to detect string encoding in Python?

I need to proccess several files. Each of them could be encoded in 
different charset (iso-8859-2, cp1250, etc). I want to detect it, and 
encode it to utf-8 (with string function encode).

Thank you for any answer
Regards
Michal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Fredrik Lundh
Ed Leafe wrote:

  That depends on your editor. Mine (vim) can be instructed to insert
  the appropriate amount of spaces on a tab, and remove them on a
  backspace.

  So let's say that you are using 4 spaces as your standard, but
 by accident type 5. You hit backspace, which deletes 4 spaces, and
 you now have to mentally compute the difference in order to keep
 things aligned.

  See, I can make up bizarre scenarios where spaces cause
 problems, too.

what's bizarre is that you're using an editor that don't understand how
blocks work in the language you're editing.

(in good python editor, tab means move to next indentation level
and backspace over a virtual tab means move to previous indentation
level.  if indentation is represented by spaces or tabs or both in the
resulting file is a serialization issue...)

/F



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


Re: How to execute an EXE via os.system() with spaces in the directoryname?

2005-12-04 Thread Fredrik Lundh
Peter Hansen wrote:

 It can't all be Windows' brain damage, since typing precisely the same
 command at the prompt (at least with the example I'm using) doesn't
 require doubling the initial quote of the command line.  Or, more
 precisely, Windows is brain damaged in at least two different places
 here, and the shell is only one of them...

the system function in the C runtime library function simply runs
the following command:

%COMSPEC% /c command

where COMSPEC usually points to cmd.exe.

so in the normal case, it's up to cmd.exe to parse the command string.
it uses the following algorithm to decide if it should remove quotes from
the command string (for compatibility with command.com?), or if they're
better left in place:

 cmd /?

 ...

 1.  If all of the following conditions are met, then quote characters
 on the command line are preserved:

 - no /S switch
 - exactly two quote characters
 - no special characters between the two quote characters,
   where special is one of: ()@^|
 - there are one or more whitespace characters between the
   the two quote characters
 - the string between the two quote characters is the name
   of an executable file.

 2.  Otherwise, old behavior is to see if the first character is
 a quote character and if so, strip the leading character and
 remove the last quote character on the command line, preserving
 any text after the last quote character.

 ...

/F



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


Request opinion on web application framework

2005-12-04 Thread Thomas
Hello,

I am new to web programming but have some experience in technical 
programming in Python and other languages.  I need to build a networked 
program which I would like to first deploy on an intranet and later on the 
web which provides access to a few technical applications, two document 
management systems (simple types), a database search tool and maybe in the 
future a groupware client.  All data will be stored in a database.  I want a 
common portal for all of these functions.

Can anyone recommend a web framework for such an application?  I have looked 
a little and most seem to focus on CMS type applications instead of 
technical programs.

Any suggestions would be appreciated.

Regards. 


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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread JohnBMudd
  you're about 10 years late

The same could be said for hoping that the GIL will be eliminated.
Utterly hopeless.

Until... there was PyPy.  Maybe now it's not so hopeless.

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


Re: distutils problem windows xp python 2.4.2

2005-12-04 Thread [EMAIL PROTECTED]
Hello Scott,

It didn't work with visual studio 5. .Net framework 2.0
Do you have any suggestions?

Thanks,
pujo

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 Python could take over the programming world except one of it's best
 features (scope by indent) is a primary reason why it never will.  It's
 not flexible enough.  A large percentage of programmers won't even try
 the language.

you're about 10 years late for this kind of trolling.

/F



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


Re: Request opinion on web application framework

2005-12-04 Thread Irmen de Jong
Thomas wrote:

 Can anyone recommend a web framework for such an application?  I have looked 
 a little and most seem to focus on CMS type applications instead of 
 technical programs.

Then IMO you haven't looked hard enough.

http://wiki.python.org/moin/WebProgramming

There's lots of libraries/frameworks/servers on that page that should
fit your needs. I made Snakelets, but Webware, Quixote, Karrigell,
CherryPy or the much discussed Turbogears are very interesting too.
I don't see why most seem to focus on CMS type apps.
Perhaps if you explain a bit better what you want?

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


Re: Scientific Notation

2005-12-04 Thread Dustan
Thanks for your help, Alex, Roy and Jorge. I'm new to Python, and
programming in general, which might explain my lack of knowledge,
Fredrick.

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


Re: Python Equivalent to Text::Autoformat

2005-12-04 Thread BartlebyScrivener
try searching on text wrapping

I tried that before I posted. Text::Autoformat does a lot more than
textwrap.

The fundamental task of the autoformat subroutine is to identify and
rearrange independent paragraphs in a text. Paragraphs typically
consist of a series of lines containing at least one non-whitespace
character, followed by one or more lines containing only optional
whitespace. This is a more liberal definition than many other
formatters use: most require an empty line to terminate a paragraph.
Paragraphs may also be denoted by bulleting, numbering, or quoting . .
.

Once a paragraph has been isolated, autoformat fills and re-wraps its
lines according to the margins that are specified in its argument list.
These are placed after the text to be formatted, in a hash reference:

It's also sensitive to comment characters in code and so on.

But I'll keep looking. Thank you. 

bs

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


Favorite flavor of Linux? (for python or anything else)

2005-12-04 Thread Ivan Shevanski
Looking to replace my older flavor of linux with something new. . .What
are some of your favorites for python programming and anything
else? 

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

Re: oval

2005-12-04 Thread Ben Bush
On 12/4/05, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 Ben Bush wrote:
  I tested the following code and wanted to get the message of oval2
  got hit if I click the red one. But I always got oval1 got hit.
  from Tkinter import *
  root=Tk()
  canvas=Canvas(root,width=100,height=100)
  canvas.pack()
  a=canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
  b=canvas.create_oval(50,50,80,80,tags='oval2',fill='red')
  def myEvent(event):
  if a:

 Here is your problem. a is a name, bound to some value. So - it is true,
 as python semantics are that way. It would not be true if it was e.g.

 False, [], {}, None, 


 What you want instead is something like

 if event.source == a:
 ...

 Please note that I don't know what event actually looks like in Tkinter,
 so check the docs what actually gets passed to you.

got AttributeError: Event instance has no attribute 'source'
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2005-12-04 Thread Cameron Laird
QOTW:  Python makes it easy to implement algorithms. - casevh

Most of the discussion of immutables here seems to be caused by
newcomers wanting to copy an idiom from another language which doesn't
have immutable variables. Their real problem is usually with binding,
not immutability. - Mike Meyer


Among the treasures available in The Wiki is the current
copy of the Sorting min-howto:
http://www.amk.ca/python/howto/sorting/sorting.html

Dabo is way cool--at least as of release 0.5:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/becf84a4f8b3d34/

Tim Golden illustrates that wmi is *not* the only way to
access win32 functionality, and in fact that Python can
mimic VisualBasicScript quite handily.  It's only mimicry,
though; VBS remains better suited for this specific class
of tasks:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/fa84850666488500/

Claudio Grondi explains ActiveX componentry--OCXs, the
registry, apartments, ...--for a Python audience:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/471306f2d6f6927/

Dao is a novel high-level language which advertises strong
multi-threading, Unicode, and particularly comfortable C++ 
interfacing.  Limin Fu provides details:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4418fac8dda696d9/

Donn Cave leads at least a score of others in comparing
lists and tuples:
http://groups.google.com/group/comp.lang.python/msg/dd6ba8df451d57e0?


Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=pythonShowStatus=all
The old Python To-Do List now lives principally in a
SourceForge reincarnation.

Re: Most SHAMEFUL one-liner:

2005-12-04 Thread Bengt Richter
On Fri, 02 Dec 2005 14:25:41 -0500, Jeremy Moles [EMAIL PROTECTED] wrote:

I was looking through some code of my today and noticed this little gem
I wrote a few days back that I had totally forgot about:

fill = [(%%-%ds\n % (columns - 1)) %   for i in range(yoffset - 2)]

...and then I went on to do:

.join(fill)

Talk about using the wrong tool for the job... :(

All I needed was:

  * (columns - 1) * (yoffset - 2)

So the original was wrong as well as a bit opaque? (What happened to the \n ? 
;-)

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


Re: want to get the pointer of any python object in C++, but I Failed.

2005-12-04 Thread lg2779
Thanks for your answer.
I cant understand yet.  The second parameter is 0  in the  python'
documentation.
Can you give up a piece of code?

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


CDDB.py binaries for Python 2.4

2005-12-04 Thread Kent Tenney
Howdy,

I'm using Python 2.4 on W2K

I would love to use the tools at
http://cddb-py.sourceforge.net/
the newest Win binaries are for Python 2.0

The dll won't load, I assume this is
due to version mismatch.

I'm not set up with a C compiler.
Does anyone know of a source of current
binaries for this package?

Thanks,
Kent

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


Re: how to handle two forms in cgi?

2005-12-04 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 Hi Dan,
 
 Sure. You are right. When I correct this according to your idea, it
 works now. Thank you very much. But I have second problem. When users
 run second form, other people can see adress in users' browers and know
 how to run the second form, so they don't need to run login form. How I
 can handle this case? How I can let users run login form firstly, then
 they can run second form(search form)?
 
 By the way I use python to write cgi.
 
 Any help is appriciated!
 
I'm afraid you are running into what are called session state 
problems. In other words, your system needs to be able to remember 
that a user has already successfully visited one page before allowing 
them to visit another.

There are various ways to solve this problem, but most of them revolve 
around maintaining state information for each different concurrent user 
of your web. Once a user successfully logs in your record logged in = 
True or similar in your session state memory, and at the start of each 
CGI script for which the user is required to be logged in you actually 
check the state memory to verify that is the case.

There are various mechanisms for maintaining session state, many of 
which rely on serving a cookie to each user's browser. This allows your 
server to identify which session any particular request is a part of.

See if

   http://starship.python.net/crew/davem/cgifaq/faqw.cgi?req=all#2.11

makes any sense to you. If not, you might want to Google around a bit 
for things like Python web session to see what you can find.

Note there are plenty of web frameworks (e.g. CherryPy, mod_python) that 
offer assistance with maintaining session state, but it isn't impossible 
to maintain it yourself in CGI scripts once you understand the problem. 
Good luck!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: want to get the pointer of any python object in C++, but I Failed.

2005-12-04 Thread lg2779
Thanks for your answer.
I cant understand yet.  The second parameter is 0  in the  python'
documentation. 
Can you give me a piece of code?

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Benji York
Ed Leafe wrote:
  So let's say that you are using 4 spaces as your standard, but  
 by accident type 5. You hit backspace, which deletes 4 spaces,

Nope, it would delete a single space.  Then an additional backspace 
would delete the 4.

  See, I can make up bizarre scenarios where spaces cause  
 problems, too.

Only if you don't know how decent editors behave. :)
--
Benji York

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


Re: want to get the pointer of any python object in C++, but I Failed.

2005-12-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote

 I cant understand yet.  The second parameter is 0  in the  python'
 documentation.

what documentation?

the official PyArg_ParseTuple documentation at

http://docs.python.org/api/arg-parsing.html

uses the letter O (use cut and paste if you don't believe me).

/F 



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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Sybren Stuvel
Ed Leafe enlightened us with:
 See, I can make up bizarre scenarios where spaces cause  problems,
 too.

You make me glad I'm always using tabs :)

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils problem windows xp python 2.4.2

2005-12-04 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
 It didn't work with visual studio 5. .Net framework 2.0
 Do you have any suggestions?

It didn't work is not very diagnosable.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Equivalent to Text::Autoformat

2005-12-04 Thread Dan Sommers
On 4 Dec 2005 05:58:08 -0800,
BartlebyScrivener [EMAIL PROTECTED] wrote:

 try searching on text wrapping
 I tried that before I posted. Text::Autoformat does a lot more than
 textwrap.

 The fundamental task of the autoformat subroutine is to identify and
 rearrange independent paragraphs in a text. Paragraphs typically
 consist of a series of lines containing at least one non-whitespace
 character, followed by one or more lines containing only optional
 whitespace. This is a more liberal definition than many other
 formatters use: most require an empty line to terminate a paragraph.
 Paragraphs may also be denoted by bulleting, numbering, or quoting . .
 .

Try the formatter module:

http://www.python.org/doc/current/lib/module-formatter.html

Regards,
Dan

-- 
Dan Sommers
http://www.tombstonezero.net/dan/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Colorize expanded tabs

2005-12-04 Thread Peter Otten
qwweeeit wrote:

 Hi all,
 from a string embedding tabs I want to colorize them when expanded:
 
 # Starting from a string:
 a= '1234\t5678\t\t90\nqwerty\nasdfg'
 # which embeds both tabs and lfs
 
 # printing it you obtain:
 print a
 # 1234567890
 # qwerty
 # asdfg
 
 # print automatically expands tabs and interprets the NL.
 
 # to colorize the expanded tabs, I tried:
 print a.replace('\t',\033[41m\t\033[0m) # 41 = red color
 # instead it works (in Linux) for the \n (substituted with a red
 space):
 print a.replace('\n',\033[41m \033[0m\n)
 
 Can you help me?
 Bye.

If all else fails you can colorize the tabs after converting them to
spaces:

def splititer(text, token):
# A lazy iter(text.split(token)).
# Probably not worth the effort.
start = 0
while True:
try:
end = text.index(token, start)
except ValueError:
break
yield text[start:end]
start = end + len(token)
yield text[start:]

def colortabs(text, tabcolor, normcolor, tabwidth=8):
parts = splititer(text, \t)
part = parts.next()
pos = len(part)
yield part
for part in parts:
width = tabwidth - pos % tabwidth
yield tabcolor
yield   * width
yield normcolor
yield part
pos += width + len(part)

print \t1234\t5678\t\t90.replace(\t, \033[41m\t\033[0m)
print .join(colortabs(\t1234\t5678\t\t90, \033[41m, \033[0m))

Peter

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


Re: oval

2005-12-04 Thread Peter Otten
Ben Bush wrote:

 On 12/4/05, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 Ben Bush wrote:
  I tested the following code and wanted to get the message of oval2
  got hit if I click the red one. But I always got oval1 got hit.
  from Tkinter import *
  root=Tk()
  canvas=Canvas(root,width=100,height=100)
  canvas.pack()
  a=canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
  b=canvas.create_oval(50,50,80,80,tags='oval2',fill='red')
  def myEvent(event):
  if a:

 Here is your problem. a is a name, bound to some value. So - it is true,
 as python semantics are that way. It would not be true if it was e.g.

 False, [], {}, None, 


 What you want instead is something like

 if event.source == a:
 ...

 Please note that I don't know what event actually looks like in Tkinter,
 so check the docs what actually gets passed to you.
 
 got AttributeError: Event instance has no attribute 'source'

Note that Diez said /something/ /like/ /event.source/. The source is
actually called widget -- but that doesn't help as it denotes the canvas as
a whole, not the individual shape.

The following should work if you want one handler for all shapes:

def handler(event):
print event.widget.gettags(current)[0], got hit
canvas.tag_bind('oval1', 'Button', handler)
canvas.tag_bind('oval2', 'Button', handler)

I prefer one handler per shape:

def make_handler(message):
def handler(event):
print message
return handler

canvas.tag_bind('oval1', 'Button', make_handler(oval 1 got hit))
canvas.tag_bind('oval2', 'Button', make_handler(oval 2 got hit))

Peter

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


Re: Python Equivalent to Text::Autoformat

2005-12-04 Thread Peter Hansen
BartlebyScrivener wrote:
try searching on text wrapping
 
 I tried that before I posted. Text::Autoformat does a lot more than
 textwrap.

Sounds like you are describing something known by various names, often 
including some part of structured text.  Try googling for that 
instead: http://www.google.com/search?q=python+structured+text

-Peter

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


Re: Detect character encoding

2005-12-04 Thread Scott David Daniels
Michal wrote:
 Hello,
 is there any way how to detect string encoding in Python?
 
 I need to proccess several files. Each of them could be encoded in 
 different charset (iso-8859-2, cp1250, etc). I want to detect it, and 
 encode it to utf-8 (with string function encode).
 
 Thank you for any answer
 Regards
 Michal
The two ways to detect a string's encoding are:
   (1) know the encoding ahead of time
   (2) guess correctly

This is the whole point of Unicode -- an encoding that works for _lots_
of languages.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: want to get the pointer of any python object in C++, but I Failed.

2005-12-04 Thread lg2779
The bug is filled. I'm fool. 
Thank's your answer. :)

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


Re: oval

2005-12-04 Thread Diez B. Roggisch

What you want instead is something like

if event.source == a:
...

Please note that I don't know what event actually looks like in Tkinter,
so check the docs what actually gets passed to you.
 
 
 got AttributeError: Event instance has no attribute 'source'

As I said: I don'k _know_ how event actually looks like,a s I'm not a 
Tkinter-expert, but I've had plenty of projects involving other 
GUI-Toolkits, which work all the same in this manner. After all the 
whole purposs of the event parameter is to inform you about the cause 
for that event - in this case the pressing of a MB on a specific canvas 
element.

But if you'd take it on you to consult the documentation as I asked you 
to do, I'm pretty sure you find the proper attribute.


Regards,

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


Re: Detect character encoding

2005-12-04 Thread Diez B. Roggisch
Michal wrote:
 Hello,
 is there any way how to detect string encoding in Python?
 
 I need to proccess several files. Each of them could be encoded in 
 different charset (iso-8859-2, cp1250, etc). I want to detect it, and 
 encode it to utf-8 (with string function encode).

You can only guess, by e.g. looking for words that contain e.g. umlauts. 
Recode might be of help here, it has such heuristics built in AFAIK.

But there is _no_ way to be absolutely sure. 8bit are 8bit, so each file 
is legal in all encodings.


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


Re: regexp non-greedy matching bug?

2005-12-04 Thread Aahz
In article [EMAIL PROTECTED],
Fredrik Lundh [EMAIL PROTECTED] wrote:

that's backwards, isn't it?  using ^ with match is usually pointless (since
match only looks at the first position anyway), and using ^ with search
is also usually pointless...

While you're technically correct, I've been bitten too many times by
forgetting whether to use match() or search().  I've fixed that problem
by choosing to always use search() and combine with ^ as appropriate.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck.  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Request opinion on web application framework

2005-12-04 Thread Bruno Desthuilliers
Thomas a écrit :
 Hello,
 
 I am new to web programming but have some experience in technical 
 programming in Python and other languages.  I need to build a networked 
 program which I would like to first deploy on an intranet and later on the 
 web which provides access to a few technical applications, two document 
 management systems (simple types), a database search tool and maybe in the 
 future a groupware client.  All data will be stored in a database.  I want a 
 common portal for all of these functions.
 
 Can anyone recommend a web framework for such an application?  I have looked 
 a little and most seem to focus on CMS type applications instead of 
 technical programs.

Django or Turbogears would be perfect candidates IMHO.
-- 
http://mail.python.org/mailman/listinfo/python-list


newbie - needing direction

2005-12-04 Thread bobueland
I'm a newbie, just got through van Rossum's tutorial and I would like
to try a small project of my own. Here's the description of my project.

When the program starts a light blue semi-transparent area, size 128 by
102,  is placed in the middle of the screen. The user can move this
area with arrow the keys. When the user hits the Enter key, a magnified
picture of the chosen area is shown on the screen (10 times
magnification on a 1280 by 1024 monitor). When the user hits the Enter
key the program exits leaving the screen as it was before the program
started.

Could someone direct me what libraries and modules I should study in
order to accomplish this.

Thanks Bob

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


Re: newbie write to file question

2005-12-04 Thread Rob E
 I'm not sure what I'm
 missing so I'd appreciate some advice.
You question is pretty general and I'm not going to go over this in any
great detail, but I will make a few comments. 

*  In your if section use if ... else constructs not all the strange if 
   and then not if blocks.  Also get rid of all those unneeded if's with the 
   pass in them.  They do nothing.
*  You may want to put the heart of the code in a separate function or if 
   you need persistance, use a class.  Optional and depends on how complex
   your analysis code is going to be.  Generally one function should not
   be two deep in terms of block nesting for readabilily
   and maintainability.
*  the table initialization i.e. table = {} was outside of your main file
   scan loop, that seemed strange to me since I think you were doing this
   file by file.
*  your log writing code was indented below the the if sub_three is None:
   if block which means that it's inside that block -- that's probably not
   what you want.  Remember python defines blocks by indentation.  The
   indentation is a nice feature because python blocking is in fact like
   it looks (unlike C++).  
*  if your parsing XML and maybe SGML the python library has some special 
   tools for this.  You might want to look at the lib or search the net.

Take care,
Rob

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


Re: Python Equivalent to Text::Autoformat

2005-12-04 Thread BartlebyScrivener
Formatter and docutils both look promising.

Thanks for providing the terminology to search on.

-rpd

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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-04 Thread Christoph Haas
On Sunday 04 December 2005 15:01, Ivan Shevanski wrote:
 Looking to replace my older flavor of linux with something new. . .What
 are some of your favorites for python programming and anything else?

The operating system/distribution is not connected to the application 
(Python). It will probably run everywhere. But we recently had this topic 
and a majority seemed to vote for Ubuntu. I personally prefer Debian.

 Christoph
-- 
~
~
.signature [Modified] 1 line --100%--1,48 All
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie write to file question

2005-12-04 Thread Scott David Daniels
ProvoWallis wrote:
...
 for root, dirs, files in os.walk(setpath):
  fname = files
  for fname in files:
   inputFile = file(os.path.join(root,fname), 'r')
   while 1:
lines = inputFile.readlines(1)
if not lines:
 break
for line in lines:
 ...
Is pretty verbose.  Also, open is meant to be the function to use.
Try:
 for root, dirs, files in os.walk(setpath):
for fname in files:
inputFile = open(os.path.join(root,fname), 'r')
for line in inputFile:
...
inputFile.close()


There is no point to lines like:
  if main is None:
   pass
Just drop it.

Perhaps what you meant was:
   if main is None:
continue
If so, change:
 if main is not None:
  table[main.group(1)] = main.group(2)
  m = main.group(1)
  if main is None:
   pass
To:
   if main is None:
   continue
   table[main.group(1)] = main.group(2)
   m = main.group(1)

As Rob E pointed out, your postlude has the wrong indentation.
You may want:
 for root, dirs, files in os.walk(setpath):
for fname in files:
inputFile = open(os.path.join(root, fname), 'r')
for line in inputFile:
...
inputFile.close()
if table:
name, ext = os.path.splitext(fname)
output_name = name + '.log'
outputFile = open(os.path.join(root, name + '.log'), 'w')
outputFile.write(str(table))
outputFile.close()
table = {}
So that you only write logs if something was found.


-- 
-Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-04 Thread Brendan
Thank you all for your help.  Alex's listify does the job well.  I will
reconsider using an atomic Thing class with Michaels' safeList.
Bengt wins the prize for reducing sLen to one line!

I still feel like I'm working against the grain somewhat, (Mike's
right, I am coming at this with a C++ mindset) but at least I have
tools to do it efficiently :)

Brendan

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-04 Thread malv
This is probably a fair answer.
My experience: Two years ago I started with Boa till I discovered eric.
I have been with eric ever since. Eric uses Qt as GUI. I think both Qt
and wx enable you to do pretty much the same thing. I like the work
F.Lundh did on Tkinter, but every time I try, I get bogged down in the
tcl mess that it builds on. Take the example of the indispensible
datagrid: a piece of cake in both Qt and wxWidgets, a nightmare
otherwise.

Since a couple of weeks I made the tour of wing-ide, komodo and PyDev.
PyDev appears really to be a top heavy kludge. Perhaps OK for java
lovers but very laborious to set up and work with, this in spite of the
abundant hype  spam on this board. Wing-ide's debugger stops on
imagined errors where eric and komodo do allright. I could not get the
designer to run on komodo. So I'm back at eric. On eric you use the
superb Qt designer. If you run linux, you get Qt and PyQt with KDE. You
can keep on running gnome if you want. For windows, Qt4 is supposed to
be free. Further, very extensive and attractive extensions exist: qwt
and qwt3d for graphics.

This is my experience. If I find better, I'll change.
malv

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


Re: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)

2005-12-04 Thread Lee Harr
 No matter what setting, the order of the indents is kept. This is not
 the case if tabs and spaces are intermixed, as some style guides
 suggest.



I have never seen anyone suggest mixing tabs and spaces, and I
have read a lot of tabs-vs-spaces flamewars in my time.

Everyone agrees that mixing is bad. I might even go so far as to
say that the only real problem is mixing. The question is, if we
are trying to pick only one, which one causes fewer problems.

For me, it is spaces.

(oh, and unix line endings ;o)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-04 Thread malv
I have been around quite a bit.
The best are Gentoo and Debian.
However, Python being very much an essential component of your distro,
not having Python2.4 as standard kind of eliminates Debian. Running two
versions in parallel is not the way to go.

Gentoo requires quite a bit of work though. As I have to support
several architectures, I looked around at Novell Suse and Ubuntu.
Especially if you want flawless notebooks on linux, these two seemed
best to me. I kind of discarded Ububtu because of the incompatibility
between the compiler coming with the latest version and the kernel. You
discover this quickly when trying to compile some kernel modules.
Ubuntu is quite nice if your technical demands don't require much. If
you're in python, you may one day run into some problem with addons.
So Suse is what I use right now. Besides their YAST they now feature
Synaptic. Overall, as nice as Ubuntu, somewhat easier with linux system
work.
I often wonder though whether I should not go back to Gentoo after all.
More work, but you never seem to run into problems like with Suse or
Ubuntu. Gentoo also has a very nice community always willing to help.
Documentation is also very nice at Gentoo. Novell is kind of a mess.

FWIW, that's my honest opinion.
malv

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


Re: newbie - needing direction

2005-12-04 Thread bobueland
I should maybe mention that I want to this on a win XP computer

Bob

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


getting data off a CDrom

2005-12-04 Thread julien . lord
Hi there,

I'm trying to load data from 2 different CD drives to compare the data
on them to see if they are identical.  I've found the WinCDRom module
online but it doesn't seem to give access to the data at all. The only
thing it seems to do is check if there is a readable cd in a specific
drive.

Any ideas/suggestions/flames?

Thanks,

Julien

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


Putting in an html table

2005-12-04 Thread Little
Could someone start me on putting in a table into this code, and some
HTML tags. I would to make the table below the map and have a header at
the top. Thanks for the help.

 Publisher example 

def query(req, building=):
# NOTE:  best way to understand this is to see the output,
#  that is, to view source on the generated web page
# read common header for any google mapping
f = file('/home/ta/public_html/maplish/googleHead.html','r')
t = f.read()
f.close()
# define the two buildings we know (because no SQL is done here)
buildings =  [ (cb, Cambus Office,  -91.552977, 41.659655)
]
buildings +=  [ (va/hardlib, VA/Hardin Library, -91.549501,
41.662348) ]
buildings +=  [ (hancher, Hancher Auditorium,  -91.538214,
41.669529) ]
buildings +=  [ (currier, Currier Hall,  -91.534996,
41.666163) ]
buildings +=  [ (schaeffer, Schaeffer Hall,  -91.535296,
41.660969) ]
buildings +=  [ (shospital, South Hospital,  -91.548900,
41.658885) ]
str = ''  #  in case no buildings match, use empty string
for x in buildings:
   a,b,c,d = x   # isolate all the tuple components into a,b,c,d
   if building.lower() == a:
  # construct javascript, using Python %s to substitute names
and data
  # see http://docs.python.org/lib/typesseq-strings.html if
needed
  str =  'var bldg%s = new GPoint( %s, %s);\n' % (a, c, d)
  str += 'var mrk%s = new GMarker( bldg%s );\n' % (a, a)
  str += 'var htm%s = %s;\n' % (a, b)
  str += 'GEvent.addListener(mrk%s,click,function() {' % a
  str += 'mrk%s.openInfoWindowHtml(htm%s); });\n' % (a, a)
  str += 'map.addOverlay(mrk%s);\n' % a
# output markers, if any
t = t + str
# then add trailing html to finish page
trail = //]] /script /body /html
t = t + trail
return t

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


Re: getting data off a CDrom

2005-12-04 Thread Irmen de Jong
[EMAIL PROTECTED] wrote:
 Hi there,
 
 I'm trying to load data from 2 different CD drives to compare the data
 on them to see if they are identical.  I've found the WinCDRom module
 online but it doesn't seem to give access to the data at all. The only
 thing it seems to do is check if there is a readable cd in a specific
 drive.
 
 Any ideas/suggestions/flames?

If you're on Linux this should do the trick, i think:

$ cmp /dev/scd0 /dev/scd1


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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-04 Thread Aahz
In article [EMAIL PROTECTED],
Christoph Haas  [EMAIL PROTECTED] wrote:

The operating system/distribution is not connected to the application
(Python). It will probably run everywhere. But we recently had this
topic and a majority seemed to vote for Ubuntu. I personally prefer
Debian.

Ubuntu *is* Debian, just repackaged.  I used to prefer Debian until
stable wouldn't work with my newest machine because it was two years out
of date (this was *not* a machine with bleeding-edge components).  Of
course, one can use Debian-testing, but that isn't packaged, and I want
a packaged OS.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck.  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)

2005-12-04 Thread Peter Decker
On 12/4/05, Lee Harr [EMAIL PROTECTED] wrote:

 Everyone agrees that mixing is bad. I might even go so far as to
 say that the only real problem is mixing. The question is, if we
 are trying to pick only one, which one causes fewer problems.

 For me, it is spaces.

Why is it that the only people who complain about this issue, and who
act all religious and self-righteous about it, are the ones who prefer
spaces?

I never cared one way or the other; I just used spaces because it
seemed that everyone else did. I recently switched to tabs because I'm
working a lot in Dabo, and they use tabs as their standard. But I must
say that listening to the space-zealots here has turned me off to
their arguments. My rule-of-thumb is that people only resort to such
zealotry when they have nothing better to offer. I've *never* seen any
of the problems they cite, and I hate to say how long I've been
around.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CDDB.py binaries for Python 2.4

2005-12-04 Thread Giovanni Bajo
Kent Tenney wrote:

 I would love to use the tools at
 http://cddb-py.sourceforge.net/
 the newest Win binaries are for Python 2.0

I packaged these for you, but they're untested:

http://www.develer.com/~rasky/CDDB-1.3.win32-py2.3.exe
http://www.develer.com/~rasky/CDDB-1.3.win32-py2.4.exe
-- 
Giovanni Bajo


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


Re: newbie - needing direction

2005-12-04 Thread Giovanni Bajo
[EMAIL PROTECTED] wrote:

 I'm a newbie, just got through van Rossum's tutorial and I would like
 to try a small project of my own. Here's the description of my project.

 When the program starts a light blue semi-transparent area, size 128 by
 102,  is placed in the middle of the screen. The user can move this
 area with arrow the keys. When the user hits the Enter key, a magnified
 picture of the chosen area is shown on the screen (10 times
 magnification on a 1280 by 1024 monitor). When the user hits the Enter
 key the program exits leaving the screen as it was before the program
 started.

 Could someone direct me what libraries and modules I should study in
 order to accomplish this.


I'd try something easier (with less interaction with Windows). Pygame should
provide everything you need for this kind of applications:
http://www.pygame.org/

Then you can use pywin32 (http://sourceforge.net/projects/pywin32) to bind
to the Windows API and accomplish what you need.
-- 
Giovanni Bajo


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


Re: Eclipse best/good or bad IDE for Python?

2005-12-04 Thread Avizoa
Though I tried most the above listed IDEs, sticking with a few for
awhile, I always find myself gravitating back to the one no one ever
mentions: IDLE. It's simple, fast, and with multiple monitors the lack
of tabs really isn't much of a problem.

The biggest reason I've found myself using IDLE is the
colorizing...I've found little support in other editors for builtins
having their own color. Granted, I haven't gotten far enough to bother
with that in some editors. Eclipse, for example, performs like a dog on
my dual opteron workstation w/ 2GB of RAM, which is more than enough to
annoy me. I shouldn't have to wait more than about 1 second for an
editor to start and then open what is essentially a text file :-P.

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


Building Python 2.4 on machines that do not support dynamic loading

2005-12-04 Thread Robert McLay
I have been trying to build python on Cray X1.  As far as I can
tell it does not support dynamic loading.  So the question is:

   How to build 2.4 without dynamic loading?

That is: can I build 2.4 where all the extensions are archived in
libpython2.4.a as a static library?

Building on the Cray X1 is slow, so I have been trying to also
build it under Linux without dynamic loading since it 
configures/builds so much faster.

I edited the configure script so that it doesn't know that dlopen 
works.  The file pyconfig.h undefines HAVE_DYNAMIC_LOADING
HAVE_LIBDL and so on.  Under linux it still builds .so files
but it gives the following message for all .so files:

   *** WARNING: importing extension dl failed with 
   exceptions.AttributeError: 'module' object has no 
   attribute 'load_dynamic'

It seems like it is possible to build python without dynamic
loading as someone build python 2.3 on the X1.  For various
reason I need 2.4, it just not clear what the trick is.

I have done some google group and web searching without success
so I'm asking all you experts to shine some light in this dark
corner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detect character encoding

2005-12-04 Thread Mike Meyer
Diez B. Roggisch [EMAIL PROTECTED] writes:
 Michal wrote:
 is there any way how to detect string encoding in Python?
 I need to proccess several files. Each of them could be encoded in
 different charset (iso-8859-2, cp1250, etc). I want to detect it,
 and encode it to utf-8 (with string function encode).
 But there is _no_ way to be absolutely sure. 8bit are 8bit, so each
 file is legal in all encodings.

Not quite. Some encodings don't use all the valid 8-bit characters, so
if you encounter a character not in an encoding, you can eliminate it
from the list of possible encodings. This doesn't really help much by
itself, though.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Mike Meyer
Benji York [EMAIL PROTECTED] writes:
  See, I can make up bizarre scenarios where spaces cause
 problems, too.
 Only if you don't know how decent editors behave. :)

But the same is also true of tabs causing problems :-).

mike

-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help on designing a project

2005-12-04 Thread Mardy
Le die Fri, 02 Dec 2005 11:34:45 +, Steve Holden ha scribite:
 Note that if you are using execfile()then the best structure for your 
 scripts would be something like:
 
 conn = db.open()
 try:
  #do CGI stuff
 finally:
  conn.close()

That was of great help! Thanks!


-- 
Saluti,
Mardy
http://interlingua.altervista.org

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


Re: Detect character encoding

2005-12-04 Thread Nemesis
Mentre io pensavo ad una intro simpatica Michal scriveva:

 Hello,
 is there any way how to detect string encoding in Python?
 I need to proccess several files. Each of them could be encoded in 
 different charset (iso-8859-2, cp1250, etc). I want to detect it, and 
 encode it to utf-8 (with string function encode).
 Thank you for any answer

Hi,
As you already heard you can't be sure but you can guess.

I use a method like this:

def guess_encoding(text):
for best_enc in guess_list:
try:
unicode(text,best_enc,strict)
except:
pass
else:
break
return best_enc

'guess_list' is an ordered charset name list like this:

['us-ascii','iso-8859-1','iso-8859-2',...,'windows-1250','windows-1252'...]

of course you can remove charsets you are sure you'll never find.
-- 
Questa potrebbe davvero essere la scintilla che fa traboccare la
goccia.
 
 |\ |   |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org

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


Re: CGI module does not parse data

2005-12-04 Thread Mardy
Le die Fri, 02 Dec 2005 12:18:28 -0800, amfr ha scribite:
 import cgi
 form = cgi.FieldStorage()
 print form[test]
 print test
 
 I would only be able to see test, not hello world
 I am sure its not my browser

As Tim said, you have tu use form['test'].value, because print
form['test'] will make pythoun output something like this:
form object at 
and your browser won't show it, mistaking it as an HTML tag.


-- 
Saluti,
Mardy
http://interlingua.altervista.org

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


Re: Building Python 2.4 on machines that do not support dynamic loading

2005-12-04 Thread Martin v. Löwis
Robert McLay wrote:
 I have been trying to build python on Cray X1.  As far as I can
 tell it does not support dynamic loading.  So the question is:
 
How to build 2.4 without dynamic loading?

Make sure HAVE_DYNAMIC_LOADING isn't defined; configure should detect
this automatically.

 That is: can I build 2.4 where all the extensions are archived in
 libpython2.4.a as a static library?

Certainly: Edit Modules/Setup to your needs.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Peter Decker
On 12/4/05, Mike Meyer [EMAIL PROTECTED] wrote:

   See, I can make up bizarre scenarios where spaces cause
  problems, too.
  Only if you don't know how decent editors behave. :)

 But the same is also true of tabs causing problems :-).

I'm starting to suspect that the same people who are zealous about
spaces are also the same people who look down on anyone who doesn't
agree with their choice of text editor.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


option argument length

2005-12-04 Thread Ritesh Raj Sarraf
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I'm using optparse module to parse all options and arguments.

My program uses mostly option arguments hence my len(args) value is always
zero. I need to check if the user has passed the correct number of option
arguments. Something like:

(options,args) = parser.parse_args()

len(options) != 1 or len(options)  2:
print Incorrect number of arguments passed.

How do I accomplish it ?

Regards,

rrs
- -- 
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
Stealing logics from one person is plagiarism, stealing from many is
research.
Necessity is the mother of invention.

Note: Please CC me. I'm not subscribed to the list
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDk1Nh4Rhi6gTxMLwRApx0AJ9XHlWFU1J0NdN02gtvimogUSgDkACgmkOO
2pX8ocoC7pot1a8R4u2BWrY=
=piNo
-END PGP SIGNATURE-

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Benji York
Peter Decker wrote:
 On 12/4/05, Mike Meyer [EMAIL PROTECTED] wrote:
 See, I can make up bizarre scenarios where spaces cause
problems, too.

Only if you don't know how decent editors behave. :)

But the same is also true of tabs causing problems :-).
 
 I'm starting to suspect that the same people who are zealous about
 spaces are also the same people who look down on anyone who doesn't
 agree with their choice of text editor.

Perhaps.  As far as editor choice goes, I'm only fervent about people 
picking a good editor (equivalent to Vim or Emacs) and learning it well. 
  Other than that I don't care.  I'm not as diplomatic about tabs. :)
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detect character encoding

2005-12-04 Thread B Mahoney
You may want to look at some Python Cookbook recipes, such as
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52257
Auto-detect XML encoding  by Paul Prescod

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


Re: Function to retrieve running script

2005-12-04 Thread Harlin Seritt
Thanks Mike,

that will work just as well... just disappointed in myself that i lack
the creativity to think of something that simple ;-)

thanks,

Harlin

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


Python support in Enterprise Architect 6.0?

2005-12-04 Thread Wolfgang Keller
Hello,

does anyone have any experience with the Python support in the new 6.0 
version of Enterprise Architect from Sparx Systems? As I understand, it 
was eriously broken in earlier versions, so I would like to know 
whether they managed to fix it by now.

TIA,

Sincerely,

Wolfgang Keller


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


Re: option argument length

2005-12-04 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Ritesh Raj
Sarraf wrote:

 My program uses mostly option arguments hence my len(args) value is always
 zero. I need to check if the user has passed the correct number of option
 arguments. Something like:
 
 (options,args) = parser.parse_args()
 
 len(options) != 1 or len(options)  2:
 print Incorrect number of arguments passed.
 
 How do I accomplish it ?

Just insert an ``if`` in front of the condition and end the program with
``sys.exit()`` after the message.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Use python to test Java and Windows (dll) applciations

2005-12-04 Thread jb
Hello everybody:

I need help, and please let me know if python is the language of choice
to implement following functionalities:

I am trying to test a Java application and a C++ (win32) application.

I want to be able to write python code to mimic user interaction with
the application.  Interaction could be mouse or keyboard
movement/events using which I want to be able to select Menus and
execute them. Please let me know if this is feasible using Python, if
yes, please refer me to a good resource.


Please help.
-jay

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-04 Thread Paul Boddie
[EMAIL PROTECTED] wrote:
 Eclipse, for example, performs like a dog on
 my dual opteron workstation w/ 2GB of RAM, which is more than enough to
 annoy me. I shouldn't have to wait more than about 1 second for an
 editor to start and then open what is essentially a text file :-P.

And then, due to the excessive project management screen furniture,
have to edit it through the keyhole...

Paul

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


Re: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)

2005-12-04 Thread Tom Anderson

On Sun, 4 Dec 2005, [utf-8] Björn Lindström wrote:


This article should explain it:

http://www.jwz.org/doc/tabs-vs-spaces.html


Ah, Jamie Zawinski, that well-known fount of sane and reasonable ideas.

It seems to me that the tabs-vs-spaces thing is really about who controls 
the indentation: with spaces, it's the writer, and with tabs, it's the 
reader. Does that match up with people's attitudes? Is it the case that 
the space cadets want to control how their code looks to others, and the 
tabulators want to control how others' code looks to them?


I wonder if there's a further correlation between preferring spaces to 
tabs and the GPL to the BSDL ...


tom

Lexicographical PS: 'tabophobia' is, apparently, fear of the 
neurodegenerative disorder tabes dorsalis.


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

Re: option argument length

2005-12-04 Thread Peter Otten
Ritesh Raj Sarraf wrote:

 My program uses mostly option arguments hence my len(args) value is
 always zero. I need to check if the user has passed the correct number of
 option arguments. Something like:
 
 (options,args) = parser.parse_args()
 
 len(options) != 1 or len(options)  2:
 print Incorrect number of arguments passed.
 
 How do I accomplish it ?

Judging from your code sample invention is the mother of that necessity.
You can pass a custom Values object with a __len__() method

class MyValues:
def __len__(self):
return len(self.__dict__)

# ...

options, args = parser.parse_args(values=MyValues())

but you should do your users a favour and give them meaningful error
messages. I can't conceive how you could achieve this by checking the
number of options. Explicit constraint checks like

options, args = parser.parse_args()
if options.eat_your_cake and options.have_it:
parser.error(Sorry, you cannot eat your cake and have it)

will increase your script's usability and make it easier to maintain for
only a tiny amount of work.

Peter

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


Re: Colorize expanded tabs

2005-12-04 Thread qwweeeit
Hi Peter,
thank you for your replay, but I was looking for a very
short routine. I even had in mind to use Linux  bash
(only one command line).
It seems that tab expansion, made by print, prevents
the working of the escape sequences for colors.
In fact, if you replace tab with a given number of spaces,
all works well.
That is :
print \t1234\t5678\t\t90.replace(\t, \033[41m\033[0m)
correctly colorizes in red the spaces replacing the tabs...
Unfortunately this is not tab expansion!
Bye.

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


Re: Detect character encoding

2005-12-04 Thread Martin P. Hellwig
Mike Meyer wrote:
 Diez B. Roggisch [EMAIL PROTECTED] writes:
 Michal wrote:
 is there any way how to detect string encoding in Python?
 I need to proccess several files. Each of them could be encoded in
 different charset (iso-8859-2, cp1250, etc). I want to detect it,
 and encode it to utf-8 (with string function encode).
 But there is _no_ way to be absolutely sure. 8bit are 8bit, so each
 file is legal in all encodings.
 
 Not quite. Some encodings don't use all the valid 8-bit characters, so
 if you encounter a character not in an encoding, you can eliminate it
 from the list of possible encodings. This doesn't really help much by
 itself, though.
 
 mike

I read or heard (can't remember the origin) that MS IE has a quite good 
implementation of guessing the language en character encoding of web 
pages when there not or falsely specified.
 From what I can remember is that they used an algorithm to create some 
statistics of the specific page and compared that with statistic about 
all kinds of languages and encodings and just mapped the most likely.

Please be aware that I don't know if the above has even the slightest 
amount of truth in it, however it didn't prevent me from posting anyway ;-)

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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-04 Thread Luis M. Gonzalez
 Looking to replace my older flavor of linux with something new. . .What
 are some of your favorites for python programming and anything else?

Ubuntu is developed by Canonical, a company owned by Mark Shuttleworth.
This guy is a fan of both linux and python, so if you want a linux
distro that gets along well with python, I guess Ubuntu is the best
choice.

If you read his website http://www.markshuttleworth.com/, you'll see
that this guy encourages development of software in Python, and he even
gransts money for developers.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Tom Anderson
On Sun, 4 Dec 2005 [EMAIL PROTECTED] wrote:

  you're about 10 years late

 The same could be said for hoping that the GIL will be eliminated.
 Utterly hopeless.

 Until... there was PyPy.  Maybe now it's not so hopeless.

No - structuring by indentation and the global lock are entirely different 
kettles of fish. The lock is an implementation detail, not part of the 
language, and barely even perceptible to users; indeed, Jython and 
IronPython, i assume, don't even have one. Structuring by indentation, on 
the other hand, is a part of the language, and a very fundamental one, at 
that. Python without structuring by indentation *is not* python.

Which is not to say that it's a bad idea - if it really is scaring off 
potential converts, then a dumbed-down dialect of python which uses curly 
brackets and semicolons might be a useful evangelical tool.

tom

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


  1   2   >