Re: Python crash when trying to generate an Excel worksheet with VBA macros

2006-10-04 Thread hg
dan_roman wrote:
> Hi,
> I developed a script with a nice interface in Tkinter that allows me to
> edit some formulas and to generate an Excel worksheet with VBA macros
> within it. The script runs perfectlly in Office 2000, but in Office
> 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)"
> Please help me :-(
> 
> the code of the module that crash is (only in Excel 2003, in 2000 not):
> 
> import os
> import string
> from win32com.client import Dispatch, constants
> 
> str_code="""
> Dim nrfunc As Integer
> Dim cursor As Integer
> Dim i As Integer
> Dim j As Integer
> 
> 
> 
> Sub Fill()
> 
> 
> 'Aflu numaru de functii din XL
> i = 1
> ..
> """
> def createExcelReport(projectName,templateName,saveToPath):
>   # acquire application object, which may start application
>   application = Dispatch("Excel.Application")
> 
>   # create new file ('Workbook' in Excel-vocabulary) using the specified
> template
>   workbook = application.Workbooks.Add("Template1.xls")
> 
>   # store default worksheet object so we can delete it later
>   defaultWorksheet = workbook.Worksheets(1)
> 
>   worksheet1 = workbook.Worksheets(1)
>   worksheet2 = workbook.Worksheets(2)
>   worksheet3 = workbook.Worksheets(3)
> 
> > wbc = workbook.VBProject.VBComponents.Add(1) -- here
> is the problem
> 
>   wbc.Name="Module1"
> 
>   wbc.CodeModule.AddFromString(str_code)
> 
>   path=saveToPath+"\\"+projectName+"_"+templateName+".xls"
> 
>   workbook.SaveAs(path)
> 
>   worksheet1 = workbook.Worksheets(1)
> 
>   # make stuff visible now.
>   worksheet1.Activate()
>   application.Visible = True
> 

Crash as in Office or as a Python exception ?

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


Re: Where is Python in the scheme of things?

2006-10-04 Thread hg
gord wrote:
> As a complete novice in the study of Python, I am asking myself where this 
> language is superior or better suited than others. For example, all I see in 
> the tutorials are lots of examples of list processing, arithmetic 
> calculations - all in a DOS-like environment.
> 
> What is particularly disappointing is the absence of a Windows IDE, 
> components and an event driven paradigm. How does Python stand relative to 
> the big 3, namely Visual C++, Visual Basic and Delphi? I realize that these 
> programming packages are quite expensive now while Python is free (at least 
> for the package I am using - ActivePython).
> 
> Please discuss where Python shines.
> Gord
> 
> 
Big three? ... not sure even Bill agrees with you.

Code in Python and decide for yourself ... but again, nowadays, you're
to compare with C#, VB ... if you want to be in; that is.

hg

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


Re: Where is Python in the scheme of things?

2006-10-04 Thread hg
hg wrote:
> gord wrote:
>> As a complete novice in the study of Python, I am asking myself where this 
>> language is superior or better suited than others. For example, all I see in 
>> the tutorials are lots of examples of list processing, arithmetic 
>> calculations - all in a DOS-like environment.
>>
>> What is particularly disappointing is the absence of a Windows IDE, 
>> components and an event driven paradigm. How does Python stand relative to 
>> the big 3, namely Visual C++, Visual Basic and Delphi? I realize that these 
>> programming packages are quite expensive now while Python is free (at least 
>> for the package I am using - ActivePython).
>>
>> Please discuss where Python shines.
>> Gord
>>
>>
> Big three? ... not sure even Bill agrees with you.
> 
> Code in Python and decide for yourself ... but again, nowadays, you're
> to compare with C#, VB ... if you want to be in; that is.
> 
> hg
> 
OK, you did say VB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to execute a python script in .NET application

2006-10-06 Thread hg
Chandra wrote:
> Hi,
> 
> Is there a way to execute a python script(file) in ASP.NET application
> (programmatically)??
> 
> Regards,
> Chandra
> 

pythondotnet@python.org ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter & systray

2006-10-09 Thread hg
billie wrote:
> Hi all. I'd like to develop a GUI-based application the most portable
> as possible, able to run in systray.
> I think that, for portability reasons, Tkinter could be the best
> choice, so I tried to google a little bit about it.
> According to this :
> http://mail.python.org/pipermail/python-list/2002-September/123257.html
> ...it seems that it's impossible (or better, it WAS impossible in
> September 2002) handling this case by using Tkinter.
> Four years later is there a way to make this happen?
> 
> Thanks in advance.
> 
I know wxPython does that and I assume PyQT also does.

I do not think Tkinter is more portable than the above two anymore ...
just easier to install since built-in.

hg

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


Re: Funky file contents when os.rename or os.remove are interrupted

2006-10-10 Thread hg
Russell Warren wrote:
> I've got a case where I'm seeing text files that are either all null
> characters, or are trailed with nulls due to interrupted file access
> resulting from an electrical power interruption on the WinXP pc.
> 
> In tracking it down, it seems that what is being interrupted is either
> os.remove(), or os.rename().  Has anyone seen this behaviour, or have
> any clue what is going on?
> 
> On first pass I would think that both of those calls are single step
> operations (removing/changing an entry in the FAT, or FAT-like thing,
> on the HDD) and wouldn't result in an intermediate, null-populated,
> step, but the evidence seems to indicate I'm wrong...
> 
> Any insight from someone with knowledge of the internal operations of
> os.remove and/or os.rename would be greatly appreciated, although I
> expect the crux may be at the os level and not in python.
> 
> Russ
> 
Taking a quick look at the code, it looks like MoveFileW (Windows API)
is eventually being called by posixmodule.c.

My gut feeling is that you are correct and not facing a Python but
Windows issue (sigh) ... you might want to test your problem on an NTFS
file system and see if the problems are similar.

Regards,

hg



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


nntplib tutorial

2006-10-11 Thread hg
Hi,

Is there such a thing ?

Trying to understand the various strings I get hereunder

Thanks,

hg



from nntplib import *


s = NNTP('news.central.cox.net')
resp, count, first, last, name = s.group('comp.lang.python')
print 'Group', name, 'has', count, 'articles, range', first, 'to', last
resp, subs = s.xhdr('subject', first + '-' + last)
for id, sub in subs[-10:]:
print id
for article in  s.article(id):
print dir(article)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: nntplib tutorial

2006-10-11 Thread hg
Gabriel Genellina wrote:
> At Wednesday 11/10/2006 14:46, hg wrote:
> 
>> Is there such a thing ?
>>
>> Trying to understand the various strings I get hereunder
> 
> A basic understanding of the protocol would help a lot. The RFC 977
> itself is not so hard to read, but you could find some tutorials using
> google.
> 
> 
will give it a shot, thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE won't run

2006-10-12 Thread hg
Rob wrote:
> I have Python 2.4.3 installed on Windows XP on both a real computer and a 
> virtual machine under VMware. Just recently, IDLE stopped working. I would 
> select IDLE from the start menu or right click on a .PY file and open it in 
> IDLE, but nothing happens. I just uninstalled Python on the virtual machine 
> and installed 2.5 in the hope that that would fix the problem, but it 
> didn't. It, too, would do nothing when I tried to run IDLE. In both cases, 
> the Python command line window will come up, but that's not what I want to 
> use.
> 
> Does anyone know of a way to fix this problem? Is there a new Windows 
> update that is now interfering with IDLE? Would Norton Antivirus be 
> interfering with it somehow? (It's running in both environments.)



What kind of error do you see by calling idle from the command line (ex:
 "c:\\python.exe c:\\idle.py"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Starting out.

2006-10-12 Thread hg
Ahmer wrote:
> Hi all!
> 
> I am a 15 year old High School Sophomore. I would like to start
> programming in Python. In school, we are learning Java (5) and I like
> to use the Eclipse IDE, I also am learning PHP as well.
> 
> What are some ways to get started (books, sites, etc.)? I am usually on
> linux, but I have a windows box and am planning on getting a mac.
> 
Eclipse does take time to get used to ... not sure you want to put this
between you and your learning Python ... you might want to assess a two
step process.

This is a very good introduction to python
(http://www.diveintopython.org/) ... and then there are a billion of
good books.

hg


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


Re: COM and Threads

2006-10-12 Thread hg
Teja wrote:
> I have an application which uses COM 's Dispatch to create a COM based
> object. Now I need to upgrade the application to a threaded one. But
> its giving an error that COM and threads wont go together. Specifically
> its an attribute error at the point where COM object is invoked. Any
> pointers please??
> 

If COM is not thread safe, then use processes

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


Re: COM and Threads

2006-10-12 Thread hg
Teja wrote:
> hg wrote:
> 
>> Teja wrote:
>>> I have an application which uses COM 's Dispatch to create a COM based
>>> object. Now I need to upgrade the application to a threaded one. But
>>> its giving an error that COM and threads wont go together. Specifically
>>> its an attribute error at the point where COM object is invoked. Any
>>> pointers please??
>>>
>> If COM is not thread safe, then use processes
> 
> Thanks a LOT for your reply.. Can u please tell me how to
> processes..
> 

I gather pywin32 gives you the trick to do it (CreateProcess ?) as I
gather "fork"ing is not available under Windows.

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


Re: Where can I find good python code?

2006-10-13 Thread hg
js wrote:
> Hi,
> 
> I've learned basics of Python and want to go to the next step.
> So I'm looking for good python examples
> I steal good techniques from.
> 
> I found Python distribution itself contains some examples in Demo
> directory.
> I spent some time to read them and
> I think they're good but seemed not so practical to me.
> 
> Any recommendations?

Sure, there are tons of pure-Python modules out there.

hg

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


Re: Loops Control with Python

2006-10-13 Thread hg
Paddy wrote:
> Wijaya Edward wrote:
>> Can we make loops control in Python?
>> What I mean is that whether we can control
>> which loops to exit/skip at the given scope.
>>
>> For example in Perl we can do something like:
>>
>> OUT:
>> foreach my $s1 ( 0 ...100) {
>>
>> IN:
>> foreach my $s2 (@array) {
>>
>>   if ($s1 == $s2) {
>>  next OUT;
>>   }
>>   else {
>>   last IN;
>>   }
>>
>>  }
>> }
>>
>> How can we implement that construct with Python?
>>
> 
> Python does not use Labels. If you want to quit a single loop then look
> up the Python break statement. If you want to exit deeply nested
> execution then Python has exceptions. this maybe new to a Perl
> programmer so please take time to understand Python exceptions.
> 
> There follows a function that you can call from an interactive session
> to explore one type of use for exceptions  that is rather like your use
> of Perl labels shown.
> 
> ==
> class Outer(Exception):
>   pass
> class Inner(Exception):
>   pass
> 
> def skip_loops(y1 = -1, y2 = -1, y3 = -1):
>   ''' Shows how to skip parts of nested loops in Python'''
>   try:
> for x0 in range(3):
>   try:
> for x1 in range(3):
>   for x2 in range(3):
> if x2 == y2:
>   raise Inner
> if x2 == y3:
>   break
> print (x0,x1,x2)
>   if x1 == y1:
> raise Outer
>   print (x0,x1)
>   except Inner:
> print "Raised exception Inner"
>   print (x0,)
>   except Outer:
> print "Raised exception Outer"
> 
> ==
> 
 skip_loops(y1=2)
> (0, 0, 0)
> (0, 0, 1)
> (0, 0, 2)
> (0, 0)
> (0, 1, 0)
> (0, 1, 1)
> (0, 1, 2)
> (0, 1)
> (0, 2, 0)
> (0, 2, 1)
> (0, 2, 2)
> Raised exception Outer
 skip_loops(y2=2)
> (0, 0, 0)
> (0, 0, 1)
> Raised exception Inner
> (0,)
> (1, 0, 0)
> (1, 0, 1)
> Raised exception Inner
> (1,)
> (2, 0, 0)
> (2, 0, 1)
> Raised exception Inner
> (2,)
> 
> 
> - Paddy.
> P.S. Welcome to Python!
> 
How about a thread on GOTOs ? ;-)

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


Re: wing ide vs. komodo?

2006-10-13 Thread hg
John Salerno wrote:
> Just curious what users of the two big commercial IDEs think of them
> compared to one another (if you've used both).
> 
> Wing IDE looks a lot nicer and fuller featured in the screenshots, but a
> glance at the feature list shows that the "personal" version doesn't
> even support code folding! That's a little ridiculous and makes me have
> doubts about it.
> 
> Komodo, on the other hand, seems to have more of the features that the
> personal version of Wing IDE lacks (call tips, class browser, etc.) but
> the look of it seems very sparse for some reason.

I'm testing them both now ... Wing IDE is in front (but I'm testing the
pro version).


hg

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


Re: wing ide vs. komodo?

2006-10-13 Thread hg
Theerasak Photha wrote:
> On 10/13/06, John Salerno <[EMAIL PROTECTED]> wrote:
> 
>> Komodo, on the other hand, seems to have more of the features that the
>> personal version of Wing IDE lacks (call tips, class browser, etc.) but
>> the look of it seems very sparse for some reason.
> 
> But that's really a good thing.
> 
> -- Theerasak


I'm really interested: my *small* company is ready to spend the ~300$ in
the process, but Komodo looks _very_ sparse.

How do you go about it? ... I have resources to look at it for one or
two days.

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


Re: wing ide vs. komodo?

2006-10-13 Thread hg
Theerasak Photha wrote:
> On 10/13/06, hg <[EMAIL PROTECTED]> wrote:
> 
>> I'm really interested: my *small* company is ready to spend the ~300$ in
>> the process, but Komodo looks _very_ sparse.
>>
>> How do you go about it? ... I have resources to look at it for one or
>> two days.
> 
> It's entirely possible you could use a free IDE as well. (Just
> throwing it out there.)
> 
> -- Theerasak

I have spend the past two years with eclipse/pydev ... a few issue are
still troublesome to me (speed, search for definitions ... being a few
of them) ... and until two days ago I had not even looked at Wing as I
wrongly thought it was on Windoze-based. But I must must admit I am
impressed - yet I feel it would be stupid to not look carefully at
Komodo ... hence my questions.

hg

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


Re: wing ide vs. komodo?

2006-10-13 Thread hg
Theerasak Photha wrote:
> On 10/13/06, hg <[EMAIL PROTECTED]> wrote:
> 
>> I have spend the past two years with eclipse/pydev ... a few issue are
>> still troublesome to me (speed, search for definitions ... being a few
>> of them) ... and until two days ago I had not even looked at Wing as I
>> wrongly thought it was on Windoze-based. But I must must admit I am
>> impressed - yet I feel it would be stupid to not look carefully at
>> Komodo ... hence my questions.
> 
> I haven't used Komodo personally. I like Emacs. However:
> 
> 1) *Appearing* sparse doesn't mean much---Emacs 22's GTK interface
> 'looks' sparse as well, and sparse is the last word that comes to mind
> when I think of Emacs
> 2) I've *heard* good things about Komodo before from others---it might
> just be awesome
> 
> Perhaps you could try the Eric IDE? I hear SPE is not in active
> dev.--- a pity to be sure, but I have used Eric before and found it
> pretty easy to use and featureful.
> 
> -- Theerasak

Eric3 is very nice and moving forward ... I believe it is based on the
QT library which free ... yet not so free under windows (i have yet to
understand the business model).


Emacs I use for very small project (my finger talk emacs ;-) ) ... but
CTAGS is a bit cumbersome for large projects and as my architectures
have much need for improvements, I need powerful tools to find my way
around.

PS: I also was taken aback by the fact that the PyDev license was
"per-year" ... it's like buying Word for a year only ... isn't it ?


hg



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


Re: Can I set up a timed callback without Tkinter or twisted or something?

2006-10-14 Thread hg
Hendrik van Rooyen wrote:
> Hi,
> 
> I want to do the equivalent of the after thingy in tkinter - setting up in
> effect a timed call back.
> 
> My use case is as a "supervisory" timer - I want to set up an alarm, which I
> want to cancel if the expected occurrence occurs - but its not a GUI app.
> 
> My googling gets a lot of stuff pointing to optparse...
> 
> Does the standard lib have anything like this?
> 
> - Hendrik
> 

http://python.active-venture.com/lib/timer-objects.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ADO with Python

2006-10-16 Thread hg
Ralf wrote:
> Is their anybody with xperience in using the both and can provide me with 
> some xamples.
> 
> Thx a lot
> Ralf 
> 
> 

I suggest you buy the book from Mark Hammond

hg


ex (major cut and paste):

   #
def Get_User_Info_From_DB(self, p_user_id):
try:
#l_query = 'Select Groups.GR_AccessDate from Groups,Members
where Members.GroupId = Groups.GR_GroupId and Members.MemberId = %s;' %
p_user_id
l_query = 'SELECT
Firstname,Lastname,GR_ExpirationDate,GR_AccessDate,GR_CurrentBal,MemberType,MemberDues
FROM MemberTypes,Members,Groups Where (Groups.GR_GroupId =
Members.GroupId) and (MemberTypes.MemberTypeID =
Groups.GR_MembershipType) and (MemberId = %s);' % p_user_id
l_conn = win32com.client.Dispatch(r'ADODB.Connection')
l_DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE='+self.__m_database + ';'
l_conn.Open(l_DSN)
l_recordset = win32com.client.Dispatch(r'ADODB.Recordset')
l_recordset.Open(l_query, l_conn, 1, 3)
l_found_date = False
try:
l_recordset.MoveFirst()
l_exp_date =
l_recordset.Fields.Item('GR_ExpirationDate').Value
l_access_date =
l_recordset.Fields.Item('GR_AccessDate').Value

l_last_name = l_recordset.Fields.Item('Lastname').Value
l_first_name = l_recordset.Fields.Item('Firstname').Value
l_membership_type =
l_recordset.Fields.Item('MemberType').Value
#print 'HERE ', l_recordset.Fields.Item('MemberType').Value
l_val = l_recordset.Fields.Item('MemberDues').Value

l_dues_amount =  '%.02f' % (float(l_val[1])/1.0)


if None == l_access_date:
self.__m_log.Log(  ('DATE IS NOT AVAILABLE FOR USER
ID %s' % p_user_id) )
else:
l_found_date = True
self.__m_log.Log(  ('FOUND NEW DATE IN DATABASE FOR
USER ID %s: %s' % (p_user_id, l_access_date)) )
except:
self.__m_log.Log(  ( 'GET DATE QUERY FAILED ON USER ID
%s' % p_user_id)  )
self.__m_log.Log(traceback.format_exc())
l_conn.Close()

if False == l_found_date:
return None

#print 'IN GET: ACCESS ', l_access_date.Format()
#print 'IN GET: EXP', l_exp_date.Format()
return ( l_exp_date.Format(),l_access_date.Format(),
l_last_name, l_first_name, l_membership_type, l_dues_amount)
except:
self.__m_log.Log(traceback.format_exc())
try:
l_conn.Close()
except:
self.__m_log.Log('Could not close database connection on
retrieval')
self.__m_log.Log(traceback.format_exc())
pass
self.__m_log.Log( ('Fatal error retrieving date from
database for user id %s ' % p_user_id))
return None
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: datetime conversion question

2006-10-17 Thread hg
kevin evans wrote:
> Hi,
> I'm trying to convert some code from Ruby to Python, specifically..
> 
> timestamp = "%08x" % Time.now.to_i
> 
> Make a hex version of the current timestamp. Any ideas how best to do
> this in python gratefully received..
> 


how about

import time
"%08X"% (int)(time.mktime(time.localtime()))

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


Re: Newbie: datetime conversion question

2006-10-17 Thread hg
Carsten Haese wrote:
> On Tue, 2006-10-17 at 08:49, hg wrote:
>> import time
>> "%08X"% (int)(time.mktime(time.localtime()))
> 
> Have you not had your coffee yet or are you trying to win an obfuscated
> python programming competition? ;)
> 
> -Carsten
> 
> 
Just one cup

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


Re: Python Web Site?

2006-10-17 Thread hg
Tim Chase wrote:
>> Is there a problem with the Python and wxPython web sites?
>> I cannot seem to get them up
> 
> Sounds like someone needs some pyagra...
> 
> (grins, ducks, and runs)
> 
> the-red-or-blue-pill'ly yers,
> 
> -tkc
> 
> 
> 
> 
> 

lol ... got to rememner that one !

hg

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


Re: Python Web Site?

2006-10-17 Thread hg
[EMAIL PROTECTED] wrote:
> wxpython is down for me also it did work befour my job interview at
> around noon central.  It may have been my wx.grid question for my
> project finaly did the system in.  I followed all the directions but
> can only post and get one responce and I can't respond to the questions
> (I get no email so I can post replies) seems odd. (last couple of days
> anyway)
> 
> http://www.dexrow.com
> 
> *% wrote:
>> Is there a problem with the Python and wxPython web sites?  I cannot
>> seem to get them up, and I am trying to find some documentation...
>>
>>  Thanks,
>>  Mike
> 
I still do get mails from the list

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


Re: tkinter won't play

2006-10-18 Thread hg
Carl Wenrich wrote:
> I installed python 2.4.4 from source. When I try to
> run the demo tkinter (hello.py) script, I get a
> message saying my python may not be configured for Tk.

Under *nix ?

Make sure you have the tcl/tk source installed also.

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


Re: Komodo

2006-10-19 Thread hg
Mark Elston wrote:
> * SpreadTooThin wrote (on 10/19/2006 8:47 AM):
>> Why is it that (On MAC OS X) in Komodo 3.5 Professional, if I try to
>> find something in my script,
>> I am unable to change the text it is searching for?
>>
> 
> Perhaps Emacs might work better ... :)
> 
> Mark

Can you suggest tools (.el) to add to emacs for large projects
management / browsing ?

Thanks,

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


Re: TNEF decoder

2006-08-29 Thread hg
Simon Forman wrote:
> David Isaac wrote:
>> I'm aware of
>> http://cheeseshop.python.org/pypi/pytnef/
>> but it uses the tnef utility, and I'd like a pure Python solution
>> (along the lines of  http://www.freeutils.net/source/jtnef/ ).
>>
>> Is there one?
>>
>> Thanks,
>> Alan Isaac
> 
> A place I once worked at had a project that included some TNEF
> handling.  There was one developer assigned fulltime to it.  He was the
> one who sat at his desk hurling curses at his workstation at the top of
> his lungs,  later he developed a pretty severe drinking problem.
> 
> Good luck.
> 
> HTH,
> ~Simon
> 
You mean he stopped ?

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


Re: Python for Windows

2006-08-30 Thread hg
Grant Edwards wrote:

> 
>> Will the msi installer modify registry or other system files?
>> Does it possible install Python not touching registry and
>> system files?
> 
You can make your own installer to install Python, and make sure the
registry is not touched - I think the current installer modifies at
least the .py .pyw file association.

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


Re: active python windows

2006-08-30 Thread hg
[EMAIL PROTECTED] wrote:
> When I test my program the graphics window opens over the top of the
> command line, but for some odd reason the command line remains the
> active window, so I have to click on the grphics window to make it the
> active window. I was just curious as to why this might be happening and
> if it was possible to change it.
> 
> 
> _
> PrivatePhone - FREE telephone number & voicemail.
> A number so private, you can make it public.
> http://www.privatephone.com
> 
> 
What GUI Lib ? What O/S

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


mysqldb + multi-threading

2006-09-08 Thread hg
Hi,

I am writing a transaction server (socket-based) under windows.

I use mysqldb to log info into MySQL.

It is all working and I need now to decide whether to use forks
(CreateProcess I guess) or threads.

I saw in another thread that some db engines did have issues with being
called from threads.

My gut feeling is to use threads (note: each transaction is finite, so
the process/thread die fairly quickly).

Any insight ?


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


Re: mysqldb + multi-threading

2006-09-09 Thread hg
hg wrote:
> Hi,
> 
> I am writing a transaction server (socket-based) under windows.
> 
> I use mysqldb to log info into MySQL.
> 
> It is all working and I need now to decide whether to use forks
> (CreateProcess I guess) or threads.
> 
> I saw in another thread that some db engines did have issues with being
> called from threads.
> 
> My gut feeling is to use threads (note: each transaction is finite, so
> the process/thread die fairly quickly).
> 
> Any insight ?
> 
> 
> hg

A thread on the mysqldb forum:

 By: Rob Steele - robsteele
  RE: Do I need to enable thread safe mysql lib
2002-10-18 11:35
Yup. You also need to either synchronize the reading and writing threads
so that only one can get at the database at a time or else open a second
connection. You should probably use sepearate connections, one for each
thread.

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


socket question

2006-09-13 Thread hg
Hi,

I am not sure whether this is a python-related question.

If I have device A than sends XX bytes to device B, and device B does a
recv(XX) using the default timeout, what could make device B wake-up
with less than XX bytes received ?

Regards,

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


Re: socket question

2006-09-13 Thread hg
Jean-Paul Calderone wrote:
> On Wed, 13 Sep 2006 08:13:43 -0500, hg <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I am not sure whether this is a python-related question.
>>
>> If I have device A than sends XX bytes to device B, and device B does a
>> recv(XX) using the default timeout, what could make device B wake-up
>> with less than XX bytes received ?
> 
> Assuming the sends take place over a TCP connection, any number of things.
> In generally, you cannot rely on anything about the length of the string
> returned from recv(N) except that:
> 
>  it will not be greater than N
>  it will not be less than 1 unless the connection has been lost
> 
> If you expect a particular number of bytes, you need to call recv()
> multiple times and collect the returned strings until you have as many
> bytes as you wanted.
> 
> Jean-Paul
Many thanks,

hg


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


Re: socket question

2006-09-13 Thread hg
Diez B. Roggisch wrote:
> hg wrote:
> 
>> Hi,
>>
>> I am not sure whether this is a python-related question.
>>
>> If I have device A than sends XX bytes to device B, and device B does a
>> recv(XX) using the default timeout, what could make device B wake-up
>> with less than XX bytes received ?
> 
> There exist higher abstractions for sockets in python for IPC - are you sure
> you want to reinvent the wheel?
> 
> If you absolutely must: the select-call allows for specification of a
> timeout. Use it with the socket file-descriptor.
> 
> Diez
Thanks I'll look, with the retry-wrapper around recv, it seem to work now.

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


Idle 1.1.3 class browser + a few questions

2006-09-13 Thread hg
Hi,

Is there a way to:

1) open the class browser automatically on the file opening
2) have the class browser updated when functions/classes ... are added
to the file
3) have a vertical scroll bar
4) have line numbers

Thanks,

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


socket and threading ... bad file descriptor

2006-09-14 Thread hg
Hi,

I have two classes, one listens and accepts connections, gets the
socket, reads the first byte from the opened socket then launches a
thread (threading) and gives it the socket identifier.

The first time the thread attempts to read from the given socket,
socket.py raises a bad file descriptor in _dummy.

I tried using plain threads with the same problem.

Any clue ?

Thanks,

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


Re: socket and threading ... bad file descriptor

2006-09-14 Thread hg
hg wrote:
> Hi,
> 
> I have two classes, one listens and accepts connections, gets the
> socket, reads the first byte from the opened socket then launches a
> thread (threading) and gives it the socket identifier.
> 
> The first time the thread attempts to read from the given socket,
> socket.py raises a bad file descriptor in _dummy.
> 
> I tried using plain threads with the same problem.
> 
> Any clue ?
> 
> Thanks,
> 
> hg

Bug discovered, sorry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a reports module/project

2006-09-20 Thread hg
John Purser wrote:
> Hello,
> 
> I'm working on a script to gather data from our servers and then present
> the data as part of daily maintenance.  Pretty straight forward stuff.
> However one of the limitations of an earlier design was presentation of
> the data so I'm working to make this version's report much clearer.  I
> hate to cut a bunch of single purpose code.  Before I wander down this
> road too far I thought I'd ask if anyone else has found a good module or
> project for writing simple text reports with python.
> 
> Thanks for the recommendations.
> 
> John Purser
> 


wxPython and htmlgen

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


Re: ruby %w equivalent

2006-09-25 Thread hg
Antoine De Groote wrote:
> Hi everybody,
> 
> is there a python equivalent for the ruby %w operator?
> %w{a b c} creates an array with strings "a", "b", and "c" in ruby...
> 
> Thanks a lot
> Regards,
> antoine

Why would they want to make such an obscure API ? ... didn't they have
Python to learn from (I am truly amazed - nothing cynical ...just ...
why ?)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ruby %w equivalent

2006-09-25 Thread hg
MonkeeSage wrote:
> hg wrote:
>> Why would they want to make such an obscure API ? ... didn't they have
>> Python to learn from (I am truly amazed - nothing cynical ...just ...
>> why ?)
> 
> In ruby there are several special literal notations, just like python.
> In ruby it goes like this:
> 
> %{blah} / %Q{blah} # same as "blah" but igornes " and '
> %q{blah} # same as 'blah' but no interpolation
> %w{blah blah} # same as "blah blah".split
> %r{blah} # same as /blah/
> %x{ls} # same as `ls`
> 
> Sometimes they are very useful, and sometimes they are cumbersome. It's
> up to the programmer to implement them effectively.
> 
> Regards,
> Jordan
> 
I am certain Ruby is a very effective language (I read much good stuff
about it) ... it's just that I cannot comprehend why a "new" language
would attempt so hard to look like assembly.


Regards,

hg

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


Re: ruby %w equivalent

2006-09-25 Thread hg
hg wrote:
> MonkeeSage wrote:
>> hg wrote:
>>> Why would they want to make such an obscure API ? ... didn't they have
>>> Python to learn from (I am truly amazed - nothing cynical ...just ...
>>> why ?)
>> In ruby there are several special literal notations, just like python.
>> In ruby it goes like this:
>>
>> %{blah} / %Q{blah} # same as "blah" but igornes " and '
>> %q{blah} # same as 'blah' but no interpolation
>> %w{blah blah} # same as "blah blah".split
>> %r{blah} # same as /blah/
>> %x{ls} # same as `ls`
>>
>> Sometimes they are very useful, and sometimes they are cumbersome. It's
>> up to the programmer to implement them effectively.
>>
>> Regards,
>> Jordan
>>
> I am certain Ruby is a very effective language (I read much good stuff
> about it) ... it's just that I cannot comprehend why a "new" language
> would attempt so hard to look like assembly.
> 
> 
> Regards,
> 
> hg
> 
To further comment: back to the PDP11 and such guys, there was a true
need to "terse" the language and give the computer a break ... "what
I've already calculated, the computer needs not to calculate ... plus
I'm avoiding potential software(assembler/compiler) bugs"

But today ? what is the cost of replacing %w("blah blah") by
Hi_I_Want_To_Split_The_String_That_Follows( "blah blah")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ruby %w equivalent

2006-09-25 Thread hg
MonkeeSage wrote:
> hg wrote:
>> But today ? what is the cost of replacing %w("blah blah") by
>> Hi_I_Want_To_Split_The_String_That_Follows( "blah blah")
> 
> How about r'blah', u'blah', """blah""", and '''blah'''. :)
> 
> Regards,
> Jordan
> 


Some truth to that !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I need Cryptogrphy in Python please .

2006-10-03 Thread hg
NicolasG wrote:
> Looking around for a Cryptography tool kit, the best recommendations I
> found about was for pyCrypto. I try to install it unsuccessfully in my
> windowsXP SP2 with python 2.4.3 and I get the following message :
> C:\Python24\pycrypto-2.0.1>python setup.py build
> running build
> running build_py
> running build_ext
> error: The .NET Framework SDK needs to be installed before building
> extensions f
> or Python.
> 
> I have installed .NET framework latest release.
> Unfortunately the pyCrypto project looks abandoned , I couldn't find an
> active mailing list and the last release are a couple of year old.
> 
> Can some one guide me how to fix the problem above or point me to
> another Cyrptography library that I can use easily ?
> 
> Thanks.
> 


I use pycrypto under *nix and Windows. Under windows, I compile it with
VC++ 2003 without any problem.

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


Re: Free Decompiler

2006-11-18 Thread hg
jim wrote:
> where can I find a free decompile that I can run in windows xp
> 

Hey Jim, where can you find a free "decompile" that you can run in
windows xp ?

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


Re: Python visual IDE

2006-11-22 Thread hg
king kikapu wrote:
> I have already downloaded and seen the trial of Komodo Professional.
> Indeed it has a simple Gui Builder but one can only use TKinter on it.
> No wxWidgets support and far from truly RAD, but it is the only
> "integrated"
> GUI builder in these IDEs...
> 
> 
> On Nov 22, 4:31 pm, "Steve" <[EMAIL PROTECTED]> wrote:
>> I haven't used it but Komodo (Professional version) says it has:
>>
>> ActiveState GUI Builder (Komodo Professional only)
>>
>> Enhance your applications with GUI dialogs: Simple, Tk-based dialog
>> builder with seamless round-trip integration, for Perl, Python, Ruby,
>> and Tcl.
> 

I do a lot of GUI programming with wxPython.

I find that switching from desktop 1 (Eclipse/PyDev) to desktop 2
(wxDesigner) becomes a reflex quite quickly ... even under Windows
thanks to virtuawin (http://virtuawin.sourceforge.net) - both packages
also are smart enough to notice when an open file has been modified
elsewhere.

I also program in Visual-Studio and overall do not find the RAD/IDE
integration that much more convenient.


Also, I generally get the job done in wxDesigner at the beginning of the
project, and seldom have to get back into it to twick the interface.

hg


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


Re: Python visual IDE

2006-11-22 Thread hg
Yes,

Actually when you create the project from wxDesigner, the "main" will
also be generated for you ... then you include the correct files in
eclipse (note that one file never needs to be edited ... like glade).

I went for wxDesigner years ago when wxglade was fairly unstable ...
have not tested it lately.

wxDesigner has its own editor (so you can say it is a complete
environment) ... but I only use it to automatically generate classes,
events ... as eclipse+pydev bring much more to the picture.


I really do not regret the expense.

PS: wxDesigner will also generate code for other languages (never tried)
 : c++, c#, perl
PPS: I'm not getting any money from them  ;-)

hg




king kikapu wrote:
> I didn't know about this product you mention (wxDesigner).
> I download the trial and it seems pretty good, reminds me the wxGlade.
> 
> So you make the GUI in this, generate Python code and import the module
> 
> on your main project and reference it respectively ??
> 
> On Nov 22, 4:58 pm, hg <[EMAIL PROTECTED]> wrote:
>> king kikapu wrote:
>>> I have already downloaded and seen the trial of Komodo Professional.
>>> Indeed it has a simple Gui Builder but one can only use TKinter on it.
>>> No wxWidgets support and far from truly RAD, but it is the only
>>> "integrated"
>>> GUI builder in these IDEs...
>>> On Nov 22, 4:31 pm, "Steve" <[EMAIL PROTECTED]> wrote:
>>>> I haven't used it but Komodo (Professional version) says it has:
>>>> ActiveState GUI Builder (Komodo Professional only)
>>>> Enhance your applications with GUI dialogs: Simple, Tk-based dialog
>>>> builder with seamless round-trip integration, for Perl, Python, Ruby,
>>>> and Tcl.I do a lot of GUI programming with wxPython.
>> I find that switching from desktop 1 (Eclipse/PyDev) to desktop 2
>> (wxDesigner) becomes a reflex quite quickly ... even under Windows
>> thanks to virtuawin (http://virtuawin.sourceforge.net) - both packages
>> also are smart enough to notice when an open file has been modified
>> elsewhere.
>>
>> I also program in Visual-Studio and overall do not find the RAD/IDE
>> integration that much more convenient.
>>
>> Also, I generally get the job done in wxDesigner at the beginning of the
>> project, and seldom have to get back into it to twick the interface.
>>
>> hg- Hide quoted text -- Show quoted text -
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


utf - string translation

2006-11-22 Thread hg
Hi,

I'm bringing over a thread that's going on on f.c.l.python.

The point was to get rid of french accents from words.

We noticed that len('à') != len('a') and I found the hack below to fix
the "problem" ... yet I do not understand - especially since 'à' is
included in the extended ASCII table, and thus can be stored in one byte.

Any clue ?

hg





# -*- coding: utf-8 -*-
import string

def convert(mot):
print len(mot)
print mot[0]
print '%x' % ord(mot[1])
table =
string.maketrans('àâäéèêëîïôöùüû','\x00a\x00a\x00a\x00e\x00e\x00e\x00e\x00i\x00i\x00o\x00o\x00u\x00u\x00u')

return mot.translate(table).replace('\x00','')


c = 'àbôö a '
print convert(c)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: utf - string translation

2006-11-22 Thread hg
Fredrik Lundh wrote:
> hg wrote:
> 
>> We noticed that len('à') != len('a')
> 
> sounds odd.
> 
>>>> len('à') == len('a')
> True
> 
> are you perhaps using an UTF-8 editor?
> 
> to keep your sanity, no matter what editor you're using, I recommend
> adding a coding directive to the source file, and using *only* Unicode
> string literals for non-ASCII text.
> 
> or in other words, put this at the top of your file (where "utf-8" is
> whatever your editor/system is using):
> 
># -*- coding: utf-8 -*-
> 
> and use
> 
>u''
> 
> for all non-ASCII literals.
> 
> 
> 

Hi,

The problem is that:

# -*- coding: utf-8 -*-
import string
print len('a')
print len('à')

returns 1 then 2

and string.maketrans(str1, str2) requires that len(str1) == len(str2)

hg





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


Re: utf - string translation

2006-11-22 Thread hg
hg wrote:
> Fredrik Lundh wrote:
>> hg wrote:
>>
>>> We noticed that len('à') != len('a')
>> sounds odd.
>>
>>>>> len('à') == len('a')
>> True
>>
>> are you perhaps using an UTF-8 editor?
>>
>> to keep your sanity, no matter what editor you're using, I recommend
>> adding a coding directive to the source file, and using *only* Unicode
>> string literals for non-ASCII text.
>>
>> or in other words, put this at the top of your file (where "utf-8" is
>> whatever your editor/system is using):
>>
>># -*- coding: utf-8 -*-
>>
>> and use
>>
>>u''
>>
>> for all non-ASCII literals.
>>
>> 
>>
> 
> Hi,
> 
> The problem is that:
> 
> # -*- coding: utf-8 -*-
> import string
> print len('a')
> print len('à')
> 
> returns 1 then 2
> 
> and string.maketrans(str1, str2) requires that len(str1) == len(str2)
> 
> hg
> 
> 
> 
> 
> 
PS: I'm running this under Idle
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: utf - string translation

2006-11-22 Thread hg
Duncan Booth wrote:
> hg <[EMAIL PROTECTED]> wrote:
> 
>>> or in other words, put this at the top of your file (where "utf-8" is
>>> whatever your editor/system is using):
>>>
>>># -*- coding: utf-8 -*-
>>>
>>> and use
>>>
>>>u''
>>>
>>> for all non-ASCII literals.
>>>
>>> 
>>>
>> Hi,
>>
>> The problem is that:
>>
>> # -*- coding: utf-8 -*-
>> import string
>> print len('a')
>> print len('à')
>>
>> returns 1 then 2
> 
> And if you do what was suggested and write:
> 
> # -*- coding: utf-8 -*-
> import string
> print len(u'a')
> print len(u'à')
> 
> then you get:
> 
> 1
> 1
OK,

How would you handle the string.maketrans then ?

hg



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


Re: utf - string translation

2006-11-22 Thread hg
Fredrik Lundh wrote:
> hg wrote:
> 
>> How would you handle the string.maketrans then ?
> 
> maketrans works on bytes, not characters.  what makes you think that you
> can use maketrans if you haven't gotten the slightest idea what's in the
> string?
> 
> if you want to get rid of accents in a Unicode string, you can do the
> approaches described here
> 
> http://www.peterbe.com/plog/unicode-to-ascii
> 
> or here
> 
> http://effbot.org/zone/unicode-convert.htm
> 
> which both works on any Unicode string.
> 
> 
> 
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple threading

2006-11-23 Thread hg
jrpfinch wrote:
> I'm just getting started on threading and was wondering why the
> following code does not work (i know globals is bad style - I'll
> eliminate them eventually).  All I get is a blank cursor flashing.
> 
> Many thanks
> 
> Jon
> 
> import threading
> import sys
> import time
> global g_datum
> global g_rawfile
> global g_rawtext
> global g_overs
> global g_currentover
> global g_secondspertick
> 
> 
> g_secondspertick=5
> g_datum=time.time()
> g_currenttick=1
> g_rawfile=open('inputashes.txt','r')
> g_rawtext=g_rawfile.read()
> g_overs=g_rawtext.split('')
> g_currentover=0
> 
> 
> class ImapThread(threading.Thread):
> def run(self):
> global g_currenttick
> if time.time() > (g_datum + (g_secondspertick *
> g_currenttick)):
> print "Ticked %s" % g_currenttick
> g_currenttick=g_currenttick+1
> print g_currenttick
> sys.stdout.flush()
> time.sleep(0.01)
> 
> def main():
> ImapThread().start()
> while 1:
> pass
> 
> if __name__ == "__main__":
>     main()
> 
Run gets called only once: you need to put your logic in a "while True"
or something equivalent/define some escape clause.

Right now you just get into the implicit "else" and get out.

hg

import time
global g_datum
global g_rawfile
global g_rawtext
global g_overs
global g_currentover
global g_secondspertick


g_secondspertick=5
g_datum=time.time()
g_currenttick=1
#g_rawfile=open('inputashes.txt','r')
#g_rawtext=g_rawfile.read()
#g_overs=g_rawtext.split('')
g_currentover=0


class ImapThread(threading.Thread):
def run(self):
while True:
global g_currenttick
if time.time() > (g_datum + (g_secondspertick *
g_currenttick)):
print "Ticked %s" % g_currenttick
g_currenttick=g_currenttick+1
print g_currenttick
sys.stdout.flush()
else:
print 'HERE'
time.sleep(0.01)

def main():
ImapThread().start()
while 1:
pass

if __name__ == "__main__":
main()

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


Re: Active State and Komodo...

2006-11-24 Thread hg
Steve Thompson wrote:
> On Fri, 24 Nov 2006 07:09:36 -0800, BartlebyScrivener wrote:
> 
>> Steve Thompson wrote:
>>> I was wondering the differnced there were betwee Active State's python and
>>> the open source version of python.
>> The biggest difference at the moment is that ActiveState is still using
>> Python 2.4.3 in their distribution. They should be coming out with 2.5
>> soon.
>>
>> Sounds like you are running Suse?  So you already have some version of
>> Python, right? You can search this group at comp.lang.python on Google
>> Groups--try "python versions linux"--or something like that--but the
>> issue you need to watch out for is running two different versions on
>> Linux.
>>
>> Long and short, you don't want to uninstall the version of Python that
>> came with your Suse, because other programs on your machine probably
>> use that particular version. It's easy to install an ADDITIONAL
>> distribution of Python and run it separately, but again. Search the
>> list
>> for how to do that, and how to run them separately once you do.
>>
>> I'm just moving to Linux myself, so can't provide the expertise. Unless
>> there is some killer feature of 2.5 you need, I would just use the
>> Python that came with your Suse.
>>
>> rd
> 
> Thanks BartlebyScrivener, but are there any other IDE's that are better,
> in your opinion, than Eric version 3. I'm using gnome and eric is built
> for KDE. I don't care it there open source or Id I have tp puchase one.
> 
> Thanks again,
> 
> Steve
I like Eclipse/Pydev better

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


Re: Active State and Komodo...

2006-11-24 Thread hg
John Machin wrote:
> Steve Thompson wrote:
>> Hello all,
>>
>> I was wondering the differnced there were betwee Active State's python and
>> the open source version of python. Would I have to unistall my opend souce
>> python? Additonally, how does Active State's Komodo IDE vs. the eric3 IDE
>> unler SuSE Linux v. 10.i?
>>
>> Addionally, is the eric IDE (version 3) an acceptible IDE or are there
>> more easy and more productive IDE's for perl?
>>
>> I'm urining Gnome v. 12.2.2 and Eric v 3.8.1
> 
> I'm not sure which to recommend: a spelling checker or a catheter :-)
> 

You _are_ bad !

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


pyxpcom

2006-11-27 Thread hg
Hi,

Can one tell me what the status of this project is ?. I did google ...
but not much out there.

Regards,

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


Re: pyxpcom

2006-11-28 Thread hg
Trent Mick wrote:
> hg wrote:
>> Hi,
>>
>> Can one tell me what the status of this project is ?. I did google ...
>> but not much out there.
> 
> PyXPCOM source is in the main Mozilla CVS tree. It is being maintained
> by Mark Hammond (the original developer of the extension). There isn't a
> lot of activity on it, I think, because:
> 1. Mark did such a good job of implementing it the first time around
> that it needs very little work :)
> 2. It is very high learning curve to get into playing with PyXPCOM
> because there are no conveniently packaged builds of PyXPCOM for current
> (or any) versions of Firefox or Mozilla.
> 
> Interestingly, Mark is currently working *full* support for Python in
> the Mozilla code base, i.e. being able to use Python anywhere you can
> currently use JavaScript (in 

Re: pyxpcom

2006-11-29 Thread hg
Trent Mick wrote:
>> My need is as follows: I have developed an activex component to access a
>> smart card on the client side / do some web site logon.
>>
>> Are xpcom / pyxpcom advanced/stable enough for such an implementation
>> under Linux / Windows ?
> 
> You mean to provide the equivalent functionality for Firefox that your
> activex component does for IE? Yes, xpcom and pyxpcom are quite stable,
> however putting together a Firefox extension that gets PyXPCOM itself up
> and running in a client's Firefox install will be quite challenging.
> 
> Trent
> 
Exactly ... are you saying I need to distribute Firefox compiled
differently in order to achieve that ?

This is less a python issue clearly if that is the case: would I have
the same issues to resolve if I were to write the module in C++ ?

Thanks,

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


Re: Using Python

2006-11-29 Thread hg
beemer328i2004 wrote:
> Hi Guys,
> 
> I am new to this language and i need some help...
> 
> I am trying to create a script that will go into a log file and bring 
> me back the xml from an order...
> 
> For example:
> 
> go into Log1.xml and extract order number 2 from top to bottom and 
> extract it into a txt file...
> 
> Does anyone know how i can create this type of script or has like a 
> sample that i can use.. I am having a hard time starting the script..
> 
> hope someone can help
> 
> Thanks agian
> 

You might want to start here: http://diveintopython.org/

hg

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


Re: pyxpcom

2006-11-29 Thread hg
Trent Mick wrote:
> hg wrote:
>> Trent Mick wrote:
>>>> My need is as follows: I have developed an activex component to
>>>> access a
>>>> smart card on the client side / do some web site logon.
>>>>
>>>> Are xpcom / pyxpcom advanced/stable enough for such an implementation
>>>> under Linux / Windows ?
>>> You mean to provide the equivalent functionality for Firefox that your
>>> activex component does for IE? Yes, xpcom and pyxpcom are quite stable,
>>> however putting together a Firefox extension that gets PyXPCOM itself up
>>> and running in a client's Firefox install will be quite challenging.
>>>
>>> Trent
>>>
>> Exactly ... are you saying I need to distribute Firefox compiled
>> differently in order to achieve that ?
> 
> No. But you'll have to get comfortable building your own Firefox and
> then building the PyXPCOM extension and then packaging the built PyXPCOM
> bits that a normal Firefox install does not have already into a Firefox
> extension. This would also mean packaging up parts of a Python build and
> possible needing to have a custom Python build to (1) get shared library
> loading to work correct and (2) ensure there isn't crosstalk between the
> python that PyXPCOM uses and possibly other Python installations on the
> target machine.
> 
>> This is less a python issue clearly if that is the case: would I have
>> the same issues to resolve if I were to write the module in C++ ?
> 
> A little, yes: I believe you'd need a Firefox build in a development
> tree to build a vanilla C++ XPCOM component. However, I am not sure of
> that.
> 
> Mostly, no: You wouldn't need to worry about all the PyXPCOM/Python
> build/install issues.
> 
> 
> Trent
> 
Thanks Trent,

I'll do some testing and bug Mark in the process I'm sure  :-)

Regards,

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


Re: python vs java & eclipse

2006-12-01 Thread hg
krishnakant Mane wrote:
> just used the py dev plugin for eclipse.
> it is great.
> auto indentation and intellisence.
> and all other things.
> so now how does it look from this end?
> python + productivity and eclipse + productivity = double productivity!
> only problem with the plugin is that I find it difficult to manage the
> script running.
> I open a command prompt and run the scripts manually.
> any suggestion for this.
> for example I had name = raw_input("please enter your name") and the
> moment I type the first letter on the keyboard the code execution
> moves over to the next statement.  should it not wait for the return
> key as it always does?
> Krishnakant.
I don't know about raw_input ... my programs all go through some GUI ...
but I run / debug(although almost never) all of my applications from
pydev - no need to change project as with Visual Studio, I just
run/debug whatever I need with a few clicks ... have not touched Konsole
 in weeks.

I also, after weeks of testing, decided to invest in the pydev
extensions / the bugs it has found for me already justify the investment.

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


Re: python vs java & eclipse

2006-12-01 Thread hg
Thomas Ploch wrote:
> Thomas Ploch schrieb:
>> Amir Michail schrieb:
>>> Hi,
>>>
>>> It seems to me that measuring productivity in a programming language
>>> must take into account available tools and libraries.
>>>
>>> Eclipse for example provides such an amazing IDE for java that it is no
>>> longer obvious to me that one would be much more productive in python
>>> for medium sized projects.
>>>
>>> Sure, all that Java static typing can be painful, but Eclipse takes
>>> some of that pain away. Moreover, static typing can result in better
>>> on-the-fly error detection and refactoring support.
>>>
>>> Any thoughts on this?
>>>
>>> Amir
>>>
>> Yes, thats true, but since eclipse is resource monster (it is still
>> using java), and some people (like me) don't have a super fresh and new
>> computer, and have to run other services to test their work locally
>> (like mysql and apache servers), it gets pretty harsh with eclipse. I
>> personally tried eclipse on my laptop (which I work most with), and I
>> had quite a system resource problem. So I switched back to vim and
>> console and it hasn't been too bad, since if you know how to use a
>> powerful editor, it can be as productive.
>>
>> But in the end, it is up to anyone to find the best solutiion for
>> themselves.
>>
>> Thomas
>>
> 
> Yes, thats true, but since eclipse is resource monster (it is still
> using java), and some people (like me) don't have a super fresh and new
> computer, and have to run other services to test their work locally
> (like mysql and apache servers), it gets pretty harsh with eclipse. I
> personally tried eclipse on my laptop (which I work most with), and I
> had quite a system resource problem. So I switched back to vim and
> console and it hasn't been too bad, since if you know how to use a
> powerful editor, it can be as productive.
> 
> But in the end, it is up to anyone to find the best solutiion for
> themselves.
> 
> Thomas
> 

If you compare eclipse to VS, it is not that memory hungry - but i agree
with you that a min-config is needed. Yet (I believe that) a complete
IDE can bring functions that an editor, however powerful, cannot (I
still use emacs).

I have tried Komodo, Wing, Eric3, Idle, emacs, (not vi ;-) ), SPE,
boa-constructor,  and many more - I like most of them but am really
addicted to eclipse + pydev.

... but even without pydev, I would not use java just because of eclipse.

hg


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


Re: wxpython worked out but can't find api docs for download.

2006-12-02 Thread hg
krishnakant Mane wrote:

> hello all.
> finally I got the accessibility issue out from wxpython.  actually
> almost got it out, but that's another story.
> now my problem is that I can't gind a downloadable version of wxpython
> api reference for the latest version or the latest api reference at
> least.
> I found the on-line version so please don't provide the same link.
> when I opened it on line, it took about 8 minuts to get the wx package
> come up on screen with over 600 links.
> I need to have some off line reference for the wxpython api.
> I have enough documentation to get started but I don't have the
> extencive api references for events and other methods, properties and
> attributes.
> can some one point me to a .zip or .tar.gz version of the api docs for
> wxpython? thanking all.
> Krishnakant.

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


Re: evaluating gui modules, any experience on tkinter?

2006-12-02 Thread hg
krishnakant Mane wrote:

> hello all,
> I seam to have noticed this a bit late but it appears to me that
> tkinter is being used very widely for gui development on all platform?
> is that right?
> since fredric lundh has written a very good introduction to tkinter
> (was that just an intro?), I have got keen interest to know the
> following.  may be fredric himself might put some light on these
> points.
> 1. I seriously don't intend to start a flame war but does tkinter
> stand up to the standards of heavy gui development?  can I have an
> entire mdi application working fine with tkinter?  I know wxpython can
> do it and I have heard enough about pyqt, but tkinter seams to be very
> rich in gui objects.
> 2.  as usual I always look out for accessibility when it comes to gui
> design.  will tkinter be useful for blind people?  I mean, are gui
> apps in tkinter accessible on windows?
> 3.  I don't know if I need any thing else as dependencies on my
> windows machine.  I am using python24 and I did not find any thing
> about installation in the introduction to tkinter.  can some one give
> me the process of installing tkinter and all necessary things?
> 4. is tkinter absolutely compatible with windows gui?  does it call on
> native api for native look and feel?  in that case I think
> accessibility issue is automatically solved.
> I am looking out gui library for some serious application development.
>  one is an erp system and the other is a customer relation management
> system.
> so I am confused between wxpython pyqt and now tkinter.
> out of the 3 I only found qt talking extencively about accessibility,
> but did not find a way to install qt in the first place.  I could not
> compile qt nor did I find any run-time dlls for mingw so that I can
> use it out of the box.
> wxpython is the poorest in documentation and tkinter seams to be best at
> that. please give me some advice.
> thanking all.
> Krishnakant.


Tkinter is fine under *nix and Windows for a large range of applications. I
think it has drawbacks and advantage compared to other toolkits. The major
advantage being bundled with python, and the drawbacks include (I
think) ... look and feel, printing support, imaging, documentation.

Then there are two schools: PyQT and wxPython - both very easy to learn and
production libraries ... I never know whether PyQT is commercial or not
under windows (trollteck changed their QT license I think). 

I strongly suggest looking at wxPython - and start with their demo package
which runs also under *nix and windows.


hg

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


Re: RAD for python

2006-12-04 Thread hg
progman wrote:

> 
> is there a  VB-alike  tool for python to create forms??
http://wxglade.sourceforge.net/
http://boa-constructor.sourceforge.net/
http://www.activestate.com/Products/Komodo/
http://www.roebling.de/

hg

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


get script path

2006-12-04 Thread hg
Hi,

must I parse argv[0] to get it, or is there an easier way (that works under
Windows and *nix)?

Ex:

python /home/hg/test/test.py ==> test.py #knows it is in /home/hg/test

Thanks,

hg



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


Re: get script path

2006-12-04 Thread hg
hg wrote:

> Hi,
> 
> must I parse argv[0] to get it, or is there an easier way (that works
> under Windows and *nix)?
> 
> Ex:
> 
> python /home/hg/test/test.py ==> test.py #knows it is in /home/hg/test
> 
> Thanks,
> 
> hg

got it: os.path.dirname(sys.argv [0])

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


Re: get script path

2006-12-04 Thread hg
Rob Wolfe wrote:

> 
> hg wrote:
>> Hi,
>>
>> must I parse argv[0] to get it, or is there an easier way (that works
>> under Windows and *nix)?
>>
>> Ex:
>>
>> python /home/hg/test/test.py ==> test.py #knows it is in /home/hg/test
> 
> IMHO it is easy enough:
> 
>>>> dname, fname = os.path.split("/home/hg/test/test.py")
>>>> dname
> '/home/hg/test'
> 
> --
> HTH,
> Rob
thanks

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


Re: List of Events in wxPython

2006-12-06 Thread hg
Jacksondf wrote:

> What is that procedure for determining which events can be binded for a
> particular widget?  The docs don't seem to help.  For example, how can I
> know which events wx.SpinButton will send.
> 
> Thanks.
from the doc:

To process input from a spin button, use one of these event handler macros
to direct input to member functions that take a wxSpinEvent argument:
EVT_SPIN(id, func) 
Generated whenever an arrow is pressed. 
EVT_SPIN_UP(id, func) 
Generated when left/up arrow is pressed. 
EVT_SPIN_DOWN(id, func) 
Generated when right/down arrow is pressed. 
Note that if you handle both SPIN and UP or DOWN events, you will be
notified about each of them twice: first the UP/DOWN event will be
receieved and then, if it wasn't vetoed, the SPIN event will be sent. See
also

hg

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


Re: merits of Lisp vs Python

2006-12-09 Thread hg
[EMAIL PROTECTED] wrote:

> Okay, since everyone ignored the FAQ, I guess I can too...
> 
> Mark Tarver wrote:
>> How do you compare Python to Lisp?  What specific advantages do you
>> think that one has over the other?
> 
> (Common) Lisp is the only industrial strength language with both pure
> compositionality and a real compiler. What Python has is stupid slogans
> ("It fits your brain." "Only one way to do things.") and an infinite
> community of flies that, for some inexplicable reason, believe these
> stupid slogns. These flies are, however, quite useful because they
> produce infinite numbers of random libraries, some of which end up
> being useful. But consider: Tcl replaced Csh, Perl replaced Tcl, Python
> is rapidly replacing Perl, and Ruby is simultaneously and even more
> rapidly replacing Python. Each is closer to Lisp than the last; the
> world is returning to Lisp and is dragging the flies with it.
> Eventually the flies will descend upon Lisp itself and will bring with
> them their infinite number of random libraries, and then things will be
> where they should have been 20 years ago, but got sidetracked by Tcl
> and other line noise.

p !

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


Re: can I download Python Imaging Library (PIL) for linux.

2006-12-11 Thread hg
[EMAIL PROTECTED] wrote:

> can I download Python Imaging Library (PIL) for linux.
http://effbot.org/downloads/Imaging-1.1.6.tar.gz

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


RE: merits of Lisp vs Python

2006-12-11 Thread hg
[EMAIL PROTECTED] wrote:

> 
> After 394 postings in this thread, you all have convinced me.  I am
> dropping all of my python code and switching to Lisp.
> 
> thank-you
> 
> 
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure.  If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof.  Thank you.

Welcome

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


Re: paramiko public key

2006-12-12 Thread hg
[EMAIL PROTECTED] wrote:

> paramiko
http://www.lag.net/paramiko/docs/

__str__ ?


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


Embedding a shell / editor in a wxPython application

2006-12-12 Thread hg
Hi,

Are there modules out there (ex: scintilla for editor ...) ?

Thanks

hg

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


Re: how to bind a command to the open button

2006-12-12 Thread hg
susan wrote:

> Hi,
>  Anybody knows how to bind a command to the open button at a file
> browser dialog? I want to add selected files to a scrolllist.
> 
> Like this:
> 
> def browseFile(self):
> 
> file = askopenfilename(filetypes = [("TDF Files", "*.TDF"),
> ("All Files", "*.*")],multiple=1)
> 
> ?.
> 
> Thanks!

why don't you add the result "file" to the list ?


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


Re: pycrypto 3DES keysize

2006-12-13 Thread hg
Ning wrote:

> I'm trying to write an IM client which sends encrypted messages to the
> server.  I tried to use pycrypto library, but when I came to 3DES
> cypher I was confused about the keysize to use.  In the standard it
> said that it should be either 112 bits or 168 bits, whereas it's 16
> bytes or 24 bytes in pycrypto.  If I use 16 bytes key to encrypt and
> send this key to the server which is expecting a 112 bits key, there'll
> be a problem.  How I should solve this?

You need to account for the parity bits:
http://en.wikipedia.org/wiki/Triple_DES


If that may reassure you ;-) I use PyCrypto to "talk" to smart cards without
any problem.

hg






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


Re: pycrypto 3DES keysize

2006-12-13 Thread hg
hg wrote:

> Ning wrote:
> 
>> I'm trying to write an IM client which sends encrypted messages to the
>> server.  I tried to use pycrypto library, but when I came to 3DES
>> cypher I was confused about the keysize to use.  In the standard it
>> said that it should be either 112 bits or 168 bits, whereas it's 16
>> bytes or 24 bytes in pycrypto.  If I use 16 bytes key to encrypt and
>> send this key to the server which is expecting a 112 bits key, there'll
>> be a problem.  How I should solve this?
> 
> You need to account for the parity bits:
> http://en.wikipedia.org/wiki/Triple_DES
> 
> 
> If that may reassure you ;-) I use PyCrypto to "talk" to smart cards
> without any problem.
> 
> hg


PS: as stated in the wiki, I would seriously consider AES as it is safer /
faster / supported by pycrypto

hg


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


Re: Serial port failure

2006-12-15 Thread hg
Rob wrote:

> Hi all,
> 
> I am fairly new to python, but not programming and embedded.  I am
> having an issue which I believe is related to the hardware, triggered
> by the software read I am doing in pySerial.  I am sending a short
> message to a group of embedded boxes daisy chained via the serial port.
>  When I send a 'global' message, all the connected units should reply
> with their Id and Ack in this format '0 Ack'  To be certain that I
> didn't miss a packet, and hence a unit, I do the procedure three times,
> sending the message and waiting for a timeout before I run through the
> next iteration.  Frequently I get through the first two iterations
> without a problem, but the third hangs up and crashes, requiring me to
> remove the Belkin USB to serial adapter, and then reconnect it.  Here
> is the code:
> 
> import sys, os
> import serial
> import sret
> import time
> 
> from serial.serialutil import SerialException
> 
>  GetAck Procedure
> 
> def GetAck(p):
> response = ""
> 
> try:
> response = p.readline()
> except SerialException:
> print ">>>>>Timed out<<<<<"
> return -1
> res = response.split()
> 
> #look for ack in the return message
> reslen = len(response)
> if reslen > 5:
> if res[1] == 'Ack':
> return res[0]
> elif res[1] == 'Nak':
> return 0x7F
> else:
> return -1
> 
> 
>>>>>> Snip <<<<<<
> 
>  GetNumLanes Procedure
> 
> def GetNumLanes(Lanes):
> print "Looking for connected units"
> # give a turn command and wait for responses
> msg = ".g t 0 336\n"
> 
> for i in range(3):
> port = OpenPort()
> time.sleep(3)
> print port.isOpen()
> print "Request #%d" % (i+1)
> try:
> port.writelines(msg)
> except OSError:
> print "Serial port failure.  Power cycle units"
> port.close()
> sys.exit(1)
> 
> done = False
> # Run first connection check
> #Loop through getting responses until we get a -1 from GetAck
> while done == False:
> # lane will either be -1 (timeout), 0x7F (Nak),
> # or the lane number that responded with an Ack
> lane = GetAck(port)
> if lane >= '0':
> if False == Lanes.has_key(lane):
> Lanes[lane] = True
> else:
> done = True
> port.close()
> time.sleep(3)
> 
> # Report number of lanes found
> NumLanes = len(Lanes)
> if NumLanes == 1:
> print "\n\nFound 1 unit connected"
> else:
> print "\n\nFound %d units connected" % NumLanes
> 
> return NumLanes
> 
> 
>>>>>>> Snip <<<<<<
> 
>  Main Program Code Section
> 
> 
> #open the serial port
> # capture serial port errors from trying to open the port
> 
> port = OpenPort()
> 
> # If we got to here, the port exists.  Set the baud rate and timeout
> values
> 
> # I need to determine how many lanes are on this chain
> # First send a turn command
> 
> #Create a dictionary of lanes so I can check each lane's responses
> Lanes = {}
> #<><><><><><><><><><><><><><><><>
> # Call the lane finder utility
> NumLanes = GetNumLanes(Lanes)
> #<><><><><><><><><><><><><><><><>
> 
> #if no lanes responded, exit from the utility
> if 0 == NumLanes:
> print "I can't find any units connected."
> print "Check your connections and try again"
> sys.exit(1)
> 
> # list the lanes we have in our dictionary
> for n in Lanes:
> print "Lane - %s" % n
> 
> Now, here is the error message that I get
> 
> [EMAIL PROTECTED]:~/py$ ./Thex.py
> Looking for connected units
> True
> Request #1
> True
> Request #2
> Serial port failure.  Power cycle units
> [EMAIL PROTECTED]:~/py$ ./Thex.py
> The serial port is unavailable.
> Disconnect your USB to Serial adapter, Then
> reconnect it and try again.
> [EMAIL PROTECTED]:~/py$
> 
> Does anyone have any ideas?
> 
> Thanks,
> 
> rob < [EMAIL PROTECTED] >


Where is OpenPort ?

hg





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


Re: Serial port failure

2006-12-15 Thread hg
Rob wrote:

> Here is OpenPort
> 
> 
>  OpenPort procedure
> 
> def OpenPort(name):
> BRate = 19200
> Tout  = 3
> 
> try:
> # Initialize the port
> p = serial.Serial(name)
> # handle failures gracefully
> except SerialException:
> print "The serial port is unavailable."
> print "Disconnect your USB to Serial adapter, Then"
> print "reconnect it and try again."
> sys.exit(1)
> 
> p.setBaudrate(19200)
> p.setTimeout(3)  #set timeout to 1.5 seconds
> 
> # finish opening the port and assign a file handle
> p.open()
> return p
> 
> 
> 
> On Dec 15, 1:07 pm, hg <[EMAIL PROTECTED]> wrote:
>> Rob wrote:
>> > Hi all,
>>
>> > I am fairly new to python, but not programming and embedded.  I am
>> > having an issue which I believe is related to the hardware, triggered
>> > by the software read I am doing in pySerial.  I am sending a short
>> > message to a group of embedded boxes daisy chained via the serial port.
>> >  When I send a 'global' message, all the connected units should reply
>> > with their Id and Ack in this format '0 Ack'  To be certain that I
>> > didn't miss a packet, and hence a unit, I do the procedure three times,
>> > sending the message and waiting for a timeout before I run through the
>> > next iteration.  Frequently I get through the first two iterations
>> > without a problem, but the third hangs up and crashes, requiring me to
>> > remove the Belkin USB to serial adapter, and then reconnect it.  Here
>> > is the code:
>>
>> > import sys, os
>> > import serial
>> > import sret
>> > import time
>>
>> > from serial.serialutil import SerialException
>> > 
>> >  GetAck Procedure
>> > 
>> > def GetAck(p):
>> > response = ""
>>
>> > try:
>> > response = p.readline()
>> > except SerialException:
>> > print ">>>>>Timed out<<<<<"
>> > return -1
>> > res = response.split()
>>
>> > #look for ack in the return message
>> > reslen = len(response)
>> > if reslen > 5:
>> > if res[1] == 'Ack':
>> > return res[0]
>> > elif res[1] == 'Nak':
>> > return 0x7F
>> > else:
>> > return -1
>>
>> >>>>>> Snip <<<<<<
>> > 
>> >  GetNumLanes Procedure
>> > 
>> > def GetNumLanes(Lanes):
>> > print "Looking for connected units"
>> > # give a turn command and wait for responses
>> > msg = ".g t 0 336\n"
>>
>> > for i in range(3):
>> > port = OpenPort()
>> > time.sleep(3)
>> > print port.isOpen()
>> > print "Request #%d" % (i+1)
>> > try:
>> > port.writelines(msg)
>> > except OSError:
>> > print "Serial port failure.  Power cycle units"
>> > port.close()
>> > sys.exit(1)
>>
>> > done = False
>> > # Run first connection check
>> > #Loop through getting responses until we get a -1 from GetAck
>> > while done == False:
>> > # lane will either be -1 (timeout), 0x7F (Nak),
>> > # or the lane number that responded with an Ack
>> > lane = GetAck(port)
>> > if lane >= '0':
>> > if False == Lanes.has_key(lane):
>> > Lanes[lane] = True
>> > else:
>> > done = True
>> > port.close()
>> > time.sleep(3)
>>
>> > # Report number of lanes found
>> > NumLanes = len(Lanes)
>> > if NumLanes == 1:
>> > print "\n\nFound 1 unit connected"
>> > else:
>> > print "\n\nFound %d units connected" % NumLanes
>>
>> > return NumLanes
>>
>> >>>>>>> Snip <<<<<<
>> > ##

Re: Is htmlGen still alive?

2006-12-19 Thread hg
[EMAIL PROTECTED] wrote:

> Does anybody know whether htmlGen, the Python-class library for
> generating HTML, is still being maintained? Or from where it can be
> downloaded? The Starship site where it used to be hosted is dead.
> 
> Thanks for your help!
> 
> Klaus Muller

I am not certain it is, but besides some deprecation warnings, it seems to
be complete/functional

hg

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


Re: Good Looking UI for a stand alone application

2006-12-19 Thread hg
The Night Blogger wrote:

> Can someone recommend me a good API for writing a sexy looking (Rich UI
> like WinForms) shrink wrap application
> 
> My requirement is that the application needs to look as good on Windows as
> on the Apple Mac


I would download the wxPython demo and test it on all platforms if I were
you: no coding and you see stuff right away / decide whether it is a good
choice.

... I know it is mine (although I must confess I never tried it on a mac).

hg



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


Re: Can a Tkinter GUI check for abort script:

2006-12-19 Thread hg
Michael Yanowitz wrote:

> Hello:
> 
>I have successfully implemented a Tkinter GUI which has
> this (simplified here for explanation):
> +-+
> |  filename: [./test3.py] |
> | |
> |  [Run Script]   |
> +-+
> 
>But, now what I would like to do while the script is
> running, is replace the "Run Script" with "Abort Script".
> 
> +-+
> |  filename: [./test3.py] |
> | |
> |  [Abort Script] |
> +-+
> 
>So, every tenth of a seconds or ??? better time, I
> would like to 'return' to the GUI and check if the
> "Abort Script" button has been pressed.
>How do I do this? Or is there a better way to
> implement this?
> 
> Thanks in advance:
> Michael Yanowitz

It depends: As you cannot "kill" a thread in Python, you need some mechanism
to stop your script another way (is that a python script or
a .sh / .bat ? ... from what you're writing, it seems you're calling some
external entity which just might launch a bunch of processes)

So do you or not control the inner workings of that external script ?

If you don't, then "killing" might be the way as posted / clearly the
methord will change from environment to environment.

hg

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


Re: array of class

2007-01-02 Thread hg
mm wrote:

> 
> How can I do a array of class?
> 
> s1=[]  ## this array should hold classes
> 
> ## class definition
> class Word:
>word=""
> 
> 
> ## empty words... INIT
> for i in range(100):  ## 0..99
>s1.append(Wort)
> 
> s1[0].word="There"
> s1[1].word="should"
> s1[2].word="be"
> s1[3].word="different"
> s1[4].word="classes"
> 
> ... but it's not.
> 
> 
> print s1
> 
> [,
> ,
> ,
> ,
> ,
> ,
> 
> ---
> 
> Here, this "classes" are all at the same position in memory. So there
> are no different classes in the array.
> 
> So I access with s1[0], s1[1], s1[2], etc. always the same data.
> 
> Any idea?
> 
> --
> Michael


do you mean object ?

your append should be append(Word()) as you need to create instances.

hg



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


Re: array of class / code optimization

2007-01-03 Thread hg
mm wrote:

> 
> Yes, it was the (), equivalent to thiks like new() create new object
> from class xy.
>>   s1.append(Word)
> s1.append(Word())
> 
> But I was looking for a "struct" equivalent like in c/c++.
> And/or "union". I can't find it.
> 
> Maybe you know a source (URL) "Python for c/c++ programmers" or things
> like that.
> 
> 
> Yes, I konw whats an object is...


A struct in C is unrelated to a struct in C++ as a struct in C++ _is_ a
class.


hg

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


Re: array of class / code optimization

2007-01-03 Thread hg
Neil Cerutti wrote:

> On 2007-01-03, Jussi Salmela <[EMAIL PROTECTED]> wrote:
>> hg kirjoitti:
>>> mm wrote:
>>> 
>>>> Yes, it was the (), equivalent to thiks like new() create new object
>>>> from class xy.
>>>>>   s1.append(Word)
>>>> s1.append(Word())
>>>>
>>>> But I was looking for a "struct" equivalent like in c/c++.
>>>> And/or "union". I can't find it.
>>>>
>>>> Maybe you know a source (URL) "Python for c/c++ programmers" or things
>>>> like that.
>>>>
>>>>
>>>> Yes, I konw whats an object is...
>>> 
>>> 
>>> A struct in C is unrelated to a struct in C++ as a struct in C++ _is_ a
>>> class.
>>> 
>>> 
>>> hg
>>
>> What does your sentence mean, exactly? If I take a C file xyz.c
>> containing a struct definition S, say, rename it to be xyz.cpp
>> and feed it to a C++ compiler, the S sure remains a struct and
>> the C++ compiler has no difficulty in handling it as a struct,
>> so ?!?
> 
> That's true.
> 
> But it's also true that
> 
> struct foo {
>   int x, y;
> };
> 
> is exactly equivalent to:
> 
> class foo {
>   public:
> int x, y;
> };
> 
> The only difference between struct and class in C++ is the
> default access specification of its members.
> 
> --
> Neil Cerutti
> For those of you who have children and don't know it, we have a nursery
> downstairs. --Church Bulletin Blooper


And that is what I meant.

hg


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


Re: Problem Running Working Code on Mac

2007-01-04 Thread hg
goodepic wrote:

> I'm newish to python and just got my first mac, so sorry if this is
> stupid.  I have a little app developed by someone else in wxGlade that
> implements a complex stats package and language package, all in python.
>  It works fine on my work PC, but not on my laptop.  I have a new
> macbook 2ghz core duo, running os x 10.4.8 with python 2.5 installed (I
> didn't erase the base 2.3, just put /usr/local/bin at the start of
> $PATH), along with the latest wxPython, can't remember the version
> number.  I need to add a few more components from the stats package,
> and I'd like eventually to pretty up the cheap GUI I was given, but
> that'd be icing.  When I try either python  or pythonw
> , I get this error:
> 
> WARNING:root:Could not import module "PyPar", defining sequential
> interface
> WARNING:root:No MySQLdb module available
> WARNING:root:No pgdb module (PostgreSQL) available
> Traceback (most recent call last):
>   File "febrlgui.py", line 513, in 
> frame_1 = MyFrame(None, -1, "")
>   File "febrlgui.py", line 198, in __init__
> self.__set_properties()
>   File "febrlgui.py", line 355, in __set_properties
> self.a_box1.SetSelection(-1)
>   File
> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi/wx/_core.py",
> line 11487, in SetSelection
> return _core_.ItemContainer_SetSelection(*args, **kwargs)
> wx._core.PyAssertionError: C++ assertion "IsValid(n)" failed at
> /BUILD/wxPython-src-2.8.0.1/src/mac/carbon/choice.cpp(242) in
> GetString(): wxChoice::GetString(): invalid index
> 
> Of course I'm traveling soon and need to be able to work on this on my
> macbook, so it's down to panic time.  Any help is GREATLY appreciated.
> 
> Thanks,
> Matt


I'd get rid of the warnings first by installing the correct librairies
(PyPar, MySQLDB, pgdb)  who knows what the side effect are ?

hg

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


find a .py path

2007-01-05 Thread hg
Hi,

Is there an easy way for a script being executed (from anywhere) to know
where is is ... something in os.path ?

Thanks,

hg

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


Re: find a .py path

2007-01-05 Thread hg
hg wrote:

> Hi,
> 
> Is there an easy way for a script being executed (from anywhere) to know
> where is is ... something in os.path ?
> 
> Thanks,
> 
> hg

oops: os.path.abspath(sys.argv[0]) 

hg

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


importing / loading a module / class dynamically

2007-01-05 Thread hg
Hi,

I have the following problem.

I find in a directory hierarchy some files following a certain sets of
rules:

.../.../../plugin/name1/name1.py

.../.../../plugin/namen/namen.py

each file will in turn have a class with the same name as the filename
(minus .py)


I fetch those names in a list of string and want to import the files /
instantiate the classes.


I block at the beginning and tried this (test.py is a real file)
>>> s = 'test.py'
>>> eval ('import ' + s)

and get 

Traceback (most recent call last):
  File "", line 1, in -toplevel-
eval ('import ' + s)
  File "", line 1
import test.py

Any clue ?

Thanks

hg

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


Re: find a .py path

2007-01-05 Thread hg
Laszlo Nagy wrote:

> hg i'rta:
>> Hi,
>>
>> Is there an easy way for a script being executed (from anywhere) to know
>> where is is ... something in os.path ?
>>   
> __file__
> 
> You can also use os.argv[0] but that is not the same...
> 
> Laszlo
Thanks

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


Re: importing / loading a module / class dynamically

2007-01-05 Thread hg
hg wrote:

> Hi,
> 
> I have the following problem.
> 
> I find in a directory hierarchy some files following a certain sets of
> rules:
> 
> .../.../../plugin/name1/name1.py
> 
> .../.../../plugin/namen/namen.py
> 
> each file will in turn have a class with the same name as the filename
> (minus .py)
> 
> 
> I fetch those names in a list of string and want to import the files /
> instantiate the classes.
> 
> 
> I block at the beginning and tried this (test.py is a real file)
>>>> s = 'test.py'
>>>> eval ('import ' + s)
> 
> and get
> 
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> eval ('import ' + s)
>   File "", line 1
> import test.py
> 
> Any clue ?
> 
> Thanks
> 
> hg


OK, from http://mail.python.org/pipermail/python-list/2004-July/272081.html,
I need to use exec and not eval

hg

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


Re: importing / loading a module / class dynamically

2007-01-05 Thread hg
Laszlo Nagy wrote:

> 
>> .../.../../plugin/name1/name1.py
>> 
>> .../.../../plugin/namen/namen.py
>>
>>
>> I block at the beginning and tried this (test.py is a real file)
>>   
>>>>> s = 'test.py'
>>>>> eval ('import ' + s)
>>>>> 
> import test.py  # This is invalid
> import test # This MAY be valid
> import name1.name1 # Most probably this is what you want if you have the
> aforementioned directory stucture
> from name1 import name1 # Or this?
> 
> You must also:
> 
> 1. Have the 'plugin' dir in your sys.path
> 2. Have at least an empty plugin/name1/__init__.py file
> 
> Another alternative is to have plugins/__init__.py and do something like:
> 
> from plugins.name1 import name1
> 
> You should not overcomplicate things anyway. If you do not need these
> name1...namen directories for sure, then just drop them.
> 
> Hint: try this (untested)
> 
> import os
> fnames = os.listdir('plugins')
> for fname in fnames:
> if os.path.isdir(fname):
>root,ext = os.path.splitext(fname)
>cmd = "from plugins.%s import %s" % (root,root)
>print "I should eval this:",cmd
> 
> Best,
> 
>Laszlo
> 
> 
>> Traceback (most recent call last):
>>   File "", line 1, in -toplevel-
>> eval ('import ' + s)
>>   File "", line 1
>> import test.py
>>


Thanks,

What I am doing is adding plugin support to PyCrust ... so I'm looking for a
mechanism where anyone can develop a plugin and have it loaded by pycrust.

the .py was a typo 


why the "...Have at least an empty plugin/name1/__init__.py file..." ?

Thanks,

hg



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


Re: importing / loading a module / class dynamically

2007-01-05 Thread hg
Laszlo Nagy wrote:

> 
>> Thanks,
>>
>> What I am doing is adding plugin support to PyCrust ... so I'm looking
>> for a mechanism where anyone can develop a plugin and have it loaded by
>> pycrust.
>>
>> the .py was a typo
>>
>>
>> why the "...Have at least an empty plugin/name1/__init__.py file..." ?
>>   
> When you do
> 
> import plugins.name1.name1
> 
> then "plugins" and "plugins/name1" should be a package, not a module. A
> package is a special directory that contains package initialization code
> in a __init__.py file. If you do not have the file, then the "plugins"
> directory will be only a directory, and it cannot be imported.
> 
> For details, see:
> 
> http://docs.python.org/tut/node8.html#SECTION00840
> 
>   Laszlo


Many thanks Laszlo, it looks like I got it to work ... result will be on
www.snakecard.com/PY for those interested ... in the next few days

hg


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


Re: Undefined symbol __pure_virtual when importing MySQLdb

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

> I downloaded MySQL-python-1.2.1 from SourceForge and installed it on a
> Mandrake system (Mandrake Linux 9.2 3.3.1-2mdk on linux2).
> 
> The installation was successful.  The gcc version is 3.3.
> 
> My Python version is 2.4.2.  When I import MySQLdb, I get an error
> which says that __pure_virtual is an undefined symbol.
> 
> Look:
> 
>>>> import MySQLdb
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/usr/local/python2.4/site-packages/MySQLdb/__init__.py", line
> 19, in ?
> import _mysql
> ImportError: /usr/local/python2.4/site-packages/_mysql.so: undefined
> symbol: __pure_virtual
> 
> By the way, mysql (5.0.27-standard)is running OK on the Mandrake
> system. Look:
> 
> [EMAIL PROTECTED] antonyliu]$ mysql -u root -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 13 to server version: 5.0.27-standard
> 
> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
> 
> mysql>
> 
> I have googled hard, and did see someone asking the same question, but
> haven't found a good solution to this problem.  Could anyone give me a
> hint?  Thanks a lot!


Hi,

I can only say that it runs fine under Mandriva 2007 ... and that Mandriva
went to gcc V4 long after 9.2 ... maybe an issue here.

Regards,

hg

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


Re: Why less emphasis on private data?

2007-01-08 Thread hg
sturlamolden wrote:

> The designers of Java, C++, C#, Ada95, Delphi, etc. seem to think that
> if an object's 'internal' variables or states cannot be kept private,
> programmers get an irresistible temptation to mess with them in
> malicious ways. But if you are that stupid, should you be programming
> in any language? The most widely used language is still C, and there is
> no concept of private data in C either, nor is it needed.


void test(void)
{
  static int i;
}


Do you agree that i is "private" to test ?

hg

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


Re: Xah's Edu Corner: Introduction to 3D Graphics Programing

2007-01-09 Thread hg
Xah Lee wrote:

> I don't know OpenGL, but i think it is a low-level crap, and have done
> the industry huge irreparable damage the same way unix has.

So you _are_ psychic ! is the end of the world be in 2007 ?




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


Python 2.5 and stdin

2007-06-03 Thread hg
Hi,

I have upgraded to 2.5 and one of my program no longre functions:

In a thread run function, I attempts to get a "raw_input('')" and get the
error
***
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.5/threading.py", line 460, in __bootstrap
self.run()
  File "/usr/local/games/RealTimeBattle/Robots/pyrobot.py", line 89, in run
l_res = raw_input('')
IOError: [Errno 11] Resource temporarily unavailable
***

The full source code is here: http://snakecard.com/rtb/


Any clue ?

Thanks,

hg




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


pyexe "format"

2007-06-09 Thread hg
Hi,

Is there a clean way to figure out that a .exe was actually generated by
pyexe ?

hg


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


Re: pyexe "format"

2007-06-09 Thread hg
hg wrote:

> Hi,
> 
> Is there a clean way to figure out that a .exe was actually generated by
> pyexe ?
> 
> hg

I should gave writtent "definite" instead of "clean"

hg

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


Re: pyexe "format"

2007-06-10 Thread hg
John Machin wrote:

> On Jun 10, 11:25 am, John Machin <[EMAIL PROTECTED]> wrote:
>> On Jun 10, 10:38 am, hg <[EMAIL PROTECTED]> wrote:
>>
>> > hg wrote:
>> > > Hi,
>>
>> > > Is there a clean way to figure out that a .exe was actually generated
>> > > by pyexe ?
>>
>> > > hg
>>
>> > I should gave writtent "definite" instead of "clean"
>>
>> > hg
>>
>> Reminds me of the story about a teacher trying to correct a student
>> who was using rather dialectal English:
>>You have went and putten "putten" when you should of putten "put"!
>> :-)
>>
>> You should of looken at this:
>>
>> http://www.py2exe.org/index.cgi/WhereAmI
>>
>> HTH,
>> John
> 
> I presumed that you were really asking: "How can Python code tell
> whether it is being run in a py2exe-generated exe, or by the Python
> interpreter?".
> 
> Alternatively, "How can a human inspect an exe and determine whether
> it was generated by py2exe?": (1) I don't know (2) Why do you care?
> 
> Cheers,
> John


An ex-partner might "by mistake" be in possession of some of my source
code ... so if this source code happens to be repackaged in a .exe and I
get to audit it ... I'd like to know where to start.

So the above link ... which I had read ... does not help me.

Regards,

hg

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


stdout/err and C extentions

2007-06-12 Thread hg
Hi,

I have the following

* C extention  - redir.c


#include "Python.h"

PyObject * test_redir_test(PyObject *self) {
  fprintf(stdout, "Hello from an extention!\n");
  Py_INCREF(Py_None);
  return Py_None;
}

static PyMethodDef test_redir_methods[] = {
{"test", (PyCFunction)test_redir_test, METH_NOARGS, "Prints test string
\n"},
{NULL, NULL, 0, NULL}
};

DL_EXPORT(void) inittest_redir(void)
{
Py_InitModule3("test_redir", test_redir_methods, "Provides a test
function.\n");   
}

* setup.py :

from distutils.core import setup, Extension
import sys
import os 


include = []



setup(name="test_redir", version="0.1",
   ext_modules=[
   Extension(
   "test_redir",
["redir.c"],
undef_macros=['RELEASE'],
library_dirs=[],
)
]
)

*** python test script: test.py:



import sys


class My_Stdout:
def write(self, p_string):
l_file = open('res.txt','a')
l_file.write(p_string)
l_file.close


sys.stdout = My_Stdout()

print 'toto'
import test_redir



test_redir.test()



**** Question:


print 'toto' does go to "res.txt" while "Hello from an extention!\n" goes to
the console.




Any clue ?


Thanks,


hg



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


  1   2   3   >