Re: Microsoft Hatred FAQ

2005-10-18 Thread John Bokma
Roedy Green <[EMAIL PROTECTED]> wrote:

> On 18 Oct 2005 06:20:56 GMT, John Bokma <[EMAIL PROTECTED]> wrote
> or quoted :
> 
>>
>>That an HTML standard (ISO/IEC 15445:2000) and an HTML recommendation by 
>>w3c (4.01 for example) are two different things, and mixing them up by 
>>calling both standards is a bad thing.
> 
> Because ... what are the consequences?

If you mean if you are put in jail for 20 years, and tortured, none.

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
I ploink googlegroups.com :-)

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


Re: bug in os.system?

2005-10-18 Thread wjzrules
What happens when you try it without the single quotes?
 result = os.system("pythonbugtest.exe" "test")

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


Re: Microsoft Hatred FAQ

2005-10-18 Thread Peter T. Breuer
In comp.os.linux.misc Richard Steiner <[EMAIL PROTECTED]> wrote:
> Here in comp.os.linux.misc,
> John Wingate <[EMAIL PROTECTED]> spake unto us, saying:

>>Peter T. Breuer <[EMAIL PROTECTED]> wrote:

>>> It seems to me that I was using 3.x. Maybe it was 3.1? I seem to
>>> remember an earlier major ... was there a 2.8 or 2.9?
>>
>>Dunno.  The first version I used was 3.4, in 1987.

> MS-DOS 3.3 was the most popular DOS release back in 1987/1988.  I don't
> recall there ever being a 3.4 release, though.

We were talking sunOS. At least I was!

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


Re: Dynamic generation of doc-strings of dynamically generated classes

2005-10-18 Thread Mikael Olofsson
Alex Martelli wrote:
> The best way to make classes on the fly is generally to call the
> metaclass with suitable parameters (just like, the best way to make
> instances of any type is generally to call that type):
> 
> derived = type(base)('derived', (base,), {'__doc__': 'zipp'})

and George Sakkis said something similar.

Thanks, both of you. As I expected, there was a much better way than my 
clumsy way. Anyway, this took me to section 3.3.3 in the reference 
manual, and that will help me further.

Thanks again. Back to the keyboard!

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


Re: Don't want to serialize a variable of object

2005-10-18 Thread Tarek Ziadé
Iyer, Prasad C wrote:

>Hi,
>I got a class which I need to serialize, except for couple of variable.
>i.e.
>
>import cPickle as p
>class Color:
>def __init__(self):
>print "hello world"
>self.x=10
>self.somechar="this are the characters"
>color=Color()
>f=file('poem.txt', 'w')
>p.dump(color, f)
>f.close()
>
>How do I serialize the object color without serializing the x and
>somechar variables?
>Is there any modifier which prevents the variable from being serialized.
>  
>
You can create your own serialization process, by providing some kind of 
serialize() method
 in a base class that would dump part of the object.

Let's say, the instance __dict__ dictionnary ?
this serialize method can then remove the attributes that starts with '_v_'
(that's what we do in Zope to avoid pickling some attribute)

>
>
>
>Another question:
>   Is there a concept of private variables?
>  
>
That's a long discussion, you should look at the archives in the list.

But anyway, all attributes that starts with '__' are considered private 
to the class.
(ie: can't be reached by "instance.__attribute")

even though you can find it if you dig into instance.__dict__


Regards,

Tarek

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


Re: bug in os.system?

2005-10-18 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> What happens when you try it without the single quotes?
>  result = os.system("pythonbugtest.exe" "test")
> 
That would be equivalent to

   result = os.system("pythonbugtest.exetest")

which almost certainly won't do anything useful.

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

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


make: circular dependency for Modules/signalmodule.o

2005-10-18 Thread James Buchanan
Hi group,

I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I
have problems with make.  configure runs fine and creates the makefile,
but right at the end ends with an error about a circular dependency in
Modules/signalmodule.o.

I'm new to makefiles and makefile rules, so I can understand what this
means, but I don't know how I can fix this problem.  Looks like I'll
need to rewrite one or more makefile rules and during Minix builds add
some code to patch it up for those rules (as opposed to perhaps porting
a more capable `make` like gmake right now).

Can someone please help me make this problem go away?

Thanks!
James Buchanan

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


RE: Don't want to serialize a variable of object

2005-10-18 Thread Iyer, Prasad C

Thanks a lot.

Actually you are right I would be trying same thing now.
Writing my own custom serializable for the object.

But everyone else who face the same problem would come up with their own
Serializable code.

Can't we plug something into cpickle So that it discards some variable from 
being serializable. Similar to __data for private variables. But on second 
thought that would be too much of change that I am asking.

Anyway thanks a lot.

regards
prasad chandrasekaran










--- Cancer cures smoking

#-Original Message-
#From: Tarek Ziadé [mailto:[EMAIL PROTECTED]
#Sent: Tuesday, October 18, 2005 1:01 PM
#To: Iyer, Prasad C
#Cc: python-list@python.org
#Subject: Re: Don't want to serialize a variable of object
#
#Iyer, Prasad C wrote:
#
#>Hi,
#>I got a class which I need to serialize, except for couple of variable.
#>i.e.
#>
#>import cPickle as p
#>class Color:
#>def __init__(self):
#>print "hello world"
#>self.x=10
#>self.somechar="this are the characters"
#>color=Color()
#>f=file('poem.txt', 'w')
#>p.dump(color, f)
#>f.close()
#>
#>How do I serialize the object color without serializing the x and
#>somechar variables?
#>Is there any modifier which prevents the variable from being serialized.
#>
#>
#You can create your own serialization process, by providing some kind of
#serialize() method
# in a base class that would dump part of the object.
#
#Let's say, the instance __dict__ dictionnary ?
#this serialize method can then remove the attributes that starts with '_v_'
#(that's what we do in Zope to avoid pickling some attribute)
#
#>
#>
#>
#>Another question:
#>  Is there a concept of private variables?
#>
#>
#That's a long discussion, you should look at the archives in the list.
#
#But anyway, all attributes that starts with '__' are considered private
#to the class.
#(ie: can't be reached by "instance.__attribute")
#
#even though you can find it if you dig into instance.__dict__
#
#
#Regards,
#
#Tarek


This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.

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


Re: Don't want to serialize a variable of object

2005-10-18 Thread Duncan Booth
Iyer, Prasad C wrote:

> How do I serialize the object color without serializing the x and
> somechar variables?
> Is there any modifier which prevents the variable from being serialized.
> 
See the pickle documentation. The example given in the documentation 
pickles a class while excluding one of its attributes.

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

> Another question:
>  Is there a concept of private variables?

'private variables' can mean either of two things: hiding the variables to 
prevent accidental naming conflicts in subclasses, or security to prevent 
malicious manipulation of a class's internal state.

Python provides the former (to a certain extent) when you give an attribute 
a name prefixed with a double underscore, but makes no attempt to provide 
the latter. Some other languages (such as C++) make no attempt to provide 
the former and a completely inadequate attempt at the latter.

In other words: Python has a concept of private variables, but it is 
different than in some other languages, and if you google past threads you 
can find endless discussions on the pro's and con's of the Python approach.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-18 Thread Tim Tyler
In comp.lang.java.programmer Paul Rubin  wrote or 
quoted:
> Tim Tyler <[EMAIL PROTECTED]> writes:

> > Are there any examples of HTML email causing security problems - outside
> > of Microsoft's software?
> 
> There was a pretty good one that went something like
> 
>   Click this link to download latest security patch!
>http://www.mxx.com.>Microsoft Security Center
> 
> where "mxx" is "microsoft" with the letter "i" replaced by some
> exotic Unicode character that looks exactly like an ascii "i" in normal 
> screen fonts.  The attacker had of course registered that domain and
> put evil stuff there.

I didn't think unicode domain names existed.

It seems that they are in the pipeline:

``After much debate and many competing proposals, a system called 
  Internationalizing Domain Names in Applications (IDNA) was adopted as 
  the chosen standard, and is currently, as of 2005, in the process of 
  being rolled out.''

 - http://en.wikipedia.org/wiki/Internationalized_domain_names

It looks like the security issues are probably going to be dealt
with via technical fixes:

``On February 17, 2005, Mozilla developers announced that they would ship 
  their next versions of their software with IDN support still enabled, 
  but showing the punycode URLs instead, thus thwarting any attacks while 
  still allowing people to access websites on an IDN domain. This is a 
  change from the earlier plans to disable IDN entirely for the time 
  being.''

 - http://en.wikipedia.org/wiki/Internationalized_domain_names

Anyway, I'm inclined to suggest this is a DNS problem.  It would
apply to any format that allowed rendering of domain names using
the unicode character set they are intended to be displayed using.

Even without unicode, the "homograph attack" is still viable, due
to things like the "l"/"I" issue in many fonts - as pointed out on:

http://www.centr.org/docs/2005/02/homographs.html
-- 
__
 |im |yler  http://timtyler.org/  [EMAIL PROTECTED]  Remove lock to reply.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-18 Thread Richie Hindle

[Ken]
> Web interfaces are missing a lot more than this. Here are just a few  
> things that cannot be done with web-based interfaces (correct me  
> where I'm wrong):
> 
> 1) A real word processor.

http://www.writely.com/
http://www.goffice.com/

> 2) Keybindings in a web application

http://rememberthemilk.com/
Google Keys (but what happened to it?  It's disappeared!)

> 3) Drag and drop

http://www.walterzorn.com/dragdrop/dragdrop_e.htm

http://qooxdoo.oss.schlund.de/demo/release/public/test/user/Index.html
(pick "Drag and Drop N" from the dropdown on the right hand side of the top
bar)

> 4) Resizable windows (i.e. not the browser window) within the  
> application.

http://qooxdoo.oss.schlund.de/demo/release/public/test/user/Index.html
(pick "Window N" from the dropdown on the right hand side of the top bar)

http://www.bindows.net/ (click "Click for a quick DEMO")

> 5) Anything other than absolutely trivial graphical programs.

Not sure what you mean by this... Google maps?

> web interfaces are still basically forms that can contain  
> buttons, checkboxes, text fields, and a few other basic controls. I  
> wish it were otherwise.

It *is* otherwise.  You should follow the Ajaxian weblog here:
http://www.ajaxian.com/

-- 
Richie Hindle
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: override a property

2005-10-18 Thread Robin Becker
Bruno Desthuilliers wrote:
> Robin Becker a écrit :
> 
>> Is there a way to override a data property in the instance? Do I need 
>> to create another class with the property changed?
> 
> 
> Do you mean attributes or properties ?

I mean property here. My aim was to create an ObserverProperty class 
that would allow adding and subtracting of set/get observers. My current 
implementation works fine for properties on the class, but when I need 
to specialize an instance I find it's quite hard.

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


Re: Jargons of Info Tech industry

2005-10-18 Thread Tim Tyler
In comp.lang.java.programmer Ross Bamford <[EMAIL PROTECTED]> wrote or quoted:

> Roedy, I would just _love_ to see the response from the industry when you  
> tell them they should dump their whole mail infrastructure, and switch  
> over to a whole new system (new protocols, new security holes, new  
> problems start to finish). [...]

That's essentially what the IM folk did.

It seems quite possible that future email systems will evolve out of
existing IM ones.

Essentially, IM can do pretty-much everything email can these days, but 
the reverse is not true at all.

IM also seems more evolvable than email is managing to be.

About all email has going for it these days is an open format and a
large existing user base.
-- 
__
 |im |yler  http://timtyler.org/  [EMAIL PROTECTED]  Remove lock to reply.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-18 Thread Alex Martelli
Paul Rubin  wrote:

> Torsten Bronger <[EMAIL PROTECTED]> writes:
> > Because everybody is capable of running a JS engine, even on
> > computers on which you don't have rights to install something.
> 
> I don't think using JS so heavily without a compelling reason is
> really in the WWW spirit.  Lots of browsers don't have JS.  And lots
> of JS is so annoying that some users like to turn it off even in
> browsers that have it.

I don't have the exact numbers, and I'm pretty certain they'd be
confidential if I did, but I believe the factors you mention (browsers
completely lacking JS, and users turning JS off), *combined*, still
allow JS-rich interfaces to run for well over 95% of visitors to our
sites.  Maybe that's the key difference between the mindset of a
mathematician and that of an engineer -- I consider reaching over 95% of
visitors to be _quite good indeed_, while you appear to disagree because
of "WWW spirit" issues.  Is making a rapidly responsive site (not
requiring roundtrips for every interaction) a "compelling reason"?  It
seems to me that it is -- and why else would one use ANY Javascript,
after all?

My one issue with the JS/AJAX mania is that I really dislike JS as a
language, particularly when you take the mixed mongrel dialect that you
do need to reach all the various browsers and releases needed to make
that 95% goal.  But, alas, there is really no alternative!-(


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


Re: Jargons of Info Tech industry

2005-10-18 Thread Tim Tyler
Gordon Burditt <[EMAIL PROTECTED]> wrote or quoted:

> Before worrying about the possible bugs in the implementations,
> worry about security issues present in the *DESIGN*.  Email ought
> to be usable to carry out a conversation *SAFELY* with some person out
> to get you.  Thus features like this are dangerous (in the *design*,
> not because they *might* hide a buffer-overflow exploit):
> 
> - Hyperlinks to anything *outside* the email in which the link
>   resides ("web bugs").

Acceptable risk, IMO.

> - Any ability to automatically generate hits on sender-specified
>   servers when the email is read.

I hadn't though of that one.  As well as use in DDOS attacks, that
can help let spammers know if they have reached a human :-|

Even a link in a plain text email can be used (though with reduced
effectiveness) in such a context :-(
-- 
__
 |im |yler  http://timtyler.org/  [EMAIL PROTECTED]  Remove lock to reply.
-- 
http://mail.python.org/mailman/listinfo/python-list


global interpreter lock

2005-10-18 Thread Tommy . Ryding
I just need confirmation that I think right.

Is the files thread_xxx.h (xxx = nt, os2 or whatever) responsible for
the
global interpreter lock in a multithreaded environment?

I'm currently writing my own thread_VW for VxWorks, thats why I'm
asking. 

//Tommy

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


Re: Vim capable IDE?

2005-10-18 Thread bruno modulix
Chris Lasher wrote:
> Hello,
>   Is there a Python-sensitive, Linux compatible IDE out there with
> standard bells and whistles (source browser, symbolic debugger, etc.)
> but with the action-per-keystroke editing capabilities of Vim? I have
> failed to turn up such an IDE in my Googling and IDE project-page
> browsing. :-(

What about a Python IDE that embed Vim as it's editor ?
http://pida.berlios.de/index.php/Main_Page

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-18 Thread Roedy Green
On Tue, 18 Oct 2005 07:40:26 GMT, Tim Tyler <[EMAIL PROTECTED]>  wrote
or quoted :

>I didn't think unicode domain names existed.

you can even buy them. See http://mindprod.com/jgloss/domainnames.html

under "Chinese Domain Names".
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: override a property

2005-10-18 Thread bruno modulix
Robin Becker wrote:
> Bruno Desthuilliers wrote:
> 
>> Robin Becker a écrit :
>>
>>> Is there a way to override a data property in the instance? Do I need
>>> to create another class with the property changed?
>>
>>
>>
>> Do you mean attributes or properties ?
> 
> 
> I mean property here.

Ok, wasn't sure... And sorry, but I've now answer.

> My aim was to create an ObserverProperty class
> that would allow adding and subtracting of set/get observers. 

Could you elaborate ? Or at least give an exemple ?

> My current
> implementation works fine for properties on the class, but when I need
> to specialize an instance I find it's quite hard.



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-18 Thread Roedy Green
On 18 Oct 2005 06:57:47 GMT, John Bokma <[EMAIL PROTECTED]> wrote
or quoted :

>>>That an HTML standard (ISO/IEC 15445:2000) and an HTML recommendation by 
>>>w3c (4.01 for example) are two different things, and mixing them up by 
>>>calling both standards is a bad thing.
>> 
>> Because ... what are the consequences?
>
>If you mean if you are put in jail for 20 years, and tortured, none.

No. ANY consequences.  You have not explained the downside.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question on class member in python

2005-10-18 Thread Johnny Lee
But I still wonder what's the difference between the A().getMember and
A().member besides the style

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


Re: Jargons of Info Tech industry

2005-10-18 Thread Roedy Green
On Tue, 18 Oct 2005 08:12:23 GMT, Tim Tyler <[EMAIL PROTECTED]>  wrote
or quoted :

>> - Any ability to automatically generate hits on sender-specified
>>   servers when the email is read.
>
>I hadn't though of that one.  As well as use in DDOS attacks, that
>can help let spammers know if they have reached a human :-|

If you think about it, much as you hate spammers you WANT them to have
that information. If you never read spam, and they know that, they
eventually might stop sending it to you and focus on the nitwits who
read it.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-18 Thread Roedy Green
On Tue, 18 Oct 2005 07:59:47 GMT, Tim Tyler <[EMAIL PROTECTED]>  wrote
or quoted :

>Essentially, IM can do pretty-much everything email can these days, but 
>the reverse is not true at all.

The problem with IM is the various IM schemes don't talk to each
other.  You need a client that knows all the IM protocols.  But that
seems to be happening with Jabber and Trillian.

You have too much reliance on a central server. You have to trust the
relaying company.  I think it is time that nearly all mail was
routinely and transparently end to end encrypted, with the exception
of long enclosures that are explicitly marked not confidential.

You still have spam to a lesser extent and strangers just wanting to
talk.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: override a property

2005-10-18 Thread Alex Martelli
Robin Becker <[EMAIL PROTECTED]> wrote:

> Bruno Desthuilliers wrote:
> > Robin Becker a écrit :
> > 
> >> Is there a way to override a data property in the instance? Do I need
> >> to create another class with the property changed?
> > 
> > Do you mean attributes or properties ?
> 
> I mean property here. My aim was to create an ObserverProperty class 
> that would allow adding and subtracting of set/get observers. My current
> implementation works fine for properties on the class, but when I need
> to specialize an instance I find it's quite hard.

A property is an 'overriding descriptor', AKA 'data descriptor', meaning
it "captures" assignments ('setattr' kinds of operations), as well as
accesses ('getattr' kinds), when used in a newstyle class.  If for some
reason you need an _instance_ to bypass the override, you'll need to set
that instance's class to one which has no overriding descriptor for that
attribute name.  A better design might be to use, instead of the builtin
type 'property', a different custom descriptor type that is specifically
designed for your purpose -- e.g., one with a method that instances can
call to add or remove themselves from the set of "instances overriding
this ``property''" and a weak-key dictionary (from the weakref module)
mapping such instances to get/set (or get/set/del, if you need to
specialize "attribute deletion" too) tuples of callables.


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


Re: wxPython question

2005-10-18 Thread vpr
I've had some problems, it seems that they dont render well in Linux. I
tried it with Ubuntu Breezy.

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


Re: Question on class member in python

2005-10-18 Thread Alex Martelli
Johnny Lee <[EMAIL PROTECTED]> wrote:
   ...
> Thanks for your help, maybe I should learn how to turn an attibute into
> a property first.

Easy -- in your class's body, just code:

  def getFoo(self): ...
  def setFoo(self, value): ...
  def delFoo(self): ...
  foo = property(getFoo, setFoo, delFoo, 'this is the foo')


Note that if you want subclasses to be able to customize behavior of foo
accesses by simple method overrides, you need to program some "hooks"
(an extra level of indirection, if you will).

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


Re: Question on class member in python

2005-10-18 Thread Alex Martelli
Johnny Lee <[EMAIL PROTECTED]> wrote:

> But I still wonder what's the difference between the A().getMember and
> A().member besides the style

Without parentheses after it, getMember is a method.  The difference
between a method object and an integer object (which is what member
itself is in your example) are many indeed, so your question is very
strange.  You cannot call an integer, you cannot divide methods, etc.


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


How to make command history persistent?

2005-10-18 Thread vbfoobar
Hello,

My question is:
  Is there an easy mean to make Python "command history"
  persistent across interpreter invokations?

PS:
  In the case the question above is not clear, I rephrase
  it below verbosely...
  When I work from the Python prompt, I enjoy features
  like command line editing and searching/recalling
  previous lines of code from the history.
  (This is similar to working from a Unix shell prompt.)
But I would like, in addition, be able to keep the history
  from one session to another (when I quit Python, the history
  is lost, but I would like to retrieve it each time In
  invoke again Python interactively).

Thanks

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


Re: override a property

2005-10-18 Thread Robin Becker
bruno modulix wrote:
.
> 
> Could you elaborate ? Or at least give an exemple ?
.
in answer to Bengt & Bruno here is what I'm sort of playing with. Alex suggests 
class change as an answer, but that looks really clunky to me. I'm not sure 
what 
Alex means by

> A better design might be to use, instead of the builtin
> type 'property', a different custom descriptor type that is specifically
> designed for your purpose -- e.g., one with a method that instances can
> call to add or remove themselves from the set of "instances overriding
> this ``property''" and a weak-key dictionary (from the weakref module)
> mapping such instances to get/set (or get/set/del, if you need to
> specialize "attribute deletion" too) tuples of callables.

I see it's clear how to modify the behaviour of the descriptor instance, but is 
he saying I need to mess with the descriptor magic methods so they know what 
applies to each instance?


## my silly example
class ObserverProperty(property):
 def __init__(self,name,observers=None,validator=None):
 self._name = name
 self._observers = observers or []
 self._validator = validator or (lambda x: x)
 self._pName = '_' + name
 property.__init__(self,
 fset=lambda inst, value: self.__notify_fset(inst,value),
 )

 def __notify_fset(self,inst,value):
 value = self._validator(value)
 for obs in self._observers:
 obs(inst,self._pName,value)
 inst.__dict__[self._pName] = value

 def add(self,obs):
 self._observers.append(obs)

def obs0(inst,pName,value):
 print 'obs0', inst, pName, value

def obs1(inst,pName,value):
 print 'obs1', inst, pName, value

class A(object):
 x = ObserverProperty('x')

a=A()
A.x.add(obs0)

a.x = 3

b = A()
b.x = 4

#I wish I could get b to use obs1 instead of obs0
#without doing the following
class B(A):
 x = ObserverProperty('x',observers=[obs1])

b.__class__ = B

b.x = 7


-- 
Robin Becker

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


Re: bug in os.system?

2005-10-18 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> The following code fails (pythonbugtest.exe takes one parameter, a
> string):
>
> import os
> result = os.system('"pythonbugtest.exe" "test"')
> assert(result == 0)
>
> The error message is:
>
> 'pythonbugtest.exe" "test' is not recognized as an internal or external
> command, operable program or batch file.
> Traceback (most recent call last):
>  File "C:\Nick\!My Programs\Python\bugtest\python1.py", line 8, in ?
>assert(result == 0)
> AssertionError
>
> If I remove the quote marks around "pythonbugtest.exe" or "test", it
> works fine.  But sometimes I need those quote marks, if e.g. there are
> spaces in filenames.
>
> I think this is a bug?

yup, but unfortunately, it's a bug at the windows level, not in Python.  from 
what
I can tell, the problem is that cmd.exe cannot parse the command string it's 
given
by the C-level system() call.

possible workarounds:

1. get rid of the quotes around the command name:

result = os.system('pythonbugtest.exe "test"')

2. add an extra quote (!) before the quoted command name:

result = os.system('""pythonbugtest.exe" "test"')

3. use os.spawn or the subprocess module instead.

 



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


Re: Microsoft Hatred FAQ

2005-10-18 Thread Eike Preuss
John Bokma wrote:
[snip]
> 
> I see little difference with other big companies. You're right that there 
> is no excuse for such behaviour, but if MS isn't doing it, another company 
> will take their place.
> 

And if companies are allowed to behave this way (because of your
'nice,fatalistic' argument), this will never change.
Showing companies that you don't excuse such behavior would include not
buying there products, using other products, whatever. To say that they
are just playing the evil part that somebody *has* to play, is to excuse
their behavior, IMO.

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


Re: Question on class member in python

2005-10-18 Thread Johnny Lee

Alex Martelli 写道:

> Johnny Lee <[EMAIL PROTECTED]> wrote:
>
> > But I still wonder what's the difference between the A().getMember and
> > A().member besides the style
>
> Without parentheses after it, getMember is a method.  The difference
> between a method object and an integer object (which is what member
> itself is in your example) are many indeed, so your question is very
> strange.  You cannot call an integer, you cannot divide methods, etc.
>
>
> Alex

Sorry, I didn't express myself clear to you. I mean:
b = A().getMember()
c = A().member
what's the difference between b and c? If they are the same, what's the
difference in the two way to get the value besides the style.

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

Re: How to make command history persistent?

2005-10-18 Thread pclinch

If using unix, you should have readline available.
See the tutotial appendix:-

http://www.python.org/doc/current/tut/node15.html

Regards, Paul Clinch

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


Bloodhound.Exploit.49 trojan found in MIMEBase.pyc

2005-10-18 Thread Alex Hunsley
Symantec antivirus has apparently picked up a virus in my Python 2.4 
(under cygwin):

Scan type:  Scheduled Scan
Event:  Threat Found!
Threat: Bloodhound.Exploit.49
File:  C:\cygwin\lib\python2.4\email\MIMEBase.pyc
Location:  Quarantine
Action taken:  Quarantine succeeded


There's info to be found on various pages, but it's a pretty terse 
explanation:
http://secunia.com/virus_information/22534/bloodhound.exploit.49/

Has anyone had this also? Is it perhaps a false positive?
alex
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: MS litigation history, was MS FAQ

2005-10-18 Thread Adriaan Renting

 
 
>>>"David Schwartz" <[EMAIL PROTECTED]> 10/18/05 7:21 am >>> 
> 
>"Roedy Green" <[EMAIL PROTECTED]> wrote in 
>message news:[EMAIL PROTECTED] 
> 
>>On Mon, 17 Oct 2005 19:44:55 -0700, "David Schwartz" 
>><[EMAIL PROTECTED]> wrote or quoted : 
> 
>>>   It is not Microsoft's obligation to be "fair". It is Microsoft's 
>>>obligation to push their vision of the future of computing, one with 
>>>Microsoft's products at the center, using anything short of force or 
>>>fraud. 
> 
>>I think that what they did borders on force/fraud. 
> 
>   I don't think any of it bordered on force or fraud. However, their 
>obligation to their shareholders requires them to do anythign that borders 
>on force/fraud so long as it isn't force/fraud. However, the use of things 
>too close to force/fraud often backfires. Microsoft has an obligation to be 
>strategic and look nice where those things beneficially impact the bottom 
>line. 
> 
>   It's Bill Gates' job to make his company worth as much as possible. 
> 
>   DS 
> 
>

I think MS obligation to its shareholders to maximise profits, does seem to 
make them cross the line quite frequently. Because of the slow legal process it 
seems that it's more profitable to do so.
A lot of these were however settled out of court, so technically, in a lot of 
them MS was not proven to have crossed the line, it does show a certain pattern 
though, some examples for googling "Microsoft lawsuit":
- 1982 Microsoft vs Seattle Computer Products, settled out of court.
- 1982 Microsoft vs Digital Research, DR won.
- 1985 Microsoft vs Apple, settled by Apple leasing MS access to the MacOS code.
- 1988-1998 Microsoft vs Apple, settled out of court, MS buys $150 mil Apple 
stock
- 1989 Microsoft vs DEC, settled out of court, MS paid $150 mil
- 1994 Microsoft vs Stac Electronics, MS lost, paid $84 mil
- 1996 Microsoft vs Novell/Caldera, settled out of court, MS paid $200 mil
- 1998-2002 Microsoft vs DOJ&20 states, MS lost, MS ordered to split up 
overturned in appeal.
- 2003 Microsoft vs Time-warner, settled out of court, MS pays $750 mil
- 2004 Microsoft vs EU, MS fined $613 mil
- 2004 Microsoft vs Sun, settled out of court, MS pays $700 mil

these guys also have a list, but it contains very few details:
http://www.theinquirer.net/?article=24621
They compute a total of over 9 billion in fines/settlements over the 30 year 
history of Microsoft.
 
To me it seems that MS finds it more profitable to do cross the line, and just 
pay the fines afterwards. I find it a real flaw in the corporate legal system 
that this is a valid way of doing business. That's a whole different topic 
though.


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


html parser?

2005-10-18 Thread Christoph S�llner
Hi *,

is there a html parser available, which could i.e. extract all links from a 
given text like that:
"""
BAR
BAR2
"""

and return a set of dicts like that:
"""
{
  ['foo.php','BAR','param1','test'],
  ['foo2.php','BAR2','param1','test','param2','test']
}
"""

thanks,
Chris 


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


Re: Bloodhound.Exploit.49 trojan found in MIMEBase.pyc

2005-10-18 Thread Fredrik Lundh
Alex Hunsley wrote:

> Symantec antivirus has apparently picked up a virus in my Python 2.4
> (under cygwin):
>
> Scan type:  Scheduled Scan
> Event:  Threat Found!
> Threat: Bloodhound.Exploit.49
> File:  C:\cygwin\lib\python2.4\email\MIMEBase.pyc
> Location:  Quarantine
> Action taken:  Quarantine succeeded
>
> There's info to be found on various pages, but it's a pretty terse
> explanation:
> http://secunia.com/virus_information/22534/bloodhound.exploit.49/
>
> Has anyone had this also? Is it perhaps a false positive?

if Python had anything to do with this, they would probably have mentioned it
in the related documents:

http://www.sarc.com/avcenter/venc/data/bloodhound.exploit.49.html
http://www.microsoft.com/technet/security/bulletin/MS05-048.mspx

 



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


Re: html parser?

2005-10-18 Thread Laszlo Zsolt Nagy
Christoph Söllner wrote:

>Hi *,
>
>is there a html parser available, which could i.e. extract all links from a 
>given text like that:
>"""
>BAR
>BAR2
>"""
>
>and return a set of dicts like that:
>"""
>{
>  ['foo.php','BAR','param1','test'],
>  ['foo2.php','BAR2','param1','test','param2','test']
>}
>"""
>
>thanks,
>Chris 
>  
>
I asked the same question a week ago, and the answer I got was a really 
beautiful one. :-)

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

  Les

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


unittest of file-reading function

2005-10-18 Thread Helge Stenstroem
Say I have a function

def f(filename):
result = openFileAndProcessContents(filename)
return result

Can that function be unit tested without having a real file as input?
Something along the lines of

import unittest
class tests(unittest.TestCase):
def test1(self):
fileContents = "bla bla bla\nmore bla bla bla"
???   # make f read this string instead of opening a file
expected = expectedResult
result = f(filename)
self.assertEqual(result, expected)

One possibility would be to make the unit test write to a temporary
file. Are there better alternatives?


-- 
Helge Stenström
-- 
http://mail.python.org/mailman/listinfo/python-list

在消息 "test"中发现病毒

2005-10-18 Thread m . hadfield
The message contains Unicode characters and has been sent as a binary 
attachment.

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

Re: Question on class member in python

2005-10-18 Thread Christophe
Johnny Lee a écrit :
> Alex Martelli 写道:
> 
> 
>>Johnny Lee <[EMAIL PROTECTED]> wrote:
>>
>>
>>>But I still wonder what's the difference between the A().getMember and
>>>A().member besides the style
>>
>>Without parentheses after it, getMember is a method.  The difference
>>between a method object and an integer object (which is what member
>>itself is in your example) are many indeed, so your question is very
>>strange.  You cannot call an integer, you cannot divide methods, etc.
>>
>>
>>Alex
> 
> 
> Sorry, I didn't express myself clear to you. I mean:
> b = A().getMember()
> c = A().member
> what's the difference between b and c? If they are the same, what's the
> difference in the two way to get the value besides the style.
> 

Second form is better because it makes it easier to refactor.

Like, at first A had a direct access to the member member. But later you 
want to control the access to it. So you change it into a property and 
you don't need to change client code.
-- 
http://mail.python.org/mailman/listinfo/python-list

ANN: ConfigObj 4.0.0 Final and Pythonutils 0.2.3

2005-10-18 Thread Fuzzyman
ConfigObj 4.0.0 final and Pythonutils 0.2.3 have just hit the streets.

http://www.voidspace.org.uk/python/configobj.html
http://www.voidspace.org.uk/python/pythonutils.html

They are both pure Python modules - the source distributions include
full documentation, which is also online.

What's New ?


ConfigObj 4.0.0 final has two bugfixes.
Using ``setdefault`` to create a new section would return a reference
to the dictionary you passed in - not the new section.
Also fixed a trivial bug in ``write`` (wouldn't have affected anyone).

Pythonutils 0.2.3 is updated to include the ConfigObj 4.0.0 final and
cgiutils 0.3.3

ConfigObj is now marked stable. (But caveat emptor :-)

What is ConfigObj ?
===

ConfigObj is a simple but powerful config file reader and writer: an
*ini file round tripper*. Its main feature is that it is very easy to
use, with a straightforward programmer's interface and a simple syntax
for config files. It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies

What is Pythonutils ?
=

The Voidspace Pythonutils package is a simple way of installing the
Voidspace collection of modules. Several of the Voidspace Projects
depend on these modules. They are also useful in their own right of
course. They are primarily general utility modules that simplify common
programming tasks in Python.

These are currently :

* ConfigObj - simple config file handling
* validate - validation and type conversion system
* listquote - string to list conversion
* StandOut - simple logging and output control object
* pathutils - for working with paths and files
* cgiutils - cgi helpers (and functions for sending emails etc)
* urlpath - functions for handling URLs
* odict - Ordered Dictionary Class

All the best,

Fuzzyman
http://www.voidspace.org.uk/python

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


Re: Question on class member in python

2005-10-18 Thread Alex Martelli
Johnny Lee <[EMAIL PROTECTED]> wrote:

> Alex Martelli ???

Now that's a peculiar question...


> > Johnny Lee <[EMAIL PROTECTED]> wrote:
> >
> > > But I still wonder what's the difference between the A().getMember and
> > > A().member besides the style
> >
> > Without parentheses after it, getMember is a method.  The difference
> > between a method object and an integer object (which is what member
> > itself is in your example) are many indeed, so your question is very
> > strange.  You cannot call an integer, you cannot divide methods, etc.
> >
> >
> > Alex
> 
> Sorry, I didn't express myself clear to you. I mean:
> b = A().getMember()
> c = A().member
> what's the difference between b and c? If they are the same, what's the
> difference in the two way to get the value besides the style.

If getMember's body is nothing but a 'return self.member', then there is
no difference -- 'assert b is c'.

What is the difference between:

x = 2

and 

y = 2+2-2*2/2

???  Answer: in terms of final results, no difference.  On the other
hand, the second approach does a lot of obviously useless and intricate
computation, so it's a sheer waste of time and effort.

Exactly the same answer applies to your question -- obtaining the
.member attribute "indirectly", by calling a method that returns it,
does some obviously useless and moderately intricate computation, which
in some ways is a waste of (some) time and effort.  That's all!


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


Re: html parser?

2005-10-18 Thread Christoph S�llner
right, that's what I was looking for. Thanks very much. 


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


HTTPResponse.read() returns an empty string?

2005-10-18 Thread Christoph S�llner
Hi again,

my Source:
"""
import httplib
conn = httplib.HTTPConnection('www.python.org');
conn.request("GET", "/index.html");
answ = conn.getresponse();
print answ.status, answ.reason
>>> 200 OK
conn.close();
print "Start";
>>> Start
print answ.read();
>>>
print len(answ.read());
>>> 0
print "End";
>>> End

And the header states a content length of 11kBytes. What am I doin wrong?

Thanks again,
Chris 


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


Re: HTTPResponse.read() returns an empty string?

2005-10-18 Thread Christoph S�llner
ok got it:
One cannot close the connection before reading the answer.
Seems that in my original source the new assigned variable
'answ' is destroyed or emptied with the connection.close()
command; very strange behaviour.
> """
> import httplib
> conn = httplib.HTTPConnection('www.python.org');
> conn.request("GET", "/index.html");
> answ = conn.getresponse();
> print answ.status, answ.reason
 200 OK
> conn.close();
> print "Start";
 Start
> print answ.read();

> print len(answ.read());
 0


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


Re: Hygenic Macros

2005-10-18 Thread Dan Farina
David Pokorny wrote:
> Hi,
> 
> Just wondering if anyone has considered macros for Python. I have one 
> good use case. In "R", the statistical programming language, you can 
> multiply matrices with A %*% B (A*B corresponds to pointwise 
> multiplication). In Python, I have to type
> 
> import Numeric
> matrixmultiply(A,B)
> 
> which makes my code almost unreadable.
> 
> Thanks,
> David

The problem here is that Python's parse trees are of non-trivial ugliness.

A page on the compiler.ast module:
http://docs.python.org/lib/node792.html

it is, in fact, perfectly possible to write yourself a pre-processor for 
your particular application.  You may have to fiddle with the token you 
want for notation depending on how the AST fleshes out (% is used by at 
least a couple of things, after all).  My cursory familiarity with 
python grammar suggests to me that this particular choice of token could 
be a problem.

I would say try it and see.  Keep in mind though that since Python's AST 
is not a trivial matter like it is in Lisp and the like that doing 
metaprogramming of this sort probably falls into the category of black 
magic unless it turns out to be very trivial.

Another option is to define your own tiny class that will override the 
__mult__ method so that you can simply do:

A * B

Which may not be what you want.

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


Re: Hygenic Macros

2005-10-18 Thread Adriaan Renting
Using numarray/pylab there's also dot:
>>> from pylab import *
>>> A = array(range(10))
>>> B = array(range(10))
>>> A * B
[ 0, 1, 4, 9,16,25,36,49,64,81,]
>>> dot(A, B)
285

It might also make your code more readable. I would like "A dot B", but even 
using ipython
I can only get as close as "dot A, B"
 
>>>Dan Farina <[EMAIL PROTECTED]> 10/18/05 1:33 pm >>> 
David Pokorny wrote: 
>Hi, 
> 
>Just wondering if anyone has considered macros for Python. I have one 
>good use case. In "R", the statistical programming language, you can 
>multiply matrices with A %*% B (A*B corresponds to pointwise 
>multiplication). In Python, I have to type 
> 
>import Numeric 
>matrixmultiply(A,B) 
> 
>which makes my code almost unreadable. 
> 
>Thanks, 
>David 
 
The problem here is that Python's parse trees are of non-trivial ugliness. 
 
A page on the compiler.ast module: 
http://docs.python.org/lib/node792.html 
 
it is, in fact, perfectly possible to write yourself a pre-processor for 
your particular application.  You may have to fiddle with the token you 
want for notation depending on how the AST fleshes out (% is used by at 
least a couple of things, after all).  My cursory familiarity with 
python grammar suggests to me that this particular choice of token could 
be a problem. 
 
I would say try it and see.  Keep in mind though that since Python's AST 
is not a trivial matter like it is in Lisp and the like that doing 
metaprogramming of this sort probably falls into the category of black 
magic unless it turns out to be very trivial. 
 
Another option is to define your own tiny class that will override the 
__mult__ method so that you can simply do: 
 
A * B 
 
Which may not be what you want. 
 
df 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: popen4

2005-10-18 Thread billie

Piet van Oostrum wrote:
> I think you need something like pyexpect for this.

PyExpect seems to be no more mantained.


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


Re: Hygenic Macros

2005-10-18 Thread Alex Stapleton
I seem to remember a rather ugly hack at some point in the past that  
created a new "operator" like so

A |dot| B

where dot was an object which had the OR operator for left and right  
arguments redefined seperately so that it only made sense when used  
in that syntax.

I guess you could hack something together along the same lines. I  
just wish I could remember what it was called, it's on the  
ActiveState Cookbook somewhere.

On 18 Oct 2005, at 13:17, Adriaan Renting wrote:

> Using numarray/pylab there's also dot:
>
 from pylab import *
 A = array(range(10))
 B = array(range(10))
 A * B

> [ 0, 1, 4, 9,16,25,36,49,64,81,]
>
 dot(A, B)

> 285
>
> It might also make your code more readable. I would like "A dot B",  
> but even using ipython
> I can only get as close as "dot A, B"
>
>
 Dan Farina <[EMAIL PROTECTED]> 10/18/05 1:33 pm >>>

> David Pokorny wrote:
>
>> Hi,
>>
>> Just wondering if anyone has considered macros for Python. I have one
>> good use case. In "R", the statistical programming language, you can
>> multiply matrices with A %*% B (A*B corresponds to pointwise
>> multiplication). In Python, I have to type
>>
>> import Numeric
>> matrixmultiply(A,B)
>>
>> which makes my code almost unreadable.
>>
>> Thanks,
>> David
>>
>
> The problem here is that Python's parse trees are of non-trivial  
> ugliness.
>
> A page on the compiler.ast module:
> http://docs.python.org/lib/node792.html
>
> it is, in fact, perfectly possible to write yourself a pre- 
> processor for
> your particular application.  You may have to fiddle with the token  
> you
> want for notation depending on how the AST fleshes out (% is used  
> by at
> least a couple of things, after all).  My cursory familiarity with
> python grammar suggests to me that this particular choice of token  
> could
> be a problem.
>
> I would say try it and see.  Keep in mind though that since  
> Python's AST
> is not a trivial matter like it is in Lisp and the like that doing
> metaprogramming of this sort probably falls into the category of black
> magic unless it turns out to be very trivial.
>
> Another option is to define your own tiny class that will override the
> __mult__ method so that you can simply do:
>
> A * B
>
> Which may not be what you want.
>
> df
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>

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


Re: How to make command history persistent?

2005-10-18 Thread vbfoobar
Great! The indicated "history save" works!
Thanks

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


wxPython + pyPlot

2005-10-18 Thread Robert
Hellow!

I'm writing program with wxpython and pyplot. 
I need to put a graph (example):

def _draw1Objects():
# 100 points sin function, plotted as green circles
data1 = 2.*Numeric.pi*Numeric.arange(200)/200.
data1.shape = (100, 2)
data1[:,1] = Numeric.sin(data1[:,0])
markers1 = PolyMarker(data1, legend='Green Markers', 
colour='green', marker='circle',size=1)

# 50 points cos function, plotted as red line
data1 = 2.*Numeric.pi*Numeric.arange(100)/100.
data1.shape = (50,2)
data1[:,1] = Numeric.cos(data1[:,0])
lines = PolyLine(data1, legend= 'Red Line', colour='red')

# A few more points...
pi = Numeric.pi
markers2 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
(3.*pi/4., -1)], legend='Cross Legend', colour='blue',
marker='cross')

return PlotGraphics([markers1, lines, markers2],"Graph 
Title", "X Axis", "Y Axis") 


 on the PlotConvas object 

  self.notebook1 = wx.Notebook(id=wxID_FRAME1NOTEBOOK1, name='notebook1',
  parent=self, pos=wx.Point(8, 24), size=wx.Size(800, 360),
  style=0)
  
  self.Okno_PT = wx.Window(id=wxID_FRAME1Okno_PT, name='Okno_PT',
  parent=self.notebook1, pos=wx.Point(0, 0),
  size=wx.Size(798,328), style=0)
  
  self.Wykres_PT = wx.lib.plot.PlotCanvas(id=wxID_FRAME1WYKRES_PT,
  name=u'Wykres_PT', parent=self.Okno_PT, pos=wx.Point(0, 0),
  size=wx.Size(510, 328), style=0)


and I don't now how to do that.

thanks for any help.
Robert
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: popen4

2005-10-18 Thread Ganesan Rajagopal
> "billie" == billie  <[EMAIL PROTECTED]> writes:

> Piet van Oostrum wrote:
>> I think you need something like pyexpect for this.

> PyExpect seems to be no more mantained.

Try pexpect instead. http://pexpect.sourceforce.net/

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan| http://rganesan.blogspot.com

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


Re: Hygenic Macros

2005-10-18 Thread Alex Stapleton
Ahar got it

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122

Would something like that be any use?

On 18 Oct 2005, at 13:21, Alex Stapleton wrote:

> I seem to remember a rather ugly hack at some point in the past that
> created a new "operator" like so
>
> A |dot| B
>
> where dot was an object which had the OR operator for left and right
> arguments redefined seperately so that it only made sense when used
> in that syntax.
>
> I guess you could hack something together along the same lines. I
> just wish I could remember what it was called, it's on the
> ActiveState Cookbook somewhere.
>
> On 18 Oct 2005, at 13:17, Adriaan Renting wrote:
>
>
>> Using numarray/pylab there's also dot:
>>
>>
> from pylab import *
> A = array(range(10))
> B = array(range(10))
> A * B
>
>
>> [ 0, 1, 4, 9,16,25,36,49,64,81,]
>>
>>
> dot(A, B)
>
>
>> 285
>>
>> It might also make your code more readable. I would like "A dot B",
>> but even using ipython
>> I can only get as close as "dot A, B"
>>
>>
>>
> Dan Farina <[EMAIL PROTECTED]> 10/18/05 1:33 pm >>>
>
>
>> David Pokorny wrote:
>>
>>
>>> Hi,
>>>
>>> Just wondering if anyone has considered macros for Python. I have  
>>> one
>>> good use case. In "R", the statistical programming language, you can
>>> multiply matrices with A %*% B (A*B corresponds to pointwise
>>> multiplication). In Python, I have to type
>>>
>>> import Numeric
>>> matrixmultiply(A,B)
>>>
>>> which makes my code almost unreadable.
>>>
>>> Thanks,
>>> David
>>>
>>>
>>
>> The problem here is that Python's parse trees are of non-trivial
>> ugliness.
>>
>> A page on the compiler.ast module:
>> http://docs.python.org/lib/node792.html
>>
>> it is, in fact, perfectly possible to write yourself a pre-
>> processor for
>> your particular application.  You may have to fiddle with the token
>> you
>> want for notation depending on how the AST fleshes out (% is used
>> by at
>> least a couple of things, after all).  My cursory familiarity with
>> python grammar suggests to me that this particular choice of token
>> could
>> be a problem.
>>
>> I would say try it and see.  Keep in mind though that since
>> Python's AST
>> is not a trivial matter like it is in Lisp and the like that doing
>> metaprogramming of this sort probably falls into the category of  
>> black
>> magic unless it turns out to be very trivial.
>>
>> Another option is to define your own tiny class that will override  
>> the
>> __mult__ method so that you can simply do:
>>
>> A * B
>>
>> Which may not be what you want.
>>
>> df
>> -- 
>> http://mail.python.org/mailman/listinfo/python-list
>>
>> -- 
>> http://mail.python.org/mailman/listinfo/python-list
>>
>>
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>

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


Re: unittest of file-reading function

2005-10-18 Thread Peter Hansen
Helge Stenstroem wrote:
> Say I have a function
> 
> def f(filename):
> result = openFileAndProcessContents(filename)
> return result
> 
> Can that function be unit tested without having a real file as input?
> Something along the lines of
> 
> import unittest
> class tests(unittest.TestCase):
> def test1(self):
> fileContents = "bla bla bla\nmore bla bla bla"
> ???   # make f read this string instead of opening a file
> expected = expectedResult
> result = f(filename)
> self.assertEqual(result, expected)
> 
> One possibility would be to make the unit test write to a temporary
> file. Are there better alternatives?

The simplest approach is to use a StringIO.  Often that will require 
passing a "file" object to the routine instead of a file *name*, but 
often that's better anyway (decouples file management and parsing).

Another approach is to create a "mock file" object.  Depending on your 
needs, this can be a very simple or a very complex thing to do.  I can 
offer more detail/suggestions here if you need.

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


Re: Bloodhound.Exploit.49 trojan found in MIMEBase.pyc

2005-10-18 Thread jepler
It's almost certainly a false positive.  In my day job we run into false
positive antivirus detections like this once or twice a year, and
typically get a runaround from the AV vendor (who often have the gall to
suggest that we should buy a copy of their broken software before
they'll fix their problems)

Jeff


pgpjaq8H7Vm4a.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Hygenic Macros

2005-10-18 Thread Steven D'Aprano
On Mon, 17 Oct 2005 22:23:43 -0700, David Pokorny wrote:

> Hi,
> 
> Just wondering if anyone has considered macros for Python. I have one 
> good use case. In "R", the statistical programming language, you can 
> multiply matrices with A %*% B (A*B corresponds to pointwise 
> multiplication). In Python, I have to type
> 
> import Numeric
> matrixmultiply(A,B)
> 
> which makes my code almost unreadable.

Yes, I see what you mean, it is pretty confusing. It almost looks like
a function that multiplies two matrices and returns the result. 

Have you tried coming up with better names for your arguments than A and
B? Many people find that using self-documenting variable names helps make
code easier to understand.


-- 
Steven.

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


Re: wxPython + pyPlot

2005-10-18 Thread Robert
Maebe, does anyone have some examples with wxPython and pyplot?

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


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-18 Thread kdahlhaus
Hmm.  I'm not sure what bothered you about cygwin, but if it has been
awhile it's worth another look.  For me it makes windows tolerable, and
even productive.

I'm scared more by your thoughts of transitioning from OS-X to windows.
  I've seen a bit of OS-X and am slowly be warmed up to it as an option
for my next machine by some folks here.   What is causing you problems
with it ( enough to swtich to windows-wow.)?

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


Re: Vim capable IDE?

2005-10-18 Thread Chris Lasher
Thanks for your responses, guys. I can't get the PIDA page to come up
for me; server timeout error. I'll have to look into Eclipse more, but
I've been warned that it's resource greedy and that the VI plugin
doesn't provide very much functionality. Still, that's hearsay, so I'll
have to find out for myself.

I would have figured Vim or VI editing behavior would be a lot more
prevalent in IDEs but it seems to be quite rare. I don't understand
that, because a lot of people seem to use IDEs, and a lot of people
seem to use VI/Vim or Emacs. Is it the young guns that are tied to the
IDEs, never knowing powerful text-editors exist, and old dogs sticking
to their favorite editors, not giving in to all those "distracting"
bells and whistles of IDEs? What's the deal? A marriage of the two
would seem like the best of both worlds.

Chris

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


Re: wxPython + pyPlot

2005-10-18 Thread Philippe C. Martin
I think wxWidget comes with a sample

Philippe

Robert wrote:

> Maebe, does anyone have some examples with wxPython and pyplot?
> 
> Thanks again,
> Robert

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


Re: global interpreter lock

2005-10-18 Thread Jeremy Jones
[EMAIL PROTECTED] wrote:

>I just need confirmation that I think right.
>
>Is the files thread_xxx.h (xxx = nt, os2 or whatever) responsible for
>the
>global interpreter lock in a multithreaded environment?
>
>I'm currently writing my own thread_VW for VxWorks, thats why I'm
>asking. 
>
>//Tommy
>
>  
>
Someone can correct me if I'm wrong, but the lock actually lives in 
ceval.c, around here:



802 PyThread_release_lock(interpreter_lock);
803
804 /* Other threads may run now */
805
806 PyThread_acquire_lock(interpreter_lock, 1);


This was taken from what appears to be a 2.4.1 release rather than a CVS 
checkout.  It looks like the PyThread_type_lock is defined in the 
thread_xxx.h files, though.

HTH,

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


Re: Vim capable IDE?

2005-10-18 Thread BJ Swope
On 18 Oct 2005 07:16:11 -0700, Chris Lasher <[EMAIL PROTECTED]> wrote:
A marriage of the twowould seem like the best of both worlds.Chris
The pessimists would say "the worst of both worlds" ;)

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

Re: unittest of file-reading function

2005-10-18 Thread Kent Johnson
Helge Stenstroem wrote:
> Say I have a function
> 
> def f(filename):
> result = openFileAndProcessContents(filename)
> return result
> 
> Can that function be unit tested without having a real file as input?

If you can refactor openFileAndProcessContents() so it looks like this:
def openFileAndProcessContents(filename):
  data = open(filename).read()
  processContents(data)

then you can write your tests against processContents() and just pass it a 
string with the test data.

I usually have a set of test files as part of my project that I can pass to 
functions like this.

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


Re: Vim capable IDE?

2005-10-18 Thread Philippe C. Martin
True and I had to give up emacs when I went to eclipse, but it was well
worth it.

I seem to recall that sourcenavigator allowed to configure an external
editor (or maybe was it sniff+ ?)

Regards,
Philippe



Chris Lasher wrote:

> Thanks for your responses, guys. I can't get the PIDA page to come up
> for me; server timeout error. I'll have to look into Eclipse more, but
> I've been warned that it's resource greedy and that the VI plugin
> doesn't provide very much functionality. Still, that's hearsay, so I'll
> have to find out for myself.
> 
> I would have figured Vim or VI editing behavior would be a lot more
> prevalent in IDEs but it seems to be quite rare. I don't understand
> that, because a lot of people seem to use IDEs, and a lot of people
> seem to use VI/Vim or Emacs. Is it the young guns that are tied to the
> IDEs, never knowing powerful text-editors exist, and old dogs sticking
> to their favorite editors, not giving in to all those "distracting"
> bells and whistles of IDEs? What's the deal? A marriage of the two
> would seem like the best of both worlds.
> 
> Chris

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


Re: Microsoft Hatred FAQ

2005-10-18 Thread Mike Schilling

"Mike Meyer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Mike Schilling" <[EMAIL PROTECTED]> writes:
>> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>> "Mike Schilling" <[EMAIL PROTECTED]> writes:
 What matters in generating HTML is which browsers you want to support 
 and
 what they understand.  Standards and recommendations are both 
 irrelevant.
>>> Unless, of course, you want to support any compliant browser.
>> Since no browser I know of is perfectly compliant (e.g. bug-free), that's
>> not a feasible goal.
>
> I guess you'd say developing any software isn't a feasible goal,
> because it'll never be bug-free, will never have bug-free compilers to
> compile it, bug-free linkers to link it, bug-free GUI/db/etc libraries
> to link with it, bug-free servers to communicate with, and bug-free
> operating systems to run it on. Fortunately, most developers aren't
> quite that anal, and realize that you can get useful work done in a
> less-than-perfect environment.

I'm not speaking theroetically. My company (though not me personally) 
creates browser-based UIs, and one of the biggest expenses has been dealing 
with IE rendering bugs   Given the market share of IE, the fact that 
something should work, and even does work in Firefox, Opera, etc, is 
irrelevant.  If it breaks IE, we can't use it.

When we've had similar issues with C++ compilers, patches have usually been 
forthcoming, or perhaps optimization has to be turned off on a few source 
files.  In a few areas, though, the solution has been "Don't do that", and 
again, the fact that the standard supports it is irrelevant.



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


Re: How to get a raised exception from other thread

2005-10-18 Thread dcrespo
> Before, after, or during the .start() call, or somewhere else?

I'd like to catch *just after* the .start() call.

> I'm quite sure the problem you are trying to solve can be solved, but
> you are still describing part of the solution you believe you need,
> rather than explaining why you want to do this (which may let us show
> you other, simpler or cleaner ways to accomplish your goals).

The thing is that I have in ProgramB a class derived from
threading.Thread, that runs a TCPServer, listening to a port on local
ip address.

As you surely know, you have to specify certain parameters when
instantiating the tcpserver:

SocketServer.TCPServer(server_address, RequestHandlerClass)
where server_address is a tuple (ip,port)
ip has to be one of three modes of values (If I remember well):

1. A null string ''
   Listens on all IP local address

2. A string containing the local IP address where you want it to listen
   Listens only in the specified local IP address

3. A string containing "localhost".
   Listens only for connections from "localhost".

Here comes the problem:
When you specify the case number 2, the IP must be valid for the
computer where the program runs, otherwise, it raises an exception
saying that "Can't assign requested address".
The TCPServer class, defined in a module, is ran (instantiatedly) from
the main program through a started thread. The thread also is in the
same module as TCPServer class.
It looks like (it's much more code than this. If you want the whole
code, tell me):

MainProgram.py
...
SrvrTCP = module.ThreadedTCPServer(ip,port)
SrvrTCP.start()
#Here, I want to know if the TCPServer started well.
...


module.py
...
class ThreadedTCPServer(threading.Thread):

def __init__(self, ip,port):
threading.Thread.__init__(self)
self.ip= ip
self.port= port

def run(self):
TCPServer((self.ip,self.port)) #Here, if the self.ip is
invalid, it raises an exception.
...

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


Re: Installing Python at Work

2005-10-18 Thread Paul Watson
"Nikola" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'm currently learning Python for my own use.
> I'm considering installing it on a work laptop, knowing that it is
> non-licensed, distributable software.
>
> However, does it access communication ports?  I know the company checks
> their ports regularly for activity.
>
> I won't be doing anything very serious; I'm just trying out Python,
> learning the basics from 'Learning Python' by O'Reilly.

Are you asking if it is ok to install Python on your company machine or if 
Python does anything that might cause you to get caught doing something the 
company has already said not to do? 


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


Re: override a property

2005-10-18 Thread Kay Schluehr
Robin Becker wrote:
> Is there a way to override a data property in the instance? Do I need to 
> create
> another class with the property changed?
> --
> Robin Becker

It is possible to decorate a method in a way that it seems like
property() respects overridden methods. The decorator cares
polymorphism and accesses the right method.

def overridable(f):
def __wrap_func(self,*args,**kwd):
func = getattr(self.__class__,f.func_name)
if func.func_name == "__wrap_func":
return f(self,*args,**kwd)
else:
return func(self,*args,**kwd)
return __wrap_func


class A(object):
def __init__(self, x):
self._x = x

@overridable
def get_x(self):
return self._x

x = property(get_x)

class B(A):

def get_x(self):
return self._x**2

class C(B):pass

>>> a = A(7)
>>> a.x
7
>>> b = B(7)
>>> b.x
49
>>> c = C(7)
>>> c.x
49

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


Re: Installing Python at Work

2005-10-18 Thread Grant Edwards
On 2005-10-17, Nikola <[EMAIL PROTECTED]> wrote:

> I'm considering installing it on a work laptop, knowing that
> it is non-licensed, distributable software.
>
> However, does it access communication ports?

Only if you tell it to.

-- 
Grant Edwards   grante Yow!  I'm having BEAUTIFUL
  at   THOUGHTS about the INSIPID
   visi.comWIVES of smug and wealthy
   CORPORATE LAWYERS...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing an immutable object in python

2005-10-18 Thread Mapisto
Ok, I've understood my mistake.

Now, my list contains a shared entry of an empty object. When an entry
is needed to be changed, I check if the entry is the shared empty
object; in that case I create a new unique instance. If the entry is
already a unique instance, I use it, so the empty object isn't touched.


Thanks,
Guy.

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


Re: Microsoft Hatred FAQ

2005-10-18 Thread John Wingate
Richard Steiner <[EMAIL PROTECTED]> wrote:
> Here in comp.os.linux.misc,
> John Wingate <[EMAIL PROTECTED]> spake unto us, saying:
> 
>>Peter T. Breuer <[EMAIL PROTECTED]> wrote:
> 
>>> It seems to me that I was using 3.x. Maybe it was 3.1? I seem to
>>> remember an earlier major ... was there a 2.8 or 2.9?
>>
>>Dunno.  The first version I used was 3.4, in 1987.
> 
> MS-DOS 3.3 was the most popular DOS release back in 1987/1988.  I don't
> recall there ever being a 3.4 release, though.

You snipped the bits that provide the context showing that here Peter and I
were talking about versions of SunOS, not MS-DOS.

I too don't recall an MS-DOS 3.4.  The Victor/Sirius version I mentioned
was definitely 3.10 (three point ten)--the version byte was hex 030A.
Perhaps the gap in sequencing was introduced to separate the versions
for IBM-compatible machines from the versions for non-IBM-compatible
machines.

-- 
John WingateMathematics is the art which teaches
[EMAIL PROTECTED]one how not to make calculations.
 --Oscar Chisini
-- 
http://mail.python.org/mailman/listinfo/python-list


example of using urllib2 with https urls

2005-10-18 Thread Michele Simionato
Can somebody provide an example of how to retrieve a https url, given
username and password? I don't find it in the standard documentation.
TIA,

  Michele Simionato

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


Re: wxPython + pyPlot

2005-10-18 Thread Robert
Philippe C. Martin wrote:

> I think wxWidget comes with a sample
> 
> Philippe
Yes I use it, but there is not a sample with pyplot.

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


Re: UI toolkits for Python

2005-10-18 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes:
> Maybe that's the key difference between the mindset of a
> mathematician and that of an engineer -- I consider reaching over
> 95% of visitors to be _quite good indeed_,

Oh? So you'd consider an SMTP/IMAP/POP/DNS/NFS/etc server that
rejected 5% of the systems connecting to be _quite good indeed_? I
think I'm glad that the internet wasn't built by people who agreed
with that.

If you know what you're doing, you can have the best of both worlds
for a lot of web applications. Yes, it won't be as rich or functional
for the five percent who worry about security (or whatever), but it'll
still work. And yes, you can't do it for every application. For those,
anyone vaguely competent will add a warning.

What surprises me is that marketing types will accept turning away -
what's the current internet user base? 200 million? - 10 million
potential customers without a complaint. Or maybe they just don't get
told that that's what's going on.

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


Re: html parser?

2005-10-18 Thread Thorsten Kampe
* Christoph Söllner (2005-10-18 12:20 +0100)
> right, that's what I was looking for. Thanks very much.

For simple things like that "BeautifulSoup" might be overkill.

import formatter, \ 
   htmllib,   \ 
   urllib 

url = 'http://python.org' 

htmlp = htmllib.HTMLParser(formatter.NullFormatter()) 
htmlp.feed(urllib.urlopen(url).read()) 
htmlp.close() 

print htmlp.anchorlist

and then use urlparse to parse the links/urls...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading hebrew text file

2005-10-18 Thread hagai26
realy thanks

hagai

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


Re: Microsoft Hatred FAQ

2005-10-18 Thread Mike Meyer
"Mike Schilling" <[EMAIL PROTECTED]> writes:
> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> "Mike Schilling" <[EMAIL PROTECTED]> writes:
>>> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message
>>> news:[EMAIL PROTECTED]
 "Mike Schilling" <[EMAIL PROTECTED]> writes:
> What matters in generating HTML is which browsers you want to support 
> and
> what they understand.  Standards and recommendations are both 
> irrelevant.
 Unless, of course, you want to support any compliant browser.
>>> Since no browser I know of is perfectly compliant (e.g. bug-free), that's
>>> not a feasible goal.
>> I guess you'd say developing any software isn't a feasible goal,
>> because it'll never be bug-free, will never have bug-free compilers to
>> compile it, bug-free linkers to link it, bug-free GUI/db/etc libraries
>> to link with it, bug-free servers to communicate with, and bug-free
>> operating systems to run it on. Fortunately, most developers aren't
>> quite that anal, and realize that you can get useful work done in a
>> less-than-perfect environment.
> I'm not speaking theroetically. My company (though not me personally) 
> creates browser-based UIs, and one of the biggest expenses has been dealing 
> with IE rendering bugs   Given the market share of IE, the fact that 
> something should work, and even does work in Firefox, Opera, etc, is 
> irrelevant.  If it breaks IE, we can't use it.

Been there, done that, threw out the T-shirt as to ugly to wear.

Yes, you have to work around bugs in the popular browsers. That hasn't
changed since the first published specs showed up. That doesn't mean
you throw out the standards and only support a trivial set of
browsers. That means you restrict yourself to a subset of the
standard, or - better - detect the deficiency and fail soft, the same
as you would do when you get a visit from someone who's disabled some
feature you want to use. In extreme cases, you wind up implementing
something twice: once for busted-but-popular browsers, and once for
people using browsers written by developers who read specifications.

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


[wxPython-users] Web based applications are possible with wxPython?

2005-10-18 Thread Ruben Charles
Hi,


I am reading some essays --http://www.paulgraham.com/avg.html "Beating
the averages"-- and i am very interested in the web-based
applications.

I want to take the advantages having the application on a server. Is
easy to update, maintain, etc...

My questions is

Can i have a wxPython GUI app available on a web browser?

I founded some doc on the www  but the most refers to GUI wrote in
java script and tool kits relates with java. Some java script samples
are interesting but is not what i am looking for.


There is a way for  having wxpython frames, dialogs etc on a web browser?

If not, can you suggest me any kind oh method for have something similar?


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


Re: Jargons of Info Tech industry

2005-10-18 Thread Mike Meyer
Tim Tyler <[EMAIL PROTECTED]> writes:
> In comp.lang.java.programmer Ross Bamford <[EMAIL PROTECTED]> wrote or quoted:
> About all email has going for it these days is an open format and a
> large existing user base.

Yeah, and all that Windows has going for it is being on 9X% of the
desktops. Nothing really important at all.

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


Re: UI toolkits for Python

2005-10-18 Thread Mark Roseman
Mike Meyer <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> > Maybe that's the key difference between the mindset of a
> > mathematician and that of an engineer -- I consider reaching over
> > 95% of visitors to be _quite good indeed_,
>> What surprises me is that marketing types will accept turning away -
> what's the current internet user base? 200 million? - 10 million
> potential customers without a complaint. Or maybe they just don't get
> told that that's what's going on.

Obviously we all agree the effort to support both is significant.  The 
question is not so much "do we turn away 5%" as "do we use the effort we 
do have to provide a better experience for the 95%, or to provide a 
slightly worse experience for the 95%, and an ok experience for the 5%".

If you're a business, the question then becomes, does the incrementally 
better experience produce a higher conversion rate (i.e. more sales), in 
which case it may well be a better investment to focus there and ignore 
the 5%.  It's but one perspective, but depending on your goals, can be a 
reasonable choice to make.

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


A little help with time calculations

2005-10-18 Thread iminal
I am trying to make a very simple program and am very new to the whole
programming thing. my program is supposed to ask a user for any time in
the for format XX:XX:XX and then ask for a time corrrection to add or
subtract to this. my only problem is that once the user inputs the time
and the correction its adding it like it was 100 not to 60 any help?

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


Re: Microsoft Hatred FAQ

2005-10-18 Thread Aragorn
On Tuesday 18 October 2005 05:32, Richard Steiner stood up and spoke the
following words to the masses in /comp.os.linux.misc...:/

> Here in comp.os.linux.misc,
> John Wingate <[EMAIL PROTECTED]> spake unto us, saying:
> 
>>Peter T. Breuer <[EMAIL PROTECTED]> wrote:
> 
>>> It seems to me that I was using 3.x. Maybe it was 3.1? I seem to
>>> remember an earlier major ... was there a 2.8 or 2.9?
>>
>>Dunno.  The first version I used was 3.4, in 1987.
> 
> MS-DOS 3.3 was the most popular DOS release back in 1987/1988.  I
> don't recall there ever being a 3.4 release, though.

There wàs indeed a version 3.4, but I don't know whether this was
MS-DOS.  IBM did have a PC-DOS 3.4 at one stage, where it offered the
purchaser of the PS/2 series computers the choice between DOS 3.4 and
DOS 4.00.

However, Peter was of course not talking of DOS. ;-)

-- 
With kind regards,

*Aragorn*
(Registered Gnu/Linux user #223157)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-18 Thread Christophe
Mike Meyer a écrit :
> [EMAIL PROTECTED] (Alex Martelli) writes:
> 
>>Maybe that's the key difference between the mindset of a
>>mathematician and that of an engineer -- I consider reaching over
>>95% of visitors to be _quite good indeed_,
> 
> 
> Oh? So you'd consider an SMTP/IMAP/POP/DNS/NFS/etc server that
> rejected 5% of the systems connecting to be _quite good indeed_? I
> think I'm glad that the internet wasn't built by people who agreed
> with that.
> 
> If you know what you're doing, you can have the best of both worlds
> for a lot of web applications. Yes, it won't be as rich or functional
> for the five percent who worry about security (or whatever), but it'll
> still work. And yes, you can't do it for every application. For those,
> anyone vaguely competent will add a warning.
> 
> What surprises me is that marketing types will accept turning away -
> what's the current internet user base? 200 million? - 10 million
> potential customers without a complaint. Or maybe they just don't get
> told that that's what's going on.
> 
>   http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-18 Thread Christophe
Mike Meyer a écrit :
> [EMAIL PROTECTED] (Alex Martelli) writes:
> 
>>Maybe that's the key difference between the mindset of a
>>mathematician and that of an engineer -- I consider reaching over
>>95% of visitors to be _quite good indeed_,
> 
> 
> Oh? So you'd consider an SMTP/IMAP/POP/DNS/NFS/etc server that
> rejected 5% of the systems connecting to be _quite good indeed_? I
> think I'm glad that the internet wasn't built by people who agreed
> with that.
> 
> If you know what you're doing, you can have the best of both worlds
> for a lot of web applications. Yes, it won't be as rich or functional
> for the five percent who worry about security (or whatever), but it'll
> still work. And yes, you can't do it for every application. For those,
> anyone vaguely competent will add a warning.
> 
> What surprises me is that marketing types will accept turning away -
> what's the current internet user base? 200 million? - 10 million
> potential customers without a complaint. Or maybe they just don't get
> told that that's what's going on.
> 
>   http://mail.python.org/mailman/listinfo/python-list


Re: wxPython + pyPlot

2005-10-18 Thread Philippe C. Martin
My mistake, I understood plot (as in "from wx.lib.plot import *" that comes
with wxwidgets and which does have a demo)

Sorry,

Philippe


Robert wrote:

> Philippe C. Martin wrote:
> 
>> I think wxWidget comes with a sample
>> 
>> Philippe
> Yes I use it, but there is not a sample with pyplot.
> 
> Robert

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


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-18 Thread Chris Lambacher
The shell that comes with MSys (from the MinGW guys). Is pretty good, although
it does have a bit of a problem with stdout output before a process exits, ie
it will hold back output until the process exits.

As a bonus, the file system is a little more sane, and if you are interested
in compiling software that is not open source, you are not tied to the Cygwin
DLL which is GPLed.

I have given up on Cygwin in favour of the tools that come with MSys because
they seem slightly better suited to the windows environment.

-Chris

On Sat, Oct 15, 2005 at 08:45:17AM +, Jorgen Grahn wrote:
> On Fri, 14 Oct 2005 12:37:25 +0200, Christophe <[EMAIL PROTECTED]> wrote:
> > Kenneth McDonald a ?crit :
> >> For unfortunate reasons, I'm considering switching back to Win XP  (from 
> >> OS X) as my "main" system. Windows has so many annoyances that  I can 
> ...
> >> Yes, I know that Cygwin is out there, but last I looked, they still  
> >> went through the Win command-line window, which imposes a lot of  
> >> restrictions.
> ...
> > Last time I checked, you could install a native win32gui version of rxvt 
> > with cygwin. This would give you a better terminal window than that 
> > crappy thing you get in XP.
> 
> Last time /I/ checked (two years ago or so) that rxvt looked nice enough,
> but was impossible to use in practice. I cannot remember /what/ the problem
> was -- possibly it was that it could only run CygWin-compiled commands, or
> something vital only worked with CygWin-compiled commands. Google probably
> knows more.
> 
> I wouldn't be surprised if this has improved since then, or if someone else
> has come up with a serious Win32 terminal. There is surely a need for one!
> 
> /Jorgen
> 
> -- 
>   // Jorgen Grahn  \X/algonet.se>   R'lyeh wgah'nagl fhtagn!
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-18 Thread John W. Kennedy
Michael Heiming wrote:
> Let's not forget about the Internet, they invented together with
> Al Gore and of course the wheel!

No fair picking on Al Gore. All he ever claimed was that he was the 
Congressional point man for the "Information Superhighway", which he was.

-- 
John W. Kennedy
Read the remains of Shakespeare's lost play, now annotated!
http://pws.prserv.net/jwkennedy/Double%20Falshood/index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-18 Thread Paul Boddie
Paul Rubin wrote:
> All this extreme use of JS misses the point, it's client side
> programming all over again

This is so true, although I don't expect those people relentlessly
hyping "AJAX" to either realise the significance of that observation or
to necessarily make an accessible Web site for those people who, for
whatever reason, can't use the mountains of JavaScript that perform the
fancy fades and colour flashes that seem "de rigeur" in their "Web 2.0"
applications.

Here's an interesting perspective from outside the "AJAX clique":

http://aseigo.blogspot.com/2005/10/web-office-suites-rofl.html

(It even has a Monty Python reference, too.)

Paul

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


Re: UI toolkits for Python

2005-10-18 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote:
   ...
> What surprises me is that marketing types will accept turning away -
> what's the current internet user base? 200 million? - 10 million
> potential customers without a complaint. Or maybe they just don't get
> told that that's what's going on.

In firms where marketing has lots of power, they may indeed well decide
to pursue those "10 millions" by demanding an expenditure of effort
that's totally out of proportion (to the detriment of the other "190
millions", of course, since there IS a finite amount of development
resources to allocate).  Maybe that's part of the explanation for the
outstanding success of some enterprises founded by engineers, led by
engineers, and staffed overwhelmingly with engineers, competing with
other firms where marketing wield power...?


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


Re: Vim capable IDE?

2005-10-18 Thread Ron Adam
Chris Lasher wrote:
> Thanks for your responses, guys. I can't get the PIDA page to come up
> for me; server timeout error. I'll have to look into Eclipse more, but
> I've been warned that it's resource greedy and that the VI plugin
> doesn't provide very much functionality. Still, that's hearsay, so I'll
> have to find out for myself.
> 
> I would have figured Vim or VI editing behavior would be a lot more
> prevalent in IDEs but it seems to be quite rare. I don't understand
> that, because a lot of people seem to use IDEs, and a lot of people
> seem to use VI/Vim or Emacs. Is it the young guns that are tied to the
> IDEs, never knowing powerful text-editors exist, and old dogs sticking
> to their favorite editors, not giving in to all those "distracting"
> bells and whistles of IDEs? What's the deal? A marriage of the two
> would seem like the best of both worlds.
> 
> Chris

What features are you looking for.  I think most Vim users just add what 
they want to Vim.

Here's what I use to launch a script and capture the output into a read 
only panel.  I think it may still needs a little fine tuning.  This is 
on windows, but it should work on linux with some minor changes.

Cheers,
Ron


Add this to your python.vim file in your ftplugin directory.

" Run a python script and get the output into a window.
set switchbuf=useopen
function! RunPython(rmode)
 if a:rmode=='wnd'
 " Run in python shell and capture the
 "   output to a vim buffer window.
 execute "w!"
 if bufnr("python_stdout") >0
 exe "sb python_stdout"
 else
 exe 'split python_stdout'
 endif
 setlocal noswapfile
 set buftype=nofile
 setlocal modifiable
 normal ggdG
 silent! exe 'r!python #'
 setlocal nomodified
 set filetype=txt
 normal 1G
 elseif a:rmode=='ext'
 " Execute script in python shell
 execute "w!"
 !start python -i %
 else
 " Open an interactive shell
 !start python
 endif
endfunction

" Add keymap to run and open console
map  :call RunPython("wnd")
map  :call RunPython("ext")
map  :call RunPython("psh")
imap  :call RunPython("wnd"):star
imap  :call RunPython("ext"):star
imap  :call RunPython("psh"):star
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I pass args using Python Windows

2005-10-18 Thread Chris Lambacher
Have a main function that you pass the arguments into.  This entry on Guido's
blog should help you out:
http://www.artima.com/forums/flat.jsp?forum=106&thread=4829

-Chris


On Mon, Oct 17, 2005 at 09:02:10PM -0400, Ross Reyes wrote:
>Hi -
>I wonder if someone might be able to lend a quick answer to this.
> 
>I have a python script that I normally run from the command line on
>Solaris.
>i.e.%pythonscript  > 
> 
>I decided to try IDLE on Windows to do some debugging with the debugger
>(which I
>unfortunately dont' have on Solaris 5.7 )
> 
>So my question is: How do I pass the command line args when using the
>Windows IDLE/Python
>environment?
> 
>Thanks for any tips.
> 
> 
> 
> 

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


Re: PEP: Adding decorators for everything

2005-10-18 Thread Diez B. Roggisch
> @GuardedClass
> class Foo:

The functionality can be done using a meta-class, in a similarily 
declarative way.

> @Transient
> a = 'a transient field, ignored when serializing'
> 
> @Const
> PI = 22.0 / 7
> 
> @TypeSafe(int)
> count = 10

These are tricky, as the implicitly change the nature of the values - 
they become properties. And the decorator protocol has to change, as the 
passed value is obviously not a callable, but a random value. So in the 
end, you could simply do something like this:


@Const(3.24)
def PI(self):
pass

with Const basically ignoring its callable-argument and simply returning 
a get-only-property. I have to admit that I was tempted to use such a 
thingy just the other day. But it is not exactly nice, and using

PI = Const(3.14) as you suggested is even more pleasing.

Additionally, the first @Transient-decorator can't be done that way, as 
the decorator protocol doesn't know about the _name_ a thing is bound to 
later. And you'd need that to actually set up e.g. __getstate__ operate 
properly.

And it doesn't mkae much sense anyway, as "a" is a class variable, not a 
instance variable.

So - I'm not very much in favour of these enhancements.


> It would also be better if multiple decorators could be written on the
> same line. E.g.:
> @A @B(x, y) @C
> def foo(): ...

That one I like.

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


Re: Vim capable IDE?

2005-10-18 Thread Chris Lambacher
I would second that.  I use Vim for editing.  I find I don't need an IDE (not
even for C/C++).  Vim does everything I need.  If I want a debugger I will use
the shell debugger.  Most other things can be added to Vim, though I tend to
run with very few plugins.

-Chris


On Tue, Oct 18, 2005 at 05:12:30PM +, Ron Adam wrote:
> What features are you looking for.  I think most Vim users just add what 
> they want to Vim.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well written open source Python apps

2005-10-18 Thread Paulo Eduardo Neves
This is an old thread in this subject that I bookmarked:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/984262217c1b3727/8793a0b7722bb32f

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


Re: html parser?

2005-10-18 Thread Paul Boddie
Thorsten Kampe wrote:
> For simple things like that "BeautifulSoup" might be overkill.

[HTMLParser example]

I've used SGMLParser with some success before, although the SAX-style
processing is objectionable to many people. One alternative is to use
libxml2dom [1] and to parse documents as HTML:

import libxml2dom, urllib
url = 'http://www.python.org'
doc = libxml2dom.parse(urllib.urlopen(url), html=1)
anchors = doc.xpath("//a")

Currently, the parseURI function in libxml2dom doesn't do HTML parsing,
mostly because I haven't yet figured out what combination of parsing
options have to be set to make it happen, but a combination of urllib
and libxml2dom should perform adequately. In the above example, you'd
process the nodes in the anchors list to get the desired results.

Paul

[1] http://www.python.org/pypi/libxml2dom

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


Re: Microsoft Hatred FAQ

2005-10-18 Thread joe
"John W. Kennedy" <[EMAIL PROTECTED]> writes:

> Michael Heiming wrote:
> > Let's not forget about the Internet, they invented together with
> > Al Gore and of course the wheel!
> 
> No fair picking on Al Gore. All he ever claimed was that he was the
> Congressional point man for the "Information Superhighway", which he
> was.

Well, what he said was

  "During my service in the United States Congress, I took the
   initiative in creating the Internet."

What you say he did is what he actually did, but what he said gives a
different impression. I don't think he's careless or stupid, so I
think he said that in order to create the impression in the minds of
the people listening to the interview that he's responsible for the
internet. 

That's just what politicians do, regardless of party affiliation.

joe
-- 
Gort, klatu barada nikto
-- 
http://mail.python.org/mailman/listinfo/python-list


Using scons zip builder to create zip

2005-10-18 Thread Chris Becker
What I am looking for is how to call the builder so that it does not
recurse directories and does not add paths:

zipFile = env.Zip(outputFile, sourcePath)

I seen something in the docs about ZIPFLAGS env var, but there is no
documentation on what the options are.

Anyone have any help or links?

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


Re: [wxPython-users] Web based applications are possible with wxPython?

2005-10-18 Thread Grant Edwards
On 2005-10-18, Ruben Charles <[EMAIL PROTECTED]> wrote:

> Can i have a wxPython GUI app available on a web browser?

I don't believe so.  I think it would be icnredibly difficult
to map a web API into wxWidgets API.

> If not, can you suggest me any kind oh method for have something similar?

I haven't tried it, but this looks sort of cool:

  http://trac.nunatak.com.au/projects/nufox



-- 
Grant Edwards   grante Yow!  HELLO, little boys!
  at   Gimme a MINT TULIP!! Let's
   visi.comdo the BOSSA NOVA!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web based applications are possible with wxPython?

2005-10-18 Thread Brett Hoerner
I don't think this is possible, unless I am grossly misunderstanding.

For the web, pretty much every "UI" is build with some variation of
HTML (XHTML is the new standard) with JavaScript thrown in for fancy
GUI-like interfaces.

You can't use OS-native widgets in the web browser, no.

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


  1   2   3   >