Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-29, Bill Mill schreef <[EMAIL PROTECTED]>:
>
> But, if your users can't figure out that they shouldn't be changing
> the variable called t._test__i without expecting side effects, what do
> you think of the users of your class?
>
> Python is for consenting adults.

No it is not. Consenting means you had the choice. Python doesn't
give you the choice not to consent. Unless of course you write
it as a C-extension, then you can hide all you want.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-29, Simon Brunning schreef <[EMAIL PROTECTED]>:
> On 9/29/05, could ildg <[EMAIL PROTECTED]> wrote:
>> **Encapsulation** is one of the 3 basic characteristics of OOP.
>
> Pyhton has encapsulation. On objetcts members are encapsulated in a
> namespace all of its own. You can't change these by accident.
>
>> Every programmer is  just a human being, but not God. Our life is limited,
>> our time is limited, so we need to use convenient tools to save time.
>> Private variables guarantee that we will never make stupid mistakes
>
> Private variables prevent the developer of the *client* of a class
> from making a small subset of all possible stupid mistakes. But if the
> developer of the classitself is mistaken in marking a variable as
> private, and if the language enforces this, then there is nothing at
> all that the client can do to fix it. Why should the developer of the
> class be more likely to be god-like than the user of the class? This
> has happened to me more than once.

So, talk to the devloper. The developer of the class is more god-like
because it is his development. If something goes wrong with the class
he has to find out what and that is easier if he can assure that clients
didn't mess with certain implementation details.

Sure the developer can make a mistake here, just as he can mistakes
anywhere in his code. If that happens, you should report a bug.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Paul Rubin
Dennis Lee Bieber <[EMAIL PROTECTED]> writes:
>   They did? Fine... Add another that Python names beginning with _ or
> __ are not to be accessed from outside the module/class that defined
> them. And if one is not the "owner" of that module/class, they should
> contact the responsible person and justify the need to have it made
> public, or to have access methods added.

People are much likelier than the compiler is, to make errors with
such policies.  For example: someplace in the application it says

  setattr(x, propname, 23)

where x is an ABC instance.  You didn't expect propname to have the
value "_ABC__private_var" but somehow it got that way, maybe through
malicious input data.  What coding standard is going to catch that?
Are you suggesting a coding standard that bans setattr?

I'm not proposing to change the behavior of a.__xyz even though that
behavior is currently broken.  The question under discussion is about
adding a new feature to Python, e.g. a "private" declaration that's
orthagonal to __xyz name mangling.  Whether such a feature is worth
implementing or not is questionable.  I'm not even saying it's worth
doing.  However, deciding to do it, and then doing it in a broken way,
is insane.

What "coding standards" let you do is review a piece of code and say
"the __xyz attribute didn't get clobbered, unless somebody, somewhere,
made an error with name mangling or the coding standard", which means
you have to consider that possibility anytime you're trying to debug
something related to the __xyz attribute.

OTOH, "private" lets you say 100% for certain that another class
didn't clobber __xyz, and that any bug that clobbered it MUST reside
in the class that declared it.  That makes auditing for __xyz-related
errors a lot simpler since you only have to look in one class for them.

If "private" exists and you don't like it, you can solve that with a
coding standard that says not to use it.  Any violation can be
instantly flagged by the build script.  If "private" doesn't exist,
there is no reasonable coding standard that can substitute for it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWin SendMessage

2005-09-30 Thread Gonzalo Monzón
g.franzkowiak escribió:

>Thomas Heller schrieb:
>  
>
>>"g.franzkowiak" <[EMAIL PROTECTED]> writes:
>>
>>
>>
>>
>>>Thomas Heller schrieb:
>>>
>>>  
>>>
"g.franzkowiak" <[EMAIL PROTECTED]> writes:





>Hello everybody,
>
>I've tryed to use an interprocess communication via
>SendMessage on Windows.
>Unfortunately, nothing goes on
>
>#
>#! /usr/bin/env python
>
>import win32api, win32ui, win32con
>import struct, array
>
>"""
>typedef struct tagCOPYDATASTRUCT {  // cds
>  DWORD dwData;
>  DWORD cbData;
>  PVOID lpData;
>} COPYDATASTRUCT;
>"""
>
>def packCopyData(nNum, sString):
>  int_buffer  = array.array("L",[nNum])
>  char_buffer = array.array('c', sString)
>  int_buffer_address  = int_buffer.buffer_info()[0]
>  char_buffer_address = char_buffer.buffer_info()[0]
>  char_buffer_size= char_buffer.buffer_info()[1]
>  copy_struct = struct.pack("pLp",# dword*, dword, char*
>int_buffer_address,
>char_buffer_size,
>char_buffer)
>  return copy_struct
>  
>
After packCopyData(...) returns, the arrays are destroyed, which will
probably void their contents.  You must keep them alive until you don't
need the COPYDATASTRUCT instance any longer.  For this kind of stuff,
ctypes may be easier to use than pywin32.

Thomas


>>>Hmm, have read something in <>
>>>and the script changed to this:
>>>
>>>#-
>>>#! /usr/bin/env python
>>>
>>>import win32api, win32ui, win32con, win32gui
>>>import struct, array
>>>  
>>>
>>>from ctypes import *
>>
>>
>>>"""
>>>typedef struct tagCOPYDATASTRUCT {  // cds
>>>   DWORD dwData;
>>>   DWORD cbData;
>>>   PVOID lpData;
>>>} COPYDATASTRUCT;
>>>"""
>>>
>>>class COPYDATATYPE(Structure):
>>>   _fields_ = [("nNum",   c_ulong),
>>>   ("szData", c_char_p)]
>>>
>>>class COPYDATASTRUCT(Structure):
>>>   _fields_ = [("dwData", c_ulong),
>>>   ("cbData", c_ulong),
>>>   ("lpData", POINTER(COPYDATATYPE))]
>>>
>>># get the window handle
>>>hwnd = win32ui.FindWindow(None, "target window")
>>>
>>># print just for fun
>>># ##print hwnd
>>>
>>># prepare copydata structure for sending data
>>>cpyData = COPYDATATYPE(1, '1')
>>>cds = COPYDATASTRUCT(c_ulong(1),
>>>c_ulong(sizeof(cpyData)),
>>>pointer(cpyData))
>>>
>>># try to send a message
>>>win32api.SendMessage(hwnd,
>>>win32con.WM_COPYDATA,
>>>0,
>>>pointer(cds))
>>>
>>>#-
>>>and the message for the last line is:
>>>==> TypeError: an integer is required"
>>>
>>>This message comes with "pointer(cds)" and with "addressof(cds)"
>>>  
>>>
>>That error refers to the first argument - win32ui.FindWindow returns a
>>PyCWnd object, which is not accepted by win32api.SendMessage.
>>Changing this brings you one step further.  win32api.SendMessage accepts
>>an integer for the last element, so addressof(cds) should work now.
>>
>>win32gui.SendMessage is more tolerant in what it accepts as 4th
>>argument, according to the error message you get when you try it it
>>expects a string, a buffer, or an integer.  So you could use addressof()
>>or pointer(), what you like best.
>>
>>Thomas
>>
>>
>
>Super, operates :-))
>
>My last answer must be in the Nirvana, strange ?
>
>Ok, only the version with 'addressof' generates a message and I must
>play with the data types. The receiver becomes a wrong data formate.
>Expect  (int=1, char[256]='1\00'), but the int is 0x31 and the string
>somewhat. Must play with my data.
>
>Thanks
>gerd
>  
>

Hi Gerd,

I'm not really sure of, but I think you must use a message value in 
range of WM_USER or WM_APP so this fact maybe let the receiver window 
getting bad data... have a look to this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesmessages/wm_user.asp

0 through WM_USER 

 
0x0400
Messages reserved for use by the system.
*WM_USER* through 0x7FFFInteger messages for use by private window 
classes.
*WM_APP* through 0xBFFF Messages available for use by applications.
0xC000 through 0x   String messages for use by applications.
Greater than 0x Reserved by the system.



I've done the same with PHP GTK and achieved 

Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-29, Rocco Moretti schreef <[EMAIL PROTECTED]>:
> [EMAIL PROTECTED] wrote:
>> On Fri, 30 Sep 2005 00:16:02 +1000
>> Steven D'Aprano wrote:
>> 
>>>Say you have written a class, with a private variable. I decide that I
>>>need access to that variable, for reasons you never foresaw.
>> 
>> What if the access to that variable was forbidden for reasons you never
>> foresaw? What if the class author decide to remove the variable in the next
>> version of the class, because it's not an interface, but only a part of the
>> class implementation?
>
> What if the class author removes a non-private variable or changes a 
> method's documented parameters in the next version of the class, because 
> he think it'll work better, or just because he can?

Changing an interface is different from changing the implementation.

A (documented) interface is like a contract. The implementation is
just one way to follow that contract.

> People who think that forbidding access to private variables/methods 
> will save themselves from upgrade woes are deluding themselves.

It helps, just as locks wont save you from burglars if they really
want to rob you, but the locks do help.

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


Re: RELEASED Python 2.4.2 (final)

2005-09-30 Thread Steve Holden
Delaney, Timothy (Tim) wrote:
> Bugs wrote:
> 
> 
>>It says ActivePython 2.4.1 but I downloaded the 2.4.2 binary installer
>>from python.org and the python.exe executable I'm running is
>>timestamped 9/28/2005 12:41PM...  Any ideas what I'm doing wrong?
> 
> 
> Visit this site:
> http://www.catb.org/~esr/faqs/smart-questions.html
> 
> Then try running the installer you downloaded (note any errors). Also,
> since the packages are produced by different groups (ActiveState vs.
> Python.org) perhaps you should uninstall the ActiveState package first
> (in which case you may need to install the pywin packages).
> 
> Tim Delaney

While that's often good advice, in this particular case I believe the 
OP's question was quite smart enough. It certainly got him the right 
answer in quick time!

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


Re: A quick c.l.p netiquette question

2005-09-30 Thread Steve Holden
Peter Hansen wrote:
> Fredrik Lundh wrote:
> 
>>Peter Hansen wrote:
>>
>>>Does it really have to be 158 lines to demonstrate these few issues?  I
>>>for one almost never take the time to dig through 158 lines of someone
>>>else's code, partly on the assumption that almost any interesting issue
>>>can be covered (using Python, specifically) in about a dozen lines of
>>>code.
> 
> 
>>did you click on the link he posted a little later?
> 
> 
> What link?  I see only two posts from him in this thread, one at 5:09 
> and the other at 6:14, and neither contains links.  I suppose I should 
> start to distrust my ISP's news feed, because that was how it was this 
> morning and how it still is now.  There are a grand total of 10 posts to 
> that thread as I'm about to post this reply.
> 
> Sorry, but I can't click on links that don't exist.
> 
> 
>>>YMMV
>>
>>no, YVFC.
> 
> 
> ??  you've lost me there too.  Your Very Fucked Computer?  I'll agree 
> that some computer around here is fucked if I can't see a post that 
> everyone else can see.
> 
> -Peter
> 
> (Well now... I just realized that it wasn't in the same thread after 
> all, and yes, I did see the post, then noticed a reply from someone 
> talking about Greenspun's law, quickly hit "k" to move on to more 
> interesting topics, and never gave it a second thought.  Certainly 
> didn't notice it was also Peter who had posted that one, nor realized 
> the connection (probably because I'd already sent my reply and thus 
> flushed the whole affair from my memory).  So, in summary, yes I did 
> click on the link he posted, but that was after I'd already replied so I 
> don't think it's particularly useful for us to be discussing it.  YMMV 
> again. :-)  )
> 
> (And I do see the YVFC part now... what was really bizarre was trying to 
> do a search on the web for what that acronym means.  Try it... strange 
> stuff.  I was thinking there was some weird conspiracy to make people 
> think there was this acronym that was well known but had no online 
> definition.)

Reminds me of the old one about them missing the world "gullible" from 
[name dictionary of your choice]. Always nice to be able to ask someone 
to read the definition once you've got them to prove you wrong.

Peter, perhaps you are getting too old to be posting on c.l.py ;-)

that'll-teach-you-to-be-rude-about-*me*-ly y'rs  - 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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-29, Steve Holden schreef <[EMAIL PROTECTED]>:

> Think about it: we have a language that has an eval() function and an 
> exec statement, and people are concerned that some service consumer 
> shouldn't be allowed to go poking around inside namespaces? What do we 
> have to do, put up signs saying "do not stab yourself with a knife"? If 
> people want control without discipline (which is effectively what 
> private and the like purport to do) then Python just may not be your 
> language ...

Well I have the following reasons not to like the current python way:

1) Beginning all your private variables with an underscore is like
starting all your integers with an 'i' or all your dictionary with
a 'd' etc.

2) The editor and font I use make it hard to see underscores. They
usually seem to belong more to the line below than to the actual
lines.

My idea as somekind of compromise between what happens in languages
like C++ and currently in python would be the following:

1) Allow keywords like private (or implemetation) to mark certain
variables, functions or classes as an implementation detail.
Personnally I would prefer the opposite such as a interface
to mark objects which are not private, but that would break too
much code.

2) Allow the client access to these private variables, through
a special construct. Maybe instead of "from ... import ..."
"from ... spy ...".

Just an idea.

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


Turning off syntax warnings?

2005-09-30 Thread Ivan Shevanski
Here's a noob question for everyone which i can't seem to find the answer to 
on google. . .Is there a way to turn off syntax warnings?




-Ivan

_
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


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

Re: Moronicity Xha Lee, Jargonizer

2005-09-30 Thread James Stroud
On Thursday 29 September 2005 19:07, Raymond Hettinger wrote:
> The tried-and-true solution is both simple and civil, "Don't feed the
> trolls."

This will also ease all suffering in the world and give us world peace and end 
hunger. If we could all just get along. If the bad men would just not be 
greedy. If there could just be a rapper v. country & western 
gangster-style-everybody-dies-shootout, then music might return to MTV.

I vote for the filter I described instead, seems more grounded in reality.

James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> On Fri, 30 Sep 2005 06:31:44 +0200
> Fredrik Lundh wrote:
> 
> 
>>[EMAIL PROTECTED] wrote:
>>
>>
>>>Looks like you must know every one of the base classes of the NotSoSecret,
>>>whether there is some base class named Secret? And, if so, you must also
>>>know these classes _implementation_
>>
>>that information isn't hidden, so there's nothing "you must know".  finding 
>>out
>>is a matter of writing a very small program, or tinkering at the interactive 
>>prompt
>>for a couple of seconds.  are you even aware that you're posting to a Python
>>group ?
> 
> 
> So you have read every line of the python std library, I guess? (Not to
> mention libc or kernel32.exe or whatever.)
> 
The effbot is actually probably about the worst opponent you could have 
taken on with a feeble argument like that being, as he (it) is, the 
author of the O'Reilly standard on the Python Standard Library. So 
Fredrik is probably *much* more likely than any other regular poster to 
be intimately familiar with the standard library.

All of which misses his point, however. Python easily allows you to 
access the information you are saying you "must know" - for 
non-extension classes it will even decompile the code if you ask it.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steve Holden
Antoon Pardon wrote:
> Op 2005-09-29, Bill Mill schreef <[EMAIL PROTECTED]>:
> 
>>But, if your users can't figure out that they shouldn't be changing
>>the variable called t._test__i without expecting side effects, what do
>>you think of the users of your class?
>>
>>Python is for consenting adults.
> 
> 
> No it is not. Consenting means you had the choice. Python doesn't
> give you the choice not to consent. Unless of course you write
> it as a C-extension, then you can hide all you want.
> 

Good grief, the ultimate choice is to use Python because you like it, or 
not to use it because you don't. Enough with the picking every available 
nit, please. Consent or stop complaining :-)

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


Re: Writing EXIF data

2005-09-30 Thread Roel Schroeven
Larry Bates schreef:
> I've used jhead and wrapped it with os.system call.
> 
> http://www.sentex.net/~mwandel/jhead/

Looks like it can do what I was looking for. Thanks a lot!

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


ANN: SciPy Core (Numeric Python Replacement) Version 0.4.X (beta) released

2005-09-30 Thread Travis Oliphant

Background:

Numeric  is an add-on Python module that has seen widespread adoption.  
It enables Python to be used as a Scientific Computing Environment 
similar to MATLAB or IDL.  Numeric was originally written nearly 10 
years ago, and while still performing admirably needed much updating to 
take advantage of the new features in Python and to remove old warts.

SciPy Core 0.4.1 (beta)

SciPy Core is a new system which builds on top of Numeric, but 
implements features (such as advanced index-selection, and user-settable 
error modes).  There are over 20 major new features over Numeric.  The 
LICENSE is still a BSD style License---the same as old Numeric.  More 
information can be found at the web-site: http://numeric.scipy.org


The primary developer of scipy core (besides the original creators of 
Numeric upon which it is based) is Travis Oliphant 
([EMAIL PROTECTED]), but his work received ideas and support from a 
wide cast of community members including:  Pearu Peterson, Robert Kern, 
Perry Greenfield, Eric Jones, John Hunter, Fernando Perez, Konrad 
Hinsen, and Paul Dubois.  These individuals should not be held 
responsible for any bugs remaining in the code.



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


Re: 1 Million users.. I can't Scale!!

2005-09-30 Thread Christos Georgiou
On Wed, 28 Sep 2005 21:58:15 -0400, rumours say that Jeff Schwab
<[EMAIL PROTECTED]> might have written:

>For many (most?) applications in need of 
>serious scalability, multi-processor servers are preferable.  IBM has 
>eServers available with up to 64 processors each, and Sun sells E25Ks 
>with 72 processors apiece.

SGI offers modular single-image Itanium2 servers of up to 512 CPU at the
moment:

http://www.sgi.com/products/servers/altix/configs.html

And NASA have clustered 20 of these machines to create a 10240 CPU
cluster...

>I like to work on those sorts of machine 
>when possible.  Of course, they're not right for every application, 
>especially since they're so expensive.

And expensive they are :)
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
> Good grief, the ultimate choice is to use Python because you like it,
> or not to use it because you don't. Enough with the picking every
> available nit, please. Consent or stop complaining :-)

Riiight.  "If she was walking in that neighborhood she must have
wanted it".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Moronicity of Guido van Rossum

2005-09-30 Thread Christos Georgiou
On Fri, 30 Sep 2005 07:50:45 +1000, rumours say that "Delaney, Timothy
(Tim)" <[EMAIL PROTECTED]> might have written:

>You have to admit though, he's remarkably good at getting past
>Spambayes. Despite classifying *every* Xah Lee post as spam, he still
>manages to get most of his posts classified as 0% or 1% spam.

IIRC this is because spambayes takes account of mostly spelling
misteaks; if syntax mistakes mattered as much, he would be classified as
spam more easily.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of socket.setdefaulttimeout?

2005-09-30 Thread Steve Holden
Russell Warren wrote:
> Does anyone know the scope of the socket.setdefaulttimeout call?  Is it
> a cross-process/system setting or does it stay local in the application
> in which it is called?
> 
> I've been testing this and it seems to stay in the application scope,
> but the paranoid side of me thinks I may be missing something... any
> confirmation would be helpful.
> 
Yes, it's an application setting, you aren't changing things for anyone 
else.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> So you have read every line of the python std library, I guess?

yes, but that's irrelevant.  in python, you don't need the source to find hidden
stuff.  finding out is a matter of writing a very small program, or tinkering 
at the
interactive prompt for a couple of seconds.  are you even aware that you're
posting to a Python group ?

 



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


Hello gnome-terminal

2005-09-30 Thread egbert
When I start the following script in a gnome-terminal:

#!/usr/bin/env python
import os
print "hello gnome-terminal"
print os.environ["PYTHONPATH"]

I see the expected results in the same gnome-terminal window.

However starting this same script via a launcher in a panel,
a new gnome-terminal window is opened for output only,
and PYTHONPATH is an unknown entity.
How can I open a terminal over whose environment and
configuration I have more control ?
-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991

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


A problem while using anygui

2005-09-30 Thread Johnny Lee
Hi,
   I've met a problem while using anygui to create a GUI. Here is a
brief example from Dave:

###
def guidialog():
   def ok(**kw):
  win.destroy()
  app.remove(win)
#
   anygui.link(btn_ok, ok)
#
   app.run()
   return n #qtgui will NEVER get here
###

   As you can see, the program will never get the sentence "return n".
I googled for the problem but didn't find much help. So any one here
could give me a hand? thanks

regards, 
Johnny

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steve Holden
Antoon Pardon wrote:
> Op 2005-09-29, Steve Holden schreef <[EMAIL PROTECTED]>:
> 
> 
>>Think about it: we have a language that has an eval() function and an 
>>exec statement, and people are concerned that some service consumer 
>>shouldn't be allowed to go poking around inside namespaces? What do we 
>>have to do, put up signs saying "do not stab yourself with a knife"? If 
>>people want control without discipline (which is effectively what 
>>private and the like purport to do) then Python just may not be your 
>>language ...
> 
> 
> Well I have the following reasons not to like the current python way:
> 
> 1) Beginning all your private variables with an underscore is like
> starting all your integers with an 'i' or all your dictionary with
> a 'd' etc.
> 
Well, surely anyone who's ever used Fortran knows that god is real 
unless explicitly declared to be integer. The convention wasn't meant 
for people who can't be safely allowed outside on their own.

> 2) The editor and font I use make it hard to see underscores. They
> usually seem to belong more to the line below than to the actual
> lines.
> 
So use a different editor and/or font, for Pete's sake.

> My idea as somekind of compromise between what happens in languages
> like C++ and currently in python would be the following:
> 
> 1) Allow keywords like private (or implemetation) to mark certain
> variables, functions or classes as an implementation detail.
> Personnally I would prefer the opposite such as a interface
> to mark objects which are not private, but that would break too
> much code.
> 
> 2) Allow the client access to these private variables, through
> a special construct. Maybe instead of "from ... import ..."
> "from ... spy ...".
> 
> Just an idea.
> 
Just an off-hand rejection.

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


Re: File Upload Script

2005-09-30 Thread Fuzzyman
On 29 Sep 2005 21:41:21 -0700, "Chuck" <[EMAIL PROTECTED]>
wrote:

>Hi, can anyone provide or point me in the direction of a simple python
>file upload script?  I've got the HTML form part going but simply
>putting the file in a directory on the server is what I'm looking for.
>Any help would be greatly appreciated.
>

An http CGI upload ?

http://www.voidspace.org.uk/python/cgi.shtml

All the best,

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

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


Re: RELEASED Python 2.4.2 (final)

2005-09-30 Thread Fuzzyman
On Thu, 29 Sep 2005 17:53:47 -0700, Bugs <[EMAIL PROTECTED]> wrote:

>I downloaded the 2.4.2 Windows Binary Installer from python.org but when 
>I try to run python.exe I get the following in the console:
>
>ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
>Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on 
>win32
>Type "help", "copyright", "credits" or "license" for more information.
> >>>
>
>It says ActivePython 2.4.1 but I downloaded the 2.4.2 binary installer 
>from python.org and the python.exe executable I'm running is timestamped 
>9/28/2005 12:41PM...  Any ideas what I'm doing wrong?
>

I had problems updating from activestate 2.4 to activestate 2.4.1

I think it was caused by not uninstalling the original. This does mean
that even a *minor* version upgrade is a PITA. To do it cleanly all
extension modules have to be uninstalled and re-installed.

*sigh*

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

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steve Holden
Paul Rubin wrote:
> Steve Holden <[EMAIL PROTECTED]> writes:
> 
>>Good grief, the ultimate choice is to use Python because you like it,
>>or not to use it because you don't. Enough with the picking every
>>available nit, please. Consent or stop complaining :-)
> 
> 
> Riiight.  "If she was walking in that neighborhood she must have
> wanted it".

This is about the most specious argument imaginable. There's plenty of 
room for discussion, heaven knows, without having to instigate a 
semantic examination of the word "consenting".

Some days you can't say anything without the nit police trampling your 
toes. Some days that gets on my nerves. Other days I'm out there picking 
nits myself. What can I tell you, I'm human.

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


Re: Fixes since 2.4.2c1?

2005-09-30 Thread Michael Ströder
Martin v. Löwis wrote:
> Michael Ströder wrote:
> 
>>Does that differ from 2.4.2c1? On Monday I noticed a crash in the test
>>suite on a box running Solaris 8. It seems I can build Python 2.4.1 and
>>run make test there without problems.
> 
> There is also a chance that you found a compiler bug. So reporting the
> compiler you used would be essential.

It's gcc 3.0 installed by a Solaris 8 (probably outdated) package from
http://www.sunfreeware.com

I can dig further into on Tuesday. It's not my box.

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Fredrik Lundh
Steve Holden wrote:

>> 1) Allow keywords like private (or implemetation) to mark certain
>> variables, functions or classes as an implementation detail.
>> Personnally I would prefer the opposite such as a interface
>> to mark objects which are not private, but that would break too
>> much code.

> Just an off-hand rejection.

fyi, an "access" mechanism was added in 1993, was only partially implemented,
was almost immediately deprecated, the supporting code were disabled in 1996,
and all traces were removed from the sources around 1997-89.

those who don't know history etc etc

 



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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Paul Rubin
Gregor Horvath <[EMAIL PROTECTED]> writes:
> >>Real open source live example from yesterdays mailinglists:
> > I don't see any use of name mangling in that example.
> 
> Someone has a problem and tweaks a private variable as a workaround.

They should have patched the source instead.

> No python program will rely by definition on access to privat
> variables, it just lets the door open, just for the case that the
> program is not used in steril theoretical environment with a lot of
> flipcharts but in real dirty live with bugs, version conflicts,
> changing demands, ill spezifications, crazy public interfaces and so
> on.

Believe it or not, not all development environments are that
disorganized.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-30, Steve Holden schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2005-09-29, Steve Holden schreef <[EMAIL PROTECTED]>:
>> 
>> 
>>>Think about it: we have a language that has an eval() function and an 
>>>exec statement, and people are concerned that some service consumer 
>>>shouldn't be allowed to go poking around inside namespaces? What do we 
>>>have to do, put up signs saying "do not stab yourself with a knife"? If 
>>>people want control without discipline (which is effectively what 
>>>private and the like purport to do) then Python just may not be your 
>>>language ...
>> 
>> 
>> Well I have the following reasons not to like the current python way:
>> 
>> 1) Beginning all your private variables with an underscore is like
>> starting all your integers with an 'i' or all your dictionary with
>> a 'd' etc.
>> 
> Well, surely anyone who's ever used Fortran knows that god is real 
> unless explicitly declared to be integer. The convention wasn't meant 
> for people who can't be safely allowed outside on their own.

What point do you have? That don't have to bother about this one
and can just skip the underscore on the attribute I feel as
private?

>> 2) The editor and font I use make it hard to see underscores. They
>> usually seem to belong more to the line below than to the actual
>> lines.
>> 
> So use a different editor and/or font, for Pete's sake.

Look, if defenders of python can use editor and font characteristics
to oppose the introduction of certain features in python, i can use
those arguments too when it suits me.  Beside almost all fonts
have this characteristic.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-30, Steve Holden schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2005-09-29, Bill Mill schreef <[EMAIL PROTECTED]>:
>> 
>>>But, if your users can't figure out that they shouldn't be changing
>>>the variable called t._test__i without expecting side effects, what do
>>>you think of the users of your class?
>>>
>>>Python is for consenting adults.
>> 
>> 
>> No it is not. Consenting means you had the choice. Python doesn't
>> give you the choice not to consent. Unless of course you write
>> it as a C-extension, then you can hide all you want.
>> 
>
> Good grief, the ultimate choice is to use Python because you like it, or 
> not to use it because you don't. Enough with the picking every available 
> nit, please. Consent or stop complaining :-)

This is IMO not a nit. IMO people are redefining words. We are also
talking within a certain context. When people use this slogan, they
don't mean that people have the choice to not use python.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Antoon Pardon
Op 2005-09-30, Fredrik Lundh schreef <[EMAIL PROTECTED]>:
> Steve Holden wrote:
>
>>> 1) Allow keywords like private (or implemetation) to mark certain
>>> variables, functions or classes as an implementation detail.
>>> Personnally I would prefer the opposite such as a interface
>>> to mark objects which are not private, but that would break too
>>> much code.
>
>> Just an off-hand rejection.
>
> fyi, an "access" mechanism was added in 1993, was only partially implemented,
> was almost immediately deprecated, the supporting code were disabled in 1996,
> and all traces were removed from the sources around 1997-89.
>
> those who don't know history etc etc

What history? If it was only partially implemented and almost
immediately deprecated, there can't have been much experience
with it. 

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


Re: Soap Question (WSDL)

2005-09-30 Thread Adriaan Renting
You need the WSDL file if you want external probrams to be able to discover 
what WebService you are running, so it depends on your need if you need to use 
one. You can perfectly run a SOAP service without a WSDL file, using SOAPpy, 
only then external programs do not have a way to find out how to talk to you.
A WSDL file just defines what messages, operations, urls etc. you 
accept/send/offer.
If your external applications know how to talk to you, you can do without a 
WSDL file.

It contains stuff like:
   
  
   
...
  
 
 
http://schemas.xmlsoap.org/soap/encoding/"; 
namespace="urn:something.test" use="encoded"/>
 
 
http://schemas.xmlsoap.org/soap/encoding/"; 
namespace="urn:something.test" use="encoded"/>
 
  


 
 
>>>"Armin" <[EMAIL PROTECTED]> 09/30/05 12:56 am >>> 
Hey everyone, 
 
I am trying to write a web app. that connects to flickr using SOAP. The 
book 'Dive into python' says I need to have a WSDL file to connect, 
while the only useful soap related url flickr api 
(flickr.com/services/api) provides is the following: 
 
The SOAP Server Endpoint URL is http://www.flickr.com/services/soap/ 
 
What am I supposed to do here? Help is very much appreciated at this 
point. 
 
Thanks, 
Armin 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Gregor Horvath
Paul Rubin wrote:

> Gregor Horvath <[EMAIL PROTECTED]> writes:

>>Someone has a problem and tweaks a private variable as a workaround.
>  
> They should have patched the source instead.
> 

I think they are going to do that. In the meantime our friend has a 
working solution otherwise he would have nothing but broken code today.

> 
> Believe it or not, not all development environments are that
> disorganized.

Martians?
Examples?

This has nothing to do with organisation but a lot with natural 
influances and constraints of software development (except really simple 
programs)

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


return (PyObject*)myPyType; ...segmentation fault!

2005-09-30 Thread elho
I called a own python type 'PyType' with a c function and returned it 
into my python programm - there it fault.
It is said that the object has a NULL-Pointer when I try to debug it?

Here are the importent snips from my code:


// == test.py =
.
:
myNewPyType = PyMyExtention.GetValue ("xxx")
# printings for testing
print "...back to python... test.py"
print "pp\t ...PyMyType.PyMyObject:", type(tySdlXml)
//===/


// == PyMyExtention.c =
.
:
static PyObject* wrap_GetValue (PyObject* self, PyObject* args)
{
 char*  pchXXX;
 if (!PyArg_ParseTuple(args, "s", &pchXXX))
 {
 return 0;
 }

 long llong = CFunktion::CallMe(pchXXX);

 // returning Python-Objekt
 PyObject *pyType = PyMyObject_NewC (llong);
 cout << "cc ..." << ((PyMyType*)pyType)->lAttribute << endl;
 cout << "\t ...proof object-valid pointer?" << (void*)pyType << endl;
 return (PyObject*)pyType;
}
.
:
//===/


// == PyMyExtention.c =
.
:
typedef struct {
 PyObject_HEAD
 long lAttribute;
} PyMyObject;

static PyObject* PyMyObject_NewC (long lAttribute)
{
 PySDLXMLNode *self;
 PySDLXMLNode *type;

 self = new PySDLXMLNode;
 self->lAttribute = lAttribute;

 return (PyObject*)self;
}

static PyMethodDef PyMyObject_methods[] = {
 {"PyMyObject_NewC", (PyCFunction)PyMyObject_NewC, METH_NOARGS,
 "Create PyMyObject_NewC from C-Code"},
 {NULL}  /* Sentinel */
};

:

static PyTypeObject PySDLXMLNodeType = {
 PyObject_HEAD_INIT(NULL)
 :
};
//===/


// :::   output  

cc ...135603272
 t ...proof object-valid pointer?: 0x8165940
...back to python... test.py
Segmentation fault

//===/


...you see: It returns to python but over there the object is something 
bad. So what is wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Self reordering list in Python

2005-09-30 Thread zooko
I've implemented such an LRU Cache in Python.  My technique was to
weave a doubly-linked list into the dict, so that it is O(dict) for all
LRU operations.  I benchmarked it against someone's Python-list-based
implementation from the ActiveState cookbook and noted that on my
machine the better constant factors of the Python list win out when the
list is cache contains fewer than about 16000 elements.  Of course,
once you exceed that cross-over point, the asymptotically worse
behavior of the list-based implementation becomes a big factor.  If you
have more than 16000 or so elements then you really oughtn't use a
list-based LRU cache.

http://zooko.com/repos/pyutil/pyutil/pyutil/cache.py

I haven't benchmarked it against Evan Podromou's heap implementation
yet, but obviously inserting and removing things from a heapq heap is
O(N).

You can find unit tests and benchmarking tools in the pyutil/test
directory.

Regards,

Zooko

P.S.  I read this list sporadically, so if you want me to read your
response, please Cc: [EMAIL PROTECTED]  Thanks.

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


Re: Self reordering list in Python

2005-09-30 Thread Paul Rubin
"zooko" <[EMAIL PROTECTED]> writes:
> I haven't benchmarked it against Evan Podromou's heap implementation
> yet, but obviously inserting and removing things from a heapq heap is
> O(N).

Good heavens, I should hope not.  The whole point of heaps is that
those operations are O(log(N)).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Font management under win32

2005-09-30 Thread Stefano Masini
On 9/30/05, Roger Upole <[EMAIL PROTECTED]> wrote:
> Here's an example of how to use EnumFontFamilies:

I'm trying the code you just posted, which works (thanks a lot), but I'm having
another problem now.

As I stated in my first post, the reason why I need to know the list
of installed fonts is that I have to decide whether to further install
some additional missing ones.
The problem I have now, is that I don't know before hand the name of
the missing fonts, I just have their .ttf or .otf files. So I'd have
to somehow go inside and look for their names.

Do you think that is possible with win32 extensions?

thanks,
stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: return (PyObject*)myPyType; ...segmentation fault!

2005-09-30 Thread Fredrik Lundh
"elho" <[EMAIL PROTECTED]> wrote:

> It is said that the object has a NULL-Pointer when I try to debug it?

what object?

> Here are the importent snips from my code:

where's the PySDLXMLNode code?  is the PySDLXMLNode constructor
really doing a proper PyObject initialization?  (PyObject subtypes are usually
allocated by Python's memory allocation layer, which does this for you).

 



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


Re: Hello gnome-terminal

2005-09-30 Thread gnukid
Hi

Launcher may spawn a new shell to execute your program. The new shell
wont have your PYTHONPATH environment variable.

Cheers,
Noorul

egbert wrote:
> When I start the following script in a gnome-terminal:
>
> #!/usr/bin/env python
> import os
> print "hello gnome-terminal"
> print os.environ["PYTHONPATH"]
>
> I see the expected results in the same gnome-terminal window.
>
> However starting this same script via a launcher in a panel,
> a new gnome-terminal window is opened for output only,
> and PYTHONPATH is an unknown entity.
> How can I open a terminal over whose environment and
> configuration I have more control ?
> --
> Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991
> 

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


Re: Soap Question (WSDL)

2005-09-30 Thread Fredrik Lundh
Armin wrote:

> I am trying to write a web app. that connects to flickr using SOAP. The
> book 'Dive into python' says I need to have a WSDL file to connect,
> while the only useful soap related url flickr api
> (flickr.com/services/api) provides is the following:
>
> The SOAP Server Endpoint URL is http://www.flickr.com/services/soap/
>
> What am I supposed to do here? Help is very much appreciated at this
> point.

any reason you cannot use one of the Python toolkits listed on this page ?

http://www.flickr.com/services/api/

(after all, if you find yourself stumbling on the first step, it might be better
to hitch a ride with someone else...)

 



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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steven D'Aprano
On Fri, 30 Sep 2005 06:31:44 +0200, Fredrik Lundh wrote:

> [EMAIL PROTECTED] wrote:
> 
>> Looks like you must know every one of the base classes of the NotSoSecret,
>> whether there is some base class named Secret? And, if so, you must also
>> know these classes _implementation_
> 
> that information isn't hidden, so there's nothing "you must know".  finding 
> out
> is a matter of writing a very small program, or tinkering at the interactive 
> prompt
> for a couple of seconds.

Which of course is only possible because Python does not hide information,
it uses semi-private attributes rather than secret private ones, and
allows close to full introspection.

Still, [EMAIL PROTECTED]'s point that you must know the base classes
is correct. It is *easy* to find them out (NotSoSecret.__bases__ should do
it), but if you don't you are taking a chance that your class name doesn't
clash with one of the bases.

In other words, this is a Gotcha, not a world-shattering disaster.


-- 
Steven.

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


Re: portable way to get process infos

2005-09-30 Thread gnukid
Try cygwin (http://www.cygwin.com)

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


Re: Font management under win32

2005-09-30 Thread Fredrik Lundh
Stefano Masini wrote:

> Do you think that is possible with win32 extensions?

you can do this via PIL's ImageFont module:

>>> import ImageFont
>>> f = ImageFont.truetype("arial.ttf")
>>> f.font.family
'Arial'
>>> f.font.style
'Regular'

or, if you don't want to ship the entire PIL library with your app, you
can grab the _imagingft module and use low-level functions:

>>> import _imagingft
>>> f = _imagingft.getfont("c:/windows/fonts/arial.ttf", 0)
>>> f.family
'Arial'
>>> f.style
'Regular'

 



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


Re: RELEASED Python 2.4.2 (final)

2005-09-30 Thread Steve Holden
Fuzzyman wrote:
> On Thu, 29 Sep 2005 17:53:47 -0700, Bugs <[EMAIL PROTECTED]> wrote:
> 
> 
>>I downloaded the 2.4.2 Windows Binary Installer from python.org but when 
>>I try to run python.exe I get the following in the console:
>>
>>ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
>>Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on 
>>win32
>>Type "help", "copyright", "credits" or "license" for more information.
>>
>>
>>It says ActivePython 2.4.1 but I downloaded the 2.4.2 binary installer 
> 
>>from python.org and the python.exe executable I'm running is timestamped 
> 
>>9/28/2005 12:41PM...  Any ideas what I'm doing wrong?
>>
> 
> 
> I had problems updating from activestate 2.4 to activestate 2.4.1
> 
> I think it was caused by not uninstalling the original. This does mean
> that even a *minor* version upgrade is a PITA. To do it cleanly all
> extension modules have to be uninstalled and re-installed.
> 
> *sigh*
> 
Not necessarily so. You should find the uninstall leaves all your local 
additions in place in site-packages, immediately available when a new 
minor version is installed.

Until 2.5, of course, *then* you'll need to reinstall.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steve Holden
Antoon Pardon wrote:
> Op 2005-09-30, Steve Holden schreef <[EMAIL PROTECTED]>:
> 
>>Antoon Pardon wrote:
>>
>>>Op 2005-09-29, Bill Mill schreef <[EMAIL PROTECTED]>:
>>>
>>>
But, if your users can't figure out that they shouldn't be changing
the variable called t._test__i without expecting side effects, what do
you think of the users of your class?

Python is for consenting adults.
>>>
>>>
>>>No it is not. Consenting means you had the choice. Python doesn't
>>>give you the choice not to consent. Unless of course you write
>>>it as a C-extension, then you can hide all you want.
>>>
>>
>>Good grief, the ultimate choice is to use Python because you like it, or 
>>not to use it because you don't. Enough with the picking every available 
>>nit, please. Consent or stop complaining :-)
> 
> 
> This is IMO not a nit. IMO people are redefining words. We are also
> talking within a certain context. When people use this slogan, they
> don't mean that people have the choice to not use python.
> 
Quite true, but people do none the less have that choice. Some days I 
wish a few more would exercise it.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steven D'Aprano
On Fri, 30 Sep 2005 06:52:50 +, Antoon Pardon wrote:

> Op 2005-09-29, Bill Mill schreef <[EMAIL PROTECTED]>:
>>
>> But, if your users can't figure out that they shouldn't be changing
>> the variable called t._test__i without expecting side effects, what do
>> you think of the users of your class?
>>
>> Python is for consenting adults.
> 
> No it is not. Consenting means you had the choice. Python doesn't
> give you the choice not to consent. 

Damn straight. I used to be a perfectly happy Pascal programmer, until
Guido and the Timbot kicked down my front door and forced me at gun point
to start programming in Python.

-- 
Steven.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Still, [EMAIL PROTECTED]'s point that you must know the base classes
> is correct. It is *easy* to find them out (NotSoSecret.__bases__ should do
> it), but if you don't you are taking a chance that your class name doesn't
> clash with one of the bases.

It's not easy if the base classes change after you check your code in.
You shouldn't need to know about that if it happens.  Modularity, remember?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steven D'Aprano
On Fri, 30 Sep 2005 00:58:17 -0700, Paul Rubin wrote:

> Steve Holden <[EMAIL PROTECTED]> writes:
>> Good grief, the ultimate choice is to use Python because you like it,
>> or not to use it because you don't. Enough with the picking every
>> available nit, please. Consent or stop complaining :-)
> 
> Riiight.  "If she was walking in that neighborhood she must have
> wanted it".

Nobody is forcing you to use Python. If you don't like it, feel free to
use Java or C++ or Ada or whatever language you prefer.

Sheesh, I know people get really worked up over language philosophies, but
comparing lack of "real" private variables to rape is going overboard.


-- 
Steven.

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


Re: A Moronicity of Guido van Rossum

2005-09-30 Thread Gerrit Holl
Tony Meyer wrote:
> X-Spambayes-Classification: ham; 0.048
> X-Spambayes-Evidence: '*H*': 0.90; '*S*': 0.00; 'bug.': 0.07; 'flagged': 
> 0.07; 
>   "i'd": 0.08; 'bayes': 0.09; 'from:addr:ihug.co.nz': 0.09;
>   'really,': 0.09; 'cc:no real name:2**0': 0.14;
>   'from:addr:t-meyer': 0.16; 'from:name:tony meyer': 0.16;
>   'obvious,': 0.16; 'spambayes': 0.16; 'subject:Guido': 0.16;
>   'trolling,': 0.16; 'regret': 0.82; 'lee,': 0.91; 'viagra': 0.91;
>   'mailings': 0.93; 'probability': 0.93

> This is a feature, not a bug.  It's the same feature that means that  
> messages talking about spam on the spambayes mailing list, or the  
> legitimate mail I get about viagra , get through to me.

True. However, most mail to this mailinglist has less than 0.001 spam
probability. As you can see, this one had 0.048 - a vast score, almost
enough to put it in my unsure box. It seems to be just not hammy enough.
It's interesting to see that no none of the foul language words used by
Xah Lee ever occurs in any spam I receive - spam is not that stupid.

Gerrit.

-- 
Temperature in Luleå, Norrbotten, Sweden:
| Current temperature   05-09-30 12:49:54   11.1 degrees Celsius ( 51.9F) |
-- 
Det finns inte dåligt väder, bara dåliga kläder.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python-list Digest, Vol 24, Issue 451

2005-09-30 Thread Elke Hohls
Sorry, the last line is wrong:
PySDLXMLNodeType = PyMyType
..above the correction

// == PyMyExtention.c =
.
:
typedef struct {
 PyObject_HEAD
 long lAttribute;
} PyMyObject;

static PyObject* PyMyObject_NewC (long lAttribute)
{
 PyMyObject *self;
 PyMyObject *type;

 self = new PyMyObject
 self->lAttribute = lAttribute;

 return (PyObject*)self;
}

static PyMethodDef PyMyObject_methods[] = {
 {"PyMyObject_NewC", (PyCFunction)PyMyObject_NewC, METH_NOARGS,
 "Create PyMyObject_NewC from C-Code"},
 {NULL}  /* Sentinel */
};

:

static PyTypeObject PyMyType = {
 PyObject_HEAD_INIT(NULL)
 :
};
//===/

[EMAIL PROTECTED] wrote:
> Send Python-list mailing list submissions to
>   [email protected]
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>   [EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>   [EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
> 
> 
> 
> 
> Today's Topics:
> 
>1. Re: Soap Question (WSDL) (Adriaan Renting)
>2. Re: Will python never intend to support private, protected
>   and public? (Gregor Horvath)
>3. return (PyObject*)myPyType;  ...segmentation fault! (elho)
>4. Re: Self reordering list in Python (zooko)
> 
> 
> 
> 
> Subject:
> Re: Soap Question (WSDL)
> From:
> "Adriaan Renting" <[EMAIL PROTECTED]>
> Date:
> Fri, 30 Sep 2005 11:22:36 +0200
> To:
> 
> 
> To:
> 
> 
> 
> You need the WSDL file if you want external probrams to be able to discover 
> what WebService you are running, so it depends on your need if you need to 
> use one. You can perfectly run a SOAP service without a WSDL file, using 
> SOAPpy, only then external programs do not have a way to find out how to talk 
> to you.
> A WSDL file just defines what messages, operations, urls etc. you 
> accept/send/offer.
> If your external applications know how to talk to you, you can do without a 
> WSDL file.
> 
> It contains stuff like:
>
>   
>
> ...
>   
>  
>  
>  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
> namespace="urn:something.test" use="encoded"/>
>  
>  
>  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
> namespace="urn:something.test" use="encoded"/>
>  
>   
> 
> 
>  
>  
> 
"Armin" <[EMAIL PROTECTED]> 09/30/05 12:56 am >>> 
> 
> Hey everyone, 
>  
> I am trying to write a web app. that connects to flickr using SOAP. The 
> book 'Dive into python' says I need to have a WSDL file to connect, 
> while the only useful soap related url flickr api 
> (flickr.com/services/api) provides is the following: 
>  
> The SOAP Server Endpoint URL is http://www.flickr.com/services/soap/ 
>  
> What am I supposed to do here? Help is very much appreciated at this 
> point. 
>  
> Thanks, 
> Armin 
>  
> 
> 
> 
> 
> Subject:
> Re: Will python never intend to support private, protected and public?
> From:
> Gregor Horvath <[EMAIL PROTECTED]>
> Date:
> Fri, 30 Sep 2005 11:31:59 +0200
> To:
> [email protected]
> 
> To:
> [email protected]
> 
> 
> Paul Rubin wrote:
> 
>> Gregor Horvath <[EMAIL PROTECTED]> writes:
> 
> 
>>> Someone has a problem and tweaks a private variable as a workaround.
>>
>>  
>> They should have patched the source instead.
>>
> 
> I think they are going to do that. In the meantime our friend has a 
> working solution otherwise he would have nothing but broken code today.
> 
>>
>> Believe it or not, not all development environments are that
>> disorganized.
> 
> 
> Martians?
> Examples?
> 
> This has nothing to do with organisation but a lot with natural 
> influances and constraints of software development (except really simple 
> programs)
> 
> -- 
> Greg
> 
> 
> 
> 
> Subject:
> return (PyObject*)myPyType; ...segmentation fault!
> From:
> elho <[EMAIL PROTECTED]>
> Date:
> Fri, 30 Sep 2005 11:50:42 +0200
> To:
> [email protected]
> 
> To:
> [email protected]
> 
> 
> I called a own python type 'PyType' with a c function and returned it 
> into my python programm - there it fault.
> It is said that the object has a NULL-Pointer when I try to debug it?
> 
> Here are the importent snips from my code:
> 
> 
> // == test.py =
> .
> :
> myNewPyType = PyMyExtention.GetValue ("xxx")
> # printings for testing
> print

Re: Problem with long strings in the Boost.Python getting_started2 sample ?

2005-09-30 Thread Sylvain MARIE
Well, answering my own question here...

See http://mail.python.org/pipermail/c++-sig/2002-November/002415.html 
8-)

Sylvain


"Sylvain MARIE" <[EMAIL PROTECTED]> a écrit dans le message de news: 
[EMAIL PROTECTED]
> Hi all,
>
> I am discovering Boost.Python, and weird exceptions in my dummy extension 
> modules lead me to think there is a potential problem with the 
> getting_started2 sample :
> if you replace the first lines
>
 hi = hello('California')
 hi.greet()
> 'Hello from California'
>
> by
 hi = hello('A longer name with more than 15 chars')
 hi.greet()
> 'Hello from A longer name with more than 15 chars'
>
> then the unit test asserts !?!? I get a c++ exception :-(
>
> Please tell me we can use strings longer than 15 chars with Boost.Python 
> :-)
> (I'm using Boost 1.33.0 with VC7.1, and the bjam makefiles)
>
> thank you very much in advance!
> Sylvain
> 


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

Re: return (PyObject*)myPyType; ...segmentation fault!

2005-09-30 Thread elho
> > It is said that the object has a NULL-Pointer when I try to debug it?
> what object?
   the python one  'myNewPyType'



Sorry, I forgot to change:
   PySDLXMLNodeType = PyMyType
..above the corrections

// == PyMyExtention.c =
.
:
typedef struct {
PyObject_HEAD
long lAttribute;
} PyMyObject;

static PyObject* PyMyObject_NewC (long lAttribute)
{
PyMyObject *self;
PyMyObject *type;

self = new PyMyObject
self->lAttribute = lAttribute;

return (PyObject*)self;
}

static PyMethodDef PyMyObject_methods[] = {
{"PyMyObject_NewC", (PyCFunction)PyMyObject_NewC, METH_NOARGS,
"Create PyMyObject_NewC from C-Code"},
{NULL}  /* Sentinel */
};

:

static PyTypeObject PyMyType = {
PyObject_HEAD_INIT(NULL)
:
};
//===/

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


Virus Found in message "Returned mail: see transcript for details"

2005-09-30 Thread Post Office
Symantec AntiVirus found a virus in an attachment from "Post Office" <[EMAIL 
PROTECTED]>.


Attachment:  mail.zip
Threat: [EMAIL PROTECTED]
Action taken:  Delete succeeded
File status:  Deleted


Message could not be delivered

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

Re: replacments for stdio?

2005-09-30 Thread Ido . Yehieli
Thanks martin,
I'll give it a shot as soon as i get back from work!

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


Re: Where to find python c-sources

2005-09-30 Thread Tor Erik S�nvisen

"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Tor Erik Sønvisen wrote:
>
>> I need to browse the socket-module source-code. I believe it's contained 
>> in the file socketmodule.c, but I can't locate this file... Where should 
>> I look?
>
> The source tarball, available on python.org.  Are people really too lazy 
> to do elementary research on Google?
>
> -- 
> Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
> San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
>   The people are to be taken in very small doses.
>   -- Ralph Waldo Emerson

Thanks for the answers... And yes, I have searched google! 


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

Re: Help with syntax warnings

2005-09-30 Thread Peter Hansen
Robert Kern wrote:
> Peter Hansen wrote:
>>Not sure... what's a "syntax warning"?
> 
> In [1]: SyntaxWarning?
> Type:   classobj
> String Form:exceptions.SyntaxWarning
> Namespace:  Python builtin
> Docstring:
> Base class for warnings about dubious syntax.

Wow... Python detects "dubious syntax"?  And here I thought programming 
was rather black and white, it's right or it's wrong.

(He notes examples such as assigning to None and "unqualified exec is 
not allowed in function" etc.)

I guess I've never accidentally hit one of those.  Seems like, if I had, 
I'd probably want to fix the problem rather than hide it, as with most 
warnings from C compilers.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steven D'Aprano
On Fri, 30 Sep 2005 07:37:14 +, Antoon Pardon wrote:

> Well I have the following reasons not to like the current python way:
> 
> 1) Beginning all your private variables with an underscore is like
> starting all your integers with an 'i' or all your dictionary with
> a 'd' etc.

Three points:

(1) It is utterly pointless in a statically typed language like C to name
integer variables starting with an i, because both you and the compiler
already know it is an integer. However, in a dynamically typed language
like Python, it may in some circumstances make sense, since you have no
other clue as to the expected type of object a variable has.

(Descriptive names like "arglist" are better, but when the descriptive
name is ambiguous, or there is no sensible descriptive name, this
convention can be helpful.)

(2) Hungarian notation wasn't supposed to be about starting integer
variables' names with an i, that was a misunderstanding of the Microsoft
OS division. See here for further details:

http://www.joelonsoftware.com/articles/Wrong.html

(3) Let's do a small thought experiment. Suppose that Python introduces
"real" private variables. Now that Python has private variables, tens of
thousands of C++ and Java developers immediately rush to use Python in
huge collaborative projects. You're working on one of these huge projects,
and reading the source code to a class that takes 45 pages for its
definition. You're on page 33, and you see these lines:

# cache the expensive lookup for extra speed
usercache = self.longcomplexcalculation()

"Ahah!" you say to yourself, "That's exactly what I need to make my code
run faster. Instead of calling Klass.longcomplexcalculation() every time I
need it, I can just look at usercache."

Quick: was usercache a private variable? How can you tell, short of
searching through those 45 pages of code? You can't.

Of course, in real Python, as soon as you see _usercache with a leading
underscore, you know it is a private variable, and you don't have to
search the source code to find out. So that's an advantage to the
existing Python system.

It seems to me that much of this argument is about terminology, not
reality. We've made a mistake in describing Python as "not having private
variables, only semi-private by convention". Bad bad bad. 

What we should have said is that Python DOES have private variables. In
the same way that Python forces you to use a consistent indentation
scheme, Python forces you to name all your private attributes with a
leading underscore. And just like C++ lets you sneakily access private
variables by defining private as public, so Python lets you sneakily
access private variables by mangling the name.

Then we'd all be happy, the language zealots would take note that Python's
implementation of private variables has a gotcha to watch out for, and
we'd all be happy.


> 2) The editor and font I use make it hard to see underscores. They
> usually seem to belong more to the line below than to the actual
> lines.

That's a bug in the editor/font combination. I've seen some versions of
Abiword cut off the bottom pixel from lines, including underscores. If
your editor made y look like v or u, you'd call it a bug, and if it makes
an underscore disappear or look like part of the next line, that's a bug
too. (Just like Ariel has the bug that the letters r n together look like
the letter m. darn vs dam.



> My idea as somekind of compromise between what happens in languages
> like C++ and currently in python would be the following:
> 
> 1) Allow keywords like private (or implemetation) to mark certain
> variables, functions or classes as an implementation detail.
> Personnally I would prefer the opposite such as a interface
> to mark objects which are not private, but that would break too
> much code.
> 
> 2) Allow the client access to these private variables, through
> a special construct. Maybe instead of "from ... import ..."
> "from ... spy ...".

What you are suggesting is that you have private variables that are only
private by convention, since anyone can simply call use spy to treat
them as public. In other words, no different from what Python already
does, except it avoids underscores and introduces at least one new keyword
(spy) and one new syntax element (something to flag a variable as private).

Yeah, that will make a huge difference.



-- 
Steven.

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


Re: RELEASED Python 2.4.2 (final)

2005-09-30 Thread Peter Hansen
Martin v. Löwis wrote:
> Trent Mick wrote:
> 
>>It is possible that the python.org installer didn't overwrite the
>>"python24.dll" in the system directory (C:\WINDOWS\system32). Try doing
>>this:
> 
> 
> Even though this is apparently what happened, I'm puzzled as to why it
> happened: shouldn't the version number of python24.dll in the pydotorg
> installer be higher than the one in the ActivePython installer, and
> shouldn't then Windows Installer overwrite the DLL?

Couldn't it also happen if the first time someone did an "admin" install 
which (I believe) puts the DLLs in the system folder, and the next time 
did just a non-admin install which doesn't do that?  (Or am I 
misunderstanding the conditions under which c:\windows\system32 has 
files written to it?)

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


Re: A Moronicity of Guido van Rossum

2005-09-30 Thread Peter Hansen
Gerrit Holl wrote:
> True. However, most mail to this mailinglist has less than 0.001 spam
> probability. As you can see, this one had 0.048 - a vast score, almost
> enough to put it in my unsure box. It seems to be just not hammy enough.
> It's interesting to see that no none of the foul language words used by
> Xah Lee ever occurs in any spam I receive - spam is not that stupid.

"Xah Lee: stupider than spam." (?)

-neologism-intentional-ly y'rs,
  Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Moronicity Xha Lee, Jargonizer

2005-09-30 Thread Peter Hansen
Kay Schluehr wrote:
> By the way I noticed also a few reasonable non-troll postings of Xah
> without any response in the forum. Not even Xahs posting strategy is
> coherent.

Really?  Every one I've noticed has actually had a response, and a 
reasonably civil one at that.  Usually from Steve Holden, too, which 
makes the civility doubly surprising. ;-)

-revenge-is-sweet-ly y'rs,
  Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > 2) Allow the client access to these private variables, through
> > a special construct. Maybe instead of "from ... import ..."
> > "from ... spy ...".
> 
> What you are suggesting is that you have private variables that are only
> private by convention, since anyone can simply call use spy to treat
> them as public.

This notion isn't so bad, if there's way for modules to notice when
they're spied on, like an import hook, e.g.:

  def __spy__(othermodule, symbol_list):
 # this gets called when another module spies on symbols

It's like a runtime version of C++'s "friend" declaration.  Well, not
quite as good, it's like having some stranger slide over to you in a
bar and say "I wanna be your friend".  But at least it's better than
not finding out at all where the external references are.
-- 
http://mail.python.org/mailman/listinfo/python-list


Compile fails on x86_64

2005-09-30 Thread Neal Becker
In file included from scipy/base/src/multiarraymodule.c:44:
scipy/base/src/arrayobject.c: In function 'array_frominterface':
scipy/base/src/arrayobject.c:5151: warning: passing argument 3 of
'PyArray_New' from incompatible pointer type
error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m64 -mtune=nocona -D_GNU_SOURCE -fPIC
-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m64 -mtune=nocona -fPIC
-Ibuild/src/scipy/base/src -Iscipy/base/include -Ibuild/src/scipy/base
-Iscipy/base/src -I/usr/include/python2.4 -c
scipy/base/src/multiarraymodule.c -o
build/temp.linux-x86_64-2.4/scipy/base/src/multiarraymodule.o" failed with
exit status 1
error: Bad exit status from /var/tmp/rpm/rpm-tmp.96024 (%build)


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


how to stop info output on screen

2005-09-30 Thread midday . hu
Hi,

Does someone know how to stop "the information output on screen"? Now
when I run my code, it outputs a lot of message when calling other
libraries, together with the info with the print command I used.

How can I mask these info on screen when calling other libraries and
how I can mask the info output produced by the print command? Is there
a way to mask them separately.

Thanks a lot if anyone knows it.

Kind regards of your help
Midday

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


compile fails on x86_64 (more)

2005-09-30 Thread Neal Becker
In file included from scipy/base/src/multiarraymodule.c:44:
scipy/base/src/arrayobject.c:41: error: conflicting types for
'PyArray_PyIntAsIntp'
build/src/scipy/base/__multiarray_api.h:147: error: previous declaration of
'PyArray_PyIntAsIntp' was here


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


Re: Help with syntax warnings

2005-09-30 Thread Roel Schroeven
Ivan Shevanski schreef:
> Here's a noob question for everyone (I'm not sure if my first message
> got through, is had a "suspicious header" so sorry for double post is
> so), is there a way to turn off syntax warnings or just make them not
> visible?

Those warnings are something I have never seen and even have never heard
about, even though I now found out there's a section in the library
reference about them. It seems you can define filters to specify what
you want to do with the warnings; you can read all about it at
http://docs.python.org/lib/module-warnings.html

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: how to stop info output on screen

2005-09-30 Thread Ido . Yehieli
maybe you can try replaceing sys.stdout and/or sys.stderr with a just a
simple file? then everything will be written to that file instead of
desplayed on the console.

Cheers,
Ido.

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


Re: how to stop info output on screen

2005-09-30 Thread Ido . Yehieli
more on the subject: your "print" statments will also be written to
that file that sys.stdout directs to, so maybe that wasn't exactly the
solution you wanted to hear.

ok, not the nicest solution but maybe it will help you anyway:
bind sys.stdout at the begining of the program to a file (don't forget
to save it first! let's say stdout = sys.stdout;
sys.stdout=file('myLogFile.dat','w') ), and write your own print
funktion that goes something like that:
def printToConsole(stringToPrint,oldStdOut):
sys.stdout=oldStdOut
print stringToPrint
sys.stdout=file('myLogFile.dat','w')

then when you want to print to the console, use this function instead
of the print statment. all the rest will go to 'myLogFile.dat'

Cheers,
Ido.

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


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Steven D'Aprano
On Fri, 30 Sep 2005 03:42:32 -0700, Paul Rubin wrote:

> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> Still, [EMAIL PROTECTED]'s point that you must know the base classes
>> is correct. It is *easy* to find them out (NotSoSecret.__bases__ should do
>> it), but if you don't you are taking a chance that your class name doesn't
>> clash with one of the bases.
> 
> It's not easy if the base classes change after you check your code in.
> You shouldn't need to know about that if it happens.  Modularity, remember?

Yes. And if you are relying on a public method in a class, and somebody
dynamically modifies that public method, your code will stop working too.

py> class Klass:
... def spam(self):
... return "spam"
...
py> def food():
... c = Klass()
... return c.spam()
...
py> food()
'spam'
py> Klass.Spam = Klass.spam; del Klass.spam
py> food()
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 3, in food
AttributeError: Klass instance has no attribute 'spam'



Let's be frank. When you have a dynamic language like Python, the cost is
that somebody -- even yourself -- can pull the rug out from under your
feet. But that cost gives you flexibility and power. While your
competitors are still defining the variables and their types in some other
language, you've finished and debugged your entire program. 

Now maybe they can put their hand on their heart and say with absolute
100% mathematical certainty that there are no bugs in their code, and you
can't do that, and perhaps that mathematical certainty is appropriate for
your ICBM control system or nuclear reactor, but it is a needless
affectation for (say) a word processor. 


-- 
Steven.

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


Re: Straight line detection

2005-09-30 Thread Juho Schultz
PyPK wrote:
> Does anyone know of a simple implementation of a straight line
> detection algorithm something like hough or anything simpler.So
> something like if we have a 2D arary of pixel elements representing a
> particular Image. How can we identify lines in this Image.
> for example:
> 
> ary =
> [[1,1,1,1,1],
>  [1,1,0,0,0],
>  [1,0,1,0,0],
>  [1,0,0,1,0],
>  [1,0,0,0,1]]
> So if 'ary' represents pxl of an image which has a horizontal line(row
> 0),a vertical line(col 0) and a diagonal line(diagonal of ary). then
> basically I want identify any horizontal or vertical or diagonal line
> anywhere in the pxl array.
> 
> Thanks.
> 

I would recommend using a module for computing, my choice would be
numarray: www.stsci.edu/resources/software_hardware/numarray
You could even write your own version of hough, should not be too complex.
A fwee things you need to consider:


1) Are all the lines through the image, or would a row with 
[0,0,1 ...(a few dozen ones in here) ... 1,0] be a line?

2) Do you also need edge detection? Then you might need to convolve
the image with a Laplacian or something like that, e.g.
new[i,j] = (4*old[i,j])-old[i-1,j]-old[i+1,j]-old[i,j-1]-old[i,j+1]

3) How "full" are the images?
It is much easier if only a small fraction of your image is lines,
in your example more than half of image pixels are lines.

4) How big images are you processing? I always have at least
one million pixels, so the rest may not work for small images.

To do some quicklook checks you can of course go through each row/column
and check if the values are different enough, something like

mat = numarray.array(ima)
x = mat.mean()
dx = mat.stddev()

then check if some rows are different from others, maybe
(mat[:,i].mean() > (x + N*dx)) for "white" lines or
(mat[:,i].mean() < (x - N*dx))) for "black" lines
you probably need do a few tests to get a good value of N.

repeat for columns (mat[j,:]) and diagonals:
numarray.diagonal(mat,o) where
o is offset from mat[0,0]

and if you need non-diagonal elements, say
ima = [[1 0 0 0 0]
   [0 0 1 0 0]
   [0 0 0 0 1]]
would contain a line of ones, then

vect = ima.flat

gives the image as a rank-1 array and you can then take strides
(every nth element) just like with normal lists, array[a:b:n]
takes every nth element in array[a:b], so vect[::7] would be [1 1 1]

I hope this helps a bit.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-30 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > It's not easy if the base classes change after you check your code in.
> > You shouldn't need to know about that if it happens.  Modularity, remember?
> 
> Yes. And if you are relying on a public method in a class, and somebody
> dynamically modifies that public method, your code will stop working too.

I'm not talking about dynamic anything.  I'm talking about a normal
software project where there are multiple people working on the code.
You write a class and carefully make sure that none of its private
variables collide with superclasses in modules that it imports.  You
check in your code and go do something else.  Then the person
maintaining the superclasses goes and changes how they use their
private variables.  He doesn't look at your code since his modules
don't import yours.  But now both your code and his are broken.

> perhaps that mathematical certainty is appropriate for
> your ICBM control system or nuclear reactor, but it is a needless
> affectation for (say) a word processor. 

Why on earth would you want to unnecessarily introduce random bugs
into a word processor or anything else?  And what happened to the
marketing claims that Python was good for critical applications?
Maybe I should post your disclaimer every time one of those
discussions comes up.  "Python is ok for word processors but no good
for anything important".  Heck, some people think word processors are
important.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Zope3 Examples?

2005-09-30 Thread Markus Wankus
Jean-François Doyon wrote:
> Markus,
> 
> Zope 3 is mature as a framework, but does not provide much "out of the 
> box".  It's a basis upon which to build applications like Plone ... If 
> you are looking for something that provides Plone-like features on top 
> of Zope 3, it doesn't exist (yet).
> 
> Personally, I'm waiting for this: http://www.z3lab.org/
> But it'll be a while yet!
> 

Yes - I was watching the screencasts (well, animations) on this and it 
looks incredible!  I can't wait to play with something like this.

> Zope 3 is brilliant, but complex, and quite the departure from Zope 2, 
> so it'll take a while for the take up to occur.
> 
> What might work better for you is to use Zope 2 + the CMF, without 
> Plone.  Plone can be fairly heavy and rigid, the CMF alone might give 
> you the tools you need.  I use Zope 2 with success and good performance 
> on a hig traffic website, I wouldn't discount it just because of your 
> first impression ... There are many tweaks available that will 
> considerably improve performance for production systems.
> 
> Cheers,
> J.F.
> 

Thanks for the reply - maybe I'll give it another shot.  I'm currently 
demoing Snakelets.  Quite a turn in the opposite direction, but small 
and super-easy to get going with.  I think once this project gets a few 
good webapps under its belt (and maybe I can contribute there!) this 
could be a nice solution for many people.  At least a good starting 
point for someone like me who knows a good deal about Python and nothing 
about web frameworks.

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


Re: A Moronicity of Guido van Rossum

2005-09-30 Thread Steve Holden
[off-list]

Peter Hansen wrote:
> Gerrit Holl wrote:
> 
>>True. However, most mail to this mailinglist has less than 0.001 spam
>>probability. As you can see, this one had 0.048 - a vast score, almost
>>enough to put it in my unsure box. It seems to be just not hammy enough.
>>It's interesting to see that no none of the foul language words used by
>>Xah Lee ever occurs in any spam I receive - spam is not that stupid.
> 
> 
> "Xah Lee: stupider than spam." (?)
> 
> -neologism-intentional-ly y'rs,
>   Peter
I'm responding off-list so's not to give this loony's threads any more 
visibility. Please do not feed the troll (I am passing on a message that 
was delivered to me, and I too should have known better).

FWIW I really like the slogan. Maybe you should register 
"stupiderthanspam.com" and make a million? Amused me no end.

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


What encoding is used when initializing sys.argv?

2005-09-30 Thread Petr Prikryl
Hi,

When solving the problem of passing the unicode
directory name through command line into a script
(MS Windows environment), I have discovered that
I do not understand what encoding should be used
to convert the sys.argv into unicode.

I know about the rejected attempt to implement
sys.argvu. Still, how the sys.argv is filled? What
encoding is used when parsing the cmd line internally?
To what encoding is it converted when non ASCII
characters appear?

Thanks for your time and experience,
  pepr


-- 
Petr Prikryl (prikrylp at skil dot cz)


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


Re: how to stop info output on screen

2005-09-30 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> Hi,
> 
> Does someone know how to stop "the information output on screen"? Now
> when I run my code, it outputs a lot of message when calling other
> libraries, together with the info with the print command I used.
> 
> How can I mask these info on screen when calling other libraries and
> how I can mask the info output produced by the print command? Is there
> a way to mask them separately.
> 
> Thanks a lot if anyone knows it.
> 
> Kind regards of your help
> Midday
> 
Since you appear to be adding your own code, with your own print 
statements, to an existing Python program the easiest thing to do is 
make sure your own code writes to a place of your choice. This is most 
easily done with

   myFile = open("myfile.txt", "w")
 ...
   print >> myFile, this, that, the other
 ...
   print >> myFile, moreStuff(things)
 ...
   myFile.close()

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


[Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Reinhold Birkenfeld
Hi,

after Guido's pronouncement yesterday, in one of the next versions of Python
there will be a conditional expression with the following syntax:

X if C else Y

which is the same as today's

(Y, X)[bool(C)]

or

C and X or Y (only if X is True)

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


Google Not Universal Panacea [was: Re: Where to find python c-sources]

2005-09-30 Thread Steve Holden
Tor Erik Sønvisen wrote:
> "Erik Max Francis" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>Tor Erik Sønvisen wrote:
>>
>>
>>>I need to browse the socket-module source-code. I believe it's contained 
>>>in the file socketmodule.c, but I can't locate this file... Where should 
>>>I look?
>>
>>The source tarball, available on python.org.  Are people really too lazy 
>>to do elementary research on Google?
>>
>>-- 
>>Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
>>San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
>>  The people are to be taken in very small doses.
>>  -- Ralph Waldo Emerson
> 
> 
> Thanks for the answers... And yes, I have searched google! 
> 
> 
> 
As Pythonistas we can all marvel at the utility of Python, possibly 
best-known for its many applications at Google. However, I've noticed an 
increasing number of replies (quite possibly including some from me, so 
I'm not being holier-than-thou in this respect) of the "sheesh, can't 
people use Google?" type lately.

However,

 >> Are people really too lazy to do elementary research on Google?

goes a bit too far in imputing motives to the enquirer and overlooking 
the fact that there are some very good reasons for *not* using Google.

Since Google and the Python Software Foundation have a relationship 
(Google are a sponsor member of the Foundation, were one of the sponsors 
of PyCon DC 2005 and employ some Foundation Board members) and since I 
am a Board member of the Foundation (there, full disclosure), I hesitate 
to suggest that Googling can't fulfil every individual's every needs, 
but the bald fact is it's true. [Thinks: if Google stock tanks today I'm 
in deep doo-doo here].

Technical people like to pretend there's only technology. The fact that 
this is demonstrably not true doesn't appear to condition their 
behaviour very much, and on newsgroups, a bastion of testosterone from 
the very early days of internetworking (due to network news' tight 
interlinking with the dial-up UUCP network that used mainly local calls 
to propagate news and mail), the position is at its worst. Note that 
we're talking male hormones here, since by and large women don't appear 
to have embraced the Python community (except perhaps individually, but 
that's no business of mine).

While a snappish "go and look it up on Google" might suffice for a 
mouthy apprentice who's just asked their thirteenth question in the last 
half hour, it's (shall we say) a little on the brusque side for someone 
who only appears on the group last February, and has a history of asking 
reasonably pertinent though sometimes beginner-level questions.

In the real world there are many reasons why people interact, and 
interactions on c.l.py reflect this diversity. Sometimes it's just (as 
Americans say) "gathering round the water cooler": it's good to be in 
touch with a number of other people who have the same technical interest 
as you, and sometimes you get to say "well done" or interject your own 
opinion.

Other people come here for a sense of affirmation ("I wonder if those 
Python guys will treat me like a leper if I post on c.l.py?"), amusement 
("I wonder what the quote of the week'll be on the python-url"), 
intelligence (I wonder if the Twisted guys have produces a new version 
of X recently") and even identity ("I'll argue about everything I can 
possibly find the minutest hole in so people know that I have a brain 
and can use it").

Also, many regular readers didn't grow up speaking English (I was 
tempted to omit those last two words and leave it at that, but I won;'t 
be quite so extreme today), and so they may not phrase their questions 
appropriately. For all I know, there may not be that much Google content 
in Norwegian.

In short, this group is a broad church, and those readers with brain s 
the size of planets should remember that they are just as much in a 
minority as the readers who appear on the list for the first time this 
week. The vast majority are here to learn and grow, and I think that's 
the sort of behaviour we should be encouraging.

Google is *very* good at delivering information. I use google.com all 
the time, and I'm also a Google Earth user. However, we wouldn't be at 
all happy if Google just stuck a pipe onto our computers and spewed 
information at them three times as fast as it could be read. Bandwidth 
on a group like this is precious (which, I recently had to be reminded, 
is why it's important Not to Feed the Trolls - trolls eat bandwidth up 
like nobody's business, and pretty soon whole days are taken up by 
responses to their inanities).

As time goes by I find myself more and more likely, getting to the end 
of a possibly sharp or vindictive response, to simply kill the post and 
take what pleasure I can from not having shared that particular piece of 
small-mindedness with the group. In the end our most valuable 
contributions to groups like this can be the gift of being able 

Overloading __init__ & Function overloading

2005-09-30 Thread Iyer, Prasad C

I am new to python.
I have few questions
a. Is there something like function overloading in python?
b. Can I overload __init__ method

Thanks in advance



regards
prasad chandrasekaran










--- Cancer cures smoking
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Friday, September 30, 2005 6:36 PM
To: [email protected]
Subject: Python-list Digest, Vol 24, Issue 455

Send Python-list mailing list submissions to
[email protected]

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

You can reach the person managing the list at
[EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."

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: Will python never intend to support private, protected and public?

2005-09-30 Thread Steve Holden
Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
> 
>>>2) Allow the client access to these private variables, through
>>>a special construct. Maybe instead of "from ... import ..."
>>>"from ... spy ...".
>>
>>What you are suggesting is that you have private variables that are only
>>private by convention, since anyone can simply call use spy to treat
>>them as public.
> 
> 
> This notion isn't so bad, if there's way for modules to notice when
> they're spied on, like an import hook, e.g.:
> 
>   def __spy__(othermodule, symbol_list):
>  # this gets called when another module spies on symbols
> 
> It's like a runtime version of C++'s "friend" declaration.  Well, not
> quite as good, it's like having some stranger slide over to you in a
> bar and say "I wanna be your friend".  But at least it's better than
> not finding out at all where the external references are.

Oh, great, so now I have to code my classes so they know what to do when 
someone starts spying on them. Don't you have work to do?

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


'ascii' codec can't encode character u'\u2013'

2005-09-30 Thread thomas Armstrong
Hi

Using Python 2.3.4 + Feedparser 3.3 (a library to parse XML documents)

I'm trying to parse a UTF-8 document with special characters like
acute-accent vowels:


...
---

But I get this error message:
---
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
position 122: ordinal not in range(128)
---

when trying to execute a MySQL query:

query = "UPDATE blogs_news SET text = '" + text_extrated + "'WHERE
id='" + id + "'"
cursor.execute (query)  #<--- error line


I tried with:
---
text_extrated = text_extrated.encode('iso-8859-1') #<--- error line
query = "UPDATE blogs_news SET text = '" + text_extrated + "'WHERE
id='" + id + "'"
cursor.execute (query)
---

But I get this error:
--
UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2013'
in position 92: ordinal not in range(256)
-

I also tried with:

text_extrated = re.sub(u'\u2013', '-' , text_extrated)
query = "UPDATE blogs_news SET text = '" + text_extrated + "'WHERE
id='" + id + "'"
cursor.execute (query)
-

It works, but I don't want to substitute each special character,
because there are
always forgotten ones which can crack the program.

Any suggestion to fix it? Thank you very much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Not Universal Panacea [was: Re: Where to find python c-sources]

2005-09-30 Thread Richie Hindle

[Steve]
> In short, this group is a broad church, and those readers with brain s 
> the size of planets should remember that they are just as much in a 
> minority as the readers who appear on the list for the first time this 
> week. The vast majority are here to learn and grow, and I think that's 
> the sort of behaviour we should be encouraging.

+1 (and +1 QOTW).

> As time goes by I find myself more and more likely, getting to the end 
> of a possibly sharp or vindictive response, to simply kill the post and 
> take what pleasure I can from not having shared that particular piece of 
> small-mindedness with the group. In the end our most valuable 
> contributions to groups like this can be the gift of being able to walk 
> away from a fight simply to keep the noise level down.

+1 (and +1 QONW).

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


Re: Zope3 Examples?

2005-09-30 Thread Gerhard Häring
Markus Wankus wrote:
> [...] Thanks for the reply - maybe I'll give it another shot.  I'm currently 
> demoing Snakelets.  Quite a turn in the opposite direction, but small 
> and super-easy to get going with. [...]

I also found Snakelets a pleasure to use and chose it for implementing a 
clan homepage in early 2005.

I'm still very interested in the Python/Web/RDBMS field and tried to 
follow the developments since then. I didn't actually build anything 
real, only played a little bit with CherryPy and the megaframeworks 
built upon, Subway and TurboGears.

If I had to choose again, I'd use TurboGears, despite the fact that it's 
very young and still developing.

-- Gerhard

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


Re: return (PyObject*)myPyType; ...segmentation fault!

2005-09-30 Thread Fredrik Lundh
"elho" wrote:

>> > It is said that the object has a NULL-Pointer when I try to debug it?
>> what object?
>   the python one  'myNewPyType'
>
> Sorry, I forgot to change:
>   PySDLXMLNodeType = PyMyType
> ..above the corrections

>self = new PyMyObject
>self->lAttribute = lAttribute;
>
>return (PyObject*)self;

unless you have some really clever C++ magic in there that I'm not seeing,
you cannot just use "new" plus a cast to get a valid Python object.

if you want to explicitly create an object, you can use PyObject_New:

http://www.python.org/doc/2.1.3/ext/dnt-basics.html

an alternative is to expose the type object, and leave the rest to Python:

http://www.python.org/doc/current/ext/dnt-basics.html

 



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


Re: 'ascii' codec can't encode character u'\u2013'

2005-09-30 Thread Fredrik Lundh
Thomas Armstrong wrote:

> I'm trying to parse a UTF-8 document with special characters like
> acute-accent vowels:
> 
> 
> ...
> ---
>
> But I get this error message:
> ---
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
> position 122: ordinal not in range(128)
> ---

> It works, but I don't want to substitute each special character, because there
> are always forgotten ones which can crack the program.

if you really want to use latin-1 in the database, and you don't mind dropping
unsupported characters, you can use

text_extrated = text_extrated.encode('iso-8859-1', 'replace')

or

text_extrated = text_extrated.encode('iso-8859-1', 'ignore')

a better approach is of course to convert your database to use UTF-8 and use

text_extrated = text_extrated.encode('utf-8')

it's also a good idea to switch to parameter substitution in your SQL queries:

cursor.execute ("update ... set text = %s where id = %s", text_extrated, id)

it's possible that your database layer can automatically encode unicode strings 
if
you pass them in as parameters; see the database API documentation for details.

 



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


Re: 'ascii' codec can't encode character u'\u2013'

2005-09-30 Thread deelan
thomas Armstrong wrote:
(...)
> when trying to execute a MySQL query:
> 
> query = "UPDATE blogs_news SET text = '" + text_extrated + "'WHERE
> id='" + id + "'"
> cursor.execute (query)  #<--- error line
> 

well, to start it's not the best way to do an update,
try this instead:

query = "UPDATE blogs_news SET text = %s WHERE id=%s"
cursor.execute(query, (text_extrated, id))

so mysqldb will take care to quote text_extrated automatically. this
may not not your problem, but it's considered "good style" when dealing
with dbs.

apart for this, IIRC feedparser returns text as unicode strings, and
you correctly tried to encode those as latin-1 str objects before to 
pass it to mysql, but not all glyphs in the orginal utf-8 feed can be 
translated to latin-1. the charecter set of latin-1 is very thin 
compared to the utf-8.

you have to decide:

* switch your mysql db to utf-8 and encode stuff before
insertion to UTF-8

* lose those characters that cannot be mapped into latin-1,
using the:

text_extrated.encode('latin-1', errors='replace')

so unrecognized chars will be replaced by ?

also, mysqldb has some support to manage unicode objects directly, but 
things changed a bit during recent releases so i cannot be precise in 
this regard.

HTH.

-- 
deelan, #1 fan of adriana lima!





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


Re: Overloading __init__ & Function overloading

2005-09-30 Thread Fredrik Lundh
"Iyer, Prasad C" wrote:

> a. Is there something like function overloading in python?

not in the usual sense, no.  function arguments are not typed, so there's 
nothing
to dispatch on.  there are several cute tricks you can use to add dispatching on
top of "raw" python, but that's nothing you should do unless you have very good
reasons.

> b. Can I overload __init__ method

not in the usual sense, no.  same reason as above.

also see:

http://www.python.org/doc/faq/programming.html#how-can-i-overload-constructors-or-methods-in-python

 



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


Re: Overloading __init__ & Function overloading

2005-09-30 Thread Steve Holden
Iyer, Prasad C wrote:
> I am new to python.
> I have few questions
> a. Is there something like function overloading in python?

Not in the same way as Java: you can't write several functions and have 
the compiler or run-rime system work out which one to call according to 
argument types. Don't forget that Python is so dynamic that the types of 
a function's arguments may vary between successive iterations of the 
same statement.

> b. Can I overload __init__ method
> 
The normal way to do this is to have the subclass's __init__ call the 
superclass's __init__, usually right at the start.

When you get deeply into Python you will learn that you even call a 
function to determine the right superclass on which to call __init__.

What is "super()"?

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


Overloading & Overriden

2005-09-30 Thread Iyer, Prasad C

Hi,
Does python supports Overloading & Overriding  of the function?


regards
prasad chandrasekaran


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: Overloading __init__ & Function overloading

2005-09-30 Thread Larry Bates
I may be reading this question different than Fredrik.

This example is with old-style classes.

class baseclass:
def __init__(self, arg):
#
# Do some initialization
#

def method1(self, arg):
#
# baseclass method goes here
#

class myclass(baseclass):
def __init__(self, arg):
#
# This method gets called when I instantiate this class.
# If I want to call the baseclass.__init__ method I must
# do it myself.
#
baseclass.__init__(arg)

def method1(self, arg):
#
# This method would replace method1 in the baseclass
# in this instance of the class.
#

myObj=myclass(arg)

I could be way off base, but maybe it will help.

-Larry Bates



Iyer, Prasad C wrote:
> I am new to python.
> 
> I have few questions
> a. Is there something like function overloading in python?
> b. Can I overload __init__ method
> 
> Thanks in advance
> 
> 
> 
> regards
> prasad chandrasekaran
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --- Cancer cures smoking
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Friday, September 30, 2005 6:36 PM
> To: [email protected]
> Subject: Python-list Digest, Vol 24, Issue 455
> 
> Send Python-list mailing list submissions to
>   [email protected]
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>   [EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>   [EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
> 
> 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: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Fredrik Lundh
Reinhold Birkenfeld wrote:

> after Guido's pronouncement yesterday, in one of the next versions of Python
> there will be a conditional expression with the following syntax:
>
> X if C else Y
>
> which is the same as today's
>
> (Y, X)[bool(C)]

hopefully, only one of Y or X is actually evaluated ?

> C and X or Y (only if X is True)

hopefully, "only if X is True" isn't in fact a limitation of "X if C else Y" ?

/... snip comment that the natural order is C, X, Y and that programmers that
care about readable code will probably want to be extremely careful with this
new feature .../

 



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


Re: how to stop info output on screen

2005-09-30 Thread Ido . Yehieli
forget my posts, Steve's solution is much more maintanable when you(or
someone else)'ll revisit the code in a couple of years.

i would go with what he wrote.

Cheers,
Ido.

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


Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Richie Hindle

[Fredrik]
> > X if C else Y
> 
> hopefully, only one of Y or X is actually evaluated ?

Yes.  From Guido's announcement at
http://mail.python.org/pipermail/python-dev/2005-September/056846.html:

> The syntax will be
> 
> A if C else B
> 
> This first evaluates C; if it is true, A is evaluated to give the
> result, otherwise, B is evaluated to give the result.

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


Re: New Python chess module

2005-09-30 Thread Pekka Karjalainen
> Its still rough around the edges and not fully tested. I'll eventualy 
> release a more polished version and possibly put it on Sourceforge. In 
> the meantime I would be grateful for any feedback..

Somebody ought to comment this in more detail...

I have one minor point. It looks like your test whether the location is on
the board is needlessly complex. Python understands multiple comparisons
like in mathematical notation, and not like in e.g. C language. This
snippet shows what I mean:

>>> [x for x in range(10) if 2http://www.python.org/doc/2.4.2/ref/comparisons.html

-- 
Pekka Henrik Karjalainen
who still occasionally writes if (test): because of all the C
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Overloading __init__ & Function overloading

2005-09-30 Thread Michael Hoffman
Larry Bates wrote:

> class myclass(baseclass):
> def __init__(self, arg):
> #
> # This method gets called when I instantiate this class.
> # If I want to call the baseclass.__init__ method I must
> # do it myself.
> #
> baseclass.__init__(arg)

This is an example of polymorphism generally, not overloading.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


what does 0 mean in MyApp(0)

2005-09-30 Thread Alex
I'm looking at a tutorial with the code below

from wxPython.wx import *

class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL, -1, "winApp", size = (800,640))
frame.Show(true)
self.SetTopWindow(frame)
return true

app = MyApp(0)
app.MainLoop()

Everything is explained nicely except the zero parameter in MyApp(0).
Anybody knows what that zero refers to? 

Alex

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


Re: what does 0 mean in MyApp(0)

2005-09-30 Thread Ido . Yehieli
i see you inherit from wxApp.
mybe the constructor of that object takes an int value?

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


Re: Overloading & Overriden

2005-09-30 Thread Fredrik Lundh
"Iyer, Prasad C" wrote:

> Does python supports Overloading & Overriding  of the function?

Please avoid posting the same question over and over again with different
subjects.  Please read the replies to your original question before reposting
the question.  This is a mail list, not a chat channel; it may take a while be-
fore people see your question, and it may take a while before you see the
reply.

> 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  essage in error,
> please notify the sender immediately and delete all  copies of this message.

Oops.  Ok.  Done. 



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


RE: Overloading __init__ & Function overloading

2005-09-30 Thread Iyer, Prasad C

Thanks a lot for the reply.
But I want to do something like this

class BaseClass:
def __init__(self):
# Some code over here
def __init__(self, a, b):
# Some code over here
def __init__(self, a, b, c):
# some code here

baseclass1=BaseClass()
baseclass2=BaseClass(2,3)
baseclass3=BaseClass(4,5,3)




regards
prasad chandrasekaran










--- Cancer cures smoking

-Original Message-
From: Larry Bates [mailto:[EMAIL PROTECTED]
Sent: Friday, September 30, 2005 7:39 PM
To: Iyer, Prasad C
Subject: Re: Overloading __init__ & Function overloading

I may be reading this question different than Fredrik.

This example is with old-style classes.

class baseclass:
def __init__(self, arg):
#
# Do some initialization
#

def method1(self, arg):
#
# baseclass method goes here
#

class myclass(baseclass):
def __init__(self, arg):
#
# This method gets called when I instantiate this class.
# If I want to call the baseclass.__init__ method I must
# do it myself.
#
baseclass.__init__(arg)

def method1(self, arg):
#
# This method would replace method1 in the baseclass
# in this instance of the class.
#

myObj=myclass(arg)

I could be way off base, but maybe it will help.

-Larry Bates



Iyer, Prasad C wrote:
> I am new to python.
>
> I have few questions
> a. Is there something like function overloading in python?
> b. Can I overload __init__ method
>
> Thanks in advance
>
>
>
> regards
> prasad chandrasekaran
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --- Cancer cures smoking
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Friday, September 30, 2005 6:36 PM
> To: [email protected]
> Subject: Python-list Digest, Vol 24, Issue 455
>
> Send Python-list mailing list submissions to
>   [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>   [EMAIL PROTECTED]
>
> You can reach the person managing the list at
>   [EMAIL PROTECTED]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> 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.
>


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: Help with syntax warnings

2005-09-30 Thread Fredrik Lundh
Peter Hansen wrote:

> Wow... Python detects "dubious syntax"?  And here I thought programming
> was rather black and white, it's right or it's wrong.

SyntaxWarnings are issued for things that has never been valid nor well-
defined nor especially clever, but has been handled (in some more or less
reasonable way) by the CPython compiler.  In practice, syntax warnings
will turn into errors in future releases.

> (He notes examples such as assigning to None and "unqualified exec is
> not allowed in function" etc.)

Compare and contrast:

Python 2.3.4 (#53, May 25 2004, 21:17:02)
>>> None = "hello"
:1: SyntaxWarning: assignment to None

Python 2.4.1 (#65, Mar 30 2005, 09:13:57)
>>> None = "hello"
SyntaxError: assignment to None

 



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


LZW decompressor

2005-09-30 Thread Jim Melton
OK, so the LZW patent has expired. Now does anybody have a package to
read LZW compressed files? Despite the patent issues, Unix "compress"
is still widely used to compress files.

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


play audio on OSX?

2005-09-30 Thread Nick Parker
I'm attempting to play an mp3 file on OSX, but am running into some 
difficulty. When using py-mad and py-ao, I only get static with the 
following code (which is derived off another mailing that I found from 
this list's archives):

#!/usr/bin/env python

'''Requires:
py-mad (mp3 ability)
py-ao (system audio ability)
'''
import mad, ao, sys
mf = mad.MadFile(sys.argv[1])
dev = ao.AudioDevice('macosx')#osx device, linux: use "oss" or "alsa"
while 1:
 buf = mf.read()
 if buf is None:
 break
 dev.play(buf, len(buf))

Does anyone know why this produces static, or whether there's a better 
method of producing audio output that's also cross-platform (OSX, 
linux)? I've looked at pymedia, but they do not support OSX at the moment.

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


  1   2   3   >