Re: Executing Javascript, then reading value

2007-01-30 Thread Diez B. Roggisch
Melih Onvural schrieb:
> I need to execute some javascript and then read the value as part of a 
> program that I am writing. I am currently doing something like this:
> 
> import htmllib, urllib, formatter
> 
> class myparser(htmllib.HTMLParser):
>   insave = 0
>   def start_div(self, attrs):
>   for i in attrs:
>   if i[0] == "id" and i[1] == "pr":
>   self.save_bgn()
>   self.insave = 1
> 
>   def end_div(self):
>   if self.insave == 1:
>   print self.save_end()
>   self.insave = 0
> 
> parser = myparser(formatter.NullFormatter())
> 
> #def getPageRank(self, url):
> try:
>   learn_url = "http://127.0.0.1/research/getPageRank.html?q=http://
> www.yahoo.com&"
>   pr_url = urllib.urlopen(learn_url)
>   parser.feed(pr_url.read())
> except IOError, e:
>   print e
> 
> but the result is the javascript function and not the calculated 
> value. Is there anyway to get the javascript to execute first, and 
> then return to me the value? thanks in advance,

Do it in a browser. There are ways to automate one, for example the 
webbrowser module, and others.

Then rework your script to work with AJAX.

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


Re: Python 2.5 Tkinter not configured

2007-01-30 Thread Diez B. Roggisch
Jim schrieb:
> I compiled Python 2.5 from python.org and I get an error message when I try
> to import the Tkinter module. Python reports that there is no such module.
> It says my Python isn't configured for Tkinter. How do I configure it? I'm
> using GCC 4.1.1 to compile the tarball. Thanks for any help with this.

You need to have tcl/tk together with it's development-headers 
installed. Python _should_ figure out where things are, and then be 
configured to include tkinter.

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


Re: Conversion of string to integer

2007-01-30 Thread Thinker
jupiter wrote:
> Hi guys,
>
> I have a problem. I have a list which contains strings and numeric. 
> What I want is to compare them in loop, ignore string and create 
> another list of numeric values.
>
> I tried int() and decimal() but without success.
>
> eq of problem is
>
> #hs=string.split(hs)
> hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]
>   
hs = [.]

import re
reo = re.compile(r'^[0-9]+(\.[0-9]+)?$')
result = [e for e in hs if reo.match(e)]



-- 
Thinker Li - [EMAIL PROTECTED] [EMAIL PROTECTED]
http://heaven.branda.to/~thinker/GinGin_CGI.py

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

How can I know both the Key c and Ctrl on the keyboard are pressed?

2007-01-30 Thread tidegenerator
Hi;
How can I know the Key c and Ctrl on the keyboard are pressed? Or how 
to let the program press the

key Ctrl+c automatically? I just want to use python to develop a 
script program.
gear

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

Re: wxPython StatusBar Help

2007-01-30 Thread jean-michel bain-cornu
Hi,
> I'm working with wxPython 2.8.1.1.
> 
> Does anybody know how to change the foreground colors in a wx.StatusBar
You can get inspiration from the following code, but the problem is you 
will have also to draw all the status bar stuff, not only the foreground 
color.
I don't know any other way. However, I'm used to 2.6 and I could miss 
something existing in 2.8 (I think to OnCreateStatusBar which exists and 
don't work in 2.6 and was supposed to work with the next release ; it 
could be a clue).
Regards,
jm


import wx
class MyStatusBar(wx.StatusBar):
 def __init__(self,*args,**kargs):
 wx.StatusBar.__init__(self,*args,**kargs)
 self.Bind(wx.EVT_PAINT,self.OnPaint)
 def OnPaint(self,event):
 dc = wx.PaintDC(self)
 self.Draw(dc)
 def Draw(self,dc):
 dc.BeginDrawing()
 dc.SetBackground( wx.Brush("White") )
 dc.Clear()
 dc.SetPen(wx.Pen('BLACK'))
 dc.DrawText(self.GetStatusText(),0,0)
 dc.EndDrawing()
if __name__ == "__main__":
 app = wx.PySimpleApp()
 frame= wx.Frame(None,wx.ID_ANY,'test frame')
 statusBar= MyStatusBar(frame,wx.ID_ANY)
 statusBar.SetStatusText("status text..")
 frame.SetStatusBar(statusBar)
 frame.Show(True)
 app.MainLoop()
-- 
http://mail.python.org/mailman/listinfo/python-list


message handling in Python / wxPython

2007-01-30 Thread murali iyengar

hi,
i have basic knowledge of python and wxPython... now i need to know about
message handling in python/wxPython?

could anybody pls help me by giving some info on how to handle (in Python),
'the user defined messages' posted from VC++, i dont know how to handle
messaes in python.

Thanks and Regards,
Murali M.S
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Help me understand this

2007-01-30 Thread Beej
On Jan 29, 11:47 pm, Steven D'Aprano 
<[EMAIL PROTECTED]> wrote:
> Outside of a print statement (and also an "except" statement), commas
> create tuples.

And function calls:

>>> 3,
(3,)
>>> type(3,)

>>> type((3,))


But here's one I still don't get:

>>> type(2)

>>> type((2))

>>> (2).__add__(1)
3
>>> 2.__add__(1)
  File "", line 1
2.__add__(1)
^
SyntaxError: invalid syntax

-Beej

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


Diff between opening files in 'r' and 'r+' mode

2007-01-30 Thread raghu
i want to know the difference between 'r' mode and 'r+' mode
1.i = open('c:\python25\integer.txt','w')>for writiing
  i.write('hai')->written some content in text file
  i = open('c:\python25\integer.txt','r')>for reading
  print i.read()>for printing the contents in that text file
  i = open('c:\python25\integer.txt','w')-->for writing
  i.write('how')---?Rewrite the contents
  print i.read()
[MY QUESTION]:i want to read the text file contents cant it be done by 
giving (print i.read())?
Before going to next question [I deleted all the contents in the text 
file]

2.i = open('c:\python25\integer.txt','r+')-For reading and writing
   i.write('hai')->written some content  to text file
   print i.read()->{؆('c:\python25\integer.txt','w')
   i write('')
   print i.read()how')
   i = open('c:\python25\integer.txt','r')
   print i.read()
   i = open('c:\python25\integer.txt','w')
   i.write()
   i = open('c:\python25\integer.txt','r')
  print i.read() } --->Thats what i saw on 
interpreter(In curly braces) when  i ran the script
[MY QUESTION]:1.from where the above in curly braces is printed?and i 
have written only 'hai' to the text file
  2.Should i recall again the opening of the 
file in 'r' mode to read the file?

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

Explanation about pickle module

2007-01-30 Thread raghu
can any one explain about pickle i read in the book but they have not 
provided any example for that so please explain with a simple example

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


Re: Help me understand this

2007-01-30 Thread Diez B. Roggisch
Beej wrote:

> On Jan 29, 11:47 pm, Steven D'Aprano
> <[EMAIL PROTECTED]> wrote:
>> Outside of a print statement (and also an "except" statement), commas
>> create tuples.
> 
> And function calls:
> 
 3,
> (3,)
 type(3,)
> 
 type((3,))
> 
> 
> But here's one I still don't get:
> 
 type(2)
> 
 type((2))
> 
 (2).__add__(1)
> 3
 2.__add__(1)
>   File "", line 1
> 2.__add__(1)
> ^
> SyntaxError: invalid syntax

Because 2. is the start of a float-literal. That isn't distinguishable for
the parsere otherwise.


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


Re: Explanation about pickle module

2007-01-30 Thread Diez B. Roggisch
raghu wrote:

> can any one explain about pickle i read in the book but they have not
> provided any example for that so please explain with a simple example

Bad google day? Or just to lazy to do it? And what is "the book"? There are
quite a few out there, some about python the language, others about snakes
of the same name. Which one?

http://www.python.org/doc/current/lib/pickle-example.html

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


Re: Explanation about pickle module

2007-01-30 Thread Marco Wahl
"raghu" <[EMAIL PROTECTED]> writes:

> can any one explain about pickle i read in the book but they have not 
> provided any example for that so please explain with a simple example
> 

>>> class Foo(object):
...   def __init__(self):
... self.bar = 1
... 
>>> import pickle
>>> a = Foo()
>>> pickle.dumps(a)
"ccopy_reg\n_reconstructor\np0\n(c__main__\nFoo\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n(dp5\nS'bar'\np6\nI1\nsb."
>>> b = 
>>> pickle.loads("ccopy_reg\n_reconstructor\np0\n(c__main__\nFoo\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n(dp5\nS'bar'\np6\nI1\nsb.")
>>> b.bar
1
>>> b
<__main__.Foo object at 0x402ae68c>
>>> 

There is also pickle.dumps and pickle.loads to work
directly with files.  Further there is module cpickle
which offers the same functionality as pickle but which
is faster.


Bye
-- 
Marco Wahl
http://visenso.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Diff between opening files in 'r' and 'r+' mode

2007-01-30 Thread Ben Finney
"raghu" <[EMAIL PROTECTED]> writes:

> i want to know the difference between 'r' mode and 'r+' mode
> 1.i = open('c:\python25\integer.txt','w')>for writiing
>   i.write('hai')->written some content in text file
>   i = open('c:\python25\integer.txt','r')>for reading
>   print i.read()>for printing the contents in that text file
>   i = open('c:\python25\integer.txt','w')-->for writing
>   i.write('how')---?Rewrite the contents
>   print i.read()
> [MY QUESTION]:i want to read the text file contents cant it be done by 
> giving (print i.read())?
> Before going to next question [I deleted all the contents in the text 
> file]

This is amazingly hard to read. Can you please post your message
again, this time using ordinary whitespace (e.g. a blank line) to
separate program examples from other text.

All the punctuation characters you're using have typographical
meaning, and your arbitrary use of them for apparently decorative
purposes make it difficult to see what you're trying to day.

-- 
 \ "Experience is that marvelous thing that enables you to |
  `\  recognize a mistake when you make it again."  -- Franklin P. |
_o__)Jones |
Ben Finney

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


thread and processes with python/GTK

2007-01-30 Thread awalter1
Hello,

I'm developping an application with python, pyGTK and GTK+.
I've performed many tests by using methods as Popen, popen2, 
os.system ... to communicate with Unix (HPUX),
The last attempt is this code written in a thread :
fin,fout = popen2.popen2('ps -def')
line = fin.readline()
while 1 :
if not line : break
print "line=",line
line = fin.readline()
fin.close()
In that case, lines are printed only when I exit my application.
Usually the behavior is not as expected and I cannot understand why. I 
am wondering that it could be a constraint from the use of GTK 
(mainloop() existence ???).
Is somebody aware about conflict between GTK use and unix mechanism.

Thanks for you help

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


Re: Is any python like linux shell?

2007-01-30 Thread Brian Visel
ipython is probably what you're looking for.

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


Re: Executing Javascript, then reading value

2007-01-30 Thread bearophileHUGS
Jean-Paul Calderone:
> You might look into the
> stand-alone Spidermonkey runtime.  However, it lacks the DOM APIs, so
> it may not be able to run the JavaScript you are interested in running.
> There are a couple other JavaScript runtimes available, at least.

This may be okay too:
http://www.digitalmars.com/dscript/

Bye,
bearophile

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


Re: select windows

2007-01-30 Thread Tom Wright
Dennis Lee Bieber wrote:
> (And the Amiga could add even more complexity -- I still miss the
> Amiga's ability to PUSH a window to the back while STILL KEEPING
> FOCUS... Made it easy to type stuff into one window while reading data
> from a covering window!)

KDE's window manager can do this (and it is useful, you're right).  I
suspect most other window managers will offer it as an option, too.

-- 
I'm at CAMbridge, not SPAMbridge
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mounting shares with python

2007-01-30 Thread half . italian
On Jan 26, 10:27 am, Bjoern Schliessmann  wrote:
> Marcpp wrote:
> > Hi, when i mount a share with python...
>
> > os.system ("mount -t smbfs -o username=nobody ...")
>
> > the problem is that I'll to be root.
>
> Consider modifying /etc/fstab.
>
> > Have a comand to send a root password...?
> > I've tried
>
> > os.system ("su")
> > os.system ("the password")
>
> > but it doesn't works.
>
> Be advised that storing a root password as clear text can be a huge
> security risk. Use sudo.
>
> Regards,
>
> Björn
>
> --
> BOFH excuse #9:
>
> doppler effect

I use pexpect.   http://pexpect.sourceforge.net/

~Sean

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


ANN: gozerbot IRC and JABBER bot

2007-01-30 Thread bthate
gozerbot

a python irc and jabber bot

see http://code.google.com/p/gozerbot

you need:

* a shell
* python 2.4 or higher
* if you want mysql support: the py-MySQLdb module
* if you want jabber support: the xmpppy module

why gozerbot?

* user management by userhost
* fleet .. use more than one bot in a program
* relaying between fleet bots
* use the bot through dcc chat
* fetch rss feeds.
* keep todo and shop lists
* karma
* quote
* remember items
* program your own plugins
* builtin webserver
* collective, run commands on other bots using their webserver
* other stuff

we are on channel #dunkbots on IRCnet .. try irc.xs4all.nl

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


Re: Help me understand this

2007-01-30 Thread James Stroud
Beej wrote:
 (2).__add__(1)

Nice. I would have never thought to put parentheses around an integer to 
get at its attributes.

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


Re: error messages containing unicode

2007-01-30 Thread Jim
Thank you for the reply.  It happens that, as I understand it, none of 
the options that you mentioned is a solution for my situation.

On Jan 29, 9:48 pm, Steven D'Aprano <[EMAIL PROTECTED]> 
wrote:
> The easiest ways to fix that are:
>
> (1) subclass an exception that already knows about Unicode;
But I often raise one of Python's built-in errors.  And also, is it 
really true that subclassing one of Python's built-ins give me 
something that is unicode deficient?  I assumed that I had missed 
something (because that's happened so many times before :-) ).

For instance, I write a lot of CGI and I want to wrap everything in a 
try .. except.
  try:
  main()
  except Exception, err:
  print "Terrible blunder: ",str(err)
so that the err can be one of my exceptions, or can be one that came 
with Python. (And, that I can see, err.args can be either the relevant 
string or a tuple containing the relevant string and the documentation 
is silent on whether in the built-in exceptions if err.args is a tuple 
then the string is guaranteed to be first in the tuple.)

> (2) convert the file name to ASCII before you store it; or
I need the non-ascii information, though, which is why I included it 
in the error message.

> (3) add a __str__ method to your exception that is Unicode aware.
I have two difficulties with this: (1) as above I often raise Python's 
built-in exceptions and for those __str__() is what it is, and (2) 
this goes against the meaning of __str__() that I find in the 
documentation in ref/customization.html which says that the return 
value must be a string object.  Obviously no one will come to my house 
and slap me if I violate that, but I'll venture that it would be odd 
if the best practice were to be to do the opposite of  the 
documentation.

> I'm going to be lazy and do a real simple-minded version of (2):
>
> >>> class MyBetterException(Exception):... def __init__(self, arg):
> ... self.args = arg.encode('ascii', 'replace')
> ... self.unicode_arg = arg  # save the original in case
This is illuminating.  How do you know that for exceptions __init__() 
should take one non-self argument?  I missed finding this information.

Thanks again,
Jim

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


Re: error messages containing unicode

2007-01-30 Thread Diez B. Roggisch
>> (2) convert the file name to ASCII before you store it; or
> I need the non-ascii information, though, which is why I included it
> in the error message.

Then convert it to utf-8, or some encoding you know it will be used by your
terminal. 

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


Re: error messages containing unicode

2007-01-30 Thread Jim
On Jan 30, 7:41 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> >> (2) convert the file name to ASCII before you store it; or
> > I need the non-ascii information, though, which is why I included it
> > in the error message.
> Then convert it to utf-8, or some encoding you know it will be used by your
> terminal.
Thank you for the suggestion.   Remember please that I am asking for a 
safe way to pull the unicode object from the exception object (derived 
from a Python built-in), so I can't store it as unicode first and then 
convert to regular string  when I need to print it out-- my exact 
question is how to get the unicode.  So I take your answer to be to 
refuse to put in a unicode-not-ascii in there in the first place.

It then seems to me that you are saying that the best practice is that 
every function definition should contain a parameter, like so.

  def openNewFile(fn,errorEncoding='utf-8'):
   :
  try:
   open(fn,'r')
  except Exception, err
   raise myException 'unable to open 
'+fn.encode(errorEncoding,'replace')

I guess that beyond that passing those parameters and putting encode 
on every variable in my routines that occurs in an error message it is 
ugly, it seems to me that it violates the principle that you should do 
everything inside the program in unicode and only encode at the 
instant you need the output, in that the exception object is carrying 
around an ascii-not-unicode object.

Jim

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


Re: error messages containing unicode

2007-01-30 Thread Peter Otten
Jim wrote:

> On Jan 30, 7:41 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> >> (2) convert the file name to ASCII before you store it; or
>> > I need the non-ascii information, though, which is why I included it
>> > in the error message.
>> Then convert it to utf-8, or some encoding you know it will be used by
>> your terminal.
> Thank you for the suggestion.   Remember please that I am asking for a
> safe way to pull the unicode object from the exception object (derived
> from a Python built-in), so I can't store it as unicode first and then
> convert to regular string  when I need to print it out-- my exact
> question is how to get the unicode.  So I take your answer to be to
> refuse to put in a unicode-not-ascii in there in the first place.
> 
> It then seems to me that you are saying that the best practice is that
> every function definition should contain a parameter, like so.
> 
>   def openNewFile(fn,errorEncoding='utf-8'):
>:
>   try:
>open(fn,'r')
>   except Exception, err
>raise myException 'unable to open
> '+fn.encode(errorEncoding,'replace')
> 
> I guess that beyond that passing those parameters and putting encode
> on every variable in my routines that occurs in an error message it is
> ugly, it seems to me that it violates the principle that you should do
> everything inside the program in unicode and only encode at the
> instant you need the output, in that the exception object is carrying
> around an ascii-not-unicode object.

Printing to a terminal should work:

>>> try:
... raise Exception(u"gewöhnlich ähnlich üblich")
... except Exception, e:
... print e.message
...
gewöhnlich ähnlich üblich

If you're writing to a file you still have to encode explicitly.

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


Re: Is any python like linux shell?

2007-01-30 Thread Szabolcs Nagy

Brian Visel wrote:
> ipython is probably what you're looking for.

or
http://sourceforge.net/projects/pyshell

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


Re: error messages containing unicode

2007-01-30 Thread Jim
On Jan 30, 8:18 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> >>> try:... raise Exception(u"gewöhnlich ähnlich üblich")
> ... except Exception, e:
> ... print e.message
> ...
> gewöhnlich ähnlich üblich
Ah, so that's what "If there is a single argument (as is preferred), 
it is bound to the message attribute" means.  Through some imbecility 
I failed to understand it.  Thank you.

> If you're writing to a file you still have to encode explicitly.
Yes; I know that.  It wasn't what to do with the unicode object that 
confused me, it was how to get it in the first place.

Much obliged,
Jim

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


Re: How can I know both the Key c and Ctrl on the keyboard are pressed?

2007-01-30 Thread Szabolcs Nagy

[EMAIL PROTECTED] wrote:
> Hi;
> How can I know the Key c and Ctrl on the keyboard are pressed? Or how
> to let the program press the
>
> key Ctrl+c automatically? I just want to use python to develop a
> script program.
> gear

depends on where you got your input from and what do you exactly want

eg:
in a gui app you get input events from the gui toolkit (wx, gtk, sdl/
pygame...)
in a console app if you use curses lib then you can use getch() oslt

if you want a general solution to get input key events in a simple 
script then you cannot do that.

however Ctrl+C is a special key combination: running python in a unix 
terminal it raises KeyboardInterrupt exception, imho in a windows cmd 
promt it raises SystemExit

so you can emulate those by using:
raise KeyboardInterrupt
or
raise SystemExit

hope this helps

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


Re: Diff between opening files in 'r' and 'r+' mode

2007-01-30 Thread Sick Monkey

It was a little hard to follow your logic of your sample code (writing,
reading and writing again), but
(1)The difference between r and r+.
-  'r+' opens the file for both reading and writing.
-  'r' should be used when the file will only be read.

I am not sure on how you want to store the contents of the file, but I have
provided an example below. You could do something like this:
--
fileContent = open(fname, 'r')

a = fileContent.readlines(); fileContent.close()

print a

--

(2) If you are just going to read the file, then yes I would use just the
'r' argument.



On 30 Jan 2007 01:36:15 -0800, raghu <[EMAIL PROTECTED]> wrote:


i want to know the difference between 'r' mode and 'r+' mode
1.i = open('c:\python25\integer.txt','w')>for writiing
i.write('hai')->written some content in text file
i = open('c:\python25\integer.txt','r')>for reading
print i.read()>for printing the contents in that text file
i = open('c:\python25\integer.txt','w')-->for writing
i.write('how')---?Rewrite the contents
print i.read()
[MY QUESTION]:i want to read the text file contents cant it be done by
giving (print i.read())?
Before going to next question [I deleted all the contents in the text
file]

2.i = open('c:\python25\integer.txt','r+')-For reading and writing
  i.write('hai')->written some content  to text file
  print i.read()->{؆('c:\python25\integer.txt','w')
  i write('')
  print i.read()how')
  i = open('c:\python25\integer.txt','r')
  print i.read()
  i = open('c:\python25\integer.txt','w')
  i.write()
  i = open('c:\python25\integer.txt','r')
 print i.read() } --->Thats what i saw on
interpreter(In curly braces) when  i ran the script
[MY QUESTION]:1.from where the above in curly braces is printed?and i
have written only 'hai' to the text file
 2.Should i recall again the opening of the
file in 'r' mode to read the file?

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

Re: deepcopy alternative?

2007-01-30 Thread none
Szabolcs Nagy wrote:
>> I believe the only thing stopping me from doing a deepcopy is the
>> function references, but I'm not sure.  If so is there any way to
>> transform a string into a function reference(w/o eval or exec)?
> 
> what's your python version?
> for me deepcopy(lambda:1) does not work in py2.4 but it works in py2.5
> (in py2.4 i tried to override __deepcopy__ but it had no effect)
> 

Thanks that fixed the problem real quick :)

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


ANN: Pyrex 0.9.5.1

2007-01-30 Thread greg
Pyrex 0.9.5.1 is now available:

   http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/

This is a minor release to fix a few bugs introduced
in 0.9.5. See the CHANGES for details.

What is Pyrex?
--

Pyrex is a language for writing Python extension modules.
It lets you freely mix operations on Python and C data, with
all Python reference counting and error checking handled
automatically.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fixed length lists from .split()?

2007-01-30 Thread Steven Bethard
On Jan 26, 11:07 am, Bob Greschke <[EMAIL PROTECTED]> wrote:
> I'm reading a file that has lines like
>
> bcsn; 100; 1223
> bcsn; 101; 1456
> bcsn; 103
> bcsn; 110; 4567
>
> The problem is the line with only the one semi-colon.
> Is there a fancy way to get Parts=Line.split(";") to make Parts always
> have three items in it

In Python 2.5 you can use the .partition() method which always returns 
a three item tuple:

>>> text = '''\
... bcsn; 100; 1223
... bcsn; 101; 1456
... bcsn; 103
... bcsn; 110; 4567
... '''
>>> for line in text.splitlines():
... bcsn, _, rest = line.partition(';')
... num1, _, num2 = rest.partition(';')
... print (bcsn, num1, num2)
...
('bcsn', ' 100', ' 1223')
('bcsn', ' 101', ' 1456')
('bcsn', ' 103', '')
('bcsn', ' 110', ' 4567')
>>> help(str.partition)
Help on method_descriptor:

partition(...)
S.partition(sep) -> (head, sep, tail)

Searches for the separator sep in S, and returns the part before 
it,
the separator itself, and the part after it.  If the separator is 
not
found, returns S and two empty strings.


STeVe

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


Re: How can I know both the Key c and Ctrl on the keyboard are pressed?

2007-01-30 Thread BJörn Lindqvist
On 30 Jan 2007 05:44:40 -0800, Szabolcs Nagy <[EMAIL PROTECTED]> wrote:
> however Ctrl+C is a special key combination: running python in a unix
> terminal it raises KeyboardInterrupt exception, imho in a windows cmd
> promt it raises SystemExit

No it is KeyboardInterrupt in Windows too.

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


Re: Compiling extension with Visual C++ Toolkit Compiler - MSVCR80.dll

2007-01-30 Thread alexandre_irrthum
Thanks for your answers Martin and Peter,

I figured out why python.exe was asking for MSVCR80.dll. The first 
time I compiled the library, MS Visual C++ Express 2005 was used 
during the build (despite my PATH pointing to MS Visual C++ Toolkit 
2003). When I removed Express 2005, I forgot to remove the build 
directory of my library. I've also had to remove and reinstall the C++ 
Toolkit, the platform SDK and the .NET Framework SDK and modify 
msvccompiler.py and my environment variables according to:

http://www.vrplumber.com/programming/mstoolkit/index.html

but finally it did work.

And Peter, your solution worked perfectly. A great alternative to 
installing all the MS libraries.

Cheers,

alex

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


data design

2007-01-30 Thread Imbaud Pierre
The applications I write are made of, lets say, algorithms and data.
I mean constant data, dicts, tables, etc: to keep algorithms simple,
describe what is peculiar, data dependent, as data rather than "case
statements". These could be called configuration data.

The lazy way to do this: have modules that initialize bunches of
objects, attributes holding the data: the object is somehow the row of
the "table", attribute names being the column. This is the way I
proceeded up to now.
Data input this way are almost "configuration data", with 2 big
drawbacks:
  - Only a python programmer can fix the file: this cant be called a
configuration file.
  - Even for the author, these data aint easy to maintain.

I feel pretty much ready to change this:
- make these data true text data, easier to read and fix.
- write the module that will make python objects out of these data:
the extra cost should yield ease of use.

2 questions arise:
- which kind of text data?
 - csv: ok for simple attributes, not easy for lists or complex
 data.
 - xml: the form wont be easier to read than python code,
   but an xml editor could be used, and a formal description
   of what is expected can be used.
- how can I make the data-to-object transformation both easy, and able
   to spot errors in text data?

Last, but not least: is there a python lib implementing at least part
of this dream?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I know both the Key c and Ctrl on the keyboard are pressed?

2007-01-30 Thread Duncan Booth
"Szabolcs Nagy" <[EMAIL PROTECTED]> wrote:

> however Ctrl+C is a special key combination: running python in a 
unix 
> terminal it raises KeyboardInterrupt exception, imho in a windows 
cmd 
> promt it raises SystemExit
> 
Your humble opinion is wrong.

Under windows Ctrl-C raises KeyboardInterrupt just as it does under 
linux. Ctrl-break by default terminates the program (without invoking 
Python's usual cleanup), but you can override that behaviour by 
registering a different signal handler.

e.g.

  import signal
  signal.signal(signal.SIGBREAK,
signal.default_int_handler)

will make Ctrl-break raise KeyboardInterrupt just like Ctrl-C.

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


Re: Secret Technology of THERMATE and 911 Crime

2007-01-30 Thread Uncle Al
[EMAIL PROTECTED] wrote:
[snip crap]

> I do not plan to make a career out of 9/11 research,
[snip more crap]

> We have found evidence for thermates in the molten metal seen pouring
> from the South Tower minutes before its collapse,
[snip still more crap]

> Thermate is the red
> powder in the steel base. The prototype worked well, and the thermate-
> jet cut through a piece of structural steel in a fraction of a second.

Google
thermite  595,000

You can't even spell it correctly.  If you wish to see the light,
begin by pullng your head out of your ass,

http://www.mazepath.com/uncleal/sunshine.jpg

Idiot.  You don't know dick about incendiaries.

-- 
Uncle Al
http://www.mazepath.com/uncleal/
 (Toxic URL! Unsafe for children and most mammals)
http://www.mazepath.com/uncleal/lajos.htm#a2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: data design

2007-01-30 Thread Larry Bates
Imbaud Pierre wrote:
> The applications I write are made of, lets say, algorithms and data.
> I mean constant data, dicts, tables, etc: to keep algorithms simple,
> describe what is peculiar, data dependent, as data rather than "case
> statements". These could be called configuration data.
> 
> The lazy way to do this: have modules that initialize bunches of
> objects, attributes holding the data: the object is somehow the row of
> the "table", attribute names being the column. This is the way I
> proceeded up to now.
> Data input this way are almost "configuration data", with 2 big
> drawbacks:
>  - Only a python programmer can fix the file: this cant be called a
>configuration file.
>  - Even for the author, these data aint easy to maintain.
> 
> I feel pretty much ready to change this:
> - make these data true text data, easier to read and fix.
> - write the module that will make python objects out of these data:
> the extra cost should yield ease of use.
> 
> 2 questions arise:
> - which kind of text data?
> - csv: ok for simple attributes, not easy for lists or complex
> data.
> - xml: the form wont be easier to read than python code,
>   but an xml editor could be used, and a formal description
>   of what is expected can be used.
> - how can I make the data-to-object transformation both easy, and able
>   to spot errors in text data?
> 
> Last, but not least: is there a python lib implementing at least part
> of this dream?

Use the configurations module.  It was built to provide a way to parse
configuration files that provide configuration data to program.  It is
VERY fast so the overhead to parse even thousands of lines of config
data is extremely small.  I use it a LOT and it is very flexible and
the format of the files is easy for users/programmers to work with.

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


Synchronous shutil.copyfile()

2007-01-30 Thread Hugo Ferreira
Hi there,

I have a problem. I'm using calling shutil.copyfile() followed by
open(). The thing is that most of the times open() is called before
the actual file is copied. I don't have this problem when doing a
step-by-step debug, since I give enough time for the OS to copy the
file, but at run-time, it throws an exception.

Is there anyway to force a sync copy of the file (make python wait for
the completion)?

Thanks in advance!

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


Re: data design

2007-01-30 Thread Szabolcs Nagy
> The lazy way to do this: have modules that initialize bunches of
> objects, attributes holding the data: the object is somehow the row of
> the "table", attribute names being the column. This is the way I
> proceeded up to now.
> Data input this way are almost "configuration data", with 2 big
> drawbacks:
>   - Only a python programmer can fix the file: this cant be called a
> configuration file.
>   - Even for the author, these data aint easy to maintain.
>
> I feel pretty much ready to change this:
> - make these data true text data, easier to read and fix.
> - write the module that will make python objects out of these data:
> the extra cost should yield ease of use.
>
> 2 questions arise:
> - which kind of text data?
>  - csv: ok for simple attributes, not easy for lists or complex
>  data.
>  - xml: the form wont be easier to read than python code,
>but an xml editor could be used, and a formal description
>of what is expected can be used.
> - how can I make the data-to-object transformation both easy, and able
>to spot errors in text data?
>
> Last, but not least: is there a python lib implementing at least part
> of this dream?

there is a csv parser and multiple xml parsers in python (eg 
xml.etree) also there is a ConfigParser module (able to parse .ini 
like config files)

i personally like the python module as config file the most

eg if you need a bunch of key-value pairs or lists of data:
* python's syntax is pretty nice (dict, tuples and lists or just 
key=value)
* xml is absolutely out of question
* csv is very limited
* .ini like config file for more complex stuff is not bad but then you 
can use .py as well.

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


Re: Synchronous shutil.copyfile()

2007-01-30 Thread Sick Monkey

First off, I am just learning Python, so if there is a more efficient way to
do this, then I am all ears   (NOTE:  The code below is something that I
was messing with to learn threads...  So some functionality is not
applicable for your needs..I just wanted to show you a demonstration)
One way that you could get around this, is to use threads.   You can lock
your thread and when the lock has been released, you could open it and
ensure your copy has succeeded.  Just a thought
~~~
import thread
def counter(myId, count):
for i in range(count):
   stdoutmutex.acquire()
   #Copy Your File Here
   stdoutmutex.release()
exitmutexes[myId].acquire()


stdoutmutex = thread.allocate_lock()
exitmutexes = []
for i in range(2):
  exitmutexes.append(thread.allocate_lock())
  thread.start_new(counter, (i, 2))

for mutex in exitmutexes:
  while not mutex.locked():
  #Open Your File Here

print 'Exiting'



On 1/30/07, Hugo Ferreira <[EMAIL PROTECTED]> wrote:


Hi there,

I have a problem. I'm using calling shutil.copyfile() followed by
open(). The thing is that most of the times open() is called before
the actual file is copied. I don't have this problem when doing a
step-by-step debug, since I give enough time for the OS to copy the
file, but at run-time, it throws an exception.

Is there anyway to force a sync copy of the file (make python wait for
the completion)?

Thanks in advance!

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

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

Please take me off the list

2007-01-30 Thread Daniel kavic
Sorry to waste email space , but I wish to be off this list because I have 
tried python and it is too difficult for me.

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


Re: Please take me off the list

2007-01-30 Thread Mikael Olofsson
Daniel kavic wrote:
> Sorry to waste email space , but I wish to be off this list because I have 
> tried python and it is too difficult for me.
>   

That's sad. Go to

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

and follow instructions.

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


[email protected]

2007-01-30 Thread Chris Lambacher
On Mon, Jan 29, 2007 at 03:12:37PM -0800, Pappy wrote:
> SHORT VERSION:
> Python File B changes sys.stdout to a file so all 'prints' are written 
> to the file.  Python file A launches python file B with os.popen("./B 
> 2>&^1 >dev/null &").  Python B's output disappears into never-never 
> land.
> 
> LONG VERSION:
> I am working on a site that can kick off large-scale simulations.  It 
> will write the output to an html file and a link will be emailed to 
> the user.  Also, the site will continue to display "Loading..." if the 
> user wants to stick around.
> 
> The simulation is legacy, and it basically writes its output to stdout 
> (via simple print statements).  In order to avoid changing all these 
> prints, I simply change sys.stdout before calling the output 
> functions.  That works fine.  The whole thing writes to an html file 
> all spiffy-like.
> 
> On the cgi end, all I want my (python) cgi script to do is check for 
> form errors, make sure the server isn't crushed, run the simulation 
> and redirect to a loading page (in detail, I write a constantly 
> updating page to the location of the final output file.  When the 
> simulation is done, the constantly updating file will be magically 
> replaced).  The root problem is that the popen mechanism described 
> above is the only way I've found to truly 'Detach' my simulation 
> process.  With anything else, Apache (in a *nix environment) sits and 
> spins until my simulation is done.  Bah.
> 
> Any ideas?
The subprocess module is probably a good starting point:
http://docs.python.org/dev/lib/module-subprocess.html

It will allow you greater control over what happens with the output of a
process that you start.  Specifically look at the the stdout and stderr
arguments to Popen.  You can provide these with an open file descriptor or a
file object and it will dump the output into there.

-Chris
> 
> _jason
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Help me override append function of list object

2007-01-30 Thread jeremito
I have created a class that inherits from the list object.  I want to 
override the append function to allow my class to append several 
copies at the same time with one function call.  I want to do 
something like:

import copy

class MyList(list):
  __init__(self):
pass

  def append(self, object, n=1):
for i in xrange(n):
self.append(copy.copy(object))

Now I know this doesn't work because I overwrite append, but want the 
original functionality of the list object.  Can someone help me?

Thanks,
Jeremy

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


[email protected]

2007-01-30 Thread Jason Persampieri

Sadly, the group is tied to Python 2.3 for now.

Actually, I got around this problem by using an intermediate process that
happens to handle output on its own (bsub).

On 1/30/07, Chris Lambacher <[EMAIL PROTECTED]> wrote:


The subprocess module is probably a good starting point:
http://docs.python.org/dev/lib/module-subprocess.html

It will allow you greater control over what happens with the output of a
process that you start.  Specifically look at the the stdout and stderr
arguments to Popen.  You can provide these with an open file descriptor or
a
file object and it will dump the output into there.

-Chris
>
> _jason
>
> --
> http://mail.python.org/mailman/listinfo/python-list

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

Re: thread and processes with python/GTK

2007-01-30 Thread Thomas Guettler
Hi,

how do you start the python app? Goes stdout
to a terminal or a pipe?

"python script.py"
and "python script.py | cat" behave different.

Maybe "sys.stdout.flush()" helps you.

BTW, I switched from threads to idle_add for pygtk
applications.

awalter1 wrote:
> Hello,
>
> I'm developping an application with python, pyGTK and GTK+.
> I've performed many tests by using methods as Popen, popen2, 
> os.system ... to communicate with Unix (HPUX),
> The last attempt is this code written in a thread :
>   fin,fout = popen2.popen2('ps -def')
>   line = fin.readline()
>   while 1 :
>   if not line : break
>   print "line=",line
>   line = fin.readline()
>   fin.close()
> In that case, lines are printed only when I exit my application.
> Usually the behavior is not as expected and I cannot understand why. I 
> am wondering that it could be a constraint from the use of GTK 
> (mainloop() existence ???).
> Is somebody aware about conflict between GTK use and unix mechanism.
>
> Thanks for you help

-- 
Thomas Güttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: [EMAIL PROTECTED]

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


Re: Help me override append function of list object

2007-01-30 Thread Peter Otten
jeremito wrote:

> I have created a class that inherits from the list object.  I want to
> override the append function to allow my class to append several
> copies at the same time with one function call.  I want to do
> something like:
> 
> import copy
> 
> class MyList(list):
>   __init__(self):
> pass
> 
>   def append(self, object, n=1):
> for i in xrange(n):
> self.append(copy.copy(object))
> 
> Now I know this doesn't work because I overwrite append, but want the
> original functionality of the list object.  Can someone help me?

Use list.append(self, obj) or super(MyList, self).append(obj), e. g.:

>>> import copy
>>> class List(list):
... def append(self, obj, n=1):
... for i in xrange(n):
... super(List, self).append(copy.copy(obj))
...
>>> items = List()
>>> items.append(42, 3)
>>> items
[42, 42, 42]

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


Re: data design

2007-01-30 Thread Imbaud Pierre
Szabolcs Nagy a écrit :
>>The lazy way to do this: have modules that initialize bunches of
>>objects, attributes holding the data: the object is somehow the row of
>>the "table", attribute names being the column. This is the way I
>>proceeded up to now.
>>Data input this way are almost "configuration data", with 2 big
>>drawbacks:
>>  - Only a python programmer can fix the file: this cant be called a
>>configuration file.
>>  - Even for the author, these data aint easy to maintain.
>>
>>I feel pretty much ready to change this:
>>- make these data true text data, easier to read and fix.
>>- write the module that will make python objects out of these data:
>>the extra cost should yield ease of use.
>>
>>2 questions arise:
>>- which kind of text data?
>> - csv: ok for simple attributes, not easy for lists or complex
>> data.
>> - xml: the form wont be easier to read than python code,
>>   but an xml editor could be used, and a formal description
>>   of what is expected can be used.
>>- how can I make the data-to-object transformation both easy, and able
>>   to spot errors in text data?
>>
>>Last, but not least: is there a python lib implementing at least part
>>of this dream?
> 
> 
> there is a csv parser and multiple xml parsers in python (eg 
> xml.etree)
I used both. both are ok, but only bring a low layer parsing.
> also there is a ConfigParser module (able to parse .ini 
> like config files)
Used this years ago, I had forgotten. Another fine data text format.
> 
> i personally like the python module as config file the most
> 
> eg if you need a bunch of key-value pairs or lists of data:
> * python's syntax is pretty nice (dict, tuples and lists or just 
> key=value)
But only python programmer editable!
> * xml is absolutely out of question
> * csv is very limited
> * .ini like config file for more complex stuff is not bad but then you 
> can use .py as well.
> 

Thanks a lot for your advices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: data design

2007-01-30 Thread Imbaud Pierre
Larry Bates a écrit :
> Imbaud Pierre wrote:
> 
>>The applications I write are made of, lets say, algorithms and data.
>>I mean constant data, dicts, tables, etc: to keep algorithms simple,
>>describe what is peculiar, data dependent, as data rather than "case
>>statements". These could be called configuration data.
>>
>>The lazy way to do this: have modules that initialize bunches of
>>objects, attributes holding the data: the object is somehow the row of
>>the "table", attribute names being the column. This is the way I
>>proceeded up to now.
>>Data input this way are almost "configuration data", with 2 big
>>drawbacks:
>> - Only a python programmer can fix the file: this cant be called a
>>   configuration file.
>> - Even for the author, these data aint easy to maintain.
>>
>>I feel pretty much ready to change this:
>>- make these data true text data, easier to read and fix.
>>- write the module that will make python objects out of these data:
>>the extra cost should yield ease of use.
>>
>>2 questions arise:
>>- which kind of text data?
>>- csv: ok for simple attributes, not easy for lists or complex
>>data.
>>- xml: the form wont be easier to read than python code,
>>  but an xml editor could be used, and a formal description
>>  of what is expected can be used.
>>- how can I make the data-to-object transformation both easy, and able
>>  to spot errors in text data?
>>
>>Last, but not least: is there a python lib implementing at least part
>>of this dream?
> 
> 
> Use the configurations module.  It was built to provide a way to parse
> configuration files that provide configuration data to program.  It is
> VERY fast so the overhead to parse even thousands of lines of config
> data is extremely small.  I use it a LOT and it is very flexible and
> the format of the files is easy for users/programmers to work with.
> 
> -Larry Bates
U mean configParser? Otherwise be more specific (if U dont mind...)
-- 
http://mail.python.org/mailman/listinfo/python-list


[email protected]

2007-01-30 Thread Chris Lambacher
On Tue, Jan 30, 2007 at 10:42:22AM -0500, Jason Persampieri wrote:
>Sadly, the group is tied to Python 2.3 for now.
Subprocess for 2.2 and 2.3:
http://www.lysator.liu.se/~astrand/popen5/

Win32 installers for subversion for 2.2 and 2.3:
http://www.lysator.liu.se/~astrand/popen5/

-Chris
> 
>Actually, I got around this problem by using an intermediate process that
>happens to handle output on its own (bsub).
> 
>On 1/30/07, Chris Lambacher <[EMAIL PROTECTED]> wrote:
> 
>  The subprocess module is probably a good starting point:
>  [2]http://docs.python.org/dev/lib/module-subprocess.html
> 
>  It will allow you greater control over what happens with the output of a
>  process that you start.  Specifically look at the the stdout and stderr
>  arguments to Popen.  You can provide these with an open file descriptor
>  or a
>  file object and it will dump the output into there.
> 
>  -Chris
>  >
>  > _jason
>  >
>  > --
>  > [3]http://mail.python.org/mailman/listinfo/python-list
> 
> References
> 
>Visible links
>1. mailto:[EMAIL PROTECTED]
>2. http://docs.python.org/dev/lib/module-subprocess.html
>3. http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Synchronous shutil.copyfile()

2007-01-30 Thread Jean-Paul Calderone
On Tue, 30 Jan 2007 15:05:23 +, Hugo Ferreira <[EMAIL PROTECTED]> wrote:
>Hi there,
>
>I have a problem. I'm using calling shutil.copyfile() followed by
>open(). The thing is that most of the times open() is called before
>the actual file is copied. I don't have this problem when doing a
>step-by-step debug, since I give enough time for the OS to copy the
>file, but at run-time, it throws an exception.
>
>Is there anyway to force a sync copy of the file (make python wait for
>the completion)?

shutil.copyfile() _is_ synchronous.  Check out the source:

def copyfileobj(fsrc, fdst, length=16*1024):
"""copy data from file-like object fsrc to file-like object fdst"""
while 1:
buf = fsrc.read(length)
if not buf:
break
fdst.write(buf)

def copyfile(src, dst):
"""Copy data from src to dst"""
if _samefile(src, dst):
raise Error, "`%s` and `%s` are the same file" % (src, dst)

fsrc = None
fdst = None
try:
fsrc = open(src, 'rb')
fdst = open(dst, 'wb')
copyfileobj(fsrc, fdst)
finally:
if fdst:
fdst.close()
if fsrc:
fsrc.close()

The problem you are experiencing must have a different cause.

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


Re: Help me override append function of list object

2007-01-30 Thread jeremito


On Jan 30, 10:47 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> jeremito wrote:
> > I have created a class that inherits from the list object.  I want to
> > override the append function to allow my class to append several
> > copies at the same time with one function call.  I want to do
> > something like:
>
> > import copy
>
> > class MyList(list):
> >   __init__(self):
> > pass
>
> >   def append(self, object, n=1):
> > for i in xrange(n):
> > self.append(copy.copy(object))
>
> > Now I know this doesn't work because I overwrite append, but want the
> > original functionality of the list object.  Can someone help me?Use 
> > list.append(self, obj) or super(MyList, self).append(obj), e. g.:
>
> >>> import copy
> >>> class List(list):... def append(self, obj, n=1):
> ... for i in xrange(n):
> ... super(List, self).append(copy.copy(obj))
> ...>>> items = List()
> >>> items.append(42, 3)
> >>> items[42, 42, 42]
>
> Peter

Thank you so much.  I'm glad it is so easy.
Jeremy

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


Re: Please take me off the list

2007-01-30 Thread Jacques Cazotte
Daniel kavic a écrit :
> Sorry to waste email space , but I wish to be off this list because I have 
> tried python and it is too difficult for me.
> 
> -Dan
Hi Daniel,
My name is God, and I am quite new to mailing lists.
I sometimes wonder wether computerizing the whole thing was a good
idea.
Do You want to give up the List downthere, and proceed to heavens, or
be completely erased?
Do You want me to remove python from the list of available langages?
(I didnt even remember I had done this one).
Without any answer from You within 1000 years, we shall transmit your
demand to the Comitee.

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


Re: Sourcing Python Developers

2007-01-30 Thread Ralf Schönian
Kartic schrieb:
> Hello,
> 
> My company has quite a few opening involving python expertise. We are 
> always looking for python resources (and find it difficult filling these 
> positions, might I add). Is there any place to find developers' resumes 
> (like finding jobs from http://python.org/community/jobs/)? If any one 
> knows of a resume repository (other than Monster, Dice, 
> Costs-an-arm-and-leg job site) please share.

Do not know if you have to give your arm or your leg away, but maybe the 
following place is of interest for you:

http://www.opensourcexperts.com

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


Re: message handling in Python / wxPython

2007-01-30 Thread Chris Mellon
On 1/30/07, murali iyengar <[EMAIL PROTECTED]> wrote:
> hi,
> i have basic knowledge of python and wxPython... now i need to know about
> message handling in python/wxPython?
>
> could anybody pls help me by giving some info on how to handle (in Python),
> 'the user defined messages' posted from VC++, i dont know how to handle
> messaes in python.
>
> Thanks and Regards,
> Murali M.S
> --

You need to override the WndProc at the C level in order to catch
these. As it happens, there is a page on the wxPyWiki about this exact
topic:


http://wiki.wxpython.org/index.cgi/HookingTheWndProc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please take me off the list

2007-01-30 Thread Paul Boddie
On 30 Jan, 16:33, Mikael Olofsson <[EMAIL PROTECTED]> wrote:
>
>http://mail.python.org/mailman/listinfo/python-list

See also the Tutor mailing list, which might be a bit better for 
starting to learn Python, should you (Daniel) decide to change your 
mind. Here's the mailing list's Web page:

http://mail.python.org/mailman/listinfo/tutor

If you haven't seen much information for beginners, take a look at 
these pages for some references:

http://www.python.org/about/gettingstarted/
http://wiki.python.org/moin/BeginnersGuide

Paul

P.S. There does seem to be a lot of information, especially in the 
upper regions of the python.org Wiki, which is either incoherent or 
which gives the signal that hacking on the Python interpreter itself 
is what everyone should be wanting to do. Before it became "immutable" 
I was tempted to give the Wiki front page an overhaul, just to link 
more prominently to stuff like tutorials as well as the more active 
reference pages, but I suppose we're stuck with the current "back 
door" overview (along with semi-personal requests pages) for the time 
being.

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


Re: Unicode error handler

2007-01-30 Thread Walter Dörwald
Rares Vernica wrote:
> Hi,
> 
> Does anyone know of any Unicode encode/decode error handler that does a 
> better replace job than the default replace error handler?
> 
> For example I have an iso-8859-1 string that has an 'e' with an accent 
> (you know, the French 'e's). When I use s.encode('ascii', 'replace') the 
> 'e' will be replaced with '?'. I would prefer to be replaced with an 'e' 
> even if I know it is not 100% correct.
> 
> If only this letter would be the problem I would do it manually, but 
> there is an entire set of letters that need to be replaced with their 
> closest ascii letter.
> 
> Is there an encode/decode error handler that can replace all the 
> not-ascii letters from iso-8859-1 with their closest ascii letter?

You might try the following:

# -*- coding: iso-8859-1 -*-

import unicodedata, codecs

def transliterate(exc):
if not isinstance(exc, UnicodeEncodeError):
raise TypeError("don'ty know how to handle %r" % r)
return (unicodedata.normalize("NFD", exc.object[exc.start])[:1],
exc.start+1)

codecs.register_error("transliterate", transliterate)

print u"Frédéric Chopin".encode("ascii", "transliterate")

Running this script gives you:
$ python transliterate.py
Frederic Chopin

Hope that helps.

Servus,
   Walter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please take me off the list

2007-01-30 Thread Christopher Mocock
Paul Boddie wrote:
> See also the Tutor mailing list, which might be a bit better for 
> starting to learn Python, should you (Daniel) decide to change your 
> mind. Here's the mailing list's Web page:
> 
> http://mail.python.org/mailman/listinfo/tutor
> 
> If you haven't seen much information for beginners, take a look at 
> these pages for some references:
> 
> http://www.python.org/about/gettingstarted/
> http://wiki.python.org/moin/BeginnersGuide
> 
> Paul

I was expecting to see a barrage of joke emails after reading the OP but
that's really useful information for me too as a bit of a beginner. Thanks.

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


ANNOUNCE: OSCON 2007 Call for Participation Ends Soon

2007-01-30 Thread Kevin Altis
Be Heard at OSCON 2007 -- Submit Your Proposal to Lead Sessions and
Tutorials by February 5!

The O'Reilly Open Source Convention
July 23-27, 2007
Portland, Oregon
http://conferences.oreillynet.com/os2007/


More than 2500 open source developers, gurus, experts and users will
gather, eager to network, learn, and share the latest knowledge on open
source software. We think of this group as "the best of the best,"
and we
invite you to contribute to the more than 400 sessions and 40 tutorials
designed to build inspiration and know-how. Submit your proposals at:
http://conferences.oreillynet.com/cs/os2007/create/e_sess

Share your favorite techniques, your proven successes, and newly
developed
technology in tracks for Linux, PHP, Perl, Python, Ruby, Java,
Databases,
Desktop Applications, Web Applications (client-side and server-side),
Windows, Administration, Security, and Emerging Topics.

No topic (other than closed source software) is off-limits, so send us
your best ideas. Among the hot topics we want to hear about are:
- Tools for the administration and deployment of large server farms
- Parallelization, grid, and multicore technologies
- Virtualization
- Ajax, Javascript, standards-based design, and other client-side web
issues
- Seaside, Rails, Django, and other interesting server-side technology
- Ubuntu as an emergent usable Linux distro and contender for Red Hat
and
Sun's client and server markets
- Java as open source
- AI, machine learning, and other ways of making software smarter
than the
people using it
- User experience and usability engineering lessons for web and desktop
software
- The spread of open source into law, culture, data, and services,
and the
accompanying issues and lessons

For full details and guidelines on submitting your proposal, go to
http://conferences.oreillynet.com/os2007/. If you know someone who would
be a good speaker, please pass this email on.

Whether as a speaker or as an attendee, you'll want to participate in
this
meeting of the best minds in the business, which will also include the
O'Reilly Radar Executive Briefing. Be sure to save the dates -- July
23-27. Registration will open in early April.

We hope to see you in Portland in July!

The OSCON Team

P.S. Remember, proposals for sessions and tutorials must be submitted to
http://conferences.oreillynet.com/os2007/
by (11:59PM Pacific Standard Time)  Monday, February 5.


***
To change your newsletter subscription options, please visit
http://www.oreillynet.com/cs/nl/home.

To unsubscribe from O'Reilly conference announcements, email
[EMAIL PROTECTED]

For assistance, email [EMAIL PROTECTED]

O'Reilly Media, Inc.
1005 Gravenstein Highway North, Sebastopol, CA  95472
***


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


test, please ignore qrm

2007-01-30 Thread Mark Harrison
test, please ignore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: data design

2007-01-30 Thread Larry Bates
Imbaud Pierre wrote:
> Larry Bates a écrit :
>> Imbaud Pierre wrote:
>>
>>> The applications I write are made of, lets say, algorithms and data.
>>> I mean constant data, dicts, tables, etc: to keep algorithms simple,
>>> describe what is peculiar, data dependent, as data rather than "case
>>> statements". These could be called configuration data.
>>>
>>> The lazy way to do this: have modules that initialize bunches of
>>> objects, attributes holding the data: the object is somehow the row of
>>> the "table", attribute names being the column. This is the way I
>>> proceeded up to now.
>>> Data input this way are almost "configuration data", with 2 big
>>> drawbacks:
>>> - Only a python programmer can fix the file: this cant be called a
>>>   configuration file.
>>> - Even for the author, these data aint easy to maintain.
>>>
>>> I feel pretty much ready to change this:
>>> - make these data true text data, easier to read and fix.
>>> - write the module that will make python objects out of these data:
>>> the extra cost should yield ease of use.
>>>
>>> 2 questions arise:
>>> - which kind of text data?
>>>- csv: ok for simple attributes, not easy for lists or complex
>>>data.
>>>- xml: the form wont be easier to read than python code,
>>>  but an xml editor could be used, and a formal description
>>>  of what is expected can be used.
>>> - how can I make the data-to-object transformation both easy, and able
>>>  to spot errors in text data?
>>>
>>> Last, but not least: is there a python lib implementing at least part
>>> of this dream?
>>
>>
>> Use the configurations module.  It was built to provide a way to parse
>> configuration files that provide configuration data to program.  It is
>> VERY fast so the overhead to parse even thousands of lines of config
>> data is extremely small.  I use it a LOT and it is very flexible and
>> the format of the files is easy for users/programmers to work with.
>>
>> -Larry Bates
> U mean configParser? Otherwise be more specific (if U dont mind...)

Sorry, yes I meant configParser module.  Had a little "brain disconnect"
there.

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


Re: Secret Technology of THERMATE and 911 Crime

2007-01-30 Thread thermate
A little intro to Uncle Al.
This bastard is a spook from the criminal agencies.
His job is to harass, disinform and such on the internet.
He has been doing it overtime for many years.

Now he was indeed doing his job in the last post.

Thermate is indeed the correct terminology.

When you search thermate you will find results for the demolition 
incendiaries accelerated by sulfur or such additives. Thermite is not 
the correct term since it is too wide and vague. The foundries use 
thermite for making alloys and that must be scrupulously free of 
sulfur and such additives. While thermate is the correct terminology 
and by its usage has now become associated with 911 research.

On Jan 30, 6:45 am, Uncle Al <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:[snip crap]
>
> > I do not plan to make a career out of 9/11 research,[snip more crap]
>
> > We have found evidence for thermates in the molten metal seen pouring
> > from the South Tower minutes before its collapse,[snip still more crap]
>
> > Thermate is the red
> > powder in the steel base. The prototype worked well, and the thermate-
> > jet cut through a piece of structural steel in a fraction of a second.Google
> thermite  595,000
>
> You can't even spell it correctly.  If you wish to see the light,
> begin by pullng your head out of your ass,
>
> http://www.mazepath.com/uncleal/sunshine.jpg
>
> Idiot.  You don't know dick about incendiaries.
>
> --
> Uncle Alhttp://www.mazepath.com/uncleal/
>  (Toxic URL! Unsafe for children and most 
> mammals)http://www.mazepath.com/uncleal/lajos.htm#a2

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


test,please ignore 2 qrm

2007-01-30 Thread Mark Harrison
please ignore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I know both the Key c and Ctrl on the keyboard are pressed?

2007-01-30 Thread Gabriel Genellina
En Tue, 30 Jan 2007 05:50:29 -0300, <[EMAIL PROTECTED]> escribió:

> How can I know the Key c and Ctrl on the keyboard are pressed? Or how
> to let the program press the
>
> key Ctrl+c automatically? I just want to use python to develop a
> script program.
> gear

If you are on Windows and want to trap the Ctrl-C combination, just catch  
the KeyboardInterrupt exception:

--- cut ---
 from time import sleep

while 1:
   try: sleep(1)
   except KeyboardInterrupt: print "Ctrl-C pressed"
--- cut ---

-- 
Gabriel Genellina

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


Re: Help me understand this

2007-01-30 Thread Gabriel Genellina
En Tue, 30 Jan 2007 06:34:01 -0300, Beej <[EMAIL PROTECTED]> escribió:

> But here's one I still don't get:
>
 type(2)
> 
 type((2))
> 
 (2).__add__(1)
> 3
 2.__add__(1)
>   File "", line 1
> 2.__add__(1)
> ^
> SyntaxError: invalid syntax

It appears to be a bug, either in the grammar implementation, or in the  
grammar documentation.
These are the relevant rules:

attributeref ::= primary "." identifier

primary ::= atom | attributeref | subscription | slicing | call

atom ::= identifier | literal | enclosure

literal ::= stringliteral | integer | longinteger | floatnumber |  
imagnumber

An integer is a primary so 2.__add(1) should be valid.

-- 
Gabriel Genellina

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


Re: Help me understand this

2007-01-30 Thread Jean-Paul Calderone
On Tue, 30 Jan 2007 14:39:28 -0300, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>En Tue, 30 Jan 2007 06:34:01 -0300, Beej <[EMAIL PROTECTED]> escribió:
>
>> But here's one I still don't get:
>>
> type(2)
>> 
> type((2))
>> 
> (2).__add__(1)
>> 3
> 2.__add__(1)
>>   File "", line 1
>> 2.__add__(1)
>> ^
>> SyntaxError: invalid syntax
>
>It appears to be a bug, either in the grammar implementation, or in the
>grammar documentation.
>These are the relevant rules:
>
>attributeref ::= primary "." identifier
>
>primary ::= atom | attributeref | subscription | slicing | call
>
>atom ::= identifier | literal | enclosure
>
>literal ::= stringliteral | integer | longinteger | floatnumber |
>imagnumber
>
>An integer is a primary so 2.__add(1) should be valid.

A float is, too.  2.__add is a float followed by an identifier.
Not legal.  As pointed out elsewhere in the thread, (2). forces
it to be an integer followed by a ".".

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

Re: The reliability of python threads

2007-01-30 Thread John Nagle
Aahz wrote:
> In article <[EMAIL PROTECTED]>,
> Carl J. Van Arsdall <[EMAIL PROTECTED]> wrote:
> My point is that an app that dies only once every few months under load
> is actually pretty damn stable!  That is not the kind of problem that
> you are likely to stimulate.

 This has all been so vague.  How does it die?

 It would be useful if Python detected obvious deadlock.  If all threads
are blocked on mutexes, you're stuck, and at that point, it's time
to abort and do tracebacks on all threads.   You shouldn't have to
run under a debugger to detect that.

 Then a timer, so that if the Global Python Lock
stays locked for more than N seconds, you get an abort and a traceback.
That way, if you get stuck in some C library, it gets noticed.

 Those would be some good basic facilities to have in thread support.

 In real-time work, you usually have a high-priority thread which
wakes up periodically and checks that a few flags have been set
indicating progress of the real time work, then clears the flags.
Throughout the real time code, flags are set indicating progress
for the checking thread to notice.  All serious real time systems
have some form of stall timer like that; there's often a stall
timer in hardware.

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


Re: Synchronous shutil.copyfile()

2007-01-30 Thread Matthew Woodcraft
Hugo Ferreira <[EMAIL PROTECTED]> wrote:
> I have a problem. I'm using calling shutil.copyfile() followed by
> open(). The thing is that most of the times open() is called before
> the actual file is copied. I don't have this problem when doing a
> step-by-step debug, since I give enough time for the OS to copy the
> file, but at run-time, it throws an exception.
>
> Is there anyway to force a sync copy of the file (make python wait for
> the completion)?

shutil.copyfile() closes both files before it returns, so I suspect
this is an OS-level bug.

The most likely culprits are buggy network filesystems and buggy
on-access virus scanners.

-M-

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


Re: Help me understand this

2007-01-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jean-Paul
Calderone wrote:

>>An integer is a primary so 2.__add(1) should be valid.
> 
> A float is, too.  2.__add is a float followed by an identifier.
> Not legal.  As pointed out elsewhere in the thread, (2). forces
> it to be an integer followed by a ".".

A space between the integer literal and the dot operator works too:

In [1]: 2 .__add__(1)
Out[1]: 3

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


Re: Convert raw data to XML

2007-01-30 Thread John Nagle
Actually, that's not "raw data" coming in, that's valid XML.
Why do you need to indent it?  Just write it to a file.

If you really need to indent XML, get BeautifulSoup, read the
XML in with BeautifulStoneSoup, and write it back out with
"prettify()".  But if the next thing to see that XML is a program,
not a human, why bother?

John Nagle

Justin Ezequiel wrote:
> On Jan 30, 10:42 am, [EMAIL PROTECTED] wrote:
> 
>>For example the raw data is as follows
>>
>>SomeText >Description>PassorFail
>>
>>without spaces or new lines. I need this to be written into an XML
>>file as
>>
>>
>>
>>   
>>  
>>  
>> SomeText
>>  
>>  
>> PassorFail
>>  
>>  
>>
>>
> 
> raw = r' 
>>SomeText PassorFail 
> ABC>'
> import xml.dom.ext
> import xml.dom.minidom
> doc = xml.dom.minidom.parseString(raw)
> xml.dom.ext.PrettyPrint(doc)
> 
> 
>   
> 
> SomeText 
> PassorFail
>   
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help me understand this

2007-01-30 Thread Neil Cerutti
On 2007-01-30, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> En Tue, 30 Jan 2007 06:34:01 -0300, Beej <[EMAIL PROTECTED]> escribió:
>
>> But here's one I still don't get:
>>
> type(2)
>> 
> type((2))
>> 
> (2).__add__(1)
>> 3
> 2.__add__(1)
>>   File "", line 1
>> 2.__add__(1)
>> ^
>> SyntaxError: invalid syntax
>
> It appears to be a bug, either in the grammar implementation, or in the  
> grammar documentation.
> These are the relevant rules:
>
> attributeref ::= primary "." identifier
>
> primary ::= atom | attributeref | subscription | slicing | call
>
> atom ::= identifier | literal | enclosure
>
> literal ::= stringliteral | integer | longinteger | floatnumber |  
> imagnumber
>
> An integer is a primary so 2.__add(1) should be valid.

Not if the tokenizer passes the parser a float.

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


Re: SQL connecting

2007-01-30 Thread Scripter47
Dennis Lee Bieber skrev:
> On Mon, 29 Jan 2007 19:45:47 GMT, John Nagle <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
> 
>> Scripter47 wrote:
>>> Hey
>>>
>>> It got a problem with python to connect to my SQL DBs, that's installed
>>> on my apache server. how do i connect to sql? Gettting data? Insert into 
>>> it?
>> You need a third-party open source package called "MySQLdb".
>>
>   Call me a nit, but did the original poster mean "MySQL" databases,
> or only that he uses SQL to access "my databases". The spelling is
> unclear as to what DBMS engine is actually being used. If it is /not/
> MySQL, then MySQLdb is futile.
Sry i didn't said it. it is a MySQL DB on a apache server

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


C extension module causes bus error on Python exit

2007-01-30 Thread Anand Patil
Hi all,

I was referred to this list from python-help. I've written an extension 
module in C which contains several new types. The types can be 
instantiated, used, and deleted under Python 2.4.3  on OS X 10.4 without 
problems.

However, whenever I import the module Python tries to dereference a NULL 
pointer and crashes *at exit*, whether or not I've instantiated any of 
the types. I've searched for memory leaks with gc.get_objects and Mac 
OS's MallocDebug utility, but haven't found any evidence.

Has anyone run into a problem like this? Any help is greatly appreciated.

Thank you,
Anand Patil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: data design

2007-01-30 Thread Paddy


On Jan 30, 2:34 pm, Imbaud Pierre <[EMAIL PROTECTED]> wrote:
> The applications I write are made of, lets say, algorithms and data.
> I mean constant data, dicts, tables, etc: to keep algorithms simple,
> describe what is peculiar, data dependent, as data rather than "case
> statements". These could be called configuration data.
>
> The lazy way to do this: have modules that initialize bunches of
> objects, attributes holding the data: the object is somehow the row of
> the "table", attribute names being the column. This is the way I
> proceeded up to now.
> Data input this way are almost "configuration data", with 2 big
> drawbacks:
>   - Only a python programmer can fix the file: this cant be called a
> configuration file.
>   - Even for the author, these data aint easy to maintain.
>
> I feel pretty much ready to change this:
> - make these data true text data, easier to read and fix.
> - write the module that will make python objects out of these data:
> the extra cost should yield ease of use.
>
> 2 questions arise:
> - which kind of text data?
>  - csv: ok for simple attributes, not easy for lists or complex
>  data.
>  - xml: the form wont be easier to read than python code,
>but an xml editor could be used, and a formal description
>of what is expected can be used.
> - how can I make the data-to-object transformation both easy, and able
>to spot errors in text data?
>
> Last, but not least: is there a python lib implementing at least part
> of this dream?
Google for YAML and JSON formats too.
http://www.yaml.org/
http://www.json.org/

-Paddy

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


Re: Convert raw data to XML

2007-01-30 Thread elrondrules
On Jan 29, 8:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Mon, 29 Jan 2007 23:42:07 -0300, <[EMAIL PROTECTED]> escribió:
>
> > For example the raw data is as follows
>
> > SomeText  > Description>PassorFail
>
> > without spaces or new lines. I need this to be written into an XML
> > file as
> > [same content but nicely indented]
>
> Is the file supposed to be processed by humans? If not, just write it as  
> you receive it.
> Spaces and newlines and indentation are mostly irrelevant on an xml file.
>
> --
> Gabriel Genellina

the reason I wanted to write it as a file was to parse the file, look 
for a specific attribute and execute a set of commands based on the 
value of the attribute.. also i needed to display the output of the 
http post in a more readable format..


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


Re: The reliability of python threads

2007-01-30 Thread Carl J. Van Arsdall
Steve Holden wrote:
> [snip]
>
> Are you using memory with built-in error detection and correction?
>
>   
You mean in the hardware?  I'm not really sure, I'd assume so but is 
there any way I can check on this?  If the hardware isn't doing that, is 
there anything I can do with my software to offer more stability?





-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


Re: strip question

2007-01-30 Thread Daniel Klein
On 26 Jan 2007 21:33:47 -0800, [EMAIL PROTECTED] wrote:

>hi
>can someone explain strip() for these :
>[code]
 x='www.example.com'
 x.strip('cmowz.')
>'example'
>[/code]
>
>when i did this:
>[code]
 x = 'abcd,words.words'
 x.strip(',.')
>'abcd,words.words'
>[/code]
>
>it does not strip off "," and "." .Why is this so?
>thanks

If you only have a couple of characters to deal with then use
replace(). Otherwise use string.translate() :

>>> import string
>>> x = 'abcd,words.words'
>>> transform = string.maketrans(',.','..')
>>> x = string.translate(x, transform)
>>> x = x.replace('.','')
>>> x
'abcdwordswords''


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


Re: The reliability of python threads

2007-01-30 Thread Carl J. Van Arsdall
John Nagle wrote:
> Aahz wrote:
>   
>> In article <[EMAIL PROTECTED]>,
>> Carl J. Van Arsdall <[EMAIL PROTECTED]> wrote:
>> My point is that an app that dies only once every few months under load
>> is actually pretty damn stable!  That is not the kind of problem that
>> you are likely to stimulate.
>> 
>
>  This has all been so vague.  How does it die?
>   
Well, before operating on most of the data I perform type checks, if the 
type check fails, my system flags an exception.  Now i'm in the process 
of finding out how the data went bad.  I gotta wait at this point 
though, so I was investigating possibilities so I could find a new way 
of throwing the kitchen sink at it.


>  It would be useful if Python detected obvious deadlock.  If all threads
> are blocked on mutexes, you're stuck, and at that point, it's time
> to abort and do tracebacks on all threads.   You shouldn't have to
> run under a debugger to detect that.
>
>  Then a timer, so that if the Global Python Lock
> stays locked for more than N seconds, you get an abort and a traceback.
> That way, if you get stuck in some C library, it gets noticed.
>
>  Those would be some good basic facilities to have in thread support.
>   
I agree.  That would be incredibly useful.  Although doesn't this spark 
up the debate on threads killing threads?  From what I understand, this 
is frowned upon (and was removed from java because it was dangerous).  
Although I think that if there was a master or control thread that 
watched the state of the system and could intervene, that would be 
powerful.  One way to do this could be to use processes, and each 
process could catch a kill signal if it appears to be stalled, although 
I am absolutely sure there is more to it than that.  I don't think this 
could be done at all with python threads though, but as a fan of python 
threads and their ease of use, it would be a nice and powerful feature 
to have.


-carl


-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


MoinMoin

2007-01-30 Thread Daniel Klein
Is it fair game to ask questions about MoinMoin here?

If not, can someone recommend a resource please?

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


Find and replace in a file with regular expression

2007-01-30 Thread TOXiC
Hi everyone,
First I say that I serched and tryed everything but I cannot figure 
out how I can do it.
I want to open a a file (not necessary a txt) and find and replace a 
string.
I can do it with:

import fileinput, string, sys
fileQuery = "Text.txt"
sourceText = '''SOURCE'''
replaceText = '''REPLACE'''
def replace(fileName, sourceText, replaceText):

file = open(fileName, "r")
text = file.read() #Reads the file and assigns the value to a 
variable
file.close() #Closes the file (read session)
file = open(fileName, "w")
file.write(text.replace(sourceText, replaceText))
file.close() #Closes the file (write session)
print "All went well, the modifications are done"

replacemachine(fileQuery, sourceText, replaceText)

Now all went ok but I'm wondering if it's possible to replace text if /
sourceText/ match a regex.
Help me please!
Thx in advance

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


SQLObject 0.7.3

2007-01-30 Thread Oleg Broytmann
Hello!

I'm pleased to announce the 0.7.3 release of SQLObject.

What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and
Firebird.  It also has newly added support for Sybase, MSSQL and MaxDB (also
known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.7.3

News and changes:
http://sqlobject.org/docs/News.html


What's New
==

News since 0.7.2


Bug Fixes
~

* Allow multiple MSSQL connections.

* Psycopg1 requires port to be a string; psycopg2 requires port to be an int.

* Fixed a bug in MSSQLConnection caused by column names being unicode.

* Fixed a bug in FirebirdConnection caused by column names having trailing
  spaces.

* Fixed a missed import in firebirdconnection.py.

* Remove a leading slash in FirebirdConnection.

* Fixed a bug in deep Inheritance tree.

For a more complete list, please see the news:
http://sqlobject.org/docs/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Executing Javascript, then reading value

2007-01-30 Thread John Nagle
Melih Onvural wrote:
> Thanks, let me check out this route, and then I'll post the results.
> 
> Melih Onvural
> 
> On Jan 29, 4:04 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> 
>> On 29 Jan 2007 12:44:07 -0800, Melih Onvural <[EMAIL PROTECTED]>
>> wrote:
>> 
>> 
>>> I need to execute some javascript and then read the value as part of a 
>>> program that I am writing. I am currently doing something like
>>> this:Python doesn't include a JavaScript runtime.  You might look into
>>> the
>> 
>> stand-alone Spidermonkey runtime.  However, it lacks the DOM APIs, so it
>> may not be able to run the JavaScript you are interested in running. There
>> are a couple other JavaScript runtimes available, at least.  If 
>> Spidermonkey is not suitable, you might look into one of them.

This is getting to be a common problem.  One used to be able to
look at web pages from a program by reading the HTML.  Now you need to
load the page into a browser-like environment, run at least the
OnLoad JavaScript, and then start looking at the document object module.
This requires a browser emulator, a browser without a renderer.
Useful for spam filters and such.

 It's not clear if the original poster needs that much capability,
though.

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


Re: MoinMoin

2007-01-30 Thread skip

Dan> Is it fair game to ask questions about MoinMoin here?
Dan> If not, can someone recommend a resource please?

Yes, however [EMAIL PROTECTED] will probably yield more
responses:

https://lists.sourceforge.net/lists/listinfo/moin-user

I've had problems getting my posts to appear there recently though.  I've
been using the gmane interface instead:

http://dir.gmane.org/gmane.comp.web.wiki.moin.general

Skip

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


Re: Sourcing Python Developers

2007-01-30 Thread John Nagle
Ralf Schönian wrote:
> Kartic schrieb:
> 
>> Hello,
>>
>> My company has quite a few opening involving python expertise. We are 
>> always looking for python resources (and find it difficult filling 
>> these positions, might I add). Is there any place to find developers' 
>> resumes (like finding jobs from http://python.org/community/jobs/)? If 
>> any one knows of a resume repository (other than Monster, Dice, 
>> Costs-an-arm-and-leg job site) please share.
> 
> 
> Do not know if you have to give your arm or your leg away, but maybe the 
> following place is of interest for you:
> 
> http://www.opensourcexperts.com
> 
> Ralf Schoenian

   I'd recommend against Rent-A-Coder.  I put a job out there
(overhauling "rwhois.py"), and three "coders" in succession
tried it and gave up.

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


Re: Convert raw data to XML

2007-01-30 Thread John Nagle
[EMAIL PROTECTED] wrote:
> On Jan 29, 8:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> 
>>En Mon, 29 Jan 2007 23:42:07 -0300, <[EMAIL PROTECTED]> escribió:

> the reason I wanted to write it as a file was to parse the file, look 
> for a specific attribute and execute a set of commands based on the 
> value of the attribute.. also i needed to display the output of the 
> http post in a more readable format..

That's straightforward.  You confused people by asking the
wrong question.  You wrote "Convert raw data to XML", but what
you want to do is parse XML and extract data from it.

This will do what you want:

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

For starters, try

from BeautifulSoup import BeautifulStoneSoup
xmlstring = somexml ## get your XML into here as one big string
soup = BeautifulStoneSoup(xmlstring)# parse XML into tree
print soup.prettify()   # print out in indented format

"soup" is a tree structure representing the XML, and there are
functions to easily find items in the tree by tag name, attribute,
and such.  Work on the tree, not a file with the text of the indented
output.


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


Re: Find and replace in a file with regular expression

2007-01-30 Thread Matimus
The re module is used for regular expressions. Something like this 
should work (untested):

 import fileinput, string, sys, re

 fileQuery = "Text.txt"
 sourceText = '''SOURCE'''
 replaceText = '''REPLACE'''

 def replace(fileName, sourceText, replaceText):
 file = open(fileName, "r")
 text = file.read() #Reads the file and assigns the value to a 
variable
 file.close() #Closes the file (read session)

 file = open(fileName, "w")
 file.write(re.sub(sourceText, replaceText,text))
 file.close() #Closes the file (write session)

 print "All went well, the modifications are done"

replacemachine(fileQuery, sourceText, replaceText)



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


Re: Convert raw data to XML

2007-01-30 Thread elrondrules
On Jan 30, 12:05 pm, John Nagle <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Jan 29, 8:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> >>En Mon, 29 Jan 2007 23:42:07 -0300, <[EMAIL PROTECTED]> escribió:
> > the reason I wanted to write it as a file was to parse the file, look
> > for a specific attribute and execute a set of commands based on the
> > value of the attribute.. also i needed to display the output of the
> > http post in a more readable format..
>
> That's straightforward.  You confused people by asking the
> wrong question.  You wrote "Convert raw data to XML", but what
> you want to do is parse XML and extract data from it.
>
> This will do what you want:
>
>http://www.crummy.com/software/BeautifulSoup/
>
> For starters, try
>
> from BeautifulSoup import BeautifulStoneSoup
> xmlstring = somexml ## get your XML into here as one big string
> soup = BeautifulStoneSoup(xmlstring)# parse XML into tree
> print soup.prettify()   # print out in indented format
>
> "soup" is a tree structure representing the XML, and there are
> functions to easily find items in the tree by tag name, attribute,
> and such.  Work on the tree, not a file with the text of the indented
> output.
>
> John Nagle

is there any other way to do this without using BeautifulStoneSoup.. 
using existing minidom or ext..
i dont want to install anything new

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


Re: Help me understand this

2007-01-30 Thread Beej
On Jan 30, 1:38 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Because 2. is the start of a float-literal. That isn't distinguishable for
> the parsere otherwise.

Oh, excellent! I wonder why I didn't think of that--I was too busy in 
"get a field" mode it didn't even occur to me that the "." had a 
different context, no matter how much more obvious.

>>> print 2.
2.0
>>> type(2.)


-Beej

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


Re: Help me understand this

2007-01-30 Thread Beej
On Jan 30, 9:52 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> A float is, too.  2.__add is a float followed by an identifier.
> Not legal.  As pointed out elsewhere in the thread, (2). forces
> it to be an integer followed by a ".".

Which leads to these two beauties:

>>> (2.).__add__(1)
3.0
>>> 2..__add__(1)
3.0

I like the second one more. :-)

-Beej


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


DCOP memory leak?

2007-01-30 Thread [EMAIL PROTECTED]
Hello,

I'm writing a python script for Amarok, I communicate with Amarok 
using DCOP.
Now, I have to call DCOP very often and I noticed that every time I 
make a DCOP call my program keeps growing in memory size.

To make sure it was DCOP i wrote the small program below:

from dcopext import DCOPClient, DCOPApp

while 0==0:
dcop=DCOPClient()
dcop.attach()
AmarokDcopRes = DCOPApp ("amarok", dcop)
ok, Ms = AmarokDcopRes.player.trackCurrentTimeMs()
print Ms

If you run this script and monitor it's memory use you'll see that it 
keeps growing.

Does anyone know how I can solve this problem?

Kind regards,

Tim

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


Re: Convert raw data to XML

2007-01-30 Thread hg
[EMAIL PROTECTED] wrote:

> On Jan 30, 12:05 pm, John Nagle <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>> > On Jan 29, 8:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>>
>> >>En Mon, 29 Jan 2007 23:42:07 -0300, <[EMAIL PROTECTED]> escribió:
>> > the reason I wanted to write it as a file was to parse the file, look
>> > for a specific attribute and execute a set of commands based on the
>> > value of the attribute.. also i needed to display the output of the
>> > http post in a more readable format..
>>
>> That's straightforward.  You confused people by asking the
>> wrong question.  You wrote "Convert raw data to XML", but what
>> you want to do is parse XML and extract data from it.
>>
>> This will do what you want:
>>
>>http://www.crummy.com/software/BeautifulSoup/
>>
>> For starters, try
>>
>> from BeautifulSoup import BeautifulStoneSoup
>> xmlstring = somexml ## get your XML into here as one big
>> string
>> soup = BeautifulStoneSoup(xmlstring)# parse XML into tree
>> print soup.prettify()   # print out in indented format
>>
>> "soup" is a tree structure representing the XML, and there are
>> functions to easily find items in the tree by tag name, attribute,
>> and such.  Work on the tree, not a file with the text of the indented
>> output.
>>
>> John Nagle
> 
> is there any other way to do this without using BeautifulStoneSoup..
> using existing minidom or ext..
> i dont want to install anything new
yes, write it ;-)




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


PythonCard

2007-01-30 Thread Tequila
I'm having some trouble starting PythonCard on my PC.

I've downloaded and ran python-2.5.msi to install Python on my 
machine.  And PythonCard-0.8.2.win32.exe to install PythonCard.

When I try to run the program I get the following error:
==
C:\Python25\Lib\site-packages\PythonCard\tools
\codeEditor>codeEditor.py
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\PythonCard\tools\codeEditor
\codeEditor.py", line 13, in 
from PythonCard import about, configuration, dialog, log, menu, 
model, resource, util
  File "C:\Python25\lib\site-packages\PythonCard\about.py", line 8, in 

import wx
ImportError: No module named wx
==

Does anyone know what the problem might be?

Thanks,
Tequila

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


Re: data design

2007-01-30 Thread Imbaud Pierre
Paddy a écrit :
> 
> On Jan 30, 2:34 pm, Imbaud Pierre <[EMAIL PROTECTED]> wrote:
> 
>>The applications I write are made of, lets say, algorithms and data.
>>I mean constant data, dicts, tables, etc: to keep algorithms simple,
>>describe what is peculiar, data dependent, as data rather than "case
>>statements". These could be called configuration data.
>>
>>The lazy way to do this: have modules that initialize bunches of
>>objects, attributes holding the data: the object is somehow the row of
>>the "table", attribute names being the column. This is the way I
>>proceeded up to now.
>>Data input this way are almost "configuration data", with 2 big
>>drawbacks:
>>  - Only a python programmer can fix the file: this cant be called a
>>configuration file.
>>  - Even for the author, these data aint easy to maintain.
>>
>>I feel pretty much ready to change this:
>>- make these data true text data, easier to read and fix.
>>- write the module that will make python objects out of these data:
>>the extra cost should yield ease of use.
>>
>>2 questions arise:
>>- which kind of text data?
>> - csv: ok for simple attributes, not easy for lists or complex
>> data.
>> - xml: the form wont be easier to read than python code,
>>   but an xml editor could be used, and a formal description
>>   of what is expected can be used.
>>- how can I make the data-to-object transformation both easy, and able
>>   to spot errors in text data?
>>
>>Last, but not least: is there a python lib implementing at least part
>>of this dream?
> 
> Google for YAML and JSON formats too.
> http://www.yaml.org/
> http://www.json.org/
> 
> -Paddy
> 
Hurray for yaml! A perfect fit for my need! And a swell tool!
Thanks a lot!

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


Re: DCOP memory leak?

2007-01-30 Thread jean-michel bain-cornu
> Now, I have to call DCOP very often and I noticed that every time I 
> make a DCOP call my program keeps growing in memory size.
> 
> To make sure it was DCOP i wrote the small program below:
> 
> from dcopext import DCOPClient, DCOPApp
> 
> while 0==0:
> dcop=DCOPClient()
> dcop.attach()
> AmarokDcopRes = DCOPApp ("amarok", dcop)
> ok, Ms = AmarokDcopRes.player.trackCurrentTimeMs()
> print Ms
> 
> If you run this script and monitor it's memory use you'll see that it 
> keeps growing.

It's probably silly, but what's about 'del dcop' as the last line of 
your loop ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Conditional expressions - PEP 308

2007-01-30 Thread Colin J. Williams
It would be helpful if the rules of the game were spelled out more clearly.

The conditional expression is defined as X if C else Y.
We don't know the precedence of the "if" operator.  From the little test 
below, it seem to have a lower precedence than "or".

Thus, it is desirable for the user to put the conditional expression in 
parentheses.

Colin W.

# condExpr.py
# PEP 308 defines a conditional expression as X if C else Y
# but we don't know exactly what X is supposed to be.
# It doesn't seem to be spelled out in the syntax.

def main():
   names= ['abc', 'def', '_ghi', 'jkl', '_mno', 'pqrs']
   res= ''
   for w in names:
res= res + w if w[0] != '_' else ''
z= 1
   print 'res1:', res

   res= ''
   for w in names:
res= res + (w if w[0] != '_' else '')
z= 1
   print 'res2:', res

if __name__ == '__main__':
   main()

Result:
[Dbg]>>>
res1: pqrs
res2: abcdefjklpqrs

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


Re: Secret Technology of THERMATE and 911 Crime

2007-01-30 Thread stj911
Thanks for this great link

On Jan 29, 7:27 pm, [EMAIL PROTECTED] wrote:
> Excellent Technology, and photos:
>
> http://stj911.org/jones/focus_on_goal.html
>
> As scientists, we look at the evidence, perform experiments, and apply
> the Scientific Method. The Greek method was to look at the evidence
> (superficially) and then try to explain things through logic and
> debate. The Greeks came up with various ideas in this way -- such as
> the geocentric theory in which the Earth was at the center of the
> universe, and all the stars and planets revolved around the earth.
> There were problems with this geocentric explanation, but Plato
> insisted that they must "save the hypothesis," and plausible
> explanations were found to account for anomalies -- i such as the
> retrograde motion of Mars. The philosophical debates and discussions
> were seemingly endless; the Dark Ages ensued.
>
> Along came Copernicus, Galileo, Newton and others with their
> experiments and observations, and the centuries-old Greek philosophy-
> based notions began to crumble. Galileo observed through a telescope
> that Jupiter had moons -- which revolved around Jupiter (not the
> Earth). He was threatened with torture if he did not recant his
> explanation (that the Earth was not at the center). He suffered house
> arrest but not torture as he quietly continued his experiments.
>
> In the lifetime of Newton, another experimenter who challenged the
> Greek approach, the scientific community worked out a system whereby
> scientific studies would be published after review by peers --
> qualified experts who could judge the quality of the research. Peer-
> reviewed technical journals arose and the peer-review process brought
> order to the relative chaos of work up to that time. Now experiments
> could be done and written up, then peer-reviewed and published. Peer-
> reviewed papers would draw the attention of others. To give an example
> of using the modern scientific method, a few colleagues and I are
> doing experiments and making observations in a scientific approach to
> what really happened at the World Trade Center. It is NOT merely a
> plausible explanation or debates about "possibilities" that we seek.
> Rather, having seen strong indications of foul play (see
> journalof911studies.com/Intersecting_facts_and_Theories_on_911.pdf )
> we are looking for hard evidence that would clearly verify an
> intentional crime beyond that of 19 hijackers. Ours is a forensic
> investigation, looking for a "smoking gun," which would then lead to a
> serious criminal investigation.
>
> I do not plan to make a career out of 9/11 research, and I am not
> making money from my investigations anyway. We need a formal, solid
> investigation of the 9/11 crimes committed, not a long-term study
> which endlessly debates all alternatives. I seek such solid evidence
> of an insider crime (beyond a reasonable doubt) that some of us will
> successfully demand a criminal investigation to confront key
> individuals who may have insider information -- within one year, if
> possible-- not many.
>
> So what evidence is likely to lead to such a criminal investigation?
>
> As identified in my talk at the University of California at Berkeley,
> there are four areas of 9/11 research that are so compelling that they
> may quickly lead to the goal of a solid investigation of 9/11 as an un-
> solved crime scene. These four areas are:
>
>1. Fall time for WTC 7.
>2. Fall times for the Towers.
>3. Challenging the NIST report and Fact Sheet.
>4. Evidence for use of Thermate reactions: What the WTC dust and
> solidified metal reveal.
>
> * Please note that I do not focus only on the thermate-hypothesis,
> and I do research in all four areas above. Details are given in my
> talk, available here:www.911blogger.com/node/4622Also:
> video.google.com/videoplay?docid=9210704017463126290 )
>
> There are other lines that may compel a criminal investigation even
> before one of the above "hard science" research lines bears fruit:
>
>5. Whistleblower statements -- including some individuals yet to
> emerge.
>6. Who made the stock-market "put-option" trades on American and
> United Air Lines in the week before 9/11, indicating clear
> foreknowledge of the attacks coupled with greed?
>7. The fact that the WTC dust was declared quite safe by the EPA/
> National Security Council when it fact scientists had proven it to be
> toxic, and the many people now clamoring for justice after being hurt
> and misled.
>8. Calls for impeachment for war issues, e.g., from a state
> legislature or Congress, which scrutinizes the "Bush Doctrine," then
> opens the 9/11 question.
>9. Pressure from 9/11 Family members, firemen and others for
> answers.
>   10. Direct appeals to Senators and Congresspersons -- who are
> charged with an oversight role. I initiated a Petition to this effect,
> demanding release of government-held information related to 9/11,
> which has sin

Re: Resizing widgets in text windows

2007-01-30 Thread deacon . sweeney
On Jan 26, 10:52 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi, I've been searching for a .resize()-like function to overload much
> > like can be done for the delete window protocol as follows:
>
> > toplevel.protocol("WM_DELETE_WINDOW", callback)
>
> > I realize that the pack manager usually handles all of the resize
> > stuff, but I've found an arrangement that the pack manager fails for.
> > That is, if one embeds a canvas into a window created inside a text
> > widget,
>
> Your meaning here is unclear. How is it possible to have "a window
> created inside a text widget"?

using the create_window function, as below.

>
> > then resize the text widget (via its container), the canvas and
> > its container windows do not resize. So I need to resize the window
> > that the canvas is embedded in.
>
> Try the Toplevel.wm_geometry() function.
>
> > The most obvious way of doing this
> > would be as above, but there does not seem to be an equivalent to the
> > "WM_DELETE_WINDOW" protocol for resizing.
>
> Do you want to detect when a window is resized or do you want to resize
> a window programatically.
>
> If the former, bind the Toplevel to ''.
>
> E.g.
>
> from Tkinter import *
>
> def config(t):
>def _r(e, t=t):
>  geom = e.widget.wm_geometry()
>  geom = geom.split('+')[0]
>  t.wm_geometry(geom)
>  print 'resized %s to %s' % (t, geom)
>return _r
>
> tk = Tk()
> tk.title('resize me')
> t2 = Toplevel(tk)
> t2.title('I get resized')
> tk.bind('', config(t2))
>
> Is that cool or what?
>

Yes, this is exactly what I was looking for. Thanks.

> James
>
> > Any help would be greatly appreciated.
>
> >DeaconSweeney





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


Re: Resizing widgets in text windows

2007-01-30 Thread deacon . sweeney
On Jan 29, 3:33 am, "Eric Brunel" <[EMAIL PROTECTED]> wrote:
> On Fri, 26 Jan 2007 22:35:20 +0100, <[EMAIL PROTECTED]> wrote:
> > Hi, I've been searching for a .resize()-like function to overload much
> > like can be done for the delete window protocol as follows:
>
> > toplevel.protocol("WM_DELETE_WINDOW", callback)
>
> > I realize that the pack manager usually handles all of the resize
> > stuff, but I've found an arrangement that the pack manager fails for.
> > That is, if one embeds a canvas into a window created inside a text
> > widget, then resize the text widget (via its container), the canvas and
> > its container windows do not resize.
>
> Supposing you call "embedding" inserting a widget in the text via the
> window_create method, why should they? Embedding a window in a Text is
> used to put some arbitrary widget in the middle of the text it contains.
> So the embedded widget has no reason to grow or shrink with the parent
> Text widget: it just moves with the text.
>
> > So I need to resize the window
> > that the canvas is embedded in. The most obvious way of doing this
> > would be as above, but there does not seem to be an equivalent to the
> > "WM_DELETE_WINDOW" protocol for resizing.
>
> As James said, the  event is your friend. But I'm not sure I
> understand your use case...
>
> HTH
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in
> 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"

I'm using a text widget to hold a set of plots, one plot per line, 
such that the scrolling capability of the text widget can be taken 
advantage of to display only a subset of the plots at any given time. 
In the analyses my program automates, there are at least several plots 
are typically loaded into the text widget. This works out splendidly, 
but the width of the plots has thus far been a static thing. Now, I'll 
be able to adjust the plots widths so that when the owner window is 
resized, the width of each plot in the text widget is adjusted and the 
plot continues to occupy the entire text widget but no more, making 
for a much more professional looking product.

I didn't mean to imply that create_window widgets should automatically 
resize with the toplevel... I just couldn't find any way to force it.

Muchas gracias.

Deacon




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


Re: PythonCard

2007-01-30 Thread Paul Watson
Tequila wrote:
> I'm having some trouble starting PythonCard on my PC.
> 
> I've downloaded and ran python-2.5.msi to install Python on my 
> machine.  And PythonCard-0.8.2.win32.exe to install PythonCard.
> 
> When I try to run the program I get the following error:
> ==
> C:\Python25\Lib\site-packages\PythonCard\tools
> \codeEditor>codeEditor.py
> Traceback (most recent call last):
>   File "C:\Python25\Lib\site-packages\PythonCard\tools\codeEditor
> \codeEditor.py", line 13, in 
> from PythonCard import about, configuration, dialog, log, menu, 
> model, resource, util
>   File "C:\Python25\lib\site-packages\PythonCard\about.py", line 8, in 
> 
> import wx
> ImportError: No module named wx
> ==
> 
> Does anyone know what the problem might be?
> 
> Thanks,
> Tequila

It would appear that you need to install wxPython also.

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


Re: Convert raw data to XML

2007-01-30 Thread Gabriel Genellina
[EMAIL PROTECTED] wrote:

> is there any other way to do this without using BeautifulStoneSoup..
> using existing minidom or ext..
> i dont want to install anything new

It appears that you already know the answer... Look at the minidom  
documentation, toprettyxml method.

-- 
Gabriel Genellina

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


  1   2   >