Re: Standalone applications ?

2005-08-14 Thread henne
 > I should have added that my platform is Linux.

http://davidf.sjsoft.com/mirrors/mcmillan-inc/install1.html

Squeeze works on Linux too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Standalone applications ?

2005-08-14 Thread TPJ
> I should have added that my platform is Linux.

In this case you shouldn't bother yourself with executables. Python is
available on any major distribution.

My Python apps are available as pyc files for Linux (and for those
Windows users, who have Python installed) and as executables for Win
(for those Windows users, who have no Python installed).

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


Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Am Samstag, den 13.08.2005, 14:01 -0700 schrieb CG:

Well, you have described your problem nicely. One thing that's missing
is how to deal with incorrect input. (For example missing connect or
disconnect messages).

Furthermore, you can now:
a) try to find somebody who writes it for you. How you motivate that
person is another question.
b) try to hack some solution yourself. Start with doing the python
tutorial?

Andreas

> I am looking for a way to parse a simple log file to get the
> information in a format that I can use.  I would like to use python,
> but I am just beginning to learn how to use it.  I am not a programmer,
> but have done some simple modifications and revisions of scripts.  I am
> willing to attempt this on my own, if someone can point me in the right
> direction (any example scripts that do similar things would be
> helpful).  This doesn't have to be Python, but I need a cross-platform
> solution (i.e. Perl or some other kind of script).  I just wanted to
> try Python because I like the concept of it.
> 
> Here is my scenario:
> I have a program that connects and disconnects to a server.  It writes
> a simple log file like this:
> 
> 08-13-2005  13:19:37:564 Program: CONNECTED to 'Server'
> 08-13-2005  15:40:08:313 Program: DISCONNECTED from 'Server'
> 08-13-2005  15:45:39:234 Program: CONNECTED to 'Server'
> 08-13-2005  15:55:18:113 Program: DISCONNECTED from 'Server'
> 08-13-2005  16:30:57:264 Program: CONNECTED to 'Server'
> 08-13-2005  16:59:46:417 Program: DISCONNECTED from 'Server'
> 08-13-2005  17:10:33:264 Program: CONNECTED to 'Server'
> 08-13-2005  18:25:26:316 Program: DISCONNECTED from 'Server'
> 08-13-2005  18:58:13:564 Program: CONNECTED to 'Server'
> 08-13-2005  19:29:10:715 Program: DISCONNECTED from 'Server'
> 
> What I basically want to do is end up with a text file that can be
> easily imported into a database with a format like this (or I guess it
> could be written in a SQL script form that could write directly to a
> database like Mysql):
> 
> Connect_Date Connect_Time Disconnect_date Disconnect_time User
>   --- --- ---
> 08-13-2005   13:19:37 08-13-2005  15:40:08John
> 08-13-2005   15:45:39 08-13-2005  15:55:18John
> 08-13-2005   16:30:57 08-13-2005  16:59:46John
> 08-13-2005   17:10:33 08-13-2005  18:25:26John
> 08-13-2005   18:58:13 08-13-2005  19:29:10John
> 
> Here are some notes about this:
> * the username would come from the log file name (i.e.
> John_Connect.log)
> * I don't need the fractions of seconds in the timestamps
> * I only need date, time, and connect or disconnect, the other info is
> not important
> * If it is possible to calculate the elapsed time between Connect and
> Disconnect and create a new field with that data, that would help (but
> I can easily do that with SQL queries)
> * This log file layout seems to be consistent
> * There may not be a "disconnect" statement if the log file is read
> while connected, so the next time it would have to insert the
> disconnect information.  The file will be read quite regularly, so this
> is very likely.
> * This would eventually need to be done without intervention (maybe
> every 5 minutes).
> 
> I am open to other ideas or existing programs and am flexible about the
> final solution.
> 
> Thanks,
> Clint
> 


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
-- 
http://mail.python.org/mailman/listinfo/python-list

What does the word "quiet" mean in this paragraph?

2005-08-14 Thread could ildg
The paragraph is as below, I mark the word quiet with *** ***.
___
One problem with distributed applications is that if no data arrives
over a long period of time, you need to wonder why. On one hand, it
could be that the other program just hasn't had any information to
send recently. On the other hand, the other program could have
crashed. TCP handles this problem by allowing you to send an "Are you
still alive?" message every so often to  ***quiet*** connections. The
way is to call setKeepAlive() with a value of true.
___
Please tell me what does the word "quiet" mean, Thank you~
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a log file

2005-08-14 Thread John Machin
CG wrote:
[snip]
> What I basically want to do is end up with a text file that can be
> easily imported into a database with a format like this (or I guess it
> could be written in a SQL script form that could write directly to a
> database like Mysql):
> 
> Connect_Date Connect_Time Disconnect_date Disconnect_time User
>   --- --- ---
> 08-13-2005   13:19:37 08-13-2005  15:40:08John
[snip]
> * I don't need the fractions of seconds in the timestamps

(1) Famous last words.
(2) What do you gain my throwing information away? Nothing! On input, 
record what you are given. You can always round/truncate on output.

> * I only need date, time, and connect or disconnect, the other info is
> not important

Think about date and time as ONE piece of info. Use a "datetime" object 
in Python, not a "date" and a "time". Same story with the columns in 
your database.

> * If it is possible to calculate the elapsed time between Connect and
> Disconnect and create a new field with that data, that would help (but
> I can easily do that with SQL queries)

and you will be able to do that even more easily if you use one "datetime".

A couple of quick silly questions: What do you do if servers are in 
different timezones? What if "John" connects before a daylight saving 
change and disconnects afterwards? Any chance of your using ISO standard 
  format for representing dates?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does the word "quiet" mean in this paragraph?

2005-08-14 Thread Peter Decker
On 8/14/05, could ildg <[EMAIL PROTECTED]> wrote:
> The paragraph is as below, I mark the word quiet with *** ***.
> ___
> One problem with distributed applications is that if no data arrives
> over a long period of time, you need to wonder why. On one hand, it
> could be that the other program just hasn't had any information to
> send recently. On the other hand, the other program could have
> crashed. TCP handles this problem by allowing you to send an "Are you
> still alive?" message every so often to  ***quiet*** connections. The
> way is to call setKeepAlive() with a value of true.
> ___
> Please tell me what does the word "quiet" mean, Thank you~

It means that the remote application has sent any data recently: 'if
no data arrives over a long period of time'. We commonly say that two
programs 'talk' to each other, or that one program 'tells' the other
when it has received input. If these programs aren't 'saying'
anything, they're considered to be 'quiet'. The paragraph you quoted
is concerned with determining why the remote app hasn't 'said'
anything in a while: has it crashed, or is it really not getting any
data to relay.
-- 

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


help with TixComboBox usage in python

2005-08-14 Thread [EMAIL PROTECTED]
 Hi,

I have to write a code in which based on a user selection in a combo
box, pages in NoteBook should be automatically added or deleted.

So, I have the following class.
class myActionsDialog:
def __init__ (self, top):

self.ActionsWidget = dict()
self.sd=None

self.ActionsWidget['Label'] = Label (text="My Actions")
top.configure(labelwidget=self.ActionsWidget['Label'])
self.actionChoice=Tix.StringVar()

self.ActionsWidget['Choice'] = Tix.ComboBox(top,
label="Pre-defined Actions: ", dropdown=1,
command=self.select_action, editable=1,
variable=self.actionChoice,
options='listbox.height 6 label.width 20 label.anchor e')
self.ActionsWidget['Choice'].configure(command=self.select_action)

self.ActionsWidget['Choice'].grid(row=1, column=0,sticky=NW)
self.ActionsWidget['CustomAction']=Frame(top)
self.ActionsWidget['CustomAction'].grid(row=2, column=0,sticky=NW+SE)
self.ActionsWidget['CustomAction'].configure(borderwidth=1,highlightthickness=1,
highlightcolor="blue", relief=GROOVE)

self.ActionsWidget['NoteBook'] =
Tix.NoteBook(self.ActionsWidget['CustomAction'])
self.ActionsWidget['NoteBook'].grid(row=0, column=0,sticky=NW+SE)
self.ActionsWidget['NoteBook'].configure(height=400, width=600)
self.ActionsWidget['NBFrame'] =
self.ActionsWidget['NoteBook'].subwidget_list["nbframe"]
self.ActionsWidget['NBFrame'].configure(relief="raised", tabpadx="8")
self.ANbook = self.ActionsWidget['NoteBook']

def add_Actions(self, toptions):
"""Usage: options = {'text':'Plain Text', 'html':'Plain Html'}
add_Actions(options)"""
print "add_Actions=", toptions
for eachOpt in toptions:
print eachOpt
self.ActionsWidget['Choice'].insert(Tix.END, eachOpt)

def add_page (self, name, text, mark):
print "add_page=", name, text, mark
self.ANbook.add(name, label=text, underline=mark, anchor="center")

def delete_page (self, name):
print "delete_page=", name
self.ANbook.delete(name)

def select_action(self,event):
print "myActionsDialog::select_action=", self.actionChoice.get(), ";"
print "select_action=", event, ";"

if self.sd != None:
print "Deleting the previous pages..."
self.sd.del_pages()
if self.actionChoice.get() == 'Send Events':
print "Found Send Events"
self.sd=mySendAlarmDialog(self)
elif self.actionChoice.get() == 'Alarm Upload':
print "Found Alarm Upload"
print "Seems alarm Upload is found"
self.sd=None

But my problem is select_action is not executing when ever user changes
his selection.

my Current widget layout is something like this now.
--
| pre-defined Actions:  |
---
| Tix.NoteBook |
---
Tix.NoteBook pages should be changed dynamically based on the user
selection in 
So, I have a doubt where this really works? or should I have to add a
new buttion called "Update NoteBook" and whenever user clicks this
button then the Notebook wiget changes. Question

New UI:

---
| pre-defined Actions:  | Update NoteBook |
---
| Tix.NoteBook |
---

or please let me know if we have any better widgets to handle this
behaviour.

Thanks in advance

Regards
Kalyan

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


Re: wx.MessageDialog displayed without components inside

2005-08-14 Thread stas
On Sat, 13 Aug 2005 16:34:17 -0700, perchef wrote:

> nope, I have put md.Destroy() away and it didn't change something.
> I don't think that's the problem because ShowModal() is a blocking
> method, execution is stop until you press YES or NO (in my case with
> wx.YES_NO)
Just a thought, do you cal the event loop ?
Because this minimal example just works like it should.

import wx
app = wx.PySimpleApp() 
md = wx.MessageDialog(None,'foo','bar',wx.YES_NO)
result = md.ShowModal()
app.MainLoop()

Stas

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


Re: Jargons of Info Tech industry ... and Xah Lee (I mean Jerry) Springer

2005-08-14 Thread Alex
Xah Lee wrote:
> Jargons of Info Tech industry
> 
> (A Love of Jargons)
> 
> Xah Lee, 2002 Feb
> 
> The jargon-soaked stupidity in computing field can be grouped into
> classes  ...  One flagrant example is Sun Microsystem's
> Java stuff  ...  fucking stupid Java and fuck Sun
> Microsystems. This is just one example of Jargon hodgepodge of one
> single commercial entity. 
> 
> The other class of jargon stupidity is from computing practitioners, of
> which the Unix/Perl community is exemplary  ...  These types of
> jargons exudes juvenile humor. Cheesiness and low-taste is their
> hall-mark.
> 
> There is another class of jargon moronicity, which i find them most
> damaging to society,   ...  I think the reason for these, is that 
> these
> massive body of average programers usually don't have much knowledge of
> significant mathematics,   ...  these people defining
> or hatching terms   ...  are often a result of sopho-morons
> trying to sound big.
> 
   ...  Because most programers are
> sopho-morons who are less capable of clear thinking but nevertheless
> possess human vanity,   ...  
> 
   ...  One can see that the term
> “closure” is quite vague in conveying its meaning. The term
> nevertheless is very popular among talkative programers and dense
> tutorials, precisely because it is vague and mysterious. These
> pseudo-wit living zombies, never thought for a moment that they are
> using a moronic term,   ...  (for an example of the
> fantastically stupid write-up on closure by the Perl folks  ...  
> 
   ... 
> 
   ...  (one may think from the above tree-diagram
> that Java the language has at least put clear distinction to interface
> and implementation, whereas in my opinion they are one fantastic fuck
> up too, in many respects.)
> 

I've extracted the preceding castigating snippets from Mr. Lee's Jargon 
"thesis". :)) When reciprocated upon his own posts; one could offer up 
the proverb, "he who lives in glass houses should not throw stones."

His inflammatory rhetoric - light on facts, weak in application, and 
generously peppered with self-aggrandizing insults - would probably 
offend Jerry Springer by comparison.

Perhaps the "professor" should more carefully scrutinize himself before 
attempting to castigate others, less he acquire the reputation of a 
hypocrite, e.g. -
   "are often a result of sopho-morons trying to sound big.";
   "who are less capable of clear thinking but nevertheless possess
human vanity";
"These types of jargons exudes juvenile humor.";
"Cheesiness and low-taste is their hall-mark."

Elementary courses in Critical Reasoning, Topical Research, Grammar, 
Creative Writing, and Technical Writing also seem warranted.

A little one on one time with a mental health practitioner probably 
wouldn't hurt either. :))

P.S. Until then, does anyones else deem it appropriate to give 
"professor" Lee the nickname "Xah Lee Springer"?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: What does the word "quiet" mean in this paragraph?

2005-08-14 Thread could ildg
Thank you very much.
I am not a native English speeker so I have problem when understanding
this sentense. Now I know that the word  "quiet" is an adjective and
I'm totally catch it. Thank you~

On 8/14/05, Peter Decker <[EMAIL PROTECTED]> wrote:
> On 8/14/05, could ildg <[EMAIL PROTECTED]> wrote:
> > The paragraph is as below, I mark the word quiet with *** ***.
> > ___
> > One problem with distributed applications is that if no data arrives
> > over a long period of time, you need to wonder why. On one hand, it
> > could be that the other program just hasn't had any information to
> > send recently. On the other hand, the other program could have
> > crashed. TCP handles this problem by allowing you to send an "Are you
> > still alive?" message every so often to  ***quiet*** connections. The
> > way is to call setKeepAlive() with a value of true.
> > ___
> > Please tell me what does the word "quiet" mean, Thank you~
> 
> It means that the remote application has sent any data recently: 'if
> no data arrives over a long period of time'. We commonly say that two
> programs 'talk' to each other, or that one program 'tells' the other
> when it has received input. If these programs aren't 'saying'
> anything, they're considered to be 'quiet'. The paragraph you quoted
> is concerned with determining why the remote app hasn't 'said'
> anything in a while: has it crashed, or is it really not getting any
> data to relay.
> --
> 
> # p.d.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Permutation Generator

2005-08-14 Thread Jack Diederich
On Fri, Aug 12, 2005 at 03:48:38PM -0400, Michael J. Fromberger wrote:
> In article <[EMAIL PROTECTED]>,
>  Talin <[EMAIL PROTECTED]> wrote:
> 
> > I'm sure I am not the first person to do this, but I wanted to share 
> > this: a generator which returns all permutations of a list:
> 
> You're right that you're not the first person to do this:  Many others 
> have also posted incorrect permutation generators.
> 
Amen, combinatorics are so popular they should be in the FAQ.
groups.google.com can show you many pure python recipies and benchmarks,
but I'll give my ususal response:
  http://probstat.sourceforge.net/ 

I'm not just the author, I'm a client-ly,
-jackdied
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I exclude a word by using re?

2005-08-14 Thread could ildg
In re, the punctuation "^" can exclude a single character, but I want
to exclude a whole word now. for example I have a string "hi, how are
you. hello", I want to extract all the part before the world "hello",
I can't use ".*[^hello]" because "^" only exclude single char "h" or
"e" or "l" or "o". Will somebody tell me how to do it? Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Standalone applications ?

2005-08-14 Thread Peter Decker
On 14 Aug 2005 03:49:08 -0700, TPJ <[EMAIL PROTECTED]> wrote:
> > I should have added that my platform is Linux.
> 
> In this case you shouldn't bother yourself with executables. Python is
> available on any major distribution.
> 
> My Python apps are available as pyc files for Linux (and for those
> Windows users, who have Python installed) and as executables for Win
> (for those Windows users, who have no Python installed).

What about any dependencies? While Linux distros may have Python
installed, it may be an older version, and may not have one or two
libraries that your app needs. E.g., I have Python that came with my
FC2 install, but it doesn't come with Tkinter, so if you build a
Tkinter-based app and just send me the .pyc file, it won't work.
-- 

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


Re: Parsing a log file

2005-08-14 Thread CG
Thanks Andreas,

In your first paragraph, you ask about incorrect input.  I guess it is
possible, but without that information, my collection of the data is
useless, so I really don't know what I would do with that.

As for the other stuff, I can hack the data in other ways, such as with
VBA and MSAccess, which I am more familiar with, but I am trying to
move to Linux and want to do it right the first time.  I figure Perl is
the more common language for this kind of stuff, but I did want to try
to learn some Python while I am at it.  I have started the tutorial,
but being a businessman, time is an issue, which, if I had an example
script that did a similar thing, I can learn by doing that (I am
looking for something similar now).

I do live in a low-labor cost country, so I can hire someone to do it
for a small amount of money, but Python people are a little harder to
find.

Thanks for the comments,
Clint

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


Re: Parsing a log file

2005-08-14 Thread CG
John,

Your comments are very helpful.  I will take the datetime stamp as the
way to go.  I don't have a need to throw away the time info, it is

You said:
>What do you do if servers are in different
>timezones?

This is all inhouse in a non-daylight savings country and would not be
an issue

You also said:
>Any chance of your using ISO standard format
>for representing dates?

I think I have very little control over the actual logfile data.  I
seem to be able to control what info it collects, but I don't think I
can change the formatting.

Thanks,
Clint

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


Re: wx.MessageDialog displayed without components inside

2005-08-14 Thread perchef

> Just a thought, do you call the event loop ?
yes i do.
I really can't see my a MessageDialog would appear without components
inside. maybe a thread problem ?

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


Re: Euclid's Algorithm in Python?

2005-08-14 Thread Antoon Pardon
On 2005-08-08, Bengt Richter <[EMAIL PROTECTED]> wrote:
> On 7 Aug 2005 17:31:02 -0700, "Jordan Rastrick" <[EMAIL PROTECTED]> wrote:
>
>>Good point. I suppose I'd only ever seen it implemented with the if
>>test, but you're right, the plain while loop should work fine. Silly
>>me.
>>
>>def gcd(a,b):
>> while b != 0:
>>   a, b = b, a%b
>>return a
>>
>>Even nicer.
>>
> what is the convention for handling signed arguments? E.g.,

As far as I understand the convention is it doesn't make
sense to talk about a gcd if not all numbers are positive.

I would be very interested if someone knows what the gcd
of 3 and -3 should/would be.

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


Re: wx.MessageDialog displayed without components inside

2005-08-14 Thread stas
On Sun, 14 Aug 2005 07:45:10 -0700, perchef wrote:

> 
>> Just a thought, do you call the event loop ?
> yes i do.
> I really can't see my a MessageDialog would appear without components
> inside. maybe a thread problem ?
Does the example I gave work?
I mean when you copy and paste it does it show a normal dialog?

Stas

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


Re: How can I exclude a word by using re?

2005-08-14 Thread Christoph Rackwitz
re.findall('(.*)hello|(.*)', 'hi, how are you. hello')
re.findall('(.*)hello|(.*)', 'hi, how are you. ello')
take a look at the outputs of these.

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


Re: How can I exclude a word by using re?

2005-08-14 Thread Jeff Schwab
could ildg wrote:
> In re, the punctuation "^" can exclude a single character, but I want
> to exclude a whole word now. for example I have a string "hi, how are
> you. hello", I want to extract all the part before the world "hello",
> I can't use ".*[^hello]" because "^" only exclude single char "h" or
> "e" or "l" or "o". Will somebody tell me how to do it? Thanks.

import re

def demonstrate(regex, text):
pattern = re.compile(regex)
match = pattern.search(text)

print " ", text
if match:
print "Matched  '%s'" % match.group(0)
print "Captured '%s'" % match.group(1)
else:
print "Did not match"

# Option 1: Match it all, but capture only the part before "hello."  The 
(.*?)
# matches as few characters as possible, so that this pattern would end 
before
# the first hello in "hello hello".

pattern = r"(.*?)hello"
print "Option 1:", pattern
demonstrate( pattern, "hi, how are you. hello" )

# Option 2: Don't even match the "hello," but make sure it's there.
# The first of these calls will match, but the second will not.  The
# (?=...) construct is using a feature called "forward look-ahead."

pattern = r"(.*)(?=hello)"
print "\nOption 2:", pattern
demonstrate( pattern, "hi, how are you. hello" )
demonstrate( pattern, "hi, how are you. ", )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I exclude a word by using re?

2005-08-14 Thread could ildg
Thank you.
But what should I do if there are more than one hello and I only want
to extract what's before the first "hello". For example, the raw
string is "hi, how are you? hello I'm fine, thank you hello. that's it
hello", I want to extract all the stuff before the first hello?

On 14 Aug 2005 08:02:16 -0700, Christoph Rackwitz
<[EMAIL PROTECTED]> wrote:
> re.findall('(.*)hello|(.*)', 'hi, how are you. hello')
> re.findall('(.*)hello|(.*)', 'hi, how are you. ello')
> take a look at the outputs of these.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Euclid's Algorithm in Python?

2005-08-14 Thread [EMAIL PROTECTED]

Antoon Pardon wrote:
> On 2005-08-08, Bengt Richter <[EMAIL PROTECTED]> wrote:
> > On 7 Aug 2005 17:31:02 -0700, "Jordan Rastrick" <[EMAIL PROTECTED]> wrote:
> >
> >>Good point. I suppose I'd only ever seen it implemented with the if
> >>test, but you're right, the plain while loop should work fine. Silly
> >>me.
> >>
> >>def gcd(a,b):
> >> while b != 0:
> >>   a, b = b, a%b
> >>return a
> >>
> >>Even nicer.
> >>
> > what is the convention for handling signed arguments? E.g.,
>
> As far as I understand the convention is it doesn't make
> sense to talk about a gcd if not all numbers are positive.

That may well be the convention but I don't know why you say
it doesn't make sense. -3/3 still has a remainder of 0.
So does -3/-3, but 3 is greater than -3 so it "makes sense"
that the GCD will be positive.

>
> I would be very interested if someone knows what the gcd
> of 3 and -3 should/would be.

Someone has already decided what it should be.

>>> from gmpy import *
>>> help(gcd)
Help on built-in function gcd:

gcd(...)
gcd(a,b): returns the greatest common denominator of numbers a and
b
(which must be mpz objects, or else get coerced to mpz)

>>> gcd(3,-3)
mpz(3)


What would really be interesting is whether this conflicts with
any other implementation of GCD.

> 
> -- 
> Antoon Pardon

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


Re: Standalone applications ?

2005-08-14 Thread Madhusudan Singh
TPJ wrote:

>> I should have added that my platform is Linux.
> 
> In this case you shouldn't bother yourself with executables. Python is
> available on any major distribution.
> 
> My Python apps are available as pyc files for Linux (and for those
> Windows users, who have Python installed) and as executables for Win
> (for those Windows users, who have no Python installed).

My python app uses a lot of modules, some custom developed by myself (and
which I am not planning on releasing right now). Which is why I posed the
question in the first place (that and curiosity).
-- 
http://mail.python.org/mailman/listinfo/python-list


A PIL Question

2005-08-14 Thread Ray
Hello,

I'm using latest PIL version with Python 2.4.1. (for solving a level in
Python Challenge actually...). Anyway, I'm trying to draw a picture. My
question is, why is it that putdata() won't work? Even this won't run:

import Image

im = Image.open("something.jpg")
seq = im.getdata()

image = Image.Image()
image.putdata(seq)

image.show()

I always get:

Traceback (most recent call last):
  File "Script1.py", line 31, in ?
image.putdata(seq)
  File "D:\Development\Python24\Lib\site-packages\PIL\Image.py", line
1120, in putdata
self.im.putdata(data, scale, offset)
AttributeError: 'NoneType' object has no attribute 'putdata'

Anybody has any idea why this is the case? 

Thanks,
Ray

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


Re: Jargons of Info Tech industry ... and Xah Lee (I mean Jerry) Springer

2005-08-14 Thread Keith Thompson
Alex <[EMAIL PROTECTED]> writes:
> Xah Lee wrote:
[SSSNNNIIIPPP!!!]
> I've extracted the preceding castigating snippets from Mr. Lee's
> Jargon "thesis".
[SSSNNNIIIPPP!!!]

*Please stop posting followups to this off-topic nonsense.  Just
ignore it.  Responding to spam is spam; responding to a troll gives
him exactly what he wants and annoys the heck out of the rest of us.

 +---+ .:\:\:/:/:.
 |   PLEASE DO NOT   |:.:\:\:/:/:.:
 |  FEED THE TROLLS  |   :=.' -   - '.=:
 |   |   '=(\ 9   9 /)='
 |   Thank you,  |  (  (_)  )
 |   Management  |  /`-vvv-'\
 +---+ / \
 |  |@@@  / /|,|\ \
 |  |@@@ /_//  /^\  \\_\
   @x@@x@|  | |/ WW(  (   )  )WW
   \/|  |\|   __\,,\ /,,/__
\||/ |  | |  jgs (__Y__)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
==

Followups redirected appropriately.

-- 
Keith Thompson (The_Other_Keith) [EMAIL PROTECTED]  
San Diego Supercomputer Center <*>  
We must do something.  This is something.  Therefore, we must do this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Permutation Generator

2005-08-14 Thread Casey Hawthorne
It's hard to make "complete" permutation generators, Knuth has a whole
fascicle on it - "The Art of Computer Programming - Volume 4 Fascicle
2 - Generating All Tuples and Permutations" - 2005
--
Regards,
Casey
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Permutation Generator

2005-08-14 Thread David Isaac

"Casey Hawthorne" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> It's hard to make "complete" permutation generators, Knuth has a whole
> fascicle on it - "The Art of Computer Programming - Volume 4 Fascicle
> 2 - Generating All Tuples and Permutations" - 2005


Can you elaborate a bit on what you mean?
Given a list of unique elements, it is easy enough to produce a
complete permutation generator in Python,
in the sense that it yields every possible permuation.
(See my previous post.)  So you must mean
something else?

Cheers,
Alan Isaac

PS If the elements are not unique, that is easy enough to
deal with too, as long as you say what you want the
outcome to be.


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


Re: A PIL Question

2005-08-14 Thread Terry Hancock
On Sunday 14 August 2005 12:34 pm, Ray wrote:
> import Image
> 
> im = Image.open("something.jpg")
> seq = im.getdata()
> 
> image = Image.Image()
> image.putdata(seq)
> 
> image.show()
> 
> I always get:
> 
> Traceback (most recent call last):
>   File "Script1.py", line 31, in ?
> image.putdata(seq)
>   File "D:\Development\Python24\Lib\site-packages\PIL\Image.py", line
> 1120, in putdata
> self.im.putdata(data, scale, offset)
> AttributeError: 'NoneType' object has no attribute 'putdata'
> 
> Anybody has any idea why this is the case? 

Well, obviously you didn't get an image back from Image.Image().
In fact, I suspect you would've at least have to have given it a size
or something.  It clearly returned None, and you're trying to call
a method that None doesn't have, like it says.

Definitely check the PIL manual for what Image.Image() is
supposed to return, and what it requires to have valid output.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: A PIL Question

2005-08-14 Thread Max Erickson
"Ray" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> 
> image = Image.Image()

> 
> Anybody has any idea why this is the case? 
> 

Image.Image() isn't the way to get a new image object in PIL. Try
Image.new(), which needs at least mode and size arguments. You can get 
those from your original image...

>>> from PIL import Image
(skip me loading an image into im)
>>> im

>>> im.mode
'RGB'
>>> im.size
(510, 800)
>>> im2=Image.new(im.mode,im.size)
>>> seq=im.getdata()
>>> im2.putdata(seq)

Then do im2.show() and everything should be ok.


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


Re: A PIL Question

2005-08-14 Thread Cyril Bazin
Try Image.new in place of Image.Image if you want to build a new image.

At which level are you?

CyrilOn 14 Aug 2005 10:34:38 -0700, Ray <[EMAIL PROTECTED]> wrote:
Hello,I'm using latest PIL version with Python 2.4.1. (for solving a level inPython Challenge actually...). Anyway, I'm trying to draw a picture. Myquestion is, why is it that putdata() won't work? Even this won't run:
import Imageim = Image.open("something.jpg")seq = im.getdata()image = Image.Image()image.putdata(seq)image.show()I always get:Traceback (most recent call last):
  File "Script1.py", line 31, in ?image.putdata(seq)  File "D:\Development\Python24\Lib\site-packages\PIL\Image.py", line1120, in putdataself.im.putdata(data, scale, offset)
AttributeError: 'NoneType' object has no attribute 'putdata'Anybody has any idea why this is the case?Thanks,Ray--http://mail.python.org/mailman/listinfo/python-list

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

Re: FTP over SSL (explicit encryption)

2005-08-14 Thread David Isaac
"Eric Nieuwland" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm having a look at FTP/S right now. That's a little
> more complicated, but it seems doable.
> If I succeed, I guess I'll donate the stuff as an extension to ftplib.


Just found this:
http://trevp.net/tlslite/
I haven't even had time to try it,
but I thought you'd want to know.

Cheers,
Alan Isaac


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


Re: Euclid's Algorithm in Python?

2005-08-14 Thread James Dennett
Antoon Pardon wrote:

> On 2005-08-08, Bengt Richter <[EMAIL PROTECTED]> wrote:
> 
>>On 7 Aug 2005 17:31:02 -0700, "Jordan Rastrick" <[EMAIL PROTECTED]> wrote:
>>
>>
>>>Good point. I suppose I'd only ever seen it implemented with the if
>>>test, but you're right, the plain while loop should work fine. Silly
>>>me.
>>>
>>>def gcd(a,b):
>>>while b != 0:
>>>  a, b = b, a%b
>>>   return a
>>>
>>>Even nicer.
>>>
>>
>>what is the convention for handling signed arguments? E.g.,
> 
> 
> As far as I understand the convention is it doesn't make
> sense to talk about a gcd if not all numbers are positive.
> 
> I would be very interested if someone knows what the gcd
> of 3 and -3 should/would be.

Within the integers, common definitions of gcd don't distinguish
positive from negative numbers, so if 3 is a gcd of x and y then
-3 is also a gcd.  That's using a definition of gcd as something
like "g is a gcd of x and y if g|x and g|y and, for any h such
that h|x and h|y, h|g", i.e., a gcd is a common divisor and is
divisible by any other common divisor.  The word "greatest" in
this context is wrt the partial ordering imposed by | ("divides").
(Note that "|" in the above is the mathematical use as a|b if
there is an (integral) c such that ac=b, i.e., b is divisible
by a.  These definitions generalize to rings other than the
integers, without requiring a meaningful < comparison on the
ring.)

All of that said, it would be reasonable when working in the
integers to always report the positive value as the gcd, to
make gcd a simpler function.  For some applications, it won't
matter if you choose positive or negative, so going positive
does no harm, and others might be simplified by assuming gcd>0.

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


Re: FTP over SSL (explicit encryption)

2005-08-14 Thread David Isaac
> > http://www.lag.net/paramiko/

"Alan Isaac" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> sock.settimeout(20)
> sock.connect((hostname, port))
> my_t = paramiko.Transport(sock)
> my_t.connect(hostkey=None ,username=username, password=password,
pkey=None)
> my_chan = my_t.open_session()
> my_chan.get_pty()
> my_chan.invoke_shell()
> my_sftp = paramiko.SFTP.from_transport(my_t)
>
> Now my_sftp is a paramiko sftp_client.
> See paramiko's sftp_client.py to see what it can do.


When it rains it pours. wxSFTP
http://home.gna.org/wxsftp/
 uses paramiko and provides a GUI.

Cheers,
Alan Isaac


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


Re: FTP over SSL (explicit encryption)

2005-08-14 Thread Paul Rubin
"David Isaac" <[EMAIL PROTECTED]> writes:
> Just found this:
> http://trevp.net/tlslite/
> I haven't even had time to try it,
> but I thought you'd want to know.

Tlslite is a very well done and promising package, but in its present
form it's not really complete.  It's missing important functionality
(the ability to validate certificates) that it relies on complex 3rd
party C libraries to provide.  Hopefully tlslite will be able to do
this by itself sometime soon.
-- 
http://mail.python.org/mailman/listinfo/python-list


help with mysql cursor.execute()

2005-08-14 Thread William Gill
I have been trying to pass parameters as indicated in the api.
when I use:

   sql= 'select * from %s where cusid = %s ' % name,recID)
   Cursor.execute(sql)

it works fine, but when I try :

   sql= 'select * from %s where cusid like %s '
   Cursor.execute(sql,(name,recID))

or

   sql= 'select * from ? where cusid like ? '
   Cursor.execute(sql,(name,recID))

it fails.

Can someone help me with the semantics of using parameterized queries?

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


Re: help with mysql cursor.execute()

2005-08-14 Thread Scott David Daniels
William Gill wrote:
> I have been trying to pass parameters as indicated in the api.
> when I use:
>   sql= 'select * from %s where cusid = %s ' % name,recID)
>   Cursor.execute(sql)
> it works fine, but when I try :
>   sql= 'select * from %s where cusid like %s '
>   Cursor.execute(sql,(name,recID))
> or
>   sql= 'select * from ? where cusid like ? '
>   Cursor.execute(sql,(name,recID))
> it fails.
> Can someone help me with the semantics of using parameterized queries?

Neither column names nor table names can be parameters to
fixed SQL.  Values are what you fiddle with.  This squares with
the DBMS being allowed to plan the query before looking at the
parameters (deciding which indices to use, which tables to join
first, ...), then reusing the plan for identical queries with
different values.  MySQL may not take advantage of this two-step
approach, but the DB interface is designed to allow it, so
the parameterization is constrained.

See if something like this works:

 sql = 'select * from %s where cusid like ? ' % name
 Cursor.execute(sql, (recID,))

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


Re: pickle.load not working?

2005-08-14 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:

> it reads a file saved this way:
> --
> import pickle
> 
> class chatuser: #container for storing user information...
> login = ""
> authcode = ""
> cookie = ""
> ip = ""
> loggedin = 0
> invalid_logins = 0
> allow_login = 1
> status = ""
> realname = ""
> phone = ""
> email = ""
> 
> derek = chatuser

If this is copy and pasted and not just a typo then `derek` is just
another name for the `chatuser` class now and not an *instance* of it.

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


Re: How can I exclude a word by using re?

2005-08-14 Thread Bruno Desthuilliers
could ildg a écrit :
> Thank you.
> But what should I do if there are more than one hello and I only want
> to extract what's before the first "hello". 

Read The Fine Manual ?-)


> For example, the raw
> string is "hi, how are you? hello I'm fine, thank you hello. that's it
> hello", I want to extract all the stuff before the first hello?

re.findall(r'^(.*)hello', your_string_full_of_hellos)
-- 
http://mail.python.org/mailman/listinfo/python-list


cgi form validation problems

2005-08-14 Thread googleboy
Hi.

I am writing up my own web form. I'm a bit of a newb, and read up many
different how-tos and examples and documentaion.  I finally had it
working just great until I decided that I wanted to add some extra
logic because there's one form that submits a particular type of
information.  a little extra validation, and the creation of a list of
the values to be mailed in to the site manager.

The code below is where I am going wrong (edited for brevity):


form=cgi.FieldStorage()

rev_fields = { "param1":None, "param3":None, "param6":None,
"param5":None, "param8":None, "param9":None, "param10":None,
"param11":None }


# Everything worked until I added the following if statement:

if form.has_key("param8"):   #  Only one form has this
param8 = form.getvalue("param8")
if param8 == 0: # 0 is the default value
print "Content-type: text/html"
debug("You must give the item a rating")
for field in form.keys():
value = form[field].value
if rev_fields.has_key(field):
rev_fields[field] = value
for key in rev_fields:
if rev_fields[key] == None:
print "Content-type: text/html"
debug("All fields must be filled in. Please check your %s
submission." % key)
else:
#feedback = ("%s, %s, %s, %s, %s, %s, %s, %s" %
(form["param1"].value, form["param3"].value, form["param6"].
value, form["param5"].value, form["param8"].value,
form["param9"].value, form["param10"].value, form["param11"].value)
#feedback = ("%s, %s, %s, %s, %s, %s, %s, %s" %
(form.getvalue("param1"), form.getvalue("param3"), form.getvalue(
"param6"), form.getvalue("param5"), form.getvalue("param8"),
form.getvalue("param9"), form.getvalue("param10"),
form.getvalue("param11"))
feedback = ("%s, %s, %s, %s, %s, %s" %
(rev_fields["param1"], rev_fields["param3"], rev_fields["param6"],
rev_fields["param5"], rev_fields["param8"], rev_fields["param9"],
rev_fields["param10"], rev_fields["param11"])


#feedback = form[ "score" ].value

msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n Feedback: %s\r\n\r\n"
%
(rev_fields["param2"], rev_fields["param7"], rev_fields["param3"],
rev_fields["param6"]))


If I comment out the 'else:' logic, it works great.  But then I don't
get a list called feedback containing all teh bits I want,  The error I
get is really strange, too:

[Mon Aug 15 05:54:58 2005] [error] [client 60.224.106.116] Premature
end of script headers: /var/www/users/senta/html/gobooks/cgi/form.py
  File "/var/www/users/senta/html/gobooks/cgi/form.py", line 99
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n Feedback:
%s\r\n\r\n" %
  ^
SyntaxError: invalid syntax

Just a simple assignation  I did think it might have been an
indentation error, but I changed that around and got a message telling
me about an indentation problem, which this doesn't do.

I have tried several different ways to assign the values, as you can
see by the commented out lines.  Tried getting the values directly from
teh form, and also from the validated rev_fields dictionary.  I'd be
extremely grateful to anyone who helps me through this.

TIA

Googleboy

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


Re: help with mysql cursor.execute()

2005-08-14 Thread William Gill
I have been testing and it seems that:

1- Cursor.execute does not like '?' as a placeholder in sql

2- Cursor.execute accepts '%s' but puts the quotation mark around the 
substitution.

   sql = 'select * from %s where cusid = ? ' % name
   Cursor.execute(sql, (recID,))

still fails, but:

   sql = 'select * from basedata where cusid = %s '
   Cursor.execute(sql, (recID,))

works regardless of recID being a string or an int.  Obviously this 
stems from trying to parameterize the table name.

If I use:

   sql = 'select * from %s where cusid = %%s ' % name
   Cursor.execute(sql, (recID,))

It makes 1 substitution in the first line, and another in the execute()

   sql = 'select * from %s where cusid = %%s ' % name
   # sql now == 'select * from basedata where cusid = %s '
   Cursor.execute(sql, (recID,))

and it works.

Between your comments re: column names and table names , and the notes 
in cursor.py, I was able to figure it out.

FYI I wanted to create a tableHandler class that could be extended for 
individual tables.  That's why the query needs to accept variables for 
tablename.

Thanks.

Bill

Scott David Daniels wrote:
> William Gill wrote:
> 
>> I have been trying to pass parameters as indicated in the api.
>> when I use:
>>   sql= 'select * from %s where cusid = %s ' % name,recID)
>>   Cursor.execute(sql)
>> it works fine, but when I try :
>>   sql= 'select * from %s where cusid like %s '
>>   Cursor.execute(sql,(name,recID))
>> or
>>   sql= 'select * from ? where cusid like ? '
>>   Cursor.execute(sql,(name,recID))
>> it fails.
>> Can someone help me with the semantics of using parameterized queries?
> 
> 
> Neither column names nor table names can be parameters to
> fixed SQL.  Values are what you fiddle with.  This squares with
> the DBMS being allowed to plan the query before looking at the
> parameters (deciding which indices to use, which tables to join
> first, ...), then reusing the plan for identical queries with
> different values.  MySQL may not take advantage of this two-step
> approach, but the DB interface is designed to allow it, so
> the parameterization is constrained.
> 
> See if something like this works:
> 
> sql = 'select * from %s where cusid like ? ' % name
> Cursor.execute(sql, (recID,))
> 
> --Scott David Daniels
> [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Intalling psycopg

2005-08-14 Thread ys
Hi
 I am getting "ImportError: No module named psycopg"  i downloaded
windows binary from http://stickpeople.com/projects/python/win-psycopg/
It is intalled in python24\lib\site-packages\psycopg2\

please help! 

Thanks
YS

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


Persistent XMLRPC Connection

2005-08-14 Thread Chris Spencer
I noticed the SimpleXMLRPCServer/ServerProxy creates a new socket for 
remote procedure call. I've written a simple IP based authentication 
scheme for the Server, and I'd like to include the port in the 
authentication, which is currently not possible since the port keeps 
changing.

I've looked at the code in SimpleXMLRPCServer.py, xmlrpclib.py, 
SocketServer.py, and BaseHTTPServer.py, but it's a little overwhelming. 
How difficult would it be to reuse connections so that only one port per 
persistent client connection is used?

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


Re: Parsing a log file

2005-08-14 Thread googleboy
I am similarly not a programmer but am trying to learn python to do
tasks like this.   I would read through the regular expressions
tutorial.  You could probably easily read in all teh lines of the log
file,  and then split them up by " " (spaces)..

If you're right about the lines all being consistent, that should
easily handle each line.

>From there you could amost certainly drop off the trailling
milliseconds on the timestamps and do the simple data manipulation
you'd like.

here are a couple of links:

http://www.amk.ca/python/howto/regex/
http://gnosis.cx/publish/programming/regular_expressions.html

HTH

googleboy

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


Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Completly untested:

#!/usr/bin/env python

import sys, datetime

user = sys.argv[1]

starttime = None
for l in sys.stdin:
flds = l.strip().split()
datestr, timestr, prog, op, to, sname = flds
month, day, year = [int(x) for x in datestr.split("-", 2)]
hour, min, sec, ms = [int(x) for x in timestr.split(":")]
timestamp = datetime.datetime(year, month, day, hour, min, sec)
if op == 'CONNECTED':
assert starttime is None
starttime = timestamp
elif op == 'DISCONNECTED':
assert starttime is not None
endtime = timestamp
sql = "insert into data (start, end, user) value (%r, %r, %r);"
print sql % (starttime, endtime, user)
else:
raise AssertationError("%r is not a valid line" % l)



Am Sonntag, den 14.08.2005, 07:31 -0700 schrieb CG:
> Thanks Andreas,
> 
> In your first paragraph, you ask about incorrect input.  I guess it is
> possible, but without that information, my collection of the data is
> useless, so I really don't know what I would do with that.
> 
> As for the other stuff, I can hack the data in other ways, such as with
> VBA and MSAccess, which I am more familiar with, but I am trying to
> move to Linux and want to do it right the first time.  I figure Perl is
> the more common language for this kind of stuff, but I did want to try
> to learn some Python while I am at it.  I have started the tutorial,
> but being a businessman, time is an issue, which, if I had an example
> script that did a similar thing, I can learn by doing that (I am
> looking for something similar now).
> 
> I do live in a low-labor cost country, so I can hire someone to do it
> for a small amount of money, but Python people are a little harder to
> find.
> 
> Thanks for the comments,
> Clint
> 


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a log file

2005-08-14 Thread Andreas Kostyrka
Completly untested:

#!/usr/bin/env python

import sys, datetime

user = sys.argv[1]

starttime = None
for l in sys.stdin:
flds = l.strip().split()
datestr, timestr, prog, op, to, sname = flds
month, day, year = [int(x) for x in datestr.split("-", 2)]
hour, min, sec, ms = [int(x) for x in timestr.split(":")]
timestamp = datetime.datetime(year, month, day, hour, min, sec)
if op == 'CONNECTED':
assert starttime is None
starttime = timestamp
elif op == 'DISCONNECTED':
assert starttime is not None
endtime = timestamp
sql = "insert into data (start, end, user) value (%r, %r, %r);"
print sql % (starttime, endtime, user)
else:
raise AssertationError("%r is not a valid line" % l)



Am Sonntag, den 14.08.2005, 07:31 -0700 schrieb CG:
> Thanks Andreas,
> 
> In your first paragraph, you ask about incorrect input.  I guess it is
> possible, but without that information, my collection of the data is
> useless, so I really don't know what I would do with that.
> 
> As for the other stuff, I can hack the data in other ways, such as with
> VBA and MSAccess, which I am more familiar with, but I am trying to
> move to Linux and want to do it right the first time.  I figure Perl is
> the more common language for this kind of stuff, but I did want to try
> to learn some Python while I am at it.  I have started the tutorial,
> but being a businessman, time is an issue, which, if I had an example
> script that did a similar thing, I can learn by doing that (I am
> looking for something similar now).
> 
> I do live in a low-labor cost country, so I can hire someone to do it
> for a small amount of money, but Python people are a little harder to
> find.
> 
> Thanks for the comments,
> Clint
> 


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: wx.MessageDialog displayed without components inside

2005-08-14 Thread perchef
yes, it did work.

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


Python and games

2005-08-14 Thread Josiah Carlson

Perhaps some of you would get a kick out of this.
 - Josiah


Like XML, scripting was extremely useful as both a mod tool and an
internal development tool.  If you don't have any need to expose code
and algorithms in a simple and safe way to others, you can argue that
providing a scripting language is not worth the effort.  However, if you
do have that need, as we did, scripting is a no brainer, and it makes
complete sense to use a powerful, documented, cross-platform standard
such as Python.
Python, like many good technologies, soon spreads virally throughout
your development team and finds its way into all sorts of applications
and tools.  In other words, Python begins to feel like a big hammer and
coding tasks look like nails.

 - Mustafa Thamer, Firaxis Games (talking about Civilization IV)
   Page 18, August 2005 Game Developer magazine
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Standalone applications ?

2005-08-14 Thread Maurice LING
henne wrote:
>  > I should have added that my platform is Linux.
> 
> http://davidf.sjsoft.com/mirrors/mcmillan-inc/install1.html
> 
> Squeeze works on Linux too.

It tells me that the installer files are not found.
M
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe: no exe produced?

2005-08-14 Thread Titi Anggono
I never use python2.4, I use python 2.3 and here is
(maybe it works). For example,  the hello.py is under
directory
C:\Python23\latihan\
and put the setup.py under that directory
--
#setup.py
from distutils.core import setup
import py2exe

setup(console=["hello.py"])
---
C:\Python23\latihan>python setup.py py2exe


--- [EMAIL PROTECTED] wrote:

> I tried py2exe the latest version with python 2.4 on
> windows.
> 
> the setup script looks like this:
> ___
> 
> # setup.py
> from distutils.core import setup
> import py2exe
> 
> setup(name="Hello",
>   scripts=["f:\python\hello.py"],)
> 
> 
> 
> when I run the script, the output looks like
> 
> F:\Python>python setup.py py2exe
>

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Loading classes dynamically

2005-08-14 Thread Ramza Brown
What is the most pythonic way to load a class and instaniate an object 
dynamically.  Right now, I am using eval:

try:
  load = eval('%s(props)' % (props['plugin.generate']))
except:

It works, doesnt seem very safe.  Where props['plugin.generate'] is a 
class name string.  And 'props' is the first arg in the constructor.

What do you think?

-- 
Ramza from Atlanta
http://www.newspiritcompany.com
-- 
http://mail.python.org/mailman/listinfo/python-list


distutils on Win32 using .NET Framework SDK

2005-08-14 Thread Jerry He
Hi, 
  I was trying to build a C++ extension on Win32 with
distutils. The extension worked on Cygwin but when I
tried it with the Win32-build python, it complained
that I don't have .NET Framework SDK installed. But
after I installed .NET Framework SDK 2.0, it still
complains
"error: The .NET Framework SDK needs to be installed
before building extensions for Python." (I also did
try restarting my computer)

Does anyone know how to make the .NET Framework SDK
visible to Python?  

thanks in advance, 

-Jerry

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


python-Excel: Chinese Characters

2005-08-14 Thread zxo102
Hi there,
I am trying to put data including Chinese Characters into Excel
through python. But I got some problems. Here is my sample code:

##
#
import win32com.client
xlapp  = win32com.client.DispatchEx("Excel.Application")
xlbook = xlapp.Workbooks.Open("test.xls")
sht= xlbook.Worksheets("Sheet1")

# data is provided in case 1 and case 2 below
...
sht.Range(sht.Cells(1, 1), sht.Cells(2,4)).Value = data
#
##

Using the above code, I tested two cases for "data". The "data" from
both two cases are same: tuple basically. But in case 1, only  and
 are inserted into Excel. All other cells are blank. in case2, all
data including Chinese Characters are inserted into Excel and
everything is fine. My real data is like case 1.



#case 1 --
rp = {'r1':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'],
  'r2':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'],
  'r3':[,],
  'r4':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6']
 }

b = ()
for k in range(len(rp['r1'])):
a = rp['r1'][k],rp['r2'][k],rp['r3'][k],rp['r4'][k]
if len(b) == 0:
b = a
else:
b = b,a
data = b

#case 2 --
data   =(('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', ,
'\xd6\xd7\xc1\xf6'),
('\xd6\xd7\xc1\xf6", '\xd6\xd7\xc1\xf6", ,
'\xd6\xd7\xc1\xf6'))

Anybody knows what is going on with it?

Thanks for your help.

Ouyang

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


Re: Spaces and tabs again

2005-08-14 Thread Paul Watson
Dan Sommers wrote:
> On Sun, 14 Aug 2005 01:04:04 GMT,
> Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> 
> 
>>On 13 Aug 2005 13:18:21 -0700, [EMAIL PROTECTED] declaimed the following
>>in comp.lang.python:
> 
> 
>>>Are you kidding? You are going to MANDATE spaces?
>>>
>>
>>  After the backlash, Python 4.0 will ban leading spaces and require
>>tabs 
> 
> 
> Why not petition the unicode people to include PYTHON INDENT and PYTHON
> DEDENT code points, and leave the display up to the text editors?  ;-)
> 
> Regards,
> Dan

The Unicode people will correctly point out that there is already a 
Unicode codepoint assignment which can be used for this purpose.  It is 
even in the BMP portion of the C0 controls group.

 0009 = HORIZONTAL TABULATION
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and games

2005-08-14 Thread Eric Lavigne
>Like XML, scripting was extremely useful as both a mod tool and an
>internal development tool.  If you don't have any need to expose code
>and algorithms in a simple and safe way to others, you can argue that
>providing a scripting language is not worth the effort.  However, if you
>do have that need, as we did, scripting is a no brainer, and it makes
>complete sense to use a powerful, documented, cross-platform standard
>such as Python.

The Torque Game Engine at www.garagegames.com is written in C++ and
comes with a customized scripting language, torquescript, with a c-like
syntax. Despite that, some game developers decided to add Python as
another scripting layer on top of torquescript. The modified version of
Torque is called PyTorque. I never tried PyTorque, but looking back on
my time with torquescript this sounds like a very good idea.
Torquescript was fine for convenient access to Torque features, but it
never felt as flexible as a general-purpose language like Python. I
expect that the Torque development team could have saved themselves a
lot of trouble by using Python as an extension language to begin with.

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


GUI tookit for science and education

2005-08-14 Thread Mateusz Łoskot
Hi,

I'd like to ask some scientists or students
which GUI toolkit they would recommend
to develop scientific prototypes (for education and
testing some theories).
I think such toolkit should fill a bit different
needs and requirements:
- very simple to learn
- easy to install
- beautyfiers and advanced features are not required like OpenGL,
direct access to Windows GDI subsystem, beauty look and skinning
- multiplatform required

Let's say someone has big amount of algorithms and
statistical models implemented in Pascal
(not well designed console apps).
Now he want to move on using better and modern language
and GUI toolkit.
Python is seleceted as user friendly and simple
language, Pascal successor.

Thank you for any piece of advice in advance.
Regards
-- 
Mateusz Łoskot, mateusz (at) loskot (dot) net
Registered Linux User #220771
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI tookit for science and education

2005-08-14 Thread Paul Rubin
Mateusz £oskot <[EMAIL PROTECTED]> writes:
> Thank you for any piece of advice in advance.

Ask yourself why you want a GUI toolkit.  Maybe you can write a web
application instead, and use a browser as the GUI.  That's a lot
easier to write (just use html), and makes it trivial to run the
application and the browser on separate machines.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-Excel: Chinese Characters

2005-08-14 Thread John Machin
zxo102 wrote:
> Hi there,
> I am trying to put data including Chinese Characters into Excel
> through python. But I got some problems. Here is my sample code:
> 
> ##
> #
> import win32com.client
> xlapp  = win32com.client.DispatchEx("Excel.Application")
> xlbook = xlapp.Workbooks.Open("test.xls")
> sht= xlbook.Worksheets("Sheet1")
> 
> # data is provided in case 1 and case 2 below
> ...
> sht.Range(sht.Cells(1, 1), sht.Cells(2,4)).Value = data
> #
> ##
> 
> Using the above code, I tested two cases for "data". The "data" from
> both two cases are same: tuple basically. But in case 1, only  and
>  are inserted into Excel. All other cells are blank. in case2, all
> data including Chinese Characters are inserted into Excel and
> everything is fine. My real data is like case 1.
> 
> 
> 
> #case 1 --
> rp = {'r1':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'],
>   'r2':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'],
>   'r3':[,],
>   'r4':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6']
>  }
> 
> b = ()
> for k in range(len(rp['r1'])):
> a = rp['r1'][k],rp['r2'][k],rp['r3'][k],rp['r4'][k]
> if len(b) == 0:
> b = a
> else:
>   b = b,a
> data = b
> 
> #case 2 --
> data   =(('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', ,
> '\xd6\xd7\xc1\xf6'),
> ('\xd6\xd7\xc1\xf6", '\xd6\xd7\xc1\xf6", ,

Bulldust alert! Syntax error caused by starting 2 strings with ' and 
ending with "

> '\xd6\xd7\xc1\xf6'))
> 
> Anybody knows what is going on with it?

No. How could we know??? Try showing us *EXACTLY* what code you ran.

FWIW, correcting the " to ' above shows no difference in the two cases:

C:\junk>type ouyang.py
rp = {'r1':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'],
   'r2':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'],
   'r3':[,],
   'r4':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6']
  }

b = ()
for k in range(len(rp['r1'])):
 a = rp['r1'][k],rp['r2'][k],rp['r3'][k],rp['r4'][k]
 if len(b) == 0:
 b = a
 else:
 b = b,a
data1 = b

#case 2 --
data2 =(('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', , '\xd6\xd7\xc1\xf6'),
 ('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', ,'\xd6\xd7\xc1\xf6'))

print
print "data1", repr(data1)
print "data2", repr(data2)
print data1 == data2

C:\junk>ouyang.py

data1 (('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', , 
'\xd6\xd7\xc1\xf6'), ('\xd
6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', , '\xd6\xd7\xc1\xf6'))
data2 (('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', , 
'\xd6\xd7\xc1\xf6'), ('\xd
6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', , '\xd6\xd7\xc1\xf6'))
True
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: client server question

2005-08-14 Thread John
Thanks a lot,
I think I could modify this to get my work done.
--j

Chris Curvey wrote:
> import threading
> import logging
>
> ##
> class Reader(threading.Thread):
> def __init__(self, clientsock):
>   threading.Thread.__init__(self)
>   self.logger = logging.getLogger("Reader")
>
> #-
> def run(self):
> self.logger.info("New child %s" %
> (threading.currentThread().getName()))
> self.logger.info("Got connection from %s" %
> (clientsock.getpeername()))
>
> 
> # set up a socket to listen for incoming connections from our clients
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> s.bind((host, port))
> s.listen(1)
>
> while True:
> try:
> clientsock, clientaddr = s.accept()
> except KeyboardInterrupt:
> raise
> except:
> traceback.print_exc()
>   continue
>
> client = Reader(clientsock)
> client.setDaemon(1)
> client.start()

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


Re: Spaces and tabs again

2005-08-14 Thread John Machin
Paul Watson wrote:
> Dan Sommers wrote:
> 
>> On Sun, 14 Aug 2005 01:04:04 GMT,
>> Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>>
>>
>>> On 13 Aug 2005 13:18:21 -0700, [EMAIL PROTECTED] declaimed the following
>>> in comp.lang.python:
>>
>>
>>
 Are you kidding? You are going to MANDATE spaces?

>>>
>>> After the backlash, Python 4.0 will ban leading spaces and require
>>> tabs 
>>
>>
>>
>> Why not petition the unicode people to include PYTHON INDENT and PYTHON
>> DEDENT code points, and leave the display up to the text editors?  ;-)
>>
>> Regards,
>> Dan
> 
> 
> The Unicode people will correctly point out that there is already a 
> Unicode codepoint assignment which can be used for this purpose.  It is 
> even in the BMP portion of the C0 controls group.
> 
> 0009 = HORIZONTAL TABULATION

and how do you use this to get the DEDENT effect? Use something out of 
the bidirectional kit? E.g. RLO then tab then PDF ;-)

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


Re: Loading classes dynamically

2005-08-14 Thread Steven Bethard
Ramza Brown wrote:
> try:
>  load = eval('%s(props)' % (props['plugin.generate']))
> except:
> 
> It works, doesnt seem very safe.  Where props['plugin.generate'] is a 
> class name string.  And 'props' is the first arg in the constructor.

Where is the class defined?  The right answer to this is usually 
somethign like:

 load = getattr(some_module, props['plugin.generate'])(props)

If the class is defined in the current module, another possibility is:

 load = globals()[props['plugin.generate']](props)

HTH,

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


Re: Spaces and tabs again

2005-08-14 Thread Paul Watson
John Machin wrote:
> Paul Watson wrote:
> 
>> Dan Sommers wrote:
>>
>>> On Sun, 14 Aug 2005 01:04:04 GMT,
>>> Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>>>
>>>
 On 13 Aug 2005 13:18:21 -0700, [EMAIL PROTECTED] declaimed the 
 following
 in comp.lang.python:
>>>
>>>
>>>
>>>
> Are you kidding? You are going to MANDATE spaces?
>

 After the backlash, Python 4.0 will ban leading spaces and require
 tabs 
>>>
>>>
>>>
>>>
>>> Why not petition the unicode people to include PYTHON INDENT and PYTHON
>>> DEDENT code points, and leave the display up to the text editors?  ;-)
>>>
>>> Regards,
>>> Dan
>>
>>
>>
>> The Unicode people will correctly point out that there is already a 
>> Unicode codepoint assignment which can be used for this purpose.  It 
>> is even in the BMP portion of the C0 controls group.
>>
>> 0009 = HORIZONTAL TABULATION
> 
> 
> and how do you use this to get the DEDENT effect? Use something out of 
> the bidirectional kit? E.g. RLO then tab then PDF ;-)

The use of one less HORIZONTAL TABULATION on a line in relation to the 
number of HORIZONTAL TABULATION codepoints used by the pervious line 
indicated "dedent" as you call it. :-)

There are things about your suggestion that would be great!  It would 
require a language aware editing tool to be used.  Like HTML was 
intended, the rendering of the program source would be managed by the 
tool.  Everyone could choose the style in which they would like to 
interact with the code.

This is also the biggest problem.  It would mean that a specialized 
editor tool would be required.  One could not just use a POTE (Plain Old 
Text Editor).

Using U+0009 HORIZONTAL TABULATION would provide both user selectable 
rendering style as well as access through most existing tools.

Of course, there is always 'expand' and 'unexpand' if you are really 
desparate.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spaces and tabs again

2005-08-14 Thread John Machin
Paul Watson wrote:
> John Machin wrote:
> 
>> Paul Watson wrote:
>>
>>> Dan Sommers wrote:
>>>
 On Sun, 14 Aug 2005 01:04:04 GMT,
 Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:


> On 13 Aug 2005 13:18:21 -0700, [EMAIL PROTECTED] declaimed the 
> following
> in comp.lang.python:





>> Are you kidding? You are going to MANDATE spaces?
>>
>
> After the backlash, Python 4.0 will ban leading spaces and require
> tabs 





 Why not petition the unicode people to include PYTHON INDENT and PYTHON
 DEDENT code points, and leave the display up to the text editors?  ;-)

 Regards,
 Dan
>>>
>>>
>>>
>>>
>>> The Unicode people will correctly point out that there is already a 
>>> Unicode codepoint assignment which can be used for this purpose.  It 
>>> is even in the BMP portion of the C0 controls group.
>>>
>>> 0009 = HORIZONTAL TABULATION
>>
>>
>>
>> and how do you use this to get the DEDENT effect? Use something out of 
>> the bidirectional kit? E.g. RLO then tab then PDF ;-)
> 
> 
> The use of one less HORIZONTAL TABULATION on a line in relation to the 
> number of HORIZONTAL TABULATION codepoints used by the pervious line 
> indicated "dedent" as you call it. :-)
> 
> There are things about your suggestion that would be great!  It would 
> require a language aware editing tool to be used.  Like HTML was 
> intended, the rendering of the program source would be managed by the 
> tool.  Everyone could choose the style in which they would like to 
> interact with the code.
> 
> This is also the biggest problem.  It would mean that a specialized 
> editor tool would be required.  One could not just use a POTE (Plain Old 
> Text Editor).
> 
> Using U+0009 HORIZONTAL TABULATION would provide both user selectable 
> rendering style as well as access through most existing tools.
> 
> Of course, there is always 'expand' and 'unexpand' if you are really 
> desparate.

OK Paul, you've convinced me. I look forward to your PEP "Mandated 
U+0009 HORIZONTAL TABULATION in Python source".
Cheers,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Dynamic autoscaling of axes with pyqwt ?

2005-08-14 Thread Madhusudan Singh
How does one enable dynamic autoscaling of the axes ?

I am using setAxisAutoScale in an application which acquires data, and when
the application ends, I do get correctly autoscaled axes, but not while the
measurement is in progress.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils on Win32 using .NET Framework SDK

2005-08-14 Thread Martin v. Löwis
Jerry He wrote:
> Hi, 
>   I was trying to build a C++ extension on Win32 with
> distutils. The extension worked on Cygwin but when I
> tried it with the Win32-build python, it complained
> that I don't have .NET Framework SDK installed. But
> after I installed .NET Framework SDK 2.0, it still
> complains
> "error: The .NET Framework SDK needs to be installed
> before building extensions for Python." (I also did
> try restarting my computer)
> 
> Does anyone know how to make the .NET Framework SDK
> visible to Python?  

It looks in
HKEY_{LOCAL_MACHINE,CURRENT_USER}\Software\Microsoft\.NETFramework\FrameworkSDKDir

This registry key should be set automatically if you choose to
install the SDK that comes with Microsoft Visual Studio 2003.
Not sure why you are trying to install .NET 2.0, though.

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


Re: How can I exclude a word by using re?

2005-08-14 Thread Peter Otten
could ildg wrote:

> But what should I do if there are more than one hello and I only want
> to extract what's before the first "hello". For example, the raw
> string is "hi, how are you? hello I'm fine, thank you hello. that's it
> hello", I want to extract all the stuff before the first hello?

The simplest solution is to use str.split():

>>> helo = "hi, how are you? HELLO I'm fine, thank you hello. that's it"
>>> helo.split("hello", 1)[0]
"hi, how are you? HELLO I'm fine, thank you "

But regular expressions offer a similar feature:

>>> re.compile("hello", re.IGNORECASE).split(helo, 1)[0]
'hi, how are you? '

Peter

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


Re: how to write thread-safe module ? and pytz

2005-08-14 Thread nicolas_riesch
Thank you very much for all your explanation !
Your pytz module is great !

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