how to drop all thread ??

2004-11-28 Thread Leon
if class A(
use threading,thread module
) to produce 100 thread,how to drop its (100 thread) when its running 


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


Re: Newbie MySQLdb / MySQL version problem, I think

2004-11-29 Thread Leon
new version MySQL use new Password encode .
you can use ¡upassword()¡v(modify user table)¡Ato change new password encode 
to old password..

good luck ^^

---by Leon--
"Dave Merrill" <[EMAIL PROTECTED]> ¼¶¼g©ó¶l¥ó·s»D:[EMAIL PROTECTED]
> Sorry for the newbness... Win2K, Python 2.3.3, MySQL 4.1.7. Downloaded and
> extracted MySQL-python-1.0.0.win32-py2.3.zip. Put the whole extracted
> directory into C:\Program Files\Python23\Lib\site-packages\ and renamed it
> to "MySQLdb.
>
> MySQLdb.__version__ returns '1.0.0', so I think it's installed ok.
>
> However, I still can't connect, and I just want to confirm my guess on 
> what
> the problem is, which is that MySQLdb doesn't yet support MySQL 4.1. I'd
> hoped that all that meant was that it wouldn't support any of 4.1's new
> features, but it appears this combination may be completely 
> non-functional.
> Test and results below.
>
> Has anyone else tried this?
>
> Thanks,
>
> Dave Merrill
>
>
> TEST CODE (from http://www.kitebird.com/articles/pydbapi.html):
> --
> import MySQLdb
> conn = MySQLdb.connect (host = "localhost",
>   user = "test_user",
>   passwd = "secret",
>   db = "test_db")
> cursor = conn.cursor ()
> cursor.execute ("SELECT VERSION()")
> row = cursor.fetchone ()
> print "server version:", row[0]
> cursor.close ()
> conn.close ()
> --
>
> RESULT:
> --
> Traceback (most recent call last):
>  File "C:\PROGRA~1\PYTHON23\Lib\site-packages\sm\scriptutils.py", line 49,
> in run
>exec codeObject in mainDict
>  File "", line 9, in ?
>  File "C:\PROGRA~1\PYTHON23\lib\site-packages\MySQLdb\__init__.py", line
> 64, in Connect
>return apply(Connection, args, kwargs)
>  File "C:\PROGRA~1\PYTHON23\lib\site-packages\MySQLdb\connections.py", 
> line
> 116, in __init__
>self._make_connection(args, kwargs2)
>  File "C:\PROGRA~1\PYTHON23\lib\site-packages\MySQLdb\connections.py", 
> line
> 41, in _make_connection
>apply(super(ConnectionBase, self).__init__, args, kwargs)
> OperationalError: (1251, 'Client does not support authentication protocol
> requested by server; consider upgrading MySQL client')
> --
>
>
>
> 


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


what module can do html encoder??

2004-12-12 Thread Leon
example:
s = ' ' --->   


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


Higher-level OpenGL modules

2006-09-05 Thread Leon
Greetings,

Does anybody know of or is working on any python modules that allow for
a direct but higher-level interface to OpenGL? For example, quick
functions to draw lines, curves, and basic shapes; define hsb color
mode; fill and stroke operations; easy loading of images, svg files,
etc (much like the processing language -
http://www.processing.org/reference/index.html).  The closest thing I
could find was devachan - http://www.cesaremarilungo.com/sw/devachan/,
but its very limited. Any response would be greatly appreciated.

Thanks
Leon

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


Re: Higher-level OpenGL modules

2006-09-05 Thread Leon
Thanks guys!, Ill look into your suggestions. I'm actually currently
working directly with pyOpenGL, but hopefully Ill find something that
would make me more efficient. I might end up writing a library myself.

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


Freetype 2 Bindings

2006-09-07 Thread Leon
Hi,

Has anybody experimented with this python binding for Freetype2
(http://www.satzbau-gmbh.de/staff/abel/ft2/index.html) ? I'm hoping to
learn more about using text in pyOpenGl by creating textures from
glyphs generated by Freetype2. I downloaded and installed the bindings,
and with the download came an example (render.py) which renders a
string to an image, when I run the example without modifying the code,
only the first character of a string I feed it appears in the image and
blank spaces are present for the rest of the characters (you'll see
what I mean if you run render.py). I'm pretty sure it's the part of the
code in the example that defines the kerning, but I'm new to Freetype2,
and I tried following the documentation and changing the code, but I
can't pinpoint the exact problem. If you have experience programming
with Freetype2 and can figure out this out, please help, I'll be
forever grateful.

Thanks,
Leon

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


Formatting a string to be a columned block of text

2006-12-26 Thread Leon
Hi,

I'm creating a python script that can take a string and print it to the
screen as a simple multi-columned block of mono-spaced, unhyphenated
text based on a specified character width and line hight for a column.
For example, if i fed the script an an essay, it would format the text
like a newspaper on the screen. Text processing is very new to me, any
ideas on how I could achieve a multi-columned text formatter. Are there
any libraries that already do this?

Thanks and happy holidays!
Leon

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


Find the ID, but how to select/copy the whole string by ID?

2007-09-19 Thread Leon
Hi everybody,

I am a beginer for  Python, hope can get help from you guys.
What I want to do is :

Input an ID -> find the ID in the file -> copy the whole string y

stringID = str(raw_input('Enter the string ID : '))
file = open('strings.txt')
sourcefile = file.read()
file.close()
sourcefile.find (stringID)

but how can I select and copy the specific string from  to 
with id I input?

Thanks!!!

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


TK 8.5

2007-12-31 Thread Leon
Hello,

First of all, I beg you pardon for my poor english...

You probably know it, but a new version of Tcl/TK has arrived : 
http://groups.google.fr/group/comp.lang.tcl/browse_frm/thread/747fcc9df3274310/

With TK8.5, I found the look and feel better that in the past :
http://wiki.tcl.tk/13636

It would be great to have the same look with TkInter...

1) Did you know if a future version of Python/Tkinter will use Tk 8.5 ? 
And when ?

2) Is it a way to use Tk 8.5 with the present version of Python (2.5) ?

3) Or may be it's possible to already have a similar and good look with 
the present version of TK[inter] included in the last version of Python 
(2.5.1) ?

Can you give me informations (or links, etc...) about this three 
questions ?

Thanx in advance !!!

Leon


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


Re: TK 8.5

2008-01-01 Thread Leon
> We are planing to use Tcl/Tk 8.5 for Python 2.6 and 3.0. The topic is
> currently being discussed but nothing has been decided yet.

Great news!
I hope you'll decide to use Tcl/Tk 8.5 !
I'm sure I'm not the only one !!!

On this page : http://www.python.org/dev/peps/pep-0361/

We can read : "the initial 2.6 target is for April 2008"

Great !

But I found nothing about Tk 8.5 ?

Leon


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


Re: Which one is best Python or Java for developing GUI applications?

2009-05-05 Thread Leon
I think there are two advantages over java for GUI application

First, python is more productive and has very rich third modules
support,
you can check the demo of wxPython.

Second, you can develop native-looking GUI

BTW: I'm developing GUI application using python and wxPython.



Second,
On May 4, 11:41 pm, srinivasan srinivas 
wrote:
> Could you tell me does Python have any advantages over Java for the 
> development of GUI applications?
>
> Thanks,
> Srini
>
>       Now surf faster and smarter ! Check out the new Firefox 3 - Yahoo! 
> Editionhttp://downloads.yahoo.com/in/firefox/?fr=om_email_firefox

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


what's the best way to call a method of object without a guarantee of its existence

2009-05-05 Thread Leon
One way,  define the object before it is used,
like this:
object = None
.
.

if object is not None:
   object.method()

The other way, using try ... catch
try:
 object.method()
catch NameError:
 pass

for  big programs, which is better, or any other way?

Miles


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


Re: what's the best way to call a method of object without a guarantee of its existence

2009-05-05 Thread Leon

On May 5, 3:25 am, Marco Mariani  wrote:
> Leon wrote:
> > One way,  define the object before it is used,
> > like this:
> > object = None
>
> This is a good practice anyway. Conditional existance of objects is
> quite evil. Resorting to if defined('foo') is double-plus-ugly.

This was why I asked this question. In my program, I use the pattern
of
object.method() a lot, but every time I need to check if it exists or
not,
which makes me feel uncomfortable.


> > The other way, using try ... catch
> > try:
> >      object.method()
> > catch NameError:
> >      pass
>
> Except you should trap AttributeError because you defined the thing as
> None before. NameErrors should be fixed as bugs, not trapped (IMHO --
> but in python there is always a use case for everything).
>
> Keep in mind that AttributeError might come from inside the method(),
> which could be confusing
>
> By using the
>
> if stuff:
>     stuff.run()
>
> idiom, you avoid the last issue and keep it simple enough.
>
> > for  big programs, which is better, or any other way?
>
> Define "big", as in scope, LOCs, or number of committers?
"big", I mean, is not in the same scope
For instance,


class frame(wx.Frame):
  def __init__(self, parent, ):
  
  self.parent = parent # parent from another module
  .

  def eventHandler_1(self,event):
  if self.parent.object_1 is not None:
 self.parent.object_1.method()

  def eventHandler_2(self, event):
  if self.parent.object_2 is not None:
 self.parent.object_2.method()

So I need to go back to the module including "parent" class
to define the objects that I maybe use in future as None,
actually, the module including "parent' class works very well
without those definitions, from parent class's point of view,
those definitions are kind of noisy.

Thanks Marco


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


Re: Regular Expression: Matching substring

2006-04-12 Thread Leon
Hi Kevin,

You may notice that, for matching the regex (0|(1(01*0)*1))*,  the left
most
three  characters of a string must not be ``101" while not followed by
an `0'.
After reading the first `1', automata expects  `1' or ``00" or ``010"
or ``11",
right?:)


Kevin CH 寫道:

> Hi,
>
> I'm currently running into a confusion on regex and hopefully you guys
> can clear it up for me.
>
> Suppose I have a regular expression (0|(1(01*0)*1))* and two test
> strings: 110_1011101_ and _101101_1. (The underscores are not part of
> the string.  They are added to show that both string has a substring
> that matches the pattern.)  Applying a match() function on the first
> string returns true while false for the second.  The difference is the
> first one has unmatched chunk in the beginning while the second at the
> end.  How's the regex rule work here?
> 
> Thanks.

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

Re: Regular Expression: Matching substring

2006-04-12 Thread Leon
You are right. In fact the procedure is as follows:
The substr ``101101" is no problem, if stop here, match will
successful.
But the tailing `1' occurs, so we may imagine the working automata move
to a state, which according to the regexp's outer most `)', and ready
to repeat
the whole regexp again. In this case, the answer is ``yes" only when
there exists
at least two ``1", but only one here.

BTW, the first string is matched exactly, according to your notion, it
should be written as: _11_0_1011101

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


How to read source code of python?

2010-06-09 Thread Leon
Hi, there,
I'm trying to read the source code of python.
I read around, and am kind of lost, so where to start?

Any comments are welcomed, thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do something in time interval

2008-10-06 Thread Leon Zhang
Petr,

I am not an expert, but why not to use time.sleep(5)?
If you are using wxPython, you may also try wx.Timer, in which you could set
its interval.

Good luck!
Leon

On Tue, Oct 7, 2008 at 2:07 AM, Petr Jakes <[EMAIL PROTECTED]> wrote:

> I have infinitive loop running script and I would like to check
> something periodically after 5 seconds (minutes, hours...) time period
> (I do not mean time.sleep(5) ). Till now, I have following script, but
> I think there must be something more elegant.
>
> eventFlag = False
> while 1:
>time.sleep(0.01)
>seconds = time.time()
>if not int(seconds % (5)):
>if eventFlag:
>print "5 seconds, hurray"
>eventFlag = False
>else:
>eventFlag = True
>
> Best regards
>
> Petr Jakes
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


the pipe reading in Thread dose not work.

2008-06-01 Thread Leon zhang

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import string, sys
from threading import Thread
import os
import time

class test_pipe(Thread):
def __init__(self, fd):
Thread.__init__(self)
self.testfd = fd

def run(self):
print "started thread begin -"
while True:
buf = self.testfd.read()
print "receive %s" % (buf)
time.sleep(1)
#print "hoho"

if __name__ == "__main__":

stdin_r, stdin_w = os.pipe()
#stdout_r, stdout_w = pipe()

f_w = os.fdopen(stdin_w, "w", 0)

thrd = test_pipe(os.fdopen(stdin_r, "r", 0))
thrd.start()

time.sleep(1)

while True:
f_w.write("help\r\n")
time.sleep(1)

thrd.join()

well, I want the following small test about pipe() in thread().
OK, I write to the pipe in the main thread, and I created a new thread
for reading from the pipe, then it will print what it received from
the pipe().

But, it seems it block at the "self.testfd.read()".

So, is there and suggestion and explaination about it?

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


Eclipse, Python, wxPython and code completion

2008-08-10 Thread leon . domingo
Hello,

I've installed Eclipse, Python 2.5 and wxPython on Ubuntu 8.04. The
problem is that I can't get code completion for wx module. I don't
know if it occurs the same with other libraries outside the python
"core".

If I compile/run my code containing the wx library, I get an
application running correctly, so it looks that definition works fine.
Obviously, the obstacle is that I don't know (I don't want to either)
the name of every method of every wxPython class so it's difficult to
develop anything within this environment.

Thanks a lot

Note: I'm a newbie-coming-from-"Billy's"-WindowsXP
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse, Python, wxPython and code completion

2008-08-11 Thread leon . domingo
On 11 ago, 04:34, "SPE - Stani's Python Editor"
<[EMAIL PROTECTED]> wrote:
> On 10 aug, 20:42, [EMAIL PROTECTED] wrote:
>
>
>
> > Hello,
>
> > I've installed Eclipse, Python 2.5 and wxPython on Ubuntu 8.04. The
> > problem is that I can't get code completion for wx module. I don't
> > know if it occurs the same with other libraries outside the python
> > "core".
>
> > If I compile/run my code containing the wx library, I get an
> > application running correctly, so it looks that definition works fine.
> > Obviously, the obstacle is that I don't know (I don't want to either)
> > the name of every method of every wxPython class so it's difficult to
> > develop anything within this environment.
>
> > Thanks a lot
>
> > Note: I'm a newbie-coming-from-"Billy's"-WindowsXP
>
> You can try SPE which is written in wxPython itself and has very good
> code completion for wxPython. It also includes some wxPython GUI
> builders such as wxGlade and XRCed. I improved it a lot for Hardy,
> which I use myself:
> sudo apt-get install spe
>
> Stani

Thanks, Stani

I will check this out
--
http://mail.python.org/mailman/listinfo/python-list


Re: Socket Question

2008-10-01 Thread Leon Zhang
Maybe you need to close the socket somewhere else, rather than to close it
when you receive the your response.

On Tue, Sep 30, 2008 at 7:01 AM, Ali Hamad <[EMAIL PROTECTED]> wrote:

> Hello All :
>
> A socket question from a networking newbie.  I need to create
> a server that:
>
> 1) receive a message from client.
> 2) check that message and response to it.
> 3) the client get the server message and send another message.
> 4) finally, the server receive the message and close the connection.
>
> I have successfully done this. However, I couldn't use the same socket
> to send the second message
> to the server. I have googled but all the examples are only for sending
> one message and receiving the response.
>
> in my client code, I have :
>
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect(('127.0.0.1', 1888))
> s.send("1st message")
> response = s.recv(1024)
> validate(response)
> s.send("2nd message")
> response2 = s.recv(1024)
> s.close()
>
> However, I got the first response just fine from the server but the
> second message didn't get to the server.
>
> So, the solution I came up with is to send the 1st message, close the
> socket, create new socket,
> and send the 2nd message.
>
> I came up with something like :
>
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect(('127.0.0.1', 1888))
> s.send("1st message")
> response = s.recv(1024)
> s.close()
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect(('127.0.0.1', 1888))
> s.send("2nd message")
> response = s.recv(1024)
> s.close()
>
> and it works !
>
> My Question :
>
> is it possible to send/receive from the same socket more than one message ?
>
> Thank you for your assistance in advance,
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Discarding STDERR generated during subprocess.popen

2010-08-23 Thread Leon Derczynski
Hi,

I would like to run an external program, and discard anything written
to stderr during its execution, capturing only stdout. My code
currently looks like:

def blaheta_tag(filename):
blaheta_dir = '/home/leon/signal_annotation/parsers/blaheta/'
process = subprocess.Popen([blaheta_dir + 'exec/funcTag',
blaheta_dir + 'data/', filename], cwd=blaheta_dir,
stdout=subprocess.PIPE)
process.wait()
return process.communicate()[0]

This returns stdout, and stderr ends up printing to the console. How
can I disregard anything sent to stderr such that it doesn't appear on
the console?

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