Re: A curses-game I need help with.

2006-10-10 Thread Gasten
Ben Finney wrote:
> If you have a problem you'd like a lot of people to look at, the most
> effective way is to make a short, complete example that demonstrates
> exactly the problem you're trying to understand.

I should make a demo, you say? I'm gonna do that next time. Thanks.

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


Re: Initialization of variables using no-arg constructor

2006-10-10 Thread jordanrastrick
Just to expand a little on what others have already said - not only is
the total = list[0] etc.approach more readable, idiomatic, and elegant,
IMO its more semantically correct.

Your constraint that list[0].__class__ has a no-arg constructor is not
strong enough; a more subtle and potentially bug-prone assumption youre
making is that this no-arg constructor returns an identity element
(something that when added doesnt affect your overall "total") with
respect to the addition operator. This happens to be true of summing
numbers (__class__ == 0), and concatenating strings (__class__() ==
""). But I don't think you can take this behaviour for granted from an
arbitrary class.

Edward Waugh wrote:
> Consider the following (working) Python code:
>
> import sys
>
> def sum(list):
> # total = 0 does not work for non-numeric types
> total = list[0].__class__()
> for v in list:
> total += v
> return total
>
> l = [1, 2, 3]
> print sum(l)
>
> l = [1.1, 2.2, 3.3]
> print sum(l)
>
> l = ["a", "b", "c"]
> print sum(l)
>
> In order for sum() to be generic I initialize total to the value of
> list[0].__class__().  This works but I would like to know if this is the
> correct or preferred way of doing it.  It means that sum() must be given a
> list whose elements are types or classes that have a no-arg constructor
> (through this is probably almost always the case).
> 
> Thanks,
> Edward

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


Re: People's names (was Re: sqlite3 error)

2006-10-10 Thread Hendrik van Rooyen
"Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote:


> In message <[EMAIL PROTECTED]>, Hendrik van
> Rooyen wrote:
>
> > "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote:
> >
> > 8<
> >
> >> I wonder if we need another "middle" field for holding the "bin/binte"
> >> part (could also hold, e.g. "Van" for those names that use this).
> >
> > NO! - I think of my surname as "van Rooyen" - its only a string with a
> > space in it - and its peculiar in that the first letter is not
> > capitalised
> >
> > And I am sure that the people called "von Kardorff" would not agree
> > either...
>
> So do the Dutch phone books have a lot of entries under V, then?
>
> It just seems less efficient to me, that's all.

Don't know about what happens in Holland - my ancestors came over here to South
Africa a long time ago -
a mixed up kid I am - Dutch and French from the time of the revocation of the
edict of Nantes...
And yes, here the phone books are sorted that way - the "van Rensburg"s precede
the "van Rooyen"s. And what is worse, there are a lot of "van der"s too - two
spaces in the string like "van der Merwe" who are preceded by "van der Bank"  -
"van" basically means "from" - like the German "von" - but in Germany its an
appellation applied to the nobility - and in my name it makes no sense as
"Rooyen" is not a place - its a strange archaic derivative of the colour red -
"rooij' in Dutch, spelt "rooi" in Afrikaans - and the "der" is an archaic form
of "the" - (and modern "the" in German, if yer male) ...

And that lot completely ignores other animals like the "Janse van Rensburg"s,
who go in amongst the "J"s...

HTH - Hendrik


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


Re: Dive Into Java?

2006-10-10 Thread Theerasak Photha
On 10/9/06, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Mon, 09 Oct 2006 15:31:56 +0200, "Diez B. Roggisch"
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>
> > C++ has a lot of wicked, complicated features like overloadable assignment
> > statements and so on, misses GC, and is in general semantically very
> > overloaded. All that make programming it a real PITA, as you permanently
> > are at risk loosing your feet through self-inflicted gun-shot-wounds.
> >
> Sounds like a natural opening for:
>
> http://www.reed.edu/~tuckers/jokes/foot.html

This is the motherlode of 'shot in the foot' jokes!

BTW, love the Anglo-Saxon nickname.

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


Re: Everything is a distributed object

2006-10-10 Thread Nick Vatamaniuc
See here:

http://wiki.python.org/moin/DistributedProgramming

-Nick V.

Martin Drautzburg wrote:
> Hello all,
>
> I've seen various attempts to add distributed computing capabilities on top
> of an existing language. For a true distributed system I would expect it to
> be possible to instantiate objects of a remote class or to subclass a
> remote class and other stuff like this. My impression is that those things
> are difficult when built on top of an existing language.
>
> Since the paradigm "everything is an object" pays so well, I thought it
> might be less painful to implement a distributed system from ground up,
> starting with the paradigm: "everything is a distributed object".
>
> Do you know if such a thing has been attempted with python, i.e. by hacking
> the python core and add new capabilities to "object". Or do you think that
> this is really a silly idea ?

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


Re: Encode differences between idle python and python

2006-10-10 Thread Gabriel Genellina
At Tuesday 10/10/2006 02:44, [EMAIL PROTECTED] wrote:

>Hello:
>Under win32 XP y select python command line and execute next code with
>results indicated:
>
>Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
>(Intel)] on
>Type "help", "copyright", "credits" or "license" for more information.
> >>> u=u'áéíóú'
> >>> u
>u'\xe1\xe9\xed\xf3\xfa'
> >>> print u
>áéíóú
> >>> a=u.encode('latin-1')
> >>> a
>'\xe1\xe9\xed\xf3\xfa'
> >>> print a
>ßÚݾ·
> >>> type(a)
>
> >>> type(u)
>
> >>>

Because the console code page != windows code page.
Exit Python. At the console prompt, type:
 >chcp
If it says 850 - your console is using codepage 850.
Enter Python again, and replace 'latin-1' with 
'cp850'. You should get the right representation.


-- 
Gabriel Genellina
Softlab SRL 






__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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


Re: Names changed to protect the guilty

2006-10-10 Thread Antoon Pardon
On 2006-10-09, Aahz <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Antoon Pardon  <[EMAIL PROTECTED]> wrote:
>>On 2006-10-08, Aahz <[EMAIL PROTECTED]> wrote:
>>> In article <[EMAIL PROTECTED]>, John J. Lee <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] (Aahz) writes:
>
> The following line of lightly munged code was found in a publicly
> available Python library...
> 
> if schema.elements.has_key(key) is False:
> 
> Sorry, just had to vent.

I think I was reading the same code recently (epydoc?) and was also
momentarily horrified ;-) until I realized that it was quite
deliberately using three-valued logic (True, False, None) for some
presumably-sensible reason.  Since None is false, they had to use
"is".  So, given the need for three-valued logic, it's not as silly as
it looks.
>>>
>>> My take is that even in that case, one should use "is" only with None.
>>> There is too much ground for bugs with True/False, particularly if you
>>> either intend to work across version *or* you might possibly accept a
>>> user's object (because *they* might be working across versions and
>>> therefore returning 1/0 instead of True/False).  I think it's safest to
>>> simply ban this idiom.  No exceptions, never.
>>
>>The problem is there is also ground for bugs if you don't use "blah is
>>True". If some application naturally seems to ask for a variable that
>>can be valued False, True or a positive integer then things like "if
>>var" or "if not var" may very well be a bug too.
>
> Anyone designing an app like that in Python deserves to lose.  It's just
> another way of shooting yourself in the foot.

Why? Just because you don't like it? The last time I mentioned this,
all those who propsed an alternative implemenation came with proposals
that couldn't work, while I never had problems with my code.

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


Re: Everything is a distributed object

2006-10-10 Thread Hendrik van Rooyen
"Martin Drautzburg" <[EMAIL PROTECTED]> wrote:

> Hello all,
> 
> I've seen various attempts to add distributed computing capabilities on top
> of an existing language. For a true distributed system I would expect it to
> be possible to instantiate objects of a remote class or to subclass a
> remote class and other stuff like this. My impression is that those things
> are difficult when built on top of an existing language.
> 
> Since the paradigm "everything is an object" pays so well, I thought it
> might be less painful to implement a distributed system from ground up,
> starting with the paradigm: "everything is a distributed object".
> 
> Do you know if such a thing has been attempted with python, i.e. by hacking
> the python core and add new capabilities to "object". Or do you think that
> this is really a silly idea ? 

Google for pyro  - Hendrik


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


Re: News on versions modules for Python-2.5?

2006-10-10 Thread michels

Méta-MCI schrieb:

> Hi, all!
>
>
> Any news, on release Python-2.5 for many modules/lib?
> Some exemples:
>
> Console (Effbot)
> SciPy
> Iconvcodec
> DirectPython
> SendKeys
> Dislin
> PyGame
> Twain
> etc.
>
>  

Dislin is recompiled for Python 2.5 and Windows. The new extension
module 'dislin.pyd'
for Python 2.5 is added to the current Dislin distribution for Python.
Dislin is
available from the site http://www.dislin.de.

Regards,

Helmut Michels
A Dislin module froython 2.5 and Windows is now available from

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


Re: A curses-game I need help with.

2006-10-10 Thread Gasten
Rob Wolfe wrote:
> > while running:
> > key_command = game.mainwin.getch()
>
>   # I've moved erasing messages here
>   game.msg.ereasMsg()

Man... I didn't even think of that. It's embarassing. Thanks. It works
perfect now. Again, thanks.

Gasten

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


Re: OT: Sarcasm and irony (was: Dive Into Java?)

2006-10-10 Thread bryan rasmussen
> >
> > > E. g. [in Java there is] no operator overloading, but "+"
> > > concatenation of strings. What if you'd like to implement your own
> > > string-derived class? Ah, never mind. Operator overloading is
> > > bad(tm) ;) <= Irony, definitely
> >
> > Definitely? That one strikes me more as sarcasm.
>

Well irony originally started out as a very specific concept of the
Ancient Greek drama, this is what we nowadays refer to as Dramatic
Irony but it is the original irony. Irony then became a literary
concept for plot elements similar to Dramatic irony in books, or a
weaker type of the Dramatic irony found in the plays of Shakespeare.
People then noticed that life was at times ironic in the literary
manner. Nowadays the use of the word irony has degenerated to by
pretty much synonymous with sarcasm.

Cheers,
Bryan Rasmussen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (semi-troll): Is Jython development dead?

2006-10-10 Thread Steve Holden
Ray wrote:
> [EMAIL PROTECTED] wrote:
> 
>>Is Jython development dead or has it just seemed that way for over a
>>year?. The jython.org website has a recent new appearance (but no new
>>content) and there is some message traffic on the developer site at
>>Sourceforge.  However nothing has been released for over a year (i.e.
>>no support for Python 2.3, 2.4 or 2.5).  Is seems that IronPython may
>>have a better future than Jython.
>>
>>I know this is a bit of a troll but I'm concerned about choosing Jython
>>as the basis for a cross platform test scipt execution environment.
> 
> 
>>Does anyone know if a Jython update is imminent?
> 
> 
> There was a time when Jython walked like the dead and quacked like the
> dead but if you dared calling it dead or asking whether it was really
> dead you'd be admonished that it was open source and you should've just
> gone to the repository and hack some Jython code. (Or the ever popular
> response: that Jython 2.1 works  here, e.g.: beautifully, perfectly, etc.>, so why bother asking about
> 2.2 and beyond?).
> 
> Also, thankfully, it's picking up again, thanks to Frank Wierzbicki,
> et. al.--just check out the jython-dev mailing list, seems that new
> bloods are coming in. AFAIK they're trying to get a release for 2.2
> ASAP, then from there go to other versions--I think there was even a
> talk about jumping versions (e.g.: probably skipping 2.3 or something)
> somewhere in the list... I'm not sure how it was concluded though.
> Personally after 2.2 is out I think they might as well jump to 2.5
> straightaway.
> 
> So, what is your main concern here that 2.1 doesn't address? Because if
> your concern is that you're using a dead thing as your environment,
> it's rising from the dead. But if your concern is that you want to use
> features in Python 2.4 in Jython, might as well look for other
> solutions--it'll be some time before a version that supports that comes
> out.
> 
As a PSF director I might add that the Foundation has certainly tried to 
encourage onward development of Jython, and would like to continue doing 
so: it's healthy to have an ecosystem of different implementations, and 
Jython represents great visibility for Python in the Java world.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Names changed to protect the guilty

2006-10-10 Thread Antoon Pardon
On 2006-10-10, Ben Finney <[EMAIL PROTECTED]> wrote:
> "Andy Salnikov" <[EMAIL PROTECTED]> writes:
>
>> "Aahz" <[EMAIL PROTECTED]> wrote:
>> > Antoon Pardon <[EMAIL PROTECTED]> wrote:
>> >>The problem is there is also ground for bugs if you don't use
>> >>"blah is True". If some application naturally seems to ask for a
>> >>variable that can be valued False, True or a positive integer then
>> >>things like "if var" or "if not var" may very well be a bug too.
>> >
>> > Anyone designing an app like that in Python deserves to lose.
>> > It's just another way of shooting yourself in the foot.
>>
>> OK, I guess nobody ever heard about three-valued logic before,
>> right?
>
> Three-valued logic is fine for some purposes. Bending boolean
> two-valued constants to play the part of three-valued is confusing and
> wrong.

Why? The variable in question gives an answer to the question:

  Has the user requested a connection.

To which the answer can be:

  1: No
  2: Yes
  3: Yes and the connection ID is ...

So tell me what is wrong with using False and True for the simple
No and Yes answer in this case?

>> Of course it does not apply to the original post because has_key()
>> can only return True or False (I hope it will not ever return
>> DontKnow:) but in general if you implement something like 3-valued
>> logic choices like (False,True,None) are almost obvious.
>
> No. Using False and True is a strong signal to the reader that you're
> using *two* value logic. If you break that expectation, the reader
> should not be expected to sympathise.

IMO that expectation is unpythonic. Python allows that a variable
can be of different types during its lifetime. There is even no
mechanism to limit a variable to a specific type. So there is no
reason to expect a variable is limited to False and True just
because one of those was used. Just as there is no reason to
expect a variable will always be an integer just because it
was assigned an integer constant at some point.

> As another poster suggested, if you want to implement three-valued
> logic, use three new objects to represent the states, so the reader
> *knows* there's something going on other than two-value logic. Don't
> re-use False and True in three-valued logic and expect anyone to
> understand your code.

I thought that was the purpose of documentation.

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


Re: does raw_input() return unicode?

2006-10-10 Thread Duncan Booth
"Stuart McGraw" <[EMAIL PROTECTED]> wrote:

> So, does raw_input() ever return unicode objects and if
> so, under what conditions?
> 
It returns unicode if reading from sys.stdin returns unicode.

Unfortunately, I can't tell you how to make sys.stdin return unicode for 
use with raw_input. I tried what I thought should work and as you can see 
it messed up the buffering on stdin. Does anyone else know how to wrap 
sys.stdin so it returns unicode but is still unbuffered?

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] 
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, codecs
>>> sys.stdin.encoding
'cp437'
>>> sys.stdin = codecs.getreader(sys.stdin.encoding)(sys.stdin)
>>> raw_input()
hello world
still going?
^Z
^Z
u'hello world'
>>>

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


Re: does raw_input() return unicode?

2006-10-10 Thread Martin v. Löwis
Stuart McGraw schrieb:
> So, does raw_input() ever return unicode objects and if
> so, under what conditions?

At the moment, it only returns unicode objects when invoked
in the IDLE shell, and only if the character entered cannot
be represented in the locale's charset.

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


Re: OT: Sarcasm and irony

2006-10-10 Thread Steve Holden
bryan rasmussen wrote:
E. g. [in Java there is] no operator overloading, but "+"
concatenation of strings. What if you'd like to implement your own
string-derived class? Ah, never mind. Operator overloading is
bad(tm) ;) <= Irony, definitely
>>>
>>>Definitely? That one strikes me more as sarcasm.
>>
> 
> Well irony originally started out as a very specific concept of the
> Ancient Greek drama, this is what we nowadays refer to as Dramatic
> Irony but it is the original irony. Irony then became a literary
> concept for plot elements similar to Dramatic irony in books, or a
> weaker type of the Dramatic irony found in the plays of Shakespeare.
> People then noticed that life was at times ironic in the literary
> manner. Nowadays the use of the word irony has degenerated to by
> pretty much synonymous with sarcasm.
> 
... in America. It's well-known among Brits that Americans don't 
understand irony. They can be pretty oblique when it come to sarcasms 
too, for that matter.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: does raw_input() return unicode?

2006-10-10 Thread Theerasak Photha
On 10/10/06, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> Stuart McGraw schrieb:
> > So, does raw_input() ever return unicode objects and if
> > so, under what conditions?
>
> At the moment, it only returns unicode objects when invoked
> in the IDLE shell, and only if the character entered cannot
> be represented in the locale's charset.

Why only IDLE? Does urwid or another console UI toolkit avoid this somehow?

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


Re: Python component model

2006-10-10 Thread Nick Vatamaniuc

Edward Diener No Spam wrote:
> Michael wrote:
> > Edward Diener No Spam wrote:
> >
> >> Has there ever been, or is there presently anybody, in the Python
> >> developer community who sees the same need and is working toward that
> >> goal of a common component model in Python, blessed and encouraged by
> >> those who maintain the Python language and standard modules themselves ?
> >
> > Someone aiming towards a standard to /replace/ everyone else's? That
> > presupposes a level of arrogance that seems unusual in the python world.
> > (whilst everyone's proud of their own code and they _generally_ respect
> > other people's even if it's not their cup of tea).
>
> The reason I would like to see a standard component model for Python is
> so 3rd party developers could create their classes to conform to this
> model and work in any RAD IDE environment which adapts it. That's the
> way JavaBeans work, that the way Borland's VCL component model works,
> and that's the way .Net works. When there are many different component
> models, the 3rd party developer must adapt their components to each
> model for a particular environment.
>
> But far be it from me to want to replace everybody else's model .
>
> By your reasoning above, standardizing anything in software is an
> arrogant proposition. Whereas I look at standardization, when it is well
> done, as a boon to programmers.
>
> >
> > The WSGI standard could be a form of component model, and has gone through
> > the PEP process so that might match your criterion.
>
> I do not know what it is but I will look it up.
>
> > As for component
> > models, they do exist.
> >
> > Our component model on the Kamaelia project [1] is one that's heavily
> > designed around the idea of composition and independent execution of
> > components and message passing (message passing maps to events for some
> > sorts of message),
> >[1] http://kamaelia.sourceforge.net/Home
>
> I will look at kamaelia. Thanks !
>
> >
> > I wouldn't think of proposing it as the single standard to rule them all
> > though, for the simple reason every approach has its own strengths. (We do
> > find the approach extremely useful though)
> >
> > If you want a quick example of the core ideas, a tutorial aimed around
> > building a massively simplified core is here:
> >http://kamaelia.sourceforge.net/MiniAxon/
> >
> > If you want to see a substantial example, you can look here:
> >* http://tinyurl.com/oqjfb - whiteboarding with audio where every client
> >  is a server. The entire resulting system is also a component.
> >
> > For something more simplistic:
> >* http://kamaelia.sourceforge.net/Examples/SimplestPresentationTool.html
> >
> > Something halfway in terms of complexity (a PVR for transcoding everything
> > broadcast on digital TV):
> >* http://tinyurl.com/lvygq
> >  (OK, you need to add more channels, but you'd need more CPU's too)
> >
> > We also have tools for introspecting a running system, and also a visual
> > composition tool (called Compose) [2] for creating simple systems
> > graphically, and that, as you say, handles a significant chunk of
> > dreariness. Suggestions on improving the model and composition tool are
> > very welcome, code is even more welcome :)
> >
> >[2] Sample system created with the newest version of Compose:
> >   http://tinyurl.com/numwk
> >Compose is also a Kamaelia system, and can be found here:
> >   http://tinyurl.com/p7z76
> >(bulk of the wiring up is in the bottom of the file - this is an
> >interesting example because of the use of Pygame and Tk for different
> >parts of the interface where appropriate)
> >
> >
> > However, off the top of my head, you should also look at Zope's component
> > model, Trac's component model, Twisted's model & PEAK, and any proposal
> > to say "this is the solution", needs to be compelling for all of these
> > projects.
>
> A standard component model could be used as a base for other more
> advanced needs. Most of those mentioned above seem to involve web
> application frameworks whereas my idea of a component model just assumes
>   the paradigms of properties, methods, and events which may allow
> re-usable components at a base level in any environment.
>
> A particular implementation is certainly allowed to build a more
> complicated idea of a component, through inheritance, from a base level
> component, and this is in fact the way that most components work in
> current component model environments I have mentioned. For instance in
> .Net a control is a component with other added qualities. So while one
> could build components which are not controls, it is necessary to add
> functionality to the base level idea of a component in order to create a
> control.
>
> >
> > Note, they do change where there's a benefit - twisted adopted some
> > interesting ideas from Zope for example - however the onus on showing the
> > benefit is on you. (Which if you can d

Re: A curses-game I need help with.

2006-10-10 Thread Jia Lu

> try:
> import curses
> except ImportError:
> print "Missing the Curses-library."
> print "Please install the curses-library correctly."
> SystemExit
   ~
 Does this work ? Maybe *raise SystemExit* ??

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


Re: OT: Sarcasm and irony

2006-10-10 Thread Theerasak Photha
On 10/10/06, Steve Holden <[EMAIL PROTECTED]> wrote:

> ... in America. It's well-known among Brits that Americans don't
> understand irony. They can be pretty oblique when it come to sarcasms
> too, for that matter.

Ford Prefect: "What?"

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


Re: Python component model

2006-10-10 Thread Paul Rubin
"Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
> Python does not _need_ a component model just as you don't _need_ a RAD
> IDE tool to write Python code. The reason for having a component model
> or a RAD IDE tool is to avoid writing a lot of boiler plate code.

It's also so that applications written in differing languages can call
each other.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to find a file or a device is currently used by which process or which program ?

2006-10-10 Thread [EMAIL PROTECTED]
Hi,

When I want to uninstall my usb disk on windows, the operating systems 
sometimes tells me the device is being used by other program. But I 
can't find which program is using it. Can I do this using python ?

Thanks.

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


Re: does raw_input() return unicode?

2006-10-10 Thread Fredrik Lundh
Theerasak Photha wrote:

>>> So, does raw_input() ever return unicode objects and if
>>> so, under what conditions?
 >>
>> At the moment, it only returns unicode objects when invoked
>> in the IDLE shell, and only if the character entered cannot
>> be represented in the locale's charset.
> 
> Why only IDLE? Does urwid or another console UI toolkit avoid this somehow?

Martin was probably thinking of the standard distribution.

The 2.3 note says that "raw_input() *can* return Unicode", not that it 
"should" or "must" do it.



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


Re: Python component model

2006-10-10 Thread Fredrik Lundh
Edward Diener No Spam wrote:

>> Why not propose something. That is the easiest way to get things moving.
> 
> How does one do that ? Propose something here on this NG or is there 
> some other official way ?

the first step towards a successful Python proposal is to stop quoting 
the entire thread in each post to this newsgroup.



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


Re: How to find a file or a device is currently used by which process or which program ?

2006-10-10 Thread Gabriel Genellina

At Tuesday 10/10/2006 05:17, [EMAIL PROTECTED] wrote:


When I want to uninstall my usb disk on windows, the operating systems
sometimes tells me the device is being used by other program. But I
can't find which program is using it. Can I do this using python ?


I don't know with Python, but Process Explorer from 
www.sysinternals.com will show you all open files from all running processes.



--
Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: does raw_input() return unicode?

2006-10-10 Thread Theerasak Photha
On 10/10/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:

> Martin was probably thinking of the standard distribution.
>
> The 2.3 note says that "raw_input() *can* return Unicode", not that it
> "should" or "must" do it.

Practically speaking, at the heart of the matter: as of Python 2.5
final, does or can raw_input() return Unicode under the appropriate
circumstances, according to user wishes?

(Yes, I would test, but I am presently away from my Linux box with
Python, and can't install it here.)

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


Converting MSWord Docs to PDF

2006-10-10 Thread [EMAIL PROTECTED]
Hello,

this is my first message sent to the python-list, so
forgive any irregularities.

is it possible to convert MSword docs into PDF format?
i told my future employer that i could, because i knew
of the COM scripting abilites that activePython had.
and i knew there was modules for PDF creation such as
reportlabs.

thanks

Melv


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


Re: Python component model

2006-10-10 Thread Diez B. Roggisch
Paul Rubin schrieb:
> "Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
>> Python does not _need_ a component model just as you don't _need_ a RAD
>> IDE tool to write Python code. The reason for having a component model
>> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
> 
> It's also so that applications written in differing languages can call
> each other.

Nope. Things like CORBA and COM do have that property, but e.g. the Java 
beans spec has only a meaning inside the VM. Not sure about .NET, but I 
can imagine there it's the same thing.

All the languages he mentioned are statically typed, or the component 
models themselves are. So the component model is basically needed (as 
others also mentioned) to glue things together, to dynamize that - 
whereas python is dynamic on the first hand, and actually lacks static 
typing to infer component properties...


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


Re: Python component model

2006-10-10 Thread Fredrik Lundh
Nick Vatamaniuc wrote:

> At the same time one could claim that Python already has certain
> policies that makes it seem as if it has a component model.

every Python object surely qualifies as a component, for any non-myopic 
definition of that word, and everything inside a Python program is an 
object.  so yes, Python has a component model, and Python programmers 
are using that model all over the place.

what might be missing is support for publishing additional metadata 
using a standardized vocabulary, and a way to access that data with-
out having to actually create the object.

implementing this using existing mechanisms is trivial (as the endless 
stream of interface/component/adapter/trait implementations have shown 
us); coming up with a good-enough-to-be-useful-for-enough-people 
vocabulary is a lot harder.



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


Re: Tkinter: Making a window disappear

2006-10-10 Thread Eric Brunel
On Mon, 09 Oct 2006 11:08:39 +0200, Claus Tondering  
<[EMAIL PROTECTED]> wrote:

> I just solved the problem myself:
>
> I wrote:
>> self.destroy()
>
> Writing "self.master.destroy()" instead does the trick.

As an alternative (which is better IMHO), you may consider specializing  
Toplevel instead of Frame for your dialog:

class MyDialog(Toplevel):
   ...

In tk/Tkinter, a Frame is a generic container for widgets; it is not what  
is usually called a window. Creating an instance of Frame when there is no  
window to contain it happens to create a new one, but it is a side-effect,  
and you should not rely on it.

Once you've done that, you can simply write:

self.destroy()

to delete the window.

> Sorry for the inconvenience.

No problem.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is Python in the scheme of things?

2006-10-10 Thread Theerasak Photha
On 10/9/06, Magnus Lycka <[EMAIL PROTECTED]> wrote:
> gord wrote:
> > As a complete novice in the study of Python, I am asking myself where this
> > language is superior or better suited than others. For example, all I see in
> > the tutorials are lots of examples of list processing, arithmetic
> > calculations - all in a DOS-like environment.

> There are a number of free and commercial IDEs and GUI tool kits,
> but I don't know if there is anything that gives you such a low
> entry threshold for GUI development as VB or Delphi. I never
> "painted" GUIs in Python, I coded them in a plain editor, but
> you get used to that pretty soon, and you'll feel more in control,
> and the more complex your GUIs get, the more you can gain from
> having that control.

Before I say anything else, let me preface it with this: I am a
language-comparisons-discussion whore. Moving on...

Glade can be used with Python you know. I haven't tried Boa
Constructer yet, this is another interface building tool that seems to
have gained a lot of popularity. I do like the wx bindings though.

> I know, it's much easier to choose if you only have one choice,
> but this is the way things work in free software: no one tries to
> lock you in, so there is a flora of different tools suited for
> different needs. This makes it a bit harder to get started: You
> need to take more decisions--but you'll hopefully end up with
> something which is a better fit, where you don't need to work
> around the limits of the tool, or limit your world view to
> idioms supported a one-size-fits-all tool.

Historical note: Esperanto was a colossal failure. :)

> On the other hand it's more like C++ than like Java in the sense that
> it supports object-oriented programming, but it doesn't enforce it. C++
> and Python (as well as Delphi's Object Pascal I guess) can be described
> as multi-paradigm languages.

Ruby is also very good in this respect, although its procedural
programming really *isn't*, however it may look like it. But that's an
implementation detail. I like Python more because of the very strongly
positive direction it is moving in, and for sheer pragmatism of
more/better tools, better documentation, etc. It has its quirks, but
really...what doesn't? I am not a web framework geek, but I have heard
that CherryPy is better than RoR. If it isn't just the fact that
Python is older and more mature, maybe there is some insidious wisdom
in what look like kludges and warts to the untrained eye. I admire
matz and Guido van Rossum both, but Guido has all in all done a
fantastic job with the thousands of compromises that needed to be made
to produce a successful language. Like matz, he is also very humble in
spite of his great talents. (Which can't be said for Larry Wall,
though he is brilliant if perhaps misguided :))

(And to be fair, the B&D approach to OOP can *occasionally* have its benefits.)

> It was a revelation to bump into Python in 1996. Suddenly, there was
> something which was easy to get started with, but still just felt
> better and better the longer I used it. That's the killer feature
> in my mind.

AGREED! :)

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


Re: does raw_input() return unicode?

2006-10-10 Thread Fredrik Lundh
Theerasak Photha wrote:

> Practically speaking, at the heart of the matter: as of Python 2.5
> final, does or can raw_input() return Unicode under the appropriate
> circumstances, according to user wishes?

didn't Martin just answer that question?



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


Re: Everything is a distributed object

2006-10-10 Thread Diez B. Roggisch
Martin Drautzburg schrieb:
> Hello all,
> 
> I've seen various attempts to add distributed computing capabilities on top
> of an existing language. For a true distributed system I would expect it to
> be possible to instantiate objects of a remote class or to subclass a
> remote class and other stuff like this. My impression is that those things
> are difficult when built on top of an existing language.
> 
> Since the paradigm "everything is an object" pays so well, I thought it
> might be less painful to implement a distributed system from ground up,
> starting with the paradigm: "everything is a distributed object".
> 
> Do you know if such a thing has been attempted with python, i.e. by hacking
> the python core and add new capabilities to "object". Or do you think that
> this is really a silly idea ? 

Pyro is pretty neat in that respect. And besides that, I think it is a 
rather silly idea. In such an environment, immediately issues about 
concurrency, connection failures and sychronous/asynchronous execution 
arise, adding tremendously to the complexity of even the simplest of 
tasks. And thus should be kept out of those simple tasks...

A natural integration of concurrency as in erlang, or with pyro, is a 
good thing(tm), but not as base principle, IMHO.

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


Re: OT: Sarcasm and irony

2006-10-10 Thread bryan rasmussen
On 10/10/06, Steve Holden <[EMAIL PROTECTED]> wrote:
> bryan rasmussen wrote:
> E. g. [in Java there is] no operator overloading, but "+"
> concatenation of strings. What if you'd like to implement your own
> string-derived class? Ah, never mind. Operator overloading is
> bad(tm) ;) <= Irony, definitely
> >>>
> >>>Definitely? That one strikes me more as sarcasm.
> >>
> >
> > Well irony originally started out as a very specific concept of the
> > Ancient Greek drama, this is what we nowadays refer to as Dramatic
> > Irony but it is the original irony. Irony then became a literary
> > concept for plot elements similar to Dramatic irony in books, or a
> > weaker type of the Dramatic irony found in the plays of Shakespeare.
> > People then noticed that life was at times ironic in the literary
> > manner. Nowadays the use of the word irony has degenerated to by
> > pretty much synonymous with sarcasm.
> >
> ... in America. It's well-known among Brits that Americans don't
> understand irony. They can be pretty oblique when it come to sarcasms
> too, for that matter.

is that 'in America' meant to be an addendum to what I said, as in
this is the situation in America and not elsewhere? If so I should
probably point out that I am writing from Denmark and was thinking
specifically of a situation where a dane told me they were being
'ironic' (when what they meant, obviously, was that they were being
ironical), when I asked what they meant by that they said "saying the
opposite of what I mean" I responded: "so, in other words, what you
mean by irony is 'sarcasm'" She responded "yes, that's what it means"

She had a degree in communications. I also know a few number of brits.
The quality of their wit is not as yet so rarified that I must strain
after its meaning.

Cheers,
Bryan Rasmussen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: does raw_input() return unicode?

2006-10-10 Thread Theerasak Photha
On 10/10/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Theerasak Photha wrote:
>
> > Practically speaking, at the heart of the matter: as of Python 2.5
> > final, does or can raw_input() return Unicode under the appropriate
> > circumstances, according to user wishes?
>
> didn't Martin just answer that question?

*slaps forehead* D'oh!

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


Re: Converting MSWord Docs to PDF

2006-10-10 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with:
> is it possible to convert MSword docs into PDF format?

Yes, it is. check out http://www.stuvel.eu/ooo-python#header3. It's
about converting Excel to PDF, but it equally applies to MSWord.

Sybren
-- 
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Oct 10)

2006-10-10 Thread Stephan Diehl
Cameron Laird wrote:

> goon summarizes WSGI resources:
>   http://groups.google.com/group/comp.lang.python/msg/f7d67bc039748792
> 

THE wsgi resource at the moment is http://wsgi.org . (sorry, I've missed 
the original thread)

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


Re: People's names (was Re: sqlite3 error)

2006-10-10 Thread Roel Schroeven
Hendrik van Rooyen schreef:
> "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote:
> 
> 
>> In message <[EMAIL PROTECTED]>, Hendrik van
>> Rooyen wrote:
>>
>>> "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote:
>>>
>>> 8<
>>>
 I wonder if we need another "middle" field for holding the "bin/binte"
 part (could also hold, e.g. "Van" for those names that use this).
>>> NO! - I think of my surname as "van Rooyen" - its only a string with a
>>> space in it - and its peculiar in that the first letter is not
>>> capitalised
>>>
>>> And I am sure that the people called "von Kardorff" would not agree
>>> either...
>> So do the Dutch phone books have a lot of entries under V, then?
>>
>> It just seems less efficient to me, that's all.
> 
> Don't know about what happens in Holland - my ancestors came over here to 
> South
> Africa a long time ago -
> a mixed up kid I am - Dutch and French from the time of the revocation of the
> edict of Nantes...
> And yes, here the phone books are sorted that way - the "van Rensburg"s 
> precede
> the "van Rooyen"s. And what is worse, there are a lot of "van der"s too - two
> spaces in the string like "van der Merwe" who are preceded by "van der Bank"  
> -
> "van" basically means "from" - like the German "von" - but in Germany its an
> appellation applied to the nobility - and in my name it makes no sense as
> "Rooyen" is not a place - its a strange archaic derivative of the colour red -
> "rooij' in Dutch, spelt "rooi" in Afrikaans - and the "der" is an archaic form
> of "the" - (and modern "the" in German, if yer male) ...

It's the same here in Belgium. Except that our Van is with a capital V 
in most cases; if it's a lower v it either indicates nobility or a Dutch 
name.

I don't see it as a problem. I prefer having Van Straeten and Van 
Stralen next to each other than having them mixed up with names without 
Van like this:
Straeten, Van
Straetmans
Stralen, Van

For me the string as a whole is the name; the parts separated don't have 
much meaning.

-- 
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: Newbie - Stuck

2006-10-10 Thread Theerasak Photha
On 10/9/06, Christoph Haas <[EMAIL PROTECTED]> wrote:

> Yes, I know Perl makes "0" from anything that doesn't look like a number
> but Python's principle is to never hide errors while Perl makes certain
> assumptions. So Python prefers to complain.

And raises real exceptions moreover, instead of leaving you with a
string and holding the bag. I still like Perl after a fashion, but
c'mon, Konrad Zuse thought of real exceptions handling in
19--bleeding--46.

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


Re: People's names (was Re: sqlite3 error)

2006-10-10 Thread Theerasak Photha
On 10/7/06, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:

> Just because most Western designers of databases do it wrong doesn't mean
> that a) you should do it wrong, or b) they will continue to do it wrong
> into the future, as increasing numbers of those designers come from Asian
> and other non-Western backgrounds.

Family name comes last in some Asian countries as well. :)

It might also be prudent to consider that, e.g,, some Tamils only have
a last name for legal purposes and traditionally go by a single name.
Lots of possibilities to consider.

> I wonder if we need another "middle" field for holding the "bin/binte" part
> (could also hold, e.g. "Van" for those names that use this).

Also 'da' for Portuguese, which means roughly same as
Nederlands/Vlaams. Maybe. As usual: IANAE.

> There would also need to be a flag field to indicate the canonical ordering
> for writing out the full name: e.g. family-name-first, given-names-first.
> Do we need something else for the Vietnamese case?

Good question, but IIRC, family name comes first followed by any other
given names, just as in a literary index written in English: e.g.,
Truman, Harry S

What if you're Ho Chi Minh? Do you get to list aliases indefinitely? LOL

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


Re: OT: Sarcasm and irony

2006-10-10 Thread Steve Holden
bryan rasmussen wrote:
> On 10/10/06, Steve Holden <[EMAIL PROTECTED]> wrote:
> 
>>bryan rasmussen wrote:
>>
>>E. g. [in Java there is] no operator overloading, but "+"
>>concatenation of strings. What if you'd like to implement your own
>>string-derived class? Ah, never mind. Operator overloading is
>>bad(tm) ;) <= Irony, definitely
>
>Definitely? That one strikes me more as sarcasm.

>>>Well irony originally started out as a very specific concept of the
>>>Ancient Greek drama, this is what we nowadays refer to as Dramatic
>>>Irony but it is the original irony. Irony then became a literary
>>>concept for plot elements similar to Dramatic irony in books, or a
>>>weaker type of the Dramatic irony found in the plays of Shakespeare.
>>>People then noticed that life was at times ironic in the literary
>>>manner. Nowadays the use of the word irony has degenerated to by
>>>pretty much synonymous with sarcasm.
>>>
>>
>>... in America. It's well-known among Brits that Americans don't
>>understand irony. They can be pretty oblique when it come to sarcasms
>>too, for that matter.
> 
> 
> is that 'in America' meant to be an addendum to what I said, as in
> this is the situation in America and not elsewhere? If so I should
> probably point out that I am writing from Denmark and was thinking
> specifically of a situation where a dane told me they were being
> 'ironic' (when what they meant, obviously, was that they were being
> ironical), when I asked what they meant by that they said "saying the
> opposite of what I mean" I responded: "so, in other words, what you
> mean by irony is 'sarcasm'" She responded "yes, that's what it means"
> 
Well, my assertion about America clearly doesn't preclude to possibility 
of confusion on the part of the Danish too :-). You are right about the 
general degradation of the (understanding of the) meaning of irony. 
People are just too damned sloppy with language nowadays.

> She had a degree in communications. I also know a few number of brits.
> The quality of their wit is not as yet so rarified that I must strain
> after its meaning.
> 
A degree in communications sadly does not necessarily require complete 
terminological exactitude. There's nothing wrong with being funny but 
obvious <0.8 wink>

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: operator overloading + - / * = etc...

2006-10-10 Thread Theerasak Photha
On 9 Oct 2006 11:27:40 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote:

> I honestly don't see why "variable" would be an inappropiate word to use.
> AFAIU, python assignment seems to behave much like lisp and smalltalk
> and I never heard that those communities found the word "variable"
> inappropiate to use. And since the word variable originally comes
> from mathematics and IMHO the mathematical semantics are closer
> to the lisp/smalltalk/python semantics than the C/algol/pascal/ada
> semantics I don't see why "variable" is seen as "sloppy talk"

Um, that's what I usually use anyway... :)

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


Jython Sounds Examples

2006-10-10 Thread Ian Vincent
I have been hunting around Google hits for any source code examples of 
using sound (preferably WAV) under Jython with no success (minus several 
using other toolkits such as JNRI and JES). Does anybody know if any such 
examples exist and if so, I would be grateful for a pointer in their 
direction?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A problem about File path encode

2006-10-10 Thread Gabriel Genellina

At Monday 9/10/2006 22:14, Kevien Lee wrote:

  There is a problem about File path encode ,when i want to parse 
an xml file.

xmldoc=minidom.parse("D:\Downloads\1.xml")
IOError: [Errno 2] No such file or directory: 'D:\\Downloads\x01.xml'

See the red line.the file path"D:\Downloads\1.xml" auto  changed 
'D:\\Downloads\x01.xml'


I think may be the version cause the problem (version2.4) at the 
beginning,but when i changed the version2.5 ,


\ is a escape character. Use "D:\\Downloads\\1.xml" or 
r"D:\Downloads\1.xml" or "D:/Downloads/1.xml"

(I wrote this same message a few hours ago...!)



--
Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Python component model

2006-10-10 Thread Steve Holden
Diez B. Roggisch wrote:
> Paul Rubin schrieb:
> 
>>"Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
>>
>>>Python does not _need_ a component model just as you don't _need_ a RAD
>>>IDE tool to write Python code. The reason for having a component model
>>>or a RAD IDE tool is to avoid writing a lot of boiler plate code.
>>
>>It's also so that applications written in differing languages can call
>>each other.
> 
> 
> Nope. Things like CORBA and COM do have that property, but e.g. the Java 
> beans spec has only a meaning inside the VM. Not sure about .NET, but I 
> can imagine there it's the same thing.
> 
Well the .NET component model is specifically designed to be 
cross-language, but that's a feature of .NET/mono rather than of the 
componenet framework. You are correct about Beans, though.

> All the languages he mentioned are statically typed, or the component 
> models themselves are. So the component model is basically needed (as 
> others also mentioned) to glue things together, to dynamize that - 
> whereas python is dynamic on the first hand, and actually lacks static 
> typing to infer component properties...
> 
Just the same, one can use IronPython to call components written in 
other languages. And, I believe, vice versa.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Everything is a distributed object

2006-10-10 Thread Steve Holden
Martin Drautzburg wrote:
> Hello all,
> 
> I've seen various attempts to add distributed computing capabilities on top
> of an existing language. For a true distributed system I would expect it to
> be possible to instantiate objects of a remote class or to subclass a
> remote class and other stuff like this. My impression is that those things
> are difficult when built on top of an existing language.
> 
> Since the paradigm "everything is an object" pays so well, I thought it
> might be less painful to implement a distributed system from ground up,
> starting with the paradigm: "everything is a distributed object".
> 
Unfortunately the overhead of supporting distribution is way too high to 
want to invoke it between two objects living in the same process.

> Do you know if such a thing has been attempted with python, i.e. by hacking
> the python core and add new capabilities to "object". Or do you think that
> this is really a silly idea ? 

I'd prefer to say "misguided" ;-)

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Converting MSWord Docs to PDF

2006-10-10 Thread Steve Holden
Sybren Stuvel wrote:
> [EMAIL PROTECTED] enlightened us with:
> 
>>is it possible to convert MSword docs into PDF format?
> 
> 
> Yes, it is. check out http://www.stuvel.eu/ooo-python#header3. It's
> about converting Excel to PDF, but it equally applies to MSWord.
> 
However, this assumed perfect import of the .doc file into Open Office, 
which can't be guaranteed (though it gets better every release). So you 
may want to do some experimentation to find out how well the import 
proceeds.

If that *isn't* satisfactory then a modest investment in Adobe 
Acrobat/Distiller plus the use of Python's scripting facilities to 
direct the conversion would be preferable to spending a huge amount of 
time writing a hand-crafted solution.

>> i told my future employer that i could, because i knew
>> of the COM scripting abilites that activePython had.
>> and i knew there was modules for PDF creation such as
>> reportlabs.
>> 

And the next time you are bragging in that way, couch your boasts in 
conditional terms to avoid losing face should you happen to be wrong. A 
lot will depend on the complexity of the Word documents.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: People's names (was Re: sqlite3 error)

2006-10-10 Thread Steve Holden
Theerasak Photha wrote:
> On 10/7/06, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:
> 
> 
>>Just because most Western designers of databases do it wrong doesn't mean
>>that a) you should do it wrong, or b) they will continue to do it wrong
>>into the future, as increasing numbers of those designers come from Asian
>>and other non-Western backgrounds.
> 
> 
> Family name comes last in some Asian countries as well. :)
> 
> It might also be prudent to consider that, e.g,, some Tamils only have
> a last name for legal purposes and traditionally go by a single name.
> Lots of possibilities to consider.
> 
> 
>>I wonder if we need another "middle" field for holding the "bin/binte" part
>>(could also hold, e.g. "Van" for those names that use this).
> 
> 
> Also 'da' for Portuguese, which means roughly same as
> Nederlands/Vlaams. Maybe. As usual: IANAE.
> 
> 
>>There would also need to be a flag field to indicate the canonical ordering
>>for writing out the full name: e.g. family-name-first, given-names-first.
>>Do we need something else for the Vietnamese case?
> 
> 
> Good question, but IIRC, family name comes first followed by any other
> given names, just as in a literary index written in English: e.g.,
> Truman, Harry S
> 
> What if you're Ho Chi Minh? Do you get to list aliases indefinitely? LOL
> 
It seems like some sort of free text search on a "full name" field looks 
like the only realistic globally-acceptable (?) option.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: operator overloading + - / * = etc...

2006-10-10 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-08 11:44:18 +0100:
> That's because assignment isn't an operator - that's why (for example)
> 
>  print x = 33
> 
> would be a syntax error. This is a deliberate design decision about 
> which, history shows, there is little use complaining.

Just to clarify: not that there's little complaining about
assignment not being an expression, it's useless to complain because
all previous complaints have been shot down on the basis of claims
of reduced safety and readability. People who complain often fail to
see how

x = foo()
while x:
process(x)
x = foo()

is safer than

while x = foo():
process(x)

(duplication hampers code safety) or how some other features present
in the language, e. g.  comprehensions, could make it past the
readability check.

Everybody has an opinion; those who put the most work in the project
get to decide what the software looks like.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting MSWord Docs to PDF

2006-10-10 Thread Alan Franzoni
Il Tue, 10 Oct 2006 01:27:35 -0700, [EMAIL PROTECTED] ha scritto:

> is it possible to convert MSword docs into PDF format?
> i told my future employer that i could, because i knew
> of the COM scripting abilites that activePython had.
> and i knew there was modules for PDF creation such as
> reportlabs.

a lot depends on the availability of ms word itself on the platform you're
planning to do the work, if you want the result to be perfect. There're
several tools on Windows (some cheap, some freeware) like FreePDF o
pdffactory, which act like 'Virtual Printers' producing a PDF file instead;
you could try using Python to automate the printing process and getting the
PDF output instead. Or if you've got access to Adobe Acrobat as well, you
could automate the whole process via Acrobat (but it's untested, don't take
it as granted).

If you're doing this in Linux, you should consider something like Crossover
Office in order to run ms word and convert its output.

The openoffice.org based solution will surely work, but you'll heavily rely
on the conversion quality of that suite.

-- 
Alan Franzoni <[EMAIL PROTECTED]>
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Sarcasm and irony

2006-10-10 Thread Max M
bryan rasmussen skrev:
> On 10/10/06, Steve Holden <[EMAIL PROTECTED]> wrote:

>> ... in America. It's well-known among Brits that Americans don't
>> understand irony. They can be pretty oblique when it come to sarcasms
>> too, for that matter.
> 
> is that 'in America' meant to be an addendum to what I said, as in
> this is the situation in America and not elsewhere? If so I should
> probably point out that I am writing from Denmark and was thinking
> specifically of a situation where a dane told me they were being
> 'ironic' (when what they meant, obviously, was that they were being
> ironical), when I asked what they meant by that they said "saying the
> opposite of what I mean" I responded: "so, in other words, what you
> mean by irony is 'sarcasm'" She responded "yes, that's what it means"


Are you an american?

Irony does mean that one says the opposite of what one really means.

If you do it for humor its irony, if you do it for mocking it is sarcasm.

So now I see... americans really *do* understand irony.


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: operator overloading + - / * = etc...

2006-10-10 Thread Fredrik Lundh
Roman Neuhauser wrote:

> People who complain often fail to see how
>
>x = foo()
>while x:
>process(x)
>x = foo()
>
>is safer than
>
>while x = foo():
>process(x)

that's spelled:

for x in foo():
process(x)

in Python, or, if foo() just refuses be turned into a well-behaved Python
citizen:

while 1:
x = foo()
if not x:
break
process(x)

(this is the standard "loop-and-a-half" pydiom, and every python pro-
grammer should be able to identify it as such in a fraction of a second).

or for the perhaps-overly-clever hackers,

for x in iter(lambda: foo() or None, None):
process(x)

it's not like the lack of assignment-as-expression is forcing anyone to
duplicate code in today's Python.

also, in my experience, most assignment-as-expression mistakes are done
in if-statements, not while-statements (if not else because if statements are
a lot more common in most code).  the "but it cuts down on duplication"
argument doesn't really apply to if-statements.

 



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


Re: OT: Sarcasm and irony

2006-10-10 Thread bryan rasmussen
On 10/10/06, Max M <[EMAIL PROTECTED]> wrote:
> bryan rasmussen skrev:
> > On 10/10/06, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> >> ... in America. It's well-known among Brits that Americans don't
> >> understand irony. They can be pretty oblique when it come to sarcasms
> >> too, for that matter.
> >
> > is that 'in America' meant to be an addendum to what I said, as in
> > this is the situation in America and not elsewhere? If so I should
> > probably point out that I am writing from Denmark and was thinking
> > specifically of a situation where a dane told me they were being
> > 'ironic' (when what they meant, obviously, was that they were being
> > ironical), when I asked what they meant by that they said "saying the
> > opposite of what I mean" I responded: "so, in other words, what you
> > mean by irony is 'sarcasm'" She responded "yes, that's what it means"
>
>
> Are you an american?
>
> Irony does mean that one says the opposite of what one really means.
>
> If you do it for humor its irony, if you do it for mocking it is sarcasm.
>
> So now I see... americans really *do* understand irony.

To reiterate:

Well irony originally started out as a very specific concept of the
 Ancient Greek drama, this is what we nowadays refer to as Dramatic
 Irony but it is the original irony. Irony then became a literary
 concept for plot elements similar to Dramatic irony in books, or a
 weaker type of the Dramatic irony found in the plays of Shakespeare.
 People then noticed that life was at times ironic in the literary
 manner. Nowadays the use of the word irony has degenerated to by
 pretty much synonymous with sarcasm.

Cheers,
Bryan Rasmussen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> or for the perhaps-overly-clever hackers,
> 
> for x in iter(lambda: foo() or None, None):
> process(x)

for x in takewhile(foo() for _ in repeat(None)):
   process (x)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch wrote:
(snip)
  Python itself is a RAD tool.

+1 QOTW

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


Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> or for the perhaps-overly-clever hackers,
> 
> for x in iter(lambda: foo() or None, None):
> process(x)

  for x in takewhile(bool, (foo() for _ in repeat(None))):
 process(x)

Meh, both are ugly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: People's names

2006-10-10 Thread Jorge Godoy
"Theerasak Photha" <[EMAIL PROTECTED]> writes:

> Also 'da' for Portuguese, which means roughly same as
> Nederlands/Vlaams. Maybe. As usual: IANAE.

It looks like the same but at least here in Brasil it isn't considered for
sorting ("da Silva" should be sorted under "Silva", "de Souza" under "Souza",
"de Melo" under "Melo" and so on) and it is even stripped in some cases.


-- 
Jorge Godoy  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: operator overloading + - / * = etc...

2006-10-10 Thread Antoon Pardon
On 2006-10-10, Paul Rubin  wrote:
> "Fredrik Lundh" <[EMAIL PROTECTED]> writes:
>> or for the perhaps-overly-clever hackers,
>> 
>> for x in iter(lambda: foo() or None, None):
>> process(x)
>
> for x in takewhile(foo() for _ in repeat(None)):
>process (x)

>>> for x in takewhile(foo() for _ in repeat(None)):
...   print x
... 
Traceback (most recent call last):
 File "", line 1, in ?
TypeError: takewhile expected 2 arguments, got 1

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


Re: People's names

2006-10-10 Thread Jorge Godoy
Steve Holden <[EMAIL PROTECTED]> writes:

> It seems like some sort of free text search on a "full name" field looks like
> the only realistic globally-acceptable (?) option.

This is what we opted doing.  Normalization to this level wouldn't add much
since there are a lot of "Smith"s that aren't relatives.

If finding relatives is something you need to do, demand that the mother's
name be filled in and put an optional field for father's name.  Then compare
and ask if there's something between two people with the same mother /
father.  (Remember about people with the same name!  There are a lot of "John
Smith" or "José da Silva" around :-))

-- 
Jorge Godoy  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python component model

2006-10-10 Thread Diez B. Roggisch
>> Nope. Things like CORBA and COM do have that property, but e.g. the Java
>> beans spec has only a meaning inside the VM. Not sure about .NET, but I
>> can imagine there it's the same thing.
>> 
> Well the .NET component model is specifically designed to be
> cross-language, but that's a feature of .NET/mono rather than of the
> componenet framework. You are correct about Beans, though.

Is this cross-language in the sense jython can use beans? Or in the sense
like CORBA? I assumed the former, which isn't cross-language in my
perception (at least not in the general sense, as CORBA is)
 
>> All the languages he mentioned are statically typed, or the component
>> models themselves are. So the component model is basically needed (as
>> others also mentioned) to glue things together, to dynamize that -
>> whereas python is dynamic on the first hand, and actually lacks static
>> typing to infer component properties...
>> 
> Just the same, one can use IronPython to call components written in
> other languages. And, I believe, vice versa.

Sure, as I can do it in jython. But the key point is: can your ordinary
python-object be published as a component? At least for jython I can
say "no", you will have to subclass an already existing
java-object/interface. And I have difficulties imagining that it is any
different in .NET - because I've read statements that claimed that the
structure of the VM/runtime is orientied towards single-inheritance
statically typed languages as C#/java.

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


Re: Python component model

2006-10-10 Thread Paul Boddie
Edward Diener No Spam wrote:
>
> In the typical RAD development environment, a particular component model
> allows one to drop components, which are classes corresponding to a
> particular inner representation which tells the development environment
> what are the "properties" and "events" of that component, and
> subsequently set "properties" for that component and add handlers for
> its "events" visually.

As others may have mentioned, Python has its own built-in support for
properties: changing the state of an object with optional side-effects.
Moreover, as you realise, Python also has capable introspection
mechanisms to reveal such properties at run-time. However, things like
event mechanisms are not generally standardised.

[...]

> OK, I have proselytized enough . Python is a great language and I
> truly love it and its flexibility and ease of programming use. If there
> is no impetus to create a component model for re-usable components for
> visual RAD environments in Python, that's fine with me. But I thought
> someone from the Python development community, given the use of visual
> RAD environments for other languages as mentioned above, to create GUI
> and large-scale applications, would have considered it.

You might want to look into environments and tools such as Qt Designer
together with PyQt. Whilst the PyQt mechanisms (really the Qt
mechanisms exposed in Python) aren't standardised as such, you get
event and property mechanisms which are actually quite powerful and
which certainly seem to demonstrate many of the RAD environment
capabilities you're interested in: you can write Python components
which can be dropped into the Designer environment and they're
responsive to introspection and interaction right there and then.

See this presentation for more details:

http://indico.cern.ch/contributionDisplay.py?contribId=33&sessionId=41&confId=44

Paul

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


How to share session with IE

2006-10-10 Thread zdp
Hello!

I need to process some webpages of a forum which is powered by discuz!.
When I login, there are some options about how long to keep the
cookies: forever, month, week, et al. If I choose forever,  I don't
need to login each time, and When I open the internet explorer I can
access any pages directly. Some urls of the pages like:

http://www.somesite.com/bbs/viewthread.php?tid=12345&extra=page%3D1

However, now I need to process some pages by a python program. When I
use urllib.urlopen(theurl), I can only get a page which told me I need
login. I think It's reasonable, becuase I wasn't in a loggined session
which as IE did.

So how can I do my job? I want to get the right webpage by the url. I
have search answers from the groups but didn't get clear answer. Should
I use win32com or urllib? Any reply or information is appreciate. Hope
I put it clear.

Dapu

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


Re: Python component model

2006-10-10 Thread Steve Holden
Diez B. Roggisch wrote:
[...]
>>Just the same, one can use IronPython to call components written in
>>other languages. And, I believe, vice versa.
> 
> 
> Sure, as I can do it in jython. But the key point is: can your ordinary
> python-object be published as a component? At least for jython I can
> say "no", you will have to subclass an already existing
> java-object/interface. And I have difficulties imagining that it is any
> different in .NET - because I've read statements that claimed that the
> structure of the VM/runtime is orientied towards single-inheritance
> statically typed languages as C#/java.
> 
The answer to this question is currently beyond me. Maybe someone who 
knows more about IronPython can elucidate. I do know (as you probably do 
also) that Python generates code for the .NET CLR, however.

I don't think there's any *theoretical* reason why IronPython components 
can't be called from other languages, but as to the practicalities 
(specifically whether IronPython produces linkable assemblies) we'll 
have to wait for someone who knows.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes:
> >>> for x in takewhile(foo() for _ in repeat(None)):
> ...   print x
> ... 
> Traceback (most recent call last):
>  File "", line 1, in ?
> TypeError: takewhile expected 2 arguments, got 1

Yeah, I cancelled and posted a followup 

 for x in takewhile(bool, foo() for _ in repeat(None)):
print x

but I haven't tested either way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to share session with IE

2006-10-10 Thread Bernard
Hello Dapu,

You can do the same thing as IE on your forum using urllib2 and
cookielib. In short you need to code a small webcrawler. I can give you
my browser module if necessary.
You might not have the time to fiddle with the coding part or my
browser module so you can also use this particularly useful module :
http://wwwsearch.sourceforge.net/mechanize/
The documentation is pretty clear for an initiated python programmer.
If it's not your case, I'd recommend to read some ebooks on the python
language first to get use to it.

Bernard




zdp wrote:
> Hello!
>
> I need to process some webpages of a forum which is powered by discuz!.
> When I login, there are some options about how long to keep the
> cookies: forever, month, week, et al. If I choose forever,  I don't
> need to login each time, and When I open the internet explorer I can
> access any pages directly. Some urls of the pages like:
>
> http://www.somesite.com/bbs/viewthread.php?tid=12345&extra=page%3D1
>
> However, now I need to process some pages by a python program. When I
> use urllib.urlopen(theurl), I can only get a page which told me I need
> login. I think It's reasonable, becuase I wasn't in a loggined session
> which as IE did.
>
> So how can I do my job? I want to get the right webpage by the url. I
> have search answers from the groups but didn't get clear answer. Should
> I use win32com or urllib? Any reply or information is appreciate. Hope
> I put it clear.
> 
> Dapu

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


Re: operator overloading + - / * = etc...

2006-10-10 Thread Antoon Pardon
On 2006-10-10, Paul Rubin  wrote:
> "Fredrik Lundh" <[EMAIL PROTECTED]> writes:
>> or for the perhaps-overly-clever hackers,
>> 
>> for x in iter(lambda: foo() or None, None):
>> process(x)
>
>   for x in takewhile(bool, (foo() for _ in repeat(None))):
>  process(x)
>
> Meh, both are ugly.

Sure, but so is IMO the current pythonic idiom.

Suppose one has the following intention in mind:

  while x = setup():
if y = pre_process() in ErrorCondition:
  break
post_process(y)
  else:
NormalTermination()

The pythonic idiom for this case would then be something like:

  while 1:
x = setup()
if x:
  NormalTermination()
  break
y = pre_process(x)
if y in ErrorCondition:
  break
post_process(y)

There was some time it seemed PEP: 315 would be implemented so
that this could have been written as:

  do:
x = setup()
  while x:
y = pre_process(x)
if y in ErrorCondition:
  break
post_process(y)
  else:
NormalTermination()


Which IMO would have been clearer. Alas PEP 315 is deffered so
it will be probably a long time before this will be implemented.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Michael Sparks
Edward Diener No Spam wrote:
> Michael wrote:
> > Edward Diener No Spam wrote:
> >
> >> Has there ever been, or is there presently anybody, in the Python
> >> developer community who sees the same need and is working toward that
> >> goal of a common component model in Python, blessed and encouraged by
> >> those who maintain the Python language and standard modules themselves ?
> >
> > Someone aiming towards a standard to /replace/ everyone else's? That
> > presupposes a level of arrogance that seems unusual in the python world.
> > (whilst everyone's proud of their own code and they _generally_ respect
> > other people's even if it's not their cup of tea).
>
> The reason I would like to see a standard component model for Python is
> so 3rd party developers could create their classes to conform to this
> model and work in any RAD IDE environment which adapts it. That's the
> way JavaBeans work, that the way Borland's VCL component model works,
> and that's the way .Net works. When there are many different component
> models, the 3rd party developer must adapt their components to each
> model for a particular environment.
>
> But far be it from me to want to replace everybody else's model .

Well that's the thing you *do* want since you want the previous
paragraph ;-)
(Or at least a way to adapt component models.)

> By your reasoning above, standardizing anything in software is an
> arrogant proposition. Whereas I look at standardization, when it is well
> done, as a boon to programmers.

OK, maybe I was being a bit strong - I was merely thinking "lots of
people have something like this already, and I've not seen anyone push
their model as THE model", (even if lots of people like *their* model
:-)

However, I was also being a bit tongue in cheek, though I should have
said unreasonable, not arrogant:
   "...all progress depends on the unreasonable man." -- Bernard Shaw.

What could have some mileage though is proposing a standard way for
these component models to interoperate. What that would look like
(given the wildly different models :), is another matter and an
exercise for the interested reader ;-)

> > The WSGI standard could be a form of component model, and has gone through
> > the PEP process so that might match your criterion.
>
> I do not know what it is but I will look it up.

NB, I'm using component model in it's loosest form there.

> > As for component
> > models, they do exist.
> >
> > Our component model on the Kamaelia project [1] is one that's heavily
> > designed around the idea of composition and independent execution of
> > components and message passing (message passing maps to events for some
> > sorts of message),
> >[1] http://kamaelia.sourceforge.net/Home
>
> I will look at kamaelia. Thanks !

You're welcome. Any deficiencies or improvements or suggestions you've
got would be very welcome (I can see some which we're planning on
addressing at some point, but fresh critical eyes are always welcome).

> > However, off the top of my head, you should also look at Zope's component
> > model, Trac's component model, Twisted's model & PEAK, and any proposal
> > to say "this is the solution", needs to be compelling for all of these
> > projects.
>
> A standard component model could be used as a base for other more
> advanced needs. Most of those mentioned above seem to involve web
> application frameworks whereas my idea of a component model just assumes
>   the paradigms of properties, methods, and events which may allow
> re-usable components at a base level in any environment.

They do, however in particular, Trac's model whilst web oriented
strikes me personally as interesting and PEAK's is applicable, as I
understand it, outside the web sphere. (Enthought was mentioned
elsewhere and is interesting (IMO) for the properties stuff)

If you're interested in event systems as well, it's probably worth
looking at the way a number of pygame applications are written since
there's an event model built into pygame that some pygame apps take
advantage of for custom events and some don't. It's a very different
problem realm to the web systems.

Twisted is worth looking at as well, since it's probably got one of the
more interesting approaches for dealing with essentially event based
systems I've seen.

> A particular implementation is certainly allowed to build a more
> complicated idea of a component, through inheritance, from a base level
> component, and this is in fact the way that most components work in
> current component model environments I have mentioned. For instance in
> .Net a control is a component with other added qualities. So while one
> could build components which are not controls, it is necessary to add
> functionality to the base level idea of a component in order to create a
> control.

You *may* also want to take a look at picolo as well then - but as far
as I'm
aware it's not actually *used* by anyone. It is in some respects more
like
the kind of component model you de

Linting python code...

2006-10-10 Thread Andrew Markebo
Alalalala lint.. alalalala lint... 

Ehm :-) 

Are there any python-code linter out there - or the code is so easy to
write that it always is so perfekt? :-)

  /Andy

-- 
 Don't walk in front of me, I might be unable to follow you. 
 Don't walk after me, I might be unable to lead you. 
 Just walk by my side and be my friend.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Linting python code...

2006-10-10 Thread Christoph Haas
On Tuesday 10 October 2006 14:06, Andrew Markebo wrote:
> Are there any python-code linter out there

PyLint (http://www.logilab.org/projects/pylint)
PyChecker (http://pychecker.sf.net)

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


Re: Linting python code...

2006-10-10 Thread skip

Christoph> On Tuesday 10 October 2006 14:06, Andrew Markebo wrote:
>> Are there any python-code linter out there

Christoph> PyLint (http://www.logilab.org/projects/pylint)
Christoph> PyChecker (http://pychecker.sf.net)

New kid on the block:

PyFlakes http://divmod.org/trac/wiki/DivmodPyflakes

It doesn't do nearly as much as the other two but doesn't import the
modules, so it can be used in places the others can't.

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


Re: OT: Sarcasm and irony

2006-10-10 Thread Max M
bryan rasmussen skrev:

> Well irony originally started out as a very specific concept of the
> Ancient Greek drama, this is what we nowadays refer to as Dramatic
> Irony but it is the original irony. Irony then became a literary
> concept for plot elements similar to Dramatic irony in books, or a
> weaker type of the Dramatic irony found in the plays of Shakespeare.
> People then noticed that life was at times ironic in the literary
> manner.

Yes and in Rome "salary" meant getting a bag of salt. Concepts changes.


> Nowadays the use of the word irony has degenerated to by
> pretty much synonymous with sarcasm.

As a Dane that is a Chronic Ironic, I beg to differ.

In Denmark at least there is a lot of difference between irony and 
sarcasm. Irony is the main form of humor here, and danes takes to it 
easily. People being sarcastic we don't much like.

But I guess that it can be hard to se the difference for someone not 
used to irony.

I believe the reason that irony works here is that we have such a 
homogenous society. Somewhere like the US where the cultural differences 
are larger, it is probably a lot harder for irony to be taken as such 
and not as sarcasm.


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: operator overloading + - / * = etc...

2006-10-10 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes:
> Suppose one has the following intention in mind:
> 
>   while x = setup():
> if y = pre_process() in ErrorCondition:
>   break
> post_process(y)
>   else:
> NormalTermination()

Maybe we need a new itertools function:

   def forever(func, *args, **kw):
  while True:
 yield func(*args, **kw)

then you'd write:

   for x in takewhile(bool, forever(setup)):
  if y = pre_process() in ErrorCondition:
 break
  post_process(y)
   else:
  NormalTermination()

It might be preferable to write pre_process to raise an exception if
there's an error condition.  Then the whole thing becomes:

   try:
  for x in takewhile(bool, forever(setup)):
 post_process(pre_process())
  NormalTermination()
   except PreprocessError:
  pass
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter: populating Mac Help menu?

2006-10-10 Thread Edward K. Ream
Hello all,



Creating a 'Help' menu 'by hand' on the Mac does not work, or rather, it 
creates a *second* Help menu.



There are hints about how to do this at:



http://tkinter.unpythonic.net/wiki/Widgets/Menu



but so far those hints have not been enough :-) The following statements are 
the result of several happy hours experimenting with dir(obj) for several 
objects obj related to menus.  (Jeeze, I love Python, but you knew that :-)



The url above suggests that the 'official' Mac menu is named x.help, where x 
is the Tk name (a string) of the menubar.  If menubar is the Tkinter menubar 
widget, then I assume that x = menubar._w.



So given x (a string), how does one create a widget whose name is '%s.help' 
% x ?  This is a can of corn in Tk, but nothing comes to mind looking at the 
Tkinter source code.



If my app does *not* create a help menu, then even long after the Mac 
menubar is created, and the official (empty) Help menu is visible, 
menubar.children does *not* contain an entry for the official Mac Help menu. 
Thus, there appears to be no way to populate the official Help menu after 
letting Tkinter create the Help menu.  Naturally, I could be wrong :-)



Thanks for any help you can provide.


Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Using Gnutar to remove a list of files

2006-10-10 Thread cmacn024
Hi folks, I've got a question for yas.  I'm trying to write code that
will open up a gzipped tar file using gnutar, and copy the list of
files(including their directories) to a list variable in python.  From
there, I want to go through the list and delete those files from my
system.  That part is easy, but what I'm stuck on is getting the list
of files in an archive into a list variable.  If I use the -t parameter
in gnutar, it prints a list of the files in a seperate cmd screen, but
only returns 0.  Is there any way to make it return a list, or to copy
the information over?  Thanks in advance!

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


Re: Using Gnutar to remove a list of files

2006-10-10 Thread Gerrit Holl
On 2006-10-10 14:35:30 +0200, [EMAIL PROTECTED] wrote:
> Hi folks, I've got a question for yas.  I'm trying to write code that
> will open up a gzipped tar file using gnutar, and copy the list of
> files(including their directories) to a list variable in python.  From
> there, I want to go through the list and delete those files from my
> system.  That part is easy, but what I'm stuck on is getting the list
> of files in an archive into a list variable.  If I use the -t parameter
> in gnutar, it prints a list of the files in a seperate cmd screen, but
> only returns 0.  Is there any way to make it return a list, or to copy
> the information over?  Thanks in advance!

Use the commands module.
Or tarfile of course.

http://docs.python.org/lib/module-commands.html
http://docs.python.org/lib/module-tarfile.html

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


Re: Dive Into Java?

2006-10-10 Thread Bjoern Schliessmann
Dan Bishop wrote:
> On Oct 9, 11:40 am, Bjoern Schliessmann

>> String eggs = new String();
>>
>> The latter seems totally unnecessary to me, as well as being too
>> verbose
 
> It is!  All you have to write is
> 
> String eggs = "";
> 
> Unfortunately, the other object types don't have literals.

LOL. Sun likes their own String objects more than their principles,
don't they? :)
 
> Can't be, because Java already uses the syntax for something
> different than C++.

Ah, know what you mean (empty reference). That seems weird to me
too, altogether. This syntax break compared to basic types makes it
all most unaesthetic.

Regards,


Björn

-- 
BOFH excuse #248:

Too much radiation coming from the soil.

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


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Nick Vatamaniuc wrote:
> Edward Diener No Spam wrote:
>> Michael wrote:
> 
> Python does not _need_ a component model just as you don't _need_ a RAD
> IDE tool to write Python code. The reason for having a component model
> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
> Python is terse enough that boiler plate code is not needed, just type
> what you need into an editor. It seems that you talk about Python but
> you are still thinking in Java or C++.

A RAD IDE tool to hook up components into an application or library ( 
module in Python ) has nothing to do with terseness and everything to do 
with ease of programming. All you are saying is that you don't have a 
need for this, but perhaps others do. I don't mind others saying they 
have no need or seeing no benefit. But if you have ever used a visual 
design-time environment for creating applications you might feel 
differently.

"Thinking in Java or C++" as opposed to Python does not mean anything to 
me as a general statement. I am well aware of the difference between 
statically and dynamically typed languages but why this should have 
anything to do with RAD programming is beyond me. Do you care to 
elucidate this distinction ?

> 
> At the same time one could claim that Python already has certain
> policies that makes it seem as if it has a component model. Take a look
> at the "magic methods". For example if a class has a __len__ method, it
> is possible to use the len() function on an instance of that class. If
> a class has the  __getitem__ then indexing can be used on that class's
> insance. Then Python has properties (see
> http://www.python.org/doc/2.2.3/whatsnew/sect-rellinks.html).  Just by
> inspecting the object one can tell a great deal about them (even read
> the documentation if needed, by using the __doc__ attribute).   What
> other standards would you propose for the core language?

Python has great facilities for a component model, much better than the 
other languages I use regularly ( C++, C#, Java ). I am not arguing 
against that. A component model for RAD tools allows the tool to expose 
properties and events to the end-user at design time so that at run-time 
the properties and events are automatically setup once an object is 
instantiated. The essence of a component model for RAD programming is 
how one specifies properties and events for a class to be manipulated by 
the RAD tool at design time. Another obvious part of the component model 
is how one specifies that the properties and events one sets up at 
design-time are serialized so that at run-time they are properly set. A 
final element of a component model is the ability of a component to 
interact with the environment in which it exists at design time, through 
property editors, and at run-time, the latter being obviously more 
important for visual controls than non-visual components.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Paul Rubin wrote:
> "Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
>> Python does not _need_ a component model just as you don't _need_ a RAD
>> IDE tool to write Python code. The reason for having a component model
>> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
> 
> It's also so that applications written in differing languages can call
> each other.

That's a possible reason, but with JavaBeans and EJBs for Java there is 
just a single language and I am sure there are many Java programmers who 
enjoy using Eclipse, NetBeans, or JBuilder to name a few RAD IDEs which 
allow them to create their applications using a design-time visual 
environment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Gnutar to remove a list of files

2006-10-10 Thread Rob Williscroft
 wrote in news:[EMAIL PROTECTED] in 
comp.lang.python:

> Hi folks, I've got a question for yas.  I'm trying to write code that
> will open up a gzipped tar file using gnutar, and copy the list of
> files(including their directories) to a list variable in python.  From
> there, I want to go through the list and delete those files from my
> system.  That part is easy, but what I'm stuck on is getting the list
> of files in an archive into a list variable.  If I use the -t parameter
> in gnutar, it prints a list of the files in a seperate cmd screen, but
> only returns 0.  Is there any way to make it return a list, or to copy
> the information over?  Thanks in advance!
> 

Perhaps this will help:

http://docs.python.org/lib/tar-examples.html

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Richard Brodie

"Edward Diener No Spam" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> "Thinking in Java or C++" as opposed to Python does not mean anything to me 
> as a general 
> statement. I am well aware of the difference between statically and 
> dynamically typed 
> languages but why this should have anything to do with RAD programming is 
> beyond me. Do 
> you care to elucidate this distinction ?

I think this blog entry http://osteele.com/archives/2004/11/ides
provides some insight into the point of view expressed. 


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


Re: Using Gnutar to remove a list of files

2006-10-10 Thread cmacn024
Yeah, I got it working with tarfile.  Thanks!

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


Re: Dive Into Java?

2006-10-10 Thread Diez B. Roggisch
>> For example: the overloading of assignment operators, casting
>> operators, copy constructors and the like that, and the fact that
>> one of them is possibly chosen in absence of the other.
> 
> Isn't the overloading concept an effect of type strength? In Java,
> you'd have to overload them too. Or am I missing something?


Yes. You can for example create a constructor for object Foo, which then is
implicitly chosen when assigning an int to a variable of that kind. So it
acts as a casting operator. I call that wicked, and subtle.

class Foo {
  int _arg;
public:
  Foo(int arg) {
_arg = arg;
  }
};

int main() {
  Foo f = 10;
}

  
>> The subtle differences between pointers and references.
> 
> That's an issue, though you don't have to use them both. Kind
> of "historically grown".

Who cares for the reason - it is there, isn't it? You are the one claiming
that a new language should get rid of old concepts, btw. Where is your
money, and where your mouth?
  
>> Missing definition of static initializer order, at least for some
>> binary formats.
> 
> Didn't come across this one though.

I did when doing embedded programming. bites you, especially in such an
environment.

> Example:
> 
> int spam = 5;
> 
> but
> 
> String eggs = new String();
> 
> The latter seems totally unnecessary to me, as well as being too
> verbose -- why couldn't they go the simple way as in Python and
> just state
> 
> String eggs;

The unfortunate separation between primitive (read: numbers) and complex
types (everything else) is a stupid idea, I agree. However, that is
remedied with 1.5, and beyond the odd corner case in a very well matter
(see below.)

> That's a wrong decision, IMHO. A new and practical language (what
> Java wanted to be) shouldn't provide 3/4-compatible syntax, but be
> clear, concise and customizable, and shouldn't say "That's bad, you
> mustn't do that."

That is a matter of taste - but in the same way, we could argue about C++
and C, can't we? And it "just" took the very basic things - building
blocks, control flow and classes.
 
>> You are confusing things here. That you can't implement your own
>> string derived class has to do with java.lang.String being final -
>> something I grief about, too.
> 
> That's not exactly my point. What if I just wanted to build my own
> interface compatible class ... impossible.

I don't understand that.

> For a start, it just doesn't look pretty ...
> 
> String ham;
> 
> ham = "1" + "2";
> 
> ... is translated to ...
> 
> ham = new StringBuffer().append("1").append("2").toString()


So what? Since when is compiler optimization a bad thing? What do you think
happens all the time when mixing types in C++? And I know of some very
elaborated schemes called "common base class idiom" for e.g. template-based
vector classes to introduce allocation optimization to arithmetic
expressions in C++.

The code _generated_ by the java compiler, and the C++ compiler, is not the
issue here. If you as a programmer can write "a" + "b", its fine. Which is
a thing to reach in C++, a bazillion of string-classes have been
written


and in C++, you can do:

char *a = "1";
char *b = "2";
char *c = a + b;

But with a totally different, unexpected outcome.. I know where *I* start
laughing here.

> Another funny thing are those awkward wrapper classes, but that's
> been "patched" in an awkward way with 1.5 IIRC.

The way is not awkward, it is called auto-boxing/unboxing and works very
well. The odd corner case being e.g.

Boolean b = null;
if(b) { // NPE here
}

 
And this is more than matched by the subtle differences between

Foo a;
Foo &a;
Foo *a;

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


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Diez B. Roggisch wrote:
> Paul Rubin schrieb:
>> "Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
>>> Python does not _need_ a component model just as you don't _need_ a RAD
>>> IDE tool to write Python code. The reason for having a component model
>>> or a RAD IDE tool is to avoid writing a lot of boiler plate code.
>>
>> It's also so that applications written in differing languages can call
>> each other.
> 
> Nope. Things like CORBA and COM do have that property, but e.g. the Java 
> beans spec has only a meaning inside the VM. Not sure about .NET, but I 
> can imagine there it's the same thing.
> 
> All the languages he mentioned are statically typed, or the component 
> models themselves are. So the component model is basically needed (as 
> others also mentioned) to glue things together, to dynamize that - 
> whereas python is dynamic on the first hand, and actually lacks static 
> typing to infer component properties...

While I understand dynamic typing, I still think it is possible to 
create attributes in a Python component model which could tell a RAD 
tool what type the attribute will encompass for the purpose of 
properties and events. Obviously a "name, type" tuple, among other 
possible information would have to be used. But given Python's amazingly 
flexible type and introspection system, this should be possible.

Of course I am not trying to change the nature of normal Python 
attributes per se at all, and one of the most important things in a 
property-method-event component model is to be able to specify 
properties that are distinct from just normal object data members. So 
one of the most important things in a Python component model would be 
the ability to tag component properties as totally distinct from normal 
Python class attributes or property attributes.

Given that Python already has new-style class properties, maybe another 
name for the component properties I envision is needed to avoid confusion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A curses-game I need help with.

2006-10-10 Thread Rainy

Gasten wrote:
> Rob Wolfe wrote:
> > > while running:
> > > key_command = game.mainwin.getch()
> >
> >   # I've moved erasing messages here
> >   game.msg.ereasMsg()
>
> Man... I didn't even think of that. It's embarassing. Thanks. It works
> perfect now. Again, thanks.
>
> Gasten

By the way, I also started doing a small rogue-like with a twist that
you control monsters. I used curses, too. It's very small and
incomplete, and I think there was a bug with monsters going through
walls, but it may help you..

You can find it at silmarill.org -> programs -> I, monster.

I'd be interested in looking at your game, as it gets imporved, too, do
you have a webpage for it yet? Please post..

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


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Steve Holden wrote:
> Diez B. Roggisch wrote:
> [...]
>>> Just the same, one can use IronPython to call components written in
>>> other languages. And, I believe, vice versa.
>>
>>
>> Sure, as I can do it in jython. But the key point is: can your ordinary
>> python-object be published as a component? At least for jython I can
>> say "no", you will have to subclass an already existing
>> java-object/interface. And I have difficulties imagining that it is any
>> different in .NET - because I've read statements that claimed that the
>> structure of the VM/runtime is orientied towards single-inheritance
>> statically typed languages as C#/java.
>>
> The answer to this question is currently beyond me. Maybe someone who 
> knows more about IronPython can elucidate. I do know (as you probably do 
> also) that Python generates code for the .NET CLR, however.

I am not sure about current IronPython functionality but the end result 
is that one should be able to create .Net components and classes using 
Python with IronPython just as one does in C#, C++/CLI, or VB .NET.

But this is not creating a component model for Python except in the .Net 
environment, which essentially means Windows unless IronPython will work 
under Mono, and Microsoft does not kill Mono. I don't think all those 
"ifs" is something a Python programmer wants to deal with in possible 
RAD component development.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python component model

2006-10-10 Thread Fredrik Lundh
"Edward Diener No Spam" wrote:

> A RAD IDE tool to hook up components into an application or library (
> module in Python ) has nothing to do with terseness and everything to do
> with ease of programming.

python already has excellent and ridiculously easy-to-program ways to hook
things up.  after all, hooking things up is what python programmers tend to do,
most of their time.

if you want better support for more precise hooking, post some examples.

> All you are saying is that you don't have a need for this, but perhaps others 
> do.

handwavy references to what "other may need" is another thing you should
avoid if you want your Python change proposal to be successful.

 



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


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote:
> Nick Vatamaniuc wrote:
> 
>> At the same time one could claim that Python already has certain
>> policies that makes it seem as if it has a component model.
> 
> every Python object surely qualifies as a component, for any non-myopic 
> definition of that word, and everything inside a Python program is an 
> object.  so yes, Python has a component model, and Python programmers 
> are using that model all over the place.
> 
> what might be missing is support for publishing additional metadata 
> using a standardized vocabulary, and a way to access that data with-
> out having to actually create the object.
> 
> implementing this using existing mechanisms is trivial (as the endless 
> stream of interface/component/adapter/trait implementations have shown 
> us); coming up with a good-enough-to-be-useful-for-enough-people 
> vocabulary is a lot harder.

There's no doubt that Python's excellent introspection mechanism allows 
an outside RAD-like tool to inspect the workings of any Python object. 
But that does not make it a component model in my original use of the 
term on this thread. A RAD tool needs to know what properties and events 
within a class can be manipulated visually, and it needs to be able to 
serialize those properties and events so that they are set at run-time 
automatically once an object is created.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Sarcasm and irony

2006-10-10 Thread bryan rasmussen
> bryan rasmussen skrev:
>
> > Well irony originally started out as a very specific concept of the
> > Ancient Greek drama, this is what we nowadays refer to as Dramatic
> > Irony but it is the original irony. Irony then became a literary
> > concept for plot elements similar to Dramatic irony in books, or a
> > weaker type of the Dramatic irony found in the plays of Shakespeare.
> > People then noticed that life was at times ironic in the literary
> > manner.
>
> Yes and in Rome "salary" meant getting a bag of salt.

According to Answers.com it derives from a word for money given to
Roman soldiers for buying salt, hence salary is pertaining to salt.

> Concepts changes.

As was noted in my original statement the weak form of irony such as
understood by Danes and I suppose by Americans as well, since that is
what Steve was originally complaining about, is descended from the
concept of Dramatic Irony. If you do a dictionary lookup of irony
dramatic irony will probably be mentioned, also such more antiquated
usages as Socratic irony.

These other concepts of irony have not changed. You can use the word
irony in a technical manner to someone in the dramatic arts and have
the usage understood.

 The weak form of irony, verbal irony, is a pretty recent addition to
the concept of irony.

To take a wikipedia discussion of the subject:
http://en.wikipedia.org/wiki/Irony

let's quote:
"Verbal irony is traditionally defined as the use of words to convey
something other than, and especially the opposite of the literal
meaning of the words. One classic example is a speaker saying, "What
lovely weather we are having!" as she looks out at a rainstorm
intending to express her dissatisfaction with the weather."

I believe this answers to the concept of irony as used by Danes
(especially given  the example of the weather comment above which I
hear similar comments all the time.)

Given the wikipedia article and Steve Holden's description of
Americans as being clueless about irony for usages that you seem to
find correct I suppose that Americans are no more clueless or less apt
to understand Danish irony than Danes are. However, having been
exposed to Danish irony quite a bit I have to say that in my case I
understand it fine but it bores me, therefore when a Dane tells me
that Americans don't understand Danish irony I always secretly think
they probably wonder why looking out at a rainstorm and saying "What
lovely weather we are having" should be considered as a particularly
inspired use of the verbal ironical form. Also although I am not an
american I am often mistaken for one by Danes and when someone says
'What lovely weather we are having' (or similar) I will tend to be
rather ironical myself and pretend not to have understood their
comment as being ironical. And then they will try to explain irony to
me with very long and drawn out explanations. Fun stuff.


> > Nowadays the use of the word irony has degenerated to by
> > pretty much synonymous with sarcasm.
>
> As a Dane that is a Chronic Ironic, I beg to differ.
>
> In Denmark at least there is a lot of difference between irony and
> sarcasm. Irony is the main form of humor here, and danes takes to it
> easily. People being sarcastic we don't much like.
>
> But I guess that it can be hard to se the difference for someone not
> used to irony.

Yes, just what I was going to say.

I suppose that you will admit that the Danish Ironisk has the same
history as the English Irony, of course as the above mentioned
Wikipedia article mentions "Irony often requires a cultural backdrop
to be understood or noticed, and as with any culture-specific idiom,
irony often cannot be perfectly transplanted. " If you do so agree
then, as opposed to your example of 'salary', the current meaning of
irony being predominantly used to convey Verbal irony is rather
recent.


I may very well be missing some sort of meta-irony in someone saying
"What wonderful weather we're having" when its pouring in København's
Rådhusplads, as in a sort of self-ironical stance consisting of an
implicit statement of "what an idiot I must be for thinking it
worthwhile to comment ironically on the weather when everyone else
today has said the same damn thing. " but I don't know. The main point
is, I think, that verbal irony is understood as a meaning for irony
between various cultures and is not a unique invention of the Danes,
for unique linguistically defined concepts I think Denmark's best
strategy is still to push 'hygge'.

Now again, it may be somewhat old time fuddy-duddyism on my part to
insist on a stronger form of the word irony than verbal irony. I am
personally ready to use all the definitions of ironical forms
discussed in the Wikipedia article because they are technically
precise words and concepts for which we do not have words and concepts
other than them.



Med Venlig Hilsen,
Bryan Rasmussen
-- 
http://mail.python.org/mailman/listinfo/python-list


Logic Programming

2006-10-10 Thread MaR
Yes! The question rears its head once again! ;o)

I have done some search and trial and horrors.. (PyLog has vanished?)
But I fail to find anything useful when it comes to do Logic
Programming (e.g. Prolog'ish)
in the context of Python.
And yes, I tend to beleive that I need to!
No, I do not really like the idea of piping def's and queries to
SWI-prolog ála PyProlog.

So, I would be *so* happy if someone could point at some module that
gives me the possibility to define a knowledgebase and queries from
within Python and still access the structures from Python code.

*pleeze!*

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


Re: Python component model

2006-10-10 Thread Fredrik Lundh
Edward Diener No Spam wrote:

> There's no doubt that Python's excellent introspection mechanism allows
> an outside RAD-like tool to inspect the workings of any Python object.
> But that does not make it a component model in my original use of the
> term on this thread. A RAD tool needs to know what properties and events
> within a class can be manipulated visually, and it needs to be able to
> serialize those properties and events so that they are set at run-time
> automatically once an object is created.

external serialization was not part of your original definition.

I think you have to be a *lot* more concrete here.  repeatedly referring to
"some kind of hypothetical property (that isn't a property)" and "some kind
of hypothetical event (that isn't a public method)" and "some kind of hypo-
thetical RAD tool" won't get you anywhere.

 



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


Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Michael Sparks wrote:
> Edward Diener No Spam wrote:
>> Michael wrote:
>>> Edward Diener No Spam wrote:
>>>
 Has there ever been, or is there presently anybody, in the Python
 developer community who sees the same need and is working toward that
 goal of a common component model in Python, blessed and encouraged by
 those who maintain the Python language and standard modules themselves ?
>>> Someone aiming towards a standard to /replace/ everyone else's? That
>>> presupposes a level of arrogance that seems unusual in the python world.
>>> (whilst everyone's proud of their own code and they _generally_ respect
>>> other people's even if it's not their cup of tea).
>> The reason I would like to see a standard component model for Python is
>> so 3rd party developers could create their classes to conform to this
>> model and work in any RAD IDE environment which adapts it. That's the
>> way JavaBeans work, that the way Borland's VCL component model works,
>> and that's the way .Net works. When there are many different component
>> models, the 3rd party developer must adapt their components to each
>> model for a particular environment.
>>
>> But far be it from me to want to replace everybody else's model .
> 
> Well that's the thing you *do* want since you want the previous
> paragraph ;-)
> (Or at least a way to adapt component models.)

I was being funny above. Yes I would like to establish a basic component 
model for RAD development in Python. But surely it need not replace all 
others but could serve at least as a base class for other derived models 
for various environments. That way a developer writing a Python 
component could have it work in these environments as a simple component 
and more complex components, tailored to that environment could be 
created as necessary through inheritance.

> 
>> By your reasoning above, standardizing anything in software is an
>> arrogant proposition. Whereas I look at standardization, when it is well
>> done, as a boon to programmers.
> 
> OK, maybe I was being a bit strong - I was merely thinking "lots of
> people have something like this already, and I've not seen anyone push
> their model as THE model", (even if lots of people like *their* model
> :-)
> 
> However, I was also being a bit tongue in cheek, though I should have
> said unreasonable, not arrogant:
>"...all progress depends on the unreasonable man." -- Bernard Shaw.

Bravo, Shaw. Of course by unreasonable I assume Shaw meant those using 
imagination and inspiration along with logic and reason.

> 
> What could have some mileage though is proposing a standard way for
> these component models to interoperate. What that would look like
> (given the wildly different models :), is another matter and an
> exercise for the interested reader ;-)
> 
>>> The WSGI standard could be a form of component model, and has gone through
>>> the PEP process so that might match your criterion.
>> I do not know what it is but I will look it up.
> 
> NB, I'm using component model in it's loosest form there.
> 
>>> As for component
>>> models, they do exist.
>>>
>>> Our component model on the Kamaelia project [1] is one that's heavily
>>> designed around the idea of composition and independent execution of
>>> components and message passing (message passing maps to events for some
>>> sorts of message),
>>>[1] http://kamaelia.sourceforge.net/Home
>> I will look at kamaelia. Thanks !
> 
> You're welcome. Any deficiencies or improvements or suggestions you've
> got would be very welcome (I can see some which we're planning on
> addressing at some point, but fresh critical eyes are always welcome).
> 
>>> However, off the top of my head, you should also look at Zope's component
>>> model, Trac's component model, Twisted's model & PEAK, and any proposal
>>> to say "this is the solution", needs to be compelling for all of these
>>> projects.
>> A standard component model could be used as a base for other more
>> advanced needs. Most of those mentioned above seem to involve web
>> application frameworks whereas my idea of a component model just assumes
>>   the paradigms of properties, methods, and events which may allow
>> re-usable components at a base level in any environment.
> 
> They do, however in particular, Trac's model whilst web oriented
> strikes me personally as interesting and PEAK's is applicable, as I
> understand it, outside the web sphere. (Enthought was mentioned
> elsewhere and is interesting (IMO) for the properties stuff)

I do like most of Enthought's notion of properties, which they call 
"traits", no doubt to also distinguish it from Python new-style class 
properties. Their notion corresponds somewhat to the idea of properties 
in Java and .Net.

Essentially a property-method-event component model in Python needs 
component properties and component events, so investigating notions of 
component properties in Python is something I want to do.

> 
> If you're interested in event syst

Using the imp module

2006-10-10 Thread Claus Tondering
I understand that you can use the imp module to programmatically mimic
the "import xyzzy" statement.

But is there any way to programmatically mimic the "from xyzzy import
*" statment?

--
Claus Tondering

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


Re: Dive Into Java?

2006-10-10 Thread Christophe
Diez B. Roggisch a écrit :
> The code _generated_ by the java compiler, and the C++ compiler, is not the
> issue here. If you as a programmer can write "a" + "b", its fine. Which is
> a thing to reach in C++, a bazillion of string-classes have been
> written
> 
> 
> and in C++, you can do:
> 
> char *a = "1";
> char *b = "2";
> char *c = a + b;
> 
> But with a totally different, unexpected outcome.. I know where *I* start
> laughing here.

That code doesn't even compile. And you shouldn't be using the char* 
compatibility strings in C++ if possible.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (semi-troll): Is Jython development dead?

2006-10-10 Thread John Roth

Ray wrote:

>
> So, what is your main concern here that 2.1 doesn't address? Because if
> your concern is that you're using a dead thing as your environment,
> it's rising from the dead. But if your concern is that you want to use
> features in Python 2.4 in Jython, might as well look for other
> solutions--it'll be some time before a version that supports that comes
> out.

And that is exactly the point. I've had a couple of
inquiries about Jython support in PyFIT, and I've
had to say that it simply isn't supported. The latest
point release requires Python 2.3, and 2.4 will be
required in the next year or so.

John Roth
Python FIT
> 
> 
> 
> > 
> > - Sloan

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


Re: Python component model

2006-10-10 Thread Tim Chase
> There's no doubt that Python's excellent introspection mechanism allows 
> an outside RAD-like tool to inspect the workings of any Python object. 
> But that does not make it a component model in my original use of the 
> term on this thread. A RAD tool needs to know what properties and events 
> within a class can be manipulated visually, and it needs to be able to 
> serialize those properties and events so that they are set at run-time 
> automatically once an object is created.

A little visual inspection of some objects:

[EMAIL PROTECTED]:~$ python
Python 2.3.5 (#2, Sep  4 2005, 22:01:42)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
 >>> class Person(object):
... def __init__(self, name, age=None):
... self.name = name
... self.age = age
... def whoami(self):
... if self.age is not None:
... return "%s (%i)" % (
... self.name,
... self.age)
... return self.name
...
 >>> p = Person("Sandy")
 >>> [s for s in dir(p) if not s.startswith('_') and 
callable(eval('p.%s' % s))]
['whoami']
 >>> [s for s in dir(p) if not s.startswith('_') and not 
callable(eval('p.%s' % s))]
['age', 'name']

Thus, you have the ability to find an object's methods/events 
(things that are callable()), and its properties (things that are 
not callable()).  Any "RAD" tool that wants can pull these 
properties, just as my command-line RAD tool can ;)

As for serializing them,

 >>> import shelve
 >>> d = shelve.open('tmp/stuff.shlv')
 >>> d['person'] = p
 >>> p = 'hello'
 >>> p
'hello'
 >>> p = d['person']
 >>> p.whoami()
'Sandy'
 >>> p.age = 42
 >>> p.whoami()
'Sandy (42)'
 >>> d['person'] = p
 >>> d.close()
 >>> p = 'hello2'
 >>> p
'hello2'
 >>> d = shelve.open('tmp/stuff.shlv')
 >>> p = d['person']
 >>> p.whoami()
'Sandy (42)'

which seems to work fine for me.  This can be used for creating 
all sorts of flavors of objects at design time, storing them, and 
then restoring them at runtime.

-tkc




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


Re: Logic Programming

2006-10-10 Thread Boris Borcic

I believe some work has been down in pypy to bring logic programming to python.
You might ask pypy-dev

Google leads to 
http://codespeak.net/pypy/dist/pypy/doc/howto-logicobjspace-0.9.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using the imp module

2006-10-10 Thread Fredrik Lundh
Claus Tondering wrote:

>I understand that you can use the imp module to programmatically mimic
> the "import xyzzy" statement.

"imp" sounds like overkill for that purpose; the usual way is do do that is to
explicitly call __import__:

xyzzy = __import__("xyzzy")

> But is there any way to programmatically mimic the "from xyzzy import
> *" statment?

you can use getattr() to pick out the objects your need.  or you could do
something like:

globals().update(vars(__import__("xyzzy")))

 



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


Re: Using the imp module

2006-10-10 Thread Steve Holden
Claus Tondering wrote:
> I understand that you can use the imp module to programmatically mimic
> the "import xyzzy" statement.
> 
> But is there any way to programmatically mimic the "from xyzzy import
> *" statment?
> 
See the docs for __import__().

I think imp is pretty much dead nowadays.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Encode differences between idle python and python

2006-10-10 Thread pretoriano_2001

Gabriel, Peter:
Many thanks for your clear answers!!
Best regards.

Vizcayno

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


Re: Python component model

2006-10-10 Thread Diez B. Roggisch
> While I understand dynamic typing, I still think it is possible to
> create attributes in a Python component model which could tell a RAD
> tool what type the attribute will encompass for the purpose of
> properties and events. Obviously a "name, type" tuple, among other
> possible information would have to be used. But given Python's amazingly
> flexible type and introspection system, this should be possible.

The amazing flexibility stems from the fact that it is _runtime_. This is
_exactly_ the difference between static and dynamic typing.

If a static analysis (_not_ importing the module, which can trigger
arbitrary code being run!!!) is supposed to deliver the component
architecture, you are either introducing static typing, or get into the
danger of lose coupling between declaration and implementation, rendering
the whole thing pretty useless.

Of course, with a bit of discipline, you can create such a introspection
facility that offers its properties after a mere import, see ZOPE
interfaces for example. 

But in the end, it boils down to declaring stuff for that purpose alone, and
introducing static typing, whereas other languages declare typing for their
own needs, and add the component model upon that. 

And then you lose a _lot_ of what python makes powerful, for a very doubtful
benefit IMHO.

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


  1   2   3   >