Re: Decline and fall of scripting languages ?

2005-08-08 Thread Donn Cave
Quoth Paul Rubin :

| Right now I'm mainly interested in OCaml, Haskell, Erlang, and maybe
| Occam.  Haskell seems to have the happiest users, which is always a
| good thing.  Erlang has been used for real-world systems and has
| built-in concurrency support.  OCaml seems to crush Haskell and Erlang
| (and even Java) in performance.

I'm sure you're aware that these are all arguable.  In particular,
shootout figures aren't a really reliable way to find out about
performance.

| The idea is to use one of those languages for a personal project after
| my current work project wraps up pretty soon.  This would be both a
| learning effort and an attempt to write something useful.  I'm
| thinking of a web application like a discussion board or wiki,
| intended to outperform the existing ones, i.e. able to handle a
| Slashdot or Wikipedia sized load (millions of hits/day) on a single
| fast PC instead of a rack full.  "Single fast PC" will probably soon
| come to mean a two-cpu-chip motherboard in a 1U rack box, where each
| cpu chip is a dual core P4 or Athlon, so the application should be
| able to take advantage of at least 4-way multiprocessing, thus the
| interest in concurrency.

Oh.  Note that the FP world has been historically attracted to the
"green" thread model, where threads are implemented in the runtime
like (old) Stackless micro-threads, much faster and more tractable
for runtime data structures ... but runs on only one CPU at a time.
Ocaml & I believe current ghc support native OS threads, Erlang I
would guess not but wouldn't know for sure.  Don't know about ghc
internals, the way I remember it ocaml's native thread system has
something like Python's global lock, instead of locks around each
memory management function etc.

Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Kay Schluehr
EP wrote:

> But sometimes a rugged individual can be even more rugged and more individual 
> if said individual has the support of friends by which to vet ideas and, by 
> absorbing counterpoint, to develop one's own thoughts even further.
>
>
> And it is kind of nice when you have two teams drilling a mountain tunnel 
> from opposite sides to have an effective way to line up efforts.

EP, maybe you/we should try out the Meta-SIG or short MESIG which did
not passed away because it was never born.

http://www.python.org/sigs/

In the context of MESIG we can discuss the shape of PEEP and create
your taskforce, blowing life into a new heroic genus - fame and
prestige may be with them. Is K serious? Speaking seriously, a few
years ago K read somewhere in the BDFLs memoirs that "fun" was once a
part of Pythons culture originating from our great anchestors namely
the commedians of Monty Python. Becoming sentimental about this and as
a true and proud reactionary K always seemed to be a fundamentalist
somehow. Not an excuse but an explanation.

Kay

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


Re: Point and click GUI builder for Python

2005-08-08 Thread Mir Nazim
neuruss neuruss wrote:
> Madhusudan Singh wrote:
> > Is there such a thing for python ? Like Qt Designer for instance ?
>
> The easiest way to create Python GUI apps: PythonCard.
> It is based on wxPython by it has a higher level of abstraction.
> You just drag and drop widgets on a form and code the events like you
> woud in Visual Basic or Delphi.
> IMHO, it's easier, simpler, more intuitive and stable than Boa
> Constructor.

Add to it wxGlade.sourceforge.net.
But remember it is only a UI designer(does it pretty well) not an IDE.
I fee wxGlade+SPE(http://www.stani.be/python/spe/blog/) are a better
combo than PythonCard.

Mir Nazim.
www.PlanetNazim.com

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


Re: Point and click GUI builder for Python

2005-08-08 Thread Mir Nazim
neuruss neuruss wrote:
> Madhusudan Singh wrote:
> > Is there such a thing for python ? Like Qt Designer for instance ?
>
> The easiest way to create Python GUI apps: PythonCard.
> It is based on wxPython by it has a higher level of abstraction.
> You just drag and drop widgets on a form and code the events like you
> woud in Visual Basic or Delphi.
> IMHO, it's easier, simpler, more intuitive and stable than Boa
> Constructor.

Add to it wxGlade.sourceforge.net.
But remember it is only a UI designer(does it pretty well) not an IDE.
I fee wxGlade+SPE(http://www.stani.be/python/spe/blog/) are a better
combo than PythonCard

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Cliff Wells
On Mon, 2005-08-08 at 10:10 -0700, Paul Rubin wrote:
> Cliff Wells <[EMAIL PROTECTED]> writes:
> > The second presentation (I don't recall the speaker's name) specifically
> > covered metaprogramming (writing DSLs) and one of the things I found
> > interesting was that despite Ruby having far more syntax than Python in
> > general, the resulting Ruby-based DSLs presented had far *less* syntax
> > than had they been written in Python.  This is undoubtedly the reason
> > why Rails is apparently completely usable even if one knows very little
> > Ruby.
> 
> Interesting.  But if we can generalize from that, then Lisp should be
> ruling the web.

Well, that is perhaps the other key feature: the Ruby/Rails community
seems pretty friendly and eager to help people jump to their side of the
fence (much like the Python community, btw), whereas Lisp community is
an oxymoron.

Regards,
Cliff

-- 
[EMAIL PROTECTED]
http://www.develix.com :: Web applications and hosting :: Linux, PostgreSQL and 
Python specialists ::


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


Re: PEP: Specialization Syntax

2005-08-08 Thread Bengt Richter
On Mon, 08 Aug 2005 21:24:15 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:

>Bengt Richter wrote:
>> On Mon, 08 Aug 2005 16:18:50 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:
>>>I wrote the PEP to see if was the only one that would benefit from 
>>>generic types *before* having optional static typing in the language.
>>>
>>>It seems I'm the only one;)
>>>
>>>According to blog entry 86641, Guido himself is prototyping with 
>>>__getitem__.  However, I cannot do the same, because the framework I use 
>>>is much more complete and keyword arguments are a must.
>>>
>> Here is a decorator object to set up function call dispatch according to 
>> type.
>> It only uses positional arguments, but could be fleshed out, I think.
>> Not tested beyond what you see ;-)
>
>That's nice.  Guido also posted this multimethods solution:
>http://www.artima.com/weblogs/viewpost.jsp?thread=101605
>
When I first read that, I thought you meant he had posted the very same thing.
Anyway, maybe mine is different enough to be a little interesting ;-)
 
>The only thing I was saying it that I can use generic types in Python 
>right now (and I do), by using (), but I can't with what will probably 
>be the syntax in future, i.e. using [].
>
Ok ;-)  Maybe sometime in the future
it will be possible to modify the language grammar and define a few classes
and regenerate a whole new python interpreter that interprets new syntax.

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread EP
"Kay Schluehr" wrote:

> I already see the headline: PEEP is the answer - PSF votes for software
> patents. All ideas are written down by volunteers in great detail they
> just have to be coded. Due to intellectual property rights PSF becomes
> one of the richest organizations in the world. Guido van Rossum,
> chairman of PSF and mighty governor of California recommends an
> invasion into Iran: "we cannot accept that they didn't payed us for a
> PEEP describing a steering mechism for a nuclear power station to be
> written in Python. They are dangerous. They didn't have our
> commitment." Mr. van Rossum also commented the unfriendly takeover of
> the former software giant Microsoft that was immediately renamed into
> "Snakeoil Corp." succinctly: "They had a platform we were interested
> in".
> 
> Yes, the Python experiment was (not just) successfull.


(Aside) Karl, I do not think K is taking the matter seriously, even though our 
very survival against an axis of eval is at stake.  Send some of your goons 
around to keep an eye on Schluehr - K may not be of, by, or for the PEEPle - 
and besides, I just don't like that attitude.

I know, I know, Barbara says K's just a bitwise, but I've seen those weak types 
before.

Sure makes me wish for my days of youth when we had the real James Baud, 0x007.

But I assert, I will one day free this world of unlicensed coders and other 
rogue inventors and innovators who have no respect for the traditional logic 
that has always been my goto.



(Seriously)  Certainly we do not want to go too far or you would not hear even 
a little PEEP out of me.

But sometimes a rugged individual can be even more rugged and more individual 
if said individual has the support of friends by which to vet ideas and, by 
absorbing counterpoint, to develop one's own thoughts even further.


And it is kind of nice when you have two teams drilling a mountain tunnel from 
opposite sides to have an effective way to line up efforts.


EP
"yes, my brain is Swiss cheese tonight"

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


Re: python for microcontrollers

2005-08-08 Thread Kay Schluehr
Hi Bastard,

one of the main reasons PyPy gets funded by the EU was the promise to
port Python to embedded systems ( but not necessarily very memory
restricted ones ). The project seems to be in a state where the team
tries to get rid of the CPython runtime alltogether and reaching some
autonomy. The idea of providing a Forth backend would fit into the
concept and would be great IMO.

Maybe You should also have a look on the JavaCard platform
specification for inspiration what is possible for an OO language on
time and memory resticted platforms.

http://java.sun.com/products/javacard/specs.html

Since there are vendors that implemented the JVM on smartcards against
SUNs spec and JavaCards are on the market ( not just research
prototypes ) the approach has been proven successfull. For the matter
of memory layout I would naively try to adapt the type inferencer (
annotator in PyPy slang ) and restrict Python to an even more smaller
subset than RPython ( SmartJava does not even support strings. On the
other hand the explicit casting to short and byte types is by no means
braindead ). I currently don't have an idea for memory management and
I'm not even sure about implicit or explicit finalization.

Kay

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


Re: Python Project (sigh with Java)

2005-08-08 Thread Evil Bastard
Ramza Brown wrote:
> And I normally don't take the entire python library with me.  I just
> take 'jython.jar' so I can distribute it easier.

Agreed - if one is happy with the costs of java inter-operation, then
jython rocks the house. Otherwise, I could recommend PMW atop Tkinter,
since the python wrapping is better implemented and documented than
other guis and, for a given level of polish and functionality in a gui,
PMW/Tkinter gets the job done with less lines of code and less litres of
blood/sweat/tears.

-- 
Cheers
EB

--

One who is not a conservative by age 20 has no brain.
One who is not a liberal by age 40 has no heart.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Chopping off spaces at both ends

2005-08-08 Thread Tim Roberts
Madhusudan Singh <[EMAIL PROTECTED]> wrote:
>
>I am a newbie to python and am using it to interface some of my lab
>equipment.
>
>How does one get rid of spaces at both ends of a string ? A little 
> like the
>trim() intrinsic in fortran 95.
>
>One of my instruments is returning a string that has one or more 
> blanks in
>it, and that is complicating string matching tests in one of my functions.

 >>>  a = '  abc '
 >>>  print a.strip()
 'abc'
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to connect to UNIX machine from windows box

2005-08-08 Thread Robert Kern
Pooja Sharma wrote:
> I want to connect to unix machine using ssh to run some commands .
> 
> Is there any python module available that can be called in any other
> python script.
> 
> Reply asap. :)

No, you don't get to demand that we reply ASAP. It's rude.

   http://www.catb.org/~esr/faqs/smart-questions.html

But since I'm fundamentally a nice guy (if incredibly crotchety for my 
young age):

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

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


Re: How to connect to UNIX machine from windows box

2005-08-08 Thread Ross Wilson
> I want to connect to unix machine using ssh to run some commands .
> 

I have not tried this, but it might be useful.

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

HTH,
Ross


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


How to connect to UNIX machine from windows box

2005-08-08 Thread Pooja Sharma
I want to connect to unix machine using ssh to run some commands .

Is there any python module available that can be called in any other
python script.

Reply asap. :)

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


Re: Python Project (sigh with Java)

2005-08-08 Thread could ildg
But the function is also too limited. What I want to do is to run much
of my py scripts in jython as good as possible.

On 8/9/05, Ramza Brown <[EMAIL PROTECTED]> wrote:
> could ildg wrote:
> > Good job~
> > I also like both java and py so I always focus on jython,
> > but now it's being moved forward kinda slow.
> > I'm looking forward to jython 2.4.
> >
> > You're right, swing is great. wxpy is also wonderfu but it's so lack
> > of docs. I mainly work on windows so I use p4d(python for delphi), I
> > use delphi for UI and use py for some other works. p4d is magic, I
> > like it. And I recommend it to everyone who is familiar with both py
> > and delphi.
> >
> > On 8/9/05, Ramza Brown <[EMAIL PROTECTED]> wrote:
> >
> >>I know you may frown at my use at java, but this is a pretty simple way
> >>to create GUIs quickly, using Java's swing.  I have some code for an
> >>approach for integrating the swing GUI components and python.  I threw
> >>the project together in a couple of days, so it is not some massive
> >>application.  And, I have some little models(hehe).  Anyway, if you want
> >>to check out an approach for working with Jython, here it is.
> >>
> >>Some questions, I do get asked, how do you us python code in java.  I
> >>normally don't like using my python objects in the java code.
> >>Basically, there is never the *.java files.  You can do everything in
> >>python, it is a lot simpler, short of language constructs you can only
> >>do in java.
> >>
> >>This is a HTML code generator, you only need a java runtime.
> >>
> >>http://www.newspiritcompany.com/phoenixproj.html
> >>
> >>--
> >>Ramza from Atlanta
> >>http://www.newspiritcompany.com
> >>--
> >>http://mail.python.org/mailman/listinfo/python-list
> >>
> 
> And I normally don't take the entire python library with me.  I just
> take 'jython.jar' so I can distribute it easier.
> 
> 
> 
> --
> Ramza from Atlanta
> http://www.newspiritcompany.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes:
> Well, I tried sending this via email, but I can't derive a valid
> address from Paul's anti-spammed address.

Yeah, I should update that url since they turned off the forwarding.
It should be .  But a thread titled "decline and
fall of scripting languages" is reasonably on-topic for clpy, and
discussion of non-Python languages is reasonable for a thread with
such a title.  So replying to the newsgroup is appropriate.

> If you're thinking about checking out Ada, you might want to take a
> look at D. I haven't gotten very far into it myself (I was attracted
> by DbC), but it looks like a modern redesign of C: GC, OO, and
> typedefs that actually define new types, while still being something
> it's possible to generate reasonably fast code for.

Yeah, I've looked at D and it seems pretty nicely designed, much more
tasteful than C++.  So far though, it seems to have only one
implementation and not much of a user base.  I dunno that I'm really
that interested in checking out Ada.  It seems like a dead end.  Its
main virtue is that it can target small embedded processors, which I
don't know if D can do all that easily.

Right now I'm mainly interested in OCaml, Haskell, Erlang, and maybe
Occam.  Haskell seems to have the happiest users, which is always a
good thing.  Erlang has been used for real-world systems and has
built-in concurrency support.  OCaml seems to crush Haskell and Erlang
(and even Java) in performance.  Occam isn't used for much practical
any more, but takes a purist approach to concurrency that seems worth
studying.

The idea is to use one of those languages for a personal project after
my current work project wraps up pretty soon.  This would be both a
learning effort and an attempt to write something useful.  I'm
thinking of a web application like a discussion board or wiki,
intended to outperform the existing ones, i.e. able to handle a
Slashdot or Wikipedia sized load (millions of hits/day) on a single
fast PC instead of a rack full.  "Single fast PC" will probably soon
come to mean a two-cpu-chip motherboard in a 1U rack box, where each
cpu chip is a dual core P4 or Athlon, so the application should be
able to take advantage of at least 4-way multiprocessing, thus the
interest in concurrency.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pickling limitation with instances defining __cmp__/__hash__?

2005-08-08 Thread Erik Max Francis
Erik Max Francis wrote:

> I've come across a limitation in unpickling certain types of complex 
> data structures which involve instances that override __hash__, and was 
> wondering if it was known (basic searches didn't seem to come up with 
> anything similar) and if there is a workaround for it short of 
> restructuring the data structures in question.

Replying to my own (old) post here, I finally got back to this and found 
the best solution was to define surrogate set and dictionary classes 
that internally used the IDs as keys, eliminating the circular 
dependency.  Examples of SafeSet and SafeDict serving this purpose 
follow, though note that I only defined the methods that I used, rather 
than the full and complete interfaces for sets and dictionaries (though 
it should serve as an example for those who need to do more):

class SafeSet(_ReprMixin):

 @staticmethod
 def ider(thing):
 return thing.id

 def __init__(self, ider=None):
 if ider is not None:
 self.ider = ider
 self._map = {} # id -> thing

 def __len__(self):
 return len(self._map)

 def __contains__(self, thing):
 return self.ider(thing) in self._map

 def add(self, thing):
 key = self.ider(thing)
 if self._map.has_key(key):
 assert self._map[key] is thing
 self._map[key] = thing

 def remove(self, thing):
 del self._map[self.ider(thing)]

 def pop(self):
 iterator = self._map.iterkeys()
 next = iterator.next()
 return self._map.pop(next)

 def clear(self):
 self._map.clear()

 def copy(self):
 return copy.copy(self)

 def update(self, sequence):
 for thing in sequence:
 self.add(thing)

 def difference(self, other):
 thisSet = set(self._map.iterkeys())
 otherSet = set(other._map.iterkeys())
 newSet = thisSet.difference(otherSet)
 safeSet = SafeSet()
 for key in newSet:
 safeSet.add(self._map[key])
 return safeSet

 def __iter__(self):
 return self._map.itervalues()

 def __str__(self):
 return 'set(' + str(self._map.keys()) + ')'


class SafeDict(_ReprMixin):

 @staticmethod
 def ider(thing):
 return thing.id

 def __init__(self, ider=None):
 if ider is not None:
 self.ider = ider
 self._keys = {} # id -> key
 self._values = {} # id -> value

 def __len__(self):
 return len(self._keys)

 def __contains__(self, thing):
 return self.ider(thing) in self._keys

 def __getitem__(self, thing):
 return self._values[self.ider(thing)]

 def __setitem__(self, thing, value):
 key = self.ider(thing)
 self._keys[key] = thing
 self._values[key] = value

 def __delitem__(self, thing, value):
 key = self.ider(thing)
 del self._keys[key]
 del self._values[key]

 def keys(self):
 return self._keys.values()

 def iterkeys(self):
 return self._keys.itervalues()

 def values(self):
 return self._values.values()

 def itervalues(self):
 return self._values.itervalues()

 def items(self):
 return [(self._keys[x], self._values[x]) for x in self._keys]

 def iteritems(self):
 return ((self._keys[x], self._values[x]) for x in self._keys)

 def clear(self):
 self._keys.clear()
 self._values.clear()

 def copy(self):
 return copy.copy(self)

 def update(self, mapping):
 for key, value in mapping.iteritems():
 self[key] = value

 def has_key(self, thing):
 return self._keys.has_key(self.ider(thing))

 def get(self, thing, default=None):
 return self._values.get(self.ider(thing), default)

 def setdefault(self, thing, default):
 key = self.ider(thing)
 if key in self._keys:
 return self._values[key]
 else:
 self._keys[key] = thing
 self._values[key] = default

 def __iter__(self):
 return self._keys.itervalues()

 def __str__(self):
 return str(self._values)



-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   The only completely consistent people are the dead.
   -- Aldous Huxley
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Project (sigh with Java)

2005-08-08 Thread Ramza Brown
could ildg wrote:
> Good job~
> I also like both java and py so I always focus on jython,
> but now it's being moved forward kinda slow.
> I'm looking forward to jython 2.4.
> 
> You're right, swing is great. wxpy is also wonderfu but it's so lack
> of docs. I mainly work on windows so I use p4d(python for delphi), I
> use delphi for UI and use py for some other works. p4d is magic, I
> like it. And I recommend it to everyone who is familiar with both py
> and delphi.
> 
> On 8/9/05, Ramza Brown <[EMAIL PROTECTED]> wrote:
> 
>>I know you may frown at my use at java, but this is a pretty simple way
>>to create GUIs quickly, using Java's swing.  I have some code for an
>>approach for integrating the swing GUI components and python.  I threw
>>the project together in a couple of days, so it is not some massive
>>application.  And, I have some little models(hehe).  Anyway, if you want
>>to check out an approach for working with Jython, here it is.
>>
>>Some questions, I do get asked, how do you us python code in java.  I
>>normally don't like using my python objects in the java code.
>>Basically, there is never the *.java files.  You can do everything in
>>python, it is a lot simpler, short of language constructs you can only
>>do in java.
>>
>>This is a HTML code generator, you only need a java runtime.
>>
>>http://www.newspiritcompany.com/phoenixproj.html
>>
>>--
>>Ramza from Atlanta
>>http://www.newspiritcompany.com
>>--
>>http://mail.python.org/mailman/listinfo/python-list
>>

And I normally don't take the entire python library with me.  I just 
take 'jython.jar' so I can distribute it easier.



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


Re: Python Project (sigh with Java)

2005-08-08 Thread could ildg
Good job~
I also like both java and py so I always focus on jython,
but now it's being moved forward kinda slow.
I'm looking forward to jython 2.4.

You're right, swing is great. wxpy is also wonderfu but it's so lack
of docs. I mainly work on windows so I use p4d(python for delphi), I
use delphi for UI and use py for some other works. p4d is magic, I
like it. And I recommend it to everyone who is familiar with both py
and delphi.

On 8/9/05, Ramza Brown <[EMAIL PROTECTED]> wrote:
> I know you may frown at my use at java, but this is a pretty simple way
> to create GUIs quickly, using Java's swing.  I have some code for an
> approach for integrating the swing GUI components and python.  I threw
> the project together in a couple of days, so it is not some massive
> application.  And, I have some little models(hehe).  Anyway, if you want
> to check out an approach for working with Jython, here it is.
> 
> Some questions, I do get asked, how do you us python code in java.  I
> normally don't like using my python objects in the java code.
> Basically, there is never the *.java files.  You can do everything in
> python, it is a lot simpler, short of language constructs you can only
> do in java.
> 
> This is a HTML code generator, you only need a java runtime.
> 
> http://www.newspiritcompany.com/phoenixproj.html
> 
> --
> Ramza from Atlanta
> http://www.newspiritcompany.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to determine that if a folder is empty?

2005-08-08 Thread could ildg
On 8/8/05, Peter Hansen <[EMAIL PROTECTED]> wrote:
> could ildg wrote:
> > I want to check if a folder named "foldername" is empty.
> > I use os.listdir(foldername)==[] to do this,
> > but it will be very slow if the folder has a lot of sub-files.
> > Is there any efficient ways to do this?
> 
> I'm just curious to know under what circumstances where it's important
> to know whether a directory is empty it's also important that the
> operation occur with lightning speed...
I want to know this because I want to zip a directory and all of its
sub-files and sub-directories to a zip file. zipfile module of python
will not automatically include the empty directories, so I have to
check if a dir is empty and do this manually. I did this with java,
it's very fast, but when I do this with python. I use the code to
backup a directory every morning after I get up. It is not import if
it's fast or not. I just want to know whether their is better
solutions.

import os,zipfile
from os.path import join
from datetime import date

def zipfolder(foldername,filename):
"""
  zip folder foldername and all its subfiles and folders into a
  zipfile named filename.
"""
zip=zipfile.ZipFile(filename,"w",zipfile.ZIP_DEFLATED)
for root,dirs,files in os.walk(foldername):
for dir in dirs:
#now I don't check any more whether a dir is empty
zif=zipfile.ZipInfo(join(root,dir)+"/")
zip.writestr(zif,"")
for filename in files:
print "compressing ",join(root,filename)
zip.write(join(root,filename))
zip.close()
print "Finished compressing."


> 
> Reinhold's suggestion to delete the folder was interesting in this
> respect... isn't that (prior to deleting a folder) just about the only
> time one cares if it's empty, normally?  And in this case you don't need
> to do the check, as Reinhard shows, so performance isn't an issue.
> 
> -Peter
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Project (sigh with Java)

2005-08-08 Thread Ramza Brown
I know you may frown at my use at java, but this is a pretty simple way 
to create GUIs quickly, using Java's swing.  I have some code for an 
approach for integrating the swing GUI components and python.  I threw 
the project together in a couple of days, so it is not some massive 
application.  And, I have some little models(hehe).  Anyway, if you want 
to check out an approach for working with Jython, here it is.

Some questions, I do get asked, how do you us python code in java.  I 
normally don't like using my python objects in the java code. 
Basically, there is never the *.java files.  You can do everything in 
python, it is a lot simpler, short of language constructs you can only 
do in java.

This is a HTML code generator, you only need a java runtime.

http://www.newspiritcompany.com/phoenixproj.html

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


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Mike Meyer
Well, I tried sending this via email, but I can't derive a valid
address from Paul's anti-spammed address.

My apologies to the rest of you for this.

Paul Rubin  writes:
> Should that bother me?  I should say, my interest in Ocaml or Haskell
> is not just to try out something new, but also as a step up from both
> Python and C/C++ for writing practical code.  That is, I'm looking for
> something with good abstraction (unlike Java) and type safety (unlike
> C/C++), but for the goal of writing high performance code (like
> C/C++).  I'm even (gasp) thinking of checking out Ada.

If you're thinking about checking out Ada, you might want to take a
look at D. I haven't gotten very far into it myself (I was attracted
by DbC), but it looks like a modern redesign of C: GC, OO, and
typedefs that actually define new types, while still being something
it's possible to generate reasonably fast code for.

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Robert Kern
Peter Decker wrote:
> On 8/8/05, Robert Kern <[EMAIL PROTECTED]> wrote:
> 
>>What I'm trying to say is that posting to c.l.py is absolutely
>>ineffective in achieving that goal. Code attracts people that like to
>>code. Tedious, repetitive c.l.py threads attract people that like to
>>write tedious, repetitive c.l.py threads. 
> 
> +1 QOTW

Meh, it's a minor riff on someone else's quote[1]. I'm actually a bit 
embarassed for having used it without acknowledging the inspiration.

[1] http://fishbowl.pastiche.org/2005/05/08/finding_discord_in_harmony 
found via http://lesscode.org/2005/07/09/whats-going-on/

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


error compiling linkchecker

2005-08-08 Thread mmarkzon
I have been struggling compiling linkchecker from
http://linkchecker.sourceforge.net/.  The last thing I get is "error:
command 'gcc' failed with exit status 1" which is not very helpful.
This is with Python 2.4.1 on Solaris 2.8.  Can anyone help?  Thank you.


-> python setup.py build
creating /home/kzvbq3/linkchecker-3.2/_linkchecker_configdata.py
running build
running build_py
running build_ext
building 'linkcheck.HtmlParser.htmlsax' extension
gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
-fPIC -I/home
/kzvbq3/include -I/home/kzvbq3/usr/local/include/python2.4
-Ilinkcheck/HtmlParse
r -I/home/kzvbq3/usr/local/lib/python2.4/lib-dynload/include/python2.4
-c linkch
eck/HtmlParser/htmllex.c -o
build/temp.solaris-2.8-sun4u-2.4/linkcheck/HtmlParse
r/htmllex.o -pedantic -std=gnu99
cc1: unknown C standard `gnu99'
In file included from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/stdio.h:20: warning: ignoring pragma: "@(#)stdio.h
1.7899/1
2/08 SMI
In file included from /home/kzvbq3/include/stdio.h:22,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/iso/stdio_iso.h:32: warning: ignoring pragma:
"@(#)stdio_is
o.h 1.2 99/10/25 SMI
In file included from /home/kzvbq3/include/iso/stdio_iso.h:35,
 from /home/kzvbq3/include/stdio.h:22,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/sys/feature_tests.h:13: warning: ignoring pragma:
"@(#)feat
ure_tests.h 1.1899/07/26 SMI
In file included from /home/kzvbq3/include/sys/feature_tests.h:15,
 from /home/kzvbq3/include/iso/stdio_iso.h:35,
 from /home/kzvbq3/include/stdio.h:22,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/sys/isa_defs.h:9: warning: ignoring pragma:
"@(#)isa_defs.h
1.2099/05/04 SMI
In file included from /home/kzvbq3/include/iso/stdio_iso.h:36,
 from /home/kzvbq3/include/stdio.h:22,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/sys/va_list.h:9: warning: ignoring pragma:
"@(#)va_list.h1.
12  99/05/04 SMI
In file included from /home/kzvbq3/include/iso/stdio_iso.h:37,
 from /home/kzvbq3/include/stdio.h:22,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/stdio_tag.h:9: warning: ignoring pragma:
"@(#)stdio_tag.h1.
3   98/04/20 SMI
In file included from /home/kzvbq3/include/iso/stdio_iso.h:38,
 from /home/kzvbq3/include/stdio.h:22,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:32,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/stdio_impl.h:9: warning: ignoring pragma:
"@(#)stdio_impl.h
1.8 99/06/10 SMI
In file included from
/home/kzvbq3/usr/local/include/python2.4/Python.h:37,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/string.h:16: warning: ignoring pragma:
"@(#)string.h1.2499/
08/10 SMI
In file included from /home/kzvbq3/include/string.h:18,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:37,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/iso/string_iso.h:28: warning: ignoring pragma:
"@(#)string_
iso.h   1.2 99/11/09 SMI
In file included from
/home/kzvbq3/usr/local/include/python2.4/Python.h:38,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/errno.h:17: warning: ignoring pragma: "@(#)errno.h
1.1699/0
7/26 SMI
In file included from /home/kzvbq3/include/errno.h:23,
 from
/home/kzvbq3/usr/local/include/python2.4/Python.h:38,
 from linkcheck/HtmlParser/htmlsax.h:20,
 from linkcheck/HtmlParser/htmllex.c:1:
/home/kzvbq3/include/sys/errno.h:11: warning: ignoring pragma:
"@(#)errno.h1.200
0/02/14 SMI
In file included from
/home/kzvbq3/usr/local/include/python2.4/Python.h:38,
 from linkcheck/HtmlParser/htmlsax.h:20

Adding custom widgets to Qt Designer

2005-08-08 Thread Madhusudan Singh
Hi

I am trying to add a QwtPlot widget to Qt Designer. I have both PyQwt 
and
libqwt installed.

I first tried to add a Custom Widget from /usr/include/qwt/qwt_plot.h as
QwtPlot. But I do not know what slot to add. If I add the widget so
created, and double click on it, I am asked if I want to create a new ui.h.
It does not seem that the widget was added correctly.

I then found a link :

http://www.pycs.net/lateral/stories/27.html

Now, I do have a file qplt.py, but the above link presumes that the ui.h
file is created before py file is generated using the pyuic translator. So,
how does one add this new widget ?

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


Re: PEP: Specialization Syntax

2005-08-08 Thread Nicolas Fleury
Bengt Richter wrote:
> On Mon, 08 Aug 2005 16:18:50 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:
>>I wrote the PEP to see if was the only one that would benefit from 
>>generic types *before* having optional static typing in the language.
>>
>>It seems I'm the only one;)
>>
>>According to blog entry 86641, Guido himself is prototyping with 
>>__getitem__.  However, I cannot do the same, because the framework I use 
>>is much more complete and keyword arguments are a must.
>>
> Here is a decorator object to set up function call dispatch according to type.
> It only uses positional arguments, but could be fleshed out, I think.
> Not tested beyond what you see ;-)

That's nice.  Guido also posted this multimethods solution:
http://www.artima.com/weblogs/viewpost.jsp?thread=101605

The only thing I was saying it that I can use generic types in Python 
right now (and I do), by using (), but I can't with what will probably 
be the syntax in future, i.e. using [].

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


Re: PEP: Specialization Syntax

2005-08-08 Thread Bengt Richter
On Tue, 09 Aug 2005 00:14:25 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
[...]
>Here is a decorator object to set up function call dispatch according to type.
>It only uses positional arguments, but could be fleshed out, I think.
>Not tested beyond what you see ;-)
>
>< typedispatcher.py >-
># typedispatcher.py
[...]
>assert len(set([f.func_name]+list(f.func_name for f in 
> self.dispdict.values(
[...]
Oops, that was a leftover hack that was supposed to check that all names were 
the same,
and was missing ==1 at the right. Replaced by using self.name. Sorry. There's 
probably
more, but the overall idea should be clear. Using **kw is also a leftover of 
starting
down the trail of handling more signature variants, but I was too lazy.

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


Re: PEP: Specialization Syntax

2005-08-08 Thread Bengt Richter
On Mon, 08 Aug 2005 16:18:50 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:

>Bengt Richter wrote:
>> On Sun, 07 Aug 2005 21:41:33 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:
>>>I mean should angle brackets <> like in C++, or another operator, be 
>>>used instead?
>> 
>> I am getting the feeling that your PEP is about a means to do something 
>> C++-like
>> in python, not necessarily to enhance python ;-) IOW, it seems like you
>> want the [] to do something like C++  in templates?
>
>Yes, exactly.  Actually Guido also mentionned pointy brackets:
>http://www.artima.com/weblogs/viewpost.jsp?thread=86641
>
>> (BTW, I have nothing against giving python new capabilities (quite the 
>> reverse),
>> but not by grafting limbs from other animals ;-)
>
>If I look at a very recent blog entry of Guido, it seems the idea is 
>still in the air:
>http://www.artima.com/weblogs/viewpost.jsp?thread=92662
>
>> Maybe you want hidden name-mangling of function defs according to arg types
>> and corresponding dispatching of calls? I am afraid I am still not clear
>> on the fundamental motivation for all this ;-)
>
>I wrote the PEP to see if was the only one that would benefit from 
>generic types *before* having optional static typing in the language.
>
>It seems I'm the only one;)
>
>According to blog entry 86641, Guido himself is prototyping with 
>__getitem__.  However, I cannot do the same, because the framework I use 
>is much more complete and keyword arguments are a must.
>

Here is a decorator object to set up function call dispatch according to type.
It only uses positional arguments, but could be fleshed out, I think.
Not tested beyond what you see ;-)

< typedispatcher.py >-
# typedispatcher.py
"""
Provides a decorator to dispatch function
calls according to arg types and signature.
Example usage:
foodisp = TypeDispatcher() # instance dedicated to foo variants
@foodisp(a=int, b=str)
def foo(a, b):
assert type(a) is int and type(b) is str
return (a,b)
@foodisp(a=str, b=str)
def foo(a, b):
assert type(a) is str and type(b) is str
return (a,b)
 
"""
class TypeDispatcher(object):
def __init__(self):
self.dispdict = {}
def __call__(self, **kwtypes):
self.kwtemp = kwtypes
return self.dodeco
def dodeco(self, f):
if not hasattr(self, 'name'):
self.name = f.func_name
if f.func_name != self.name:
raise ValueError('This TypeDispatcher instance decorates only 
functions named %r' % self.name)
sig = tuple((self.kwtemp[argname] for argname in 
f.func_code.co_varnames[:f.func_code.co_argcount]))
assert len(set([f.func_name]+list(f.func_name for f in 
self.dispdict.values(
self.dispdict[sig] = f
return self.docall
def docall(self, *args):
sig = tuple(map(type, args))
try: f = self.dispdict[sig]
except KeyError:
raise TypeError('no function %r with signature %r' % (self.name, 
sig))
return f(*args)

def test():
try:
foodisp = TypeDispatcher()
@foodisp(a=int, b=str)
def foo(a, b):
assert type(a) is int and type(b) is str
return 'foo(int, str):', (a,b)
@foodisp(a=str, b=str)
def foo(a, b):
assert type(a) is str and type(b) is str
return 'foo(str, str):', (a,b)
@foodisp()
def foo():
return 'foo()', ()
print foo(123, 'hello')
print foo('hi','there')
print foo()
print foo(456, 789)
except Exception, e:
print 'Exception %s: %s' % (e.__class__.__name__, e)
try:
@foodisp()
def bar(): pass
except Exception, e:
print 'Exception %s: %s' % (e.__class__.__name__, e)


if __name__ == '__main__':
test()
--

Result:

[17:12] C:\pywk\ut>py24 typedispatcher.py
('foo(int, str):', (123, 'hello'))
('foo(str, str):', ('hi', 'there'))
('foo()', ())
Exception TypeError: no function 'foo' with signature (, )
Exception ValueError: This TypeDispatcher instance decorates only functions 
named 'foo'


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


Re: [Python-Dev] PEP-343 - Context Managment variant

2005-08-08 Thread Josiah Carlson

falcon <[EMAIL PROTECTED]> wrote:
> It's idea was token from Ruby. But I think, good idea is good whatever it 
> came from.
> It can be not Pythonic.

Just because something may be a good idea, doesn't mean that the idea is
Pythonic.  The only person who can truely say is Guido, but you can gain
some insight by reading the zens (from the console, 'import this').

The fact is, context management has a syntax that has been accepted. 
Your first example:

> def Synhronised(lock,func):
> lock.acquire()
> try:
> func()
> finally:
> lock.release()
> 
> lock=Lock()
> def Some():
> local_var1=x
> local_var2=y
> local_var3=Z
> def Work():
> global local_var3
> local_var3=Here_I_work(local_var1,local_var2,local_var3)
> Synhronised(lock,Work)
> return asd(local_var3)

... becomes ...

def Synchronized(lock):
lock.acquire()
try:
yield None
finally:
lock.release()

def Some():
...
with Synchronized(lock):
local_var3 = Here_I_work(local_var1,local_var2,local_var3)
...

Which is quite close to what you offer:

> Synhronised(lock,block)
> local_var3=Here_I_work(local_var1,local_var2,local_var3)


It is of my opinion that your proposal is destined to fail for at least
two reasons; 1) context management already has an accepted syntax 2)
ruby blocks were found (due to lack of evidence to the contrary) to gain
Python users very little (if anything) over the accepted context
management syntax.


To note; unless your post is of the utmost importance, cross-posting to
python-list and python-dev seems quite rude to me.  Further, a variant
of Ruby block syntax was offered way back in February and March (read
the python-dev archives available at
http://mail.python.org/pipermail/python-dev/ ).  Reading what was
already discussed may offer you insight into what (if any) open issues
were remaining, and precisely why the context management syntax was
supported over anonymous blocks/thunks/Ruby blocks.


 - Josiah

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


Re: issues with doctest and threads

2005-08-08 Thread Tim Peters
[Michele Simionato]
> I am getting a strange error with this script:
>
> $ cat doctest-threads.py
> """
> >>> import time, threading
> >>> def example():
> ... thread.out = []
> ... while thread.running:
> ... time.sleep(.01)
> ... thread.out.append(".")
> >>> thread = threading.Thread(None, example)
> >>> thread.running = True; thread.start()
> >>> time.sleep(.1)
> >>> thread.running = False
> >>> print thread.out
> ['.', '.', '.', '.', '.', '.', '.', '.', '.']
> """
> 
> if __name__ == "__main__":
>import doctest; doctest.testmod()
> 
> $ python doctest-threads.py
> Exception in thread Thread-1:
> Traceback (most recent call last):
>  File "/usr/lib/python2.4/threading.py", line 442, in __bootstrap
>self.run()
>  File "/usr/lib/python2.4/threading.py", line 422, in run
>self.__target(*self.__args, **self.__kwargs)
>  File "", line 5, in example
> NameError: global name 'thread' is not defined

It looks like pure thread-race accident to me.  The main program does
nothing to guarantee that the thread is finished before it prints
`thread.out`, neither anything to guarantee that Python doesn't exit
while the thread is still running.  Stuff, e.g., a time.sleep(5) after
"thread.running = False", and it's much more likely to work the way
you intended (but still not guaranteed).

A guarantee requires explicit synchronization; adding

>>> thread.join()

after "thread.running = False" should be sufficient.  That ensures two things:

1. The `example` thread is done before thread.out gets printed.
2. The *main* thread doesn't exit (and Python doesn't start tearing itself
   down) while the `example` thread is still running.

The exact output depends on OS scheduling accidents, but I expect
you'll see 10 dots most often.

BTW, trying to coordinate threads with sleep() calls is usually a Bad
Idea; you can't generally expect more from an OS than that it will
treat sleep's argument as a lower bound on the elapsed time the
sleeper actually yields the CPU.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python for microcontrollers

2005-08-08 Thread David Cuthbert
Paul Rubin wrote:
> I don't think you want to do this.  Runtime type tags and the overhead
> of checking them on every operation will kill you all by themselves.
> Processors like that haven't been used much as Lisp targets either,
> for the same reasons.  Pick a different language.

I was thinking that you could avoid this by adding some type inference 
to Python and/or reducing everything to two basic types (strings and 
ints), but the end result would require a lot of work and not look much 
like Python.

For a PIC, I'm not even sure I'd want to use C++.  Then again, I'm not 
much of a fan of BASIC stamp modules, either, so...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string into groups of three characters

2005-08-08 Thread John Machin
William Park wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
>>Hi,
>>
>>Is there a function that split a string into groups, containing an "x"
>>amount of characters?
>>
>>Ex.
>>TheFunction("Hello World",3)
>>
>>Returns:
>>
>>['Hell','o W','orl','d']
>>
>>
>>Any reply would be truly appreciated.
> 
> 
> Look into 're' module.  Essentially, split using '...', but return the
> separator as well.  Then, remove empty items.  In Bash shell, you would

This would have to be a candidate for arcane side-effect of the month.
Not in front of the children, please.

> do
> a="Hello World"
> set -- "${a|?...}"# extract '...' separators
> pp_collapse   # remove null items
> printf '{%s}\n' "[EMAIL PROTECTED]"
> 
> Translating to Python is left as homework.

Given that the OP was struggling to write a simple loop in Python, 
giving him an answer in hieroglypghics and suggesting he translate it 
into Python could be described as unhelpful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python for microcontrollers

2005-08-08 Thread Guy Robinson
How about just helping this project:

http://pyastra.sourceforge.net/

I know he's trying to rewrite it to work across multiple uC's (AVR,msp430 etc)

HTH,

Guy

Evil Bastard wrote:
> Hi all,
> 
> I'm currently tackling the problem of implementing a python to assembler
> compiler for PIC 18Fxxx microcontrollers, and thought I'd open it up
> publicly for suggestions before I embed too many mistakes in the
> implementation.
> 
> The easy part is getting the ast, via compiler.ast. Also easy is
> generating the code, once the data models are worked out.
> 
> The hard part is mapping from the abundant high-level python reality to
> the sparse 8-bit microcontroller reality.
> 
> I looked at pyastra, but it has fatal problems for my situation:
>  - no backend for 18fxxx devices
>  - only 8-bit ints supported
> 
> I'm presently ripping some parts from the runtime engine of a forth
> compiler I wrote earlier, to add support for 8-32 bit ints, floats, and
> a dual-stack environment that offers comfortable support for local
> variables/function parameters, as well as support for simpler and more
> compact code generation.
> 
> Python is all about implicitly and dynamically creating/destroying
> arbitrarily typed objects from a heap. I've got a very compact
> malloc/free, and could cook up a refcounting scheme, but using this for
> core types like ints would destroy performance, on a chip that's already
> struggling to do 10 mips.
> 
> The best idea I've come up with so far is to use a convention of
> identifier endings to specify type, eg:
>  - foo_i16 - signed 16-bit
>  - foo_u32 - unsigned 32-bit
>  - bar_f - 24-bit float
>  - blah - if an identifier doesn't have a 'magic ending', it will
>   be deemed to be signed 16-bit
> 
> also, some virtual functions uint16(), int16(), uint32(), int32(),
> float() etc, which work similar to C casting and type conversion, so I
> don't have to struggle with type inference at compile time.
> 
> Yes, this approach sucks. But can anyone offer any suggestions which
> suck less?
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python for microcontrollers

2005-08-08 Thread Paul Rubin
Evil Bastard <[EMAIL PROTECTED]> writes:
> Yes, this approach sucks. But can anyone offer any suggestions which
> suck less?

I don't think you want to do this.  Runtime type tags and the overhead
of checking them on every operation will kill you all by themselves.
Processors like that haven't been used much as Lisp targets either,
for the same reasons.  Pick a different language.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string into groups of three characters

2005-08-08 Thread Gregory Piñero
I guess this question has already been thouroughly answered but here
is my version:

def split(string,n):
outlist=[]
for bottom in range(0,len(string),n):
top=min(bottom+n,len(string))
outlist.append(string[bottom:top])
return outlist




On 8/8/05, William Park <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:
> > Hi,
> >
> > Is there a function that split a string into groups, containing an "x"
> > amount of characters?
> >
> > Ex.
> > TheFunction("Hello World",3)
> >
> > Returns:
> >
> > ['Hell','o W','orl','d']
> >
> >
> > Any reply would be truly appreciated.
> 
> Look into 're' module.  Essentially, split using '...', but return the
> separator as well.  Then, remove empty items.  In Bash shell, you would
> do
> a="Hello World"
> set -- "${a|?...}"  # extract '...' separators
> pp_collapse # remove null items
> printf '{%s}\n' "[EMAIL PROTECTED]"
> 
> Translating to Python is left as homework.
> 
> --
> William Park <[EMAIL PROTECTED] >, Toronto, Canada
> ThinFlash: Linux thin-client on USB key (flash) drive
>http://home.eol.ca/~parkw/thinflash.html 
> BashDiff: Super Bash shell
>   http://freshmeat.net/projects/bashdiff/ 
> --
> http://mail.python.org/mailman/listinfo/python-list 
> 


-- 
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Paul Rubin  wrote:
...
> I notice that Haskell strings are character lists, i.e. at least
> conceptually, "hello" takes the equivalent of five cons cells.  Do
> real implementations (i.e. GHC) actually work like that?  If so, that's
> enough to kill the whole thing right there.

Yep.  There is a separate packed string type.

> > Objective CAML is indeed not a pure functional language.
> 
> Should that bother me?  I should say, my interest in Ocaml or Haskell
> is not just to try out something new, but also as a step up from both
> Python and C/C++ for writing practical code.  That is, I'm looking for
> something with good abstraction (unlike Java) and type safety (unlike
> C/C++), but for the goal of writing high performance code (like
> C/C++).  I'm even (gasp) thinking of checking out Ada.

It's up to you, I'm just saying.  Speaking of C++, would
you start someone with Python or Java for their first OOPL?
Kind of the same idea.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Michael Hudson
Donn Cave <[EMAIL PROTECTED]> writes:

> On the contrary, there are a couple.  Ghc is probably the
> leading implementation these days, and by any reasonable
> measure, it is serious.
>
> Objective CAML is indeed not a pure functional language.

*cough* unsafePerformIO *cough*

Cheers,
mwh

-- 
  MAN:  How can I tell that the past isn't a fiction designed to
account for the discrepancy between my immediate physical
sensations and my state of mind?
   -- The Hitch-Hikers Guide to the Galaxy, Episode 12
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python for microcontrollers

2005-08-08 Thread Peter Hansen
Evil Bastard wrote:
> Benji York wrote:
>>Perhaps porting Pyrex would be easier.  

> Pyrex totally rocks. But for the PIC targetting, no can do:
...
> Any other suggestions?

Yes, port Lua instead.  Lua is pretty much designed for this sort of 
application, and is probably "Pythonic" enough to provide whatever 
advantages you were trying to get from using Python, short of it 
actually being Python.

FWIW, the interpreter/virtual machine appears to be designed to be very 
conservative with memory, though there's a chance it is somewhat tied to 
having 32-bit integers available (yet could perhaps be ported easily to 
some freaky 12-bit microcontroller anyway :-) ).

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


Re: Syntax error after upgrading to Python 2.4

2005-08-08 Thread Michael Hudson
[EMAIL PROTECTED] writes:

> On Sat, Aug 06, 2005 at 05:15:22PM -0400, Terry Reedy wrote:
>> In any case letting developers add new features is part of the price of 
>> getting unpaid bug fixes for free software.  But note that PSF does not 
>> make you to upgrade.  Here is the current list of possible downloads.
>> 
> [a mere 8 versions]
>
> Oh, don't give such a short list!  Here's what I found on the python.org ftp 
> site:

[...]

> And then there's CVS...

Which doesn't build for the really early versions.  I think
python1.0.1.tar.gz is as old as it's easy to get.

Cheers,
mwh

-- 
  Ignoring the rules in the FAQ: 1" slice in spleen and prevention
of immediate medical care.
  -- Mark C. Langston, asr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does __init__ not get called?

2005-08-08 Thread Lonnie Princehouse
Uh... are you actually trying to instantiate this class?

  mydate = DateTime(2005, 8, 8)

The reason I ask is that __init__ /is/ called when I run your code on
Python 2.4, provided that the above line is added to the end.

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


Re: python for microcontrollers

2005-08-08 Thread Evil Bastard
Benji York wrote:
> Perhaps porting Pyrex would be easier.  Pyrex takes a python-like syntax
> (plus type information, etc.) and emits C, which is then compiled.

Pyrex totally rocks. But for the PIC targetting, no can do:
 - pyrex generates a **LOT** of code, which makes extensive use of the
   python-C api, which is inextricably tied to dynamic objects
 - PIC program memory is 32kbytes max

Thanks all the same.

Any other suggestions?

-- 
Cheers
EB

--

One who is not a conservative by age 20 has no brain.
One who is not a liberal by age 40 has no heart.
-- 
http://mail.python.org/mailman/listinfo/python-list


Why does __init__ not get called?

2005-08-08 Thread Rob Conner
I'm still working on my DateTime class from last week...
Why does __init__ not get called?

The docs at
http://www.python.org/dev/doc/devel/ref/customization.html
read "If __new__() returns an instance of cls, then the new instance's
__init__() method will be invoked" and as far as I can tell cls is very
much an instance of DateTime


import datetime
_datetime = datetime.datetime

class DateTime(_datetime):
"""
Identical to builtin datetime.datetime, except it accepts
invalid dates and times as input.
"""
_valid = True
__dict__ = _datetime.__dict__

def __init__(self, year, month, day, *args, **kw):
print "init called"
_valid = False
self.year   = year
self.month  = month
self.day= day
self.args   = args
self.kw = kw

def throwError():
raise ValueError, 'Invalid Date'
for method in _datetime.__dict__.keys():
if method!='__doc__':
setattr(self, method, throwError)


def __new__(cls, year, month, day, *args, **kw):
print "new called"
try:
return _datetime.__new__(cls, year, month, day, *args,
**kw)
except ValueError:
return cls
*

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


Re: python for microcontrollers

2005-08-08 Thread Benji York
Evil Bastard wrote:
> I'm currently tackling the problem of implementing a python to assembler
> compiler for PIC 18Fxxx microcontrollers

Perhaps porting Pyrex would be easier.  Pyrex takes a python-like syntax 
(plus type information, etc.) and emits C, which is then compiled.
--
Benji York


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


python for microcontrollers

2005-08-08 Thread Evil Bastard
Hi all,

I'm currently tackling the problem of implementing a python to assembler
compiler for PIC 18Fxxx microcontrollers, and thought I'd open it up
publicly for suggestions before I embed too many mistakes in the
implementation.

The easy part is getting the ast, via compiler.ast. Also easy is
generating the code, once the data models are worked out.

The hard part is mapping from the abundant high-level python reality to
the sparse 8-bit microcontroller reality.

I looked at pyastra, but it has fatal problems for my situation:
 - no backend for 18fxxx devices
 - only 8-bit ints supported

I'm presently ripping some parts from the runtime engine of a forth
compiler I wrote earlier, to add support for 8-32 bit ints, floats, and
a dual-stack environment that offers comfortable support for local
variables/function parameters, as well as support for simpler and more
compact code generation.

Python is all about implicitly and dynamically creating/destroying
arbitrarily typed objects from a heap. I've got a very compact
malloc/free, and could cook up a refcounting scheme, but using this for
core types like ints would destroy performance, on a chip that's already
struggling to do 10 mips.

The best idea I've come up with so far is to use a convention of
identifier endings to specify type, eg:
 - foo_i16 - signed 16-bit
 - foo_u32 - unsigned 32-bit
 - bar_f - 24-bit float
 - blah - if an identifier doesn't have a 'magic ending', it will
  be deemed to be signed 16-bit

also, some virtual functions uint16(), int16(), uint32(), int32(),
float() etc, which work similar to C casting and type conversion, so I
don't have to struggle with type inference at compile time.

Yes, this approach sucks. But can anyone offer any suggestions which
suck less?

-- 
Cheers
EB

--

One who is not a conservative by age 20 has no brain.
One who is not a liberal by age 40 has no heart.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Kay Schluehr
Bengt Richter wrote:

> It occurs to me that we have the PEP process for core python, but no PEP 
> process
> for the python app/lib environment. What about starting a PEEP process
> (Python Environment Enhancement Proposals) modeled on PEPs, where those 
> motivated
> to formalize their pet projects or feature requests could collaborate to 
> create
> a spec to document and guide development?

I already see the headline: PEEP is the answer - PSF votes for software
patents. All ideas are written down by volunteers in great detail they
just have to be coded. Due to intellectual property rights PSF becomes
one of the richest organizations in the world. Guido van Rossum,
chairman of PSF and mighty governor of California recommends an
invasion into Iran: "we cannot accept that they didn't payed us for a
PEEP describing a steering mechism for a nuclear power station to be
written in Python. They are dangerous. They didn't have our
commitment." Mr. van Rossum also commented the unfriendly takeover of
the former software giant Microsoft that was immediately renamed into
"Snakeoil Corp." succinctly: "They had a platform we were interested
in".

Yes, the Python experiment was (not just) successfull.

Kay

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


Re: Splitting a string into groups of three characters

2005-08-08 Thread William Park
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> Is there a function that split a string into groups, containing an "x"
> amount of characters?
> 
> Ex.
> TheFunction("Hello World",3)
> 
> Returns:
> 
> ['Hell','o W','orl','d']
> 
> 
> Any reply would be truly appreciated.

Look into 're' module.  Essentially, split using '...', but return the
separator as well.  Then, remove empty items.  In Bash shell, you would
do
a="Hello World"
set -- "${a|?...}"  # extract '...' separators
pp_collapse # remove null items
printf '{%s}\n' "[EMAIL PROTECTED]"

Translating to Python is left as homework.

-- 
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
   http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
  http://freshmeat.net/projects/bashdiff/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: World's largest Python caught!:)

2005-08-08 Thread Ivan Van Laningham
Hi All--

James Stroud wrote:
> 
> http://www.afghania.com/News-article-sid-4792-mode-thread.html
> 
> 3rd hit in google with "world's largest python". The first two hits were your
> email below to the newsgroups.
> 

This hit says it's not the world's largest:

http://www.reptilia.org/NEWS.htm

And this one offers a better picture:

http://www.clubavalanche.com/forums/index.php?showtopic=2837&;

Metta,
Ivan


> James
> 
> On Sunday 07 August 2005 09:15 pm, Ashok Rajasingh wrote:
> > Hi
> >
> >
> >
> > Can I please get some information on this python?  I saw a brief news
> > clip last year & am very keen to know more.
> >
> >
> >
> > Thanks
> >
> > Ashok Rajasingh
> >
> > 21 Cumberland street
> >
> > New Plymouth
> >
> > New Zealand
> >
> > +646 7575698 (home)
> >
> >   7599592 (work)
> >
> >
> >
> >
> > ##
> > Attention:
> > The information contained in this message and or attachments is intended
> > only for the person or entity to which it is addressed and may contain
> > confidential and/or privileged material. Any review, retransmission,
> > dissemination or other use of, or taking of any action in reliance upon,
> > this information by persons or entities other than the intended recipient
> > is prohibited. If you received this in error, please contact the sender and
> > delete the material from any system and destroy any copies. Please note
> > that the views or opinions expressed in this message may be those of the
> > individual and not necessarily those of Tegel Foods Ltd.
> >
> > This email was scanned and cleared by NetIQ MailMarshal.
> > ##
> 
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
> 
> http://www.jamesstroud.com/
> --
> http://mail.python.org/mailman/listinfo/python-list

-- 
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP: Specialization Syntax

2005-08-08 Thread Nicolas Fleury
Bengt Richter wrote:
> On Sun, 07 Aug 2005 21:41:33 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:
>>I mean should angle brackets <> like in C++, or another operator, be 
>>used instead?
> 
> I am getting the feeling that your PEP is about a means to do something 
> C++-like
> in python, not necessarily to enhance python ;-) IOW, it seems like you
> want the [] to do something like C++  in templates?

Yes, exactly.  Actually Guido also mentionned pointy brackets:
http://www.artima.com/weblogs/viewpost.jsp?thread=86641

> (BTW, I have nothing against giving python new capabilities (quite the 
> reverse),
> but not by grafting limbs from other animals ;-)

If I look at a very recent blog entry of Guido, it seems the idea is 
still in the air:
http://www.artima.com/weblogs/viewpost.jsp?thread=92662

> Maybe you want hidden name-mangling of function defs according to arg types
> and corresponding dispatching of calls? I am afraid I am still not clear
> on the fundamental motivation for all this ;-)

I wrote the PEP to see if was the only one that would benefit from 
generic types *before* having optional static typing in the language.

It seems I'm the only one;)

According to blog entry 86641, Guido himself is prototyping with 
__getitem__.  However, I cannot do the same, because the framework I use 
is much more complete and keyword arguments are a must.

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


Re: Splitting a string into groups of three characters

2005-08-08 Thread Cyril Bazin
Another solution derived from an old discussion about the same problem?

def takeBy(s, n):
    import itertools
    list(''.join(x) for x in itertools.izip(*[iter(s)]*n))

(Hoping len(s) % n = 0)

CyrilOn 8 Aug 2005 11:04:31 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> wrote:Yes i know i made a mistake,>['Hell','o W','orl','d']but you know what I mean lol,
I'll probly useJohn Machin's def nsplit(s, n):return [s[k:k+n] for k in xrange(0, len(s), n)]It seems fast, and does not require any imports.But anyways, thank you for all your help, you rock! :)
--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Making a timebomb

2005-08-08 Thread Cantankerous Old Git
Peter Hansen wrote:
> Cantankerous Old Git wrote:
> 
>> Peter Hansen wrote:
>>
>>> Cantankerous Old Git wrote:
>>>
 The dirty way, which can leave corrupt half-written files and other 
 nasties, is something like sys.exit().
>>>
>>>
>>> sys.exit() won't help you if your server is running in the main 
>>> thread, nor if your server thread is not marked as a daemon, but that 
>>> does raise another possibility.  
>>
>>
>> I assume you know that I actually meant System.exit(). Why do you 
>> think that won't help?
> 
> 
> No, I didn't know that, but if you were confused the first time, I think 
>  you're getting even more confused now.  What is System.exit()?  I don't 
> have one, and have never seen it mentioned.  Perhaps you meant 
> SystemExit, the exception that's raised when you call sys.exit()?  If 
> so, I still don't see your point, because there's no difference between 
> the two in this context.
> 
> Maybe you meant os._exit()?  Now *that* one is messy, and will work as 
> you described.
> 
> -Peter



Yup - I guess you're not interested in java.lang.System.exit() at 
all, are you. You're right about me getting confused!

Perhaps I should take a break between reading the two newsgroups. 
Doh!

sys.exit() docs (for Python) say it raises a SystemExit 
exception. A quick test shows that:
* You can catch this to prevent being killed
* It only gets raised on the calling thread - not the others

So you're right - sys.exit is not very helpful in this case.

os._exit is the one I was thinking of - equivalent to java's 
System.exit().

And to the OP, Bill - sorry for messing you around. As you see - 
I got confused.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -- (just) a successful experiment?

2005-08-08 Thread A.M. Kuchling
On Mon, 08 Aug 2005 16:58:40 GMT, 
Bengt Richter <[EMAIL PROTECTED]> wrote:
> It occurs to me that we have the PEP process for core python, but no PEP 
> process
> for the python app/lib environment. What about starting a PEEP process
> (Python Environment Enhancement Proposals) modeled on PEPs, where those 
> motivated
> to formalize their pet projects or feature requests could collaborate to 
> create
> a spec to document and guide development?

The PEP process could be used for some of this. There are existing
informational PEPs that aren't connected to the core language, but just
specify some interface for the community's use:

 IR  216  Docstring Format
 IF  248  Python Database API Specification v1.0  
 IF  249  Python Database API Specification v2.0  
 I   333  Python Web Server Gateway Interface v1.0

Other PEPs describe how to modernize code (PEP 290) and hack the code (290,
339).  This is similar to RFCs: there are normative RFCs that actually
specify something, and informative RFCs that publish information about an
experimental protocol or system.

PEPs would be especially good for things like WSGI that are intended to be
supported by many different projects; it's less useful to document how a pet
project works.

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


Re: Fat and happy Pythonistas (was Re: Replacement forkeyword'global' good idea? ...)

2005-08-08 Thread Bengt Richter
On Sun, 7 Aug 2005 23:52:40 -0400, "Terry Reedy" <[EMAIL PROTECTED]> wrote:

>
>"Bengt Richter" <[EMAIL PROTECTED]> wrote in message 
>news:[EMAIL PROTECTED]
>> I think the relationship of abstract entities and their concrete 
>> representations
>> is very interesting.
>
>ditto
>
>> BTW, maybe this is a place to mention the concept of an AST decorator, 
>> that works like
>> a function decorator except that it is prefixed with @@ instead of @ and 
>> it operates
>> at compile time when the AST becomes available, but before it gets 
>> translated to code,
>> and what gets passed to the decorator is the AST
>
>One can do this much today:
>
>import compiler
>
>new_ast = ast_transformer(compiler.parse('''\
>
>''')
>
>However, I can't see any way in the docs to get a code object from the AST. 
>I believe the AST-to-code compilet is currently being worked on.  When it 
>is, @@ would be nice syntactic sugar but not really necessary.
>
>> The idea is that this form of decoration could transform the
>> AST arbitrarily before code generation, and be a very flexible tool
>> for mischief of course, but also useful tricky things.
>
>At the moment, we are limited to manipulating concrete text before 
>compiling it.
>
Have we gone backwards from this?


http://groups.google.com/group/comp.lang.python/browse_thread/thread/5fa80186d9f067f4/7a2351b221063a8c

I've been meaning to do something with that, to implement @@ decoration, I 
think probably in the context
of a customized importer, where I would be able to control the whole source 
conversion process, anticipating
usage something like (ut is my hodgepodge utility package ;-)

from ut.astdecoimport import astdecoimport
amodule = astdecoimport('amodule') # searches like import for amodule.py 
and does its thing

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


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Paul Rubin
Donn Cave <[EMAIL PROTECTED]> writes:
> > I'm not sure what you mean by that about OCAML.  That its functional
> > model is not pure enough?  I'd like to look at Haskell as well, but I
> > have the impression that its implementation is not as serious as
> > OCaml's, i.e. no native-code compiler.
> 
> On the contrary, there are a couple.  Ghc is probably the leading
> implementation these days, and by any reasonable measure, it is serious.

OK, I've looked at the Haskell "gentle introduction" page a little bit
and it's nice.  I do remember Ocaml beating Haskell on a performance
shootout and am not sure whether Ghc was used for the Haskell entry.

I notice that Haskell strings are character lists, i.e. at least
conceptually, "hello" takes the equivalent of five cons cells.  Do
real implementations (i.e. GHC) actually work like that?  If so, that's
enough to kill the whole thing right there.

> Objective CAML is indeed not a pure functional language.

Should that bother me?  I should say, my interest in Ocaml or Haskell
is not just to try out something new, but also as a step up from both
Python and C/C++ for writing practical code.  That is, I'm looking for
something with good abstraction (unlike Java) and type safety (unlike
C/C++), but for the goal of writing high performance code (like
C/C++).  I'm even (gasp) thinking of checking out Ada.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Paul Rubin  wrote:

> "Donn Cave" <[EMAIL PROTECTED]> writes:
> > My vote would be Haskell first, then other functional languages.
> > Learning FP with Objective CAML is like learning to swim in a
> > wading pool -- you won't drown, but there's a good chance you
> > won't really learn to swim either.  Has an interesting, very
> > rigorous OOP model though.
> 
> I'm not sure what you mean by that about OCAML.  That its functional
> model is not pure enough?  I'd like to look at Haskell as well, but I
> have the impression that its implementation is not as serious as
> OCaml's, i.e. no native-code compiler.

On the contrary, there are a couple.  Ghc is probably the
leading implementation these days, and by any reasonable
measure, it is serious.

Objective CAML is indeed not a pure functional language.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


sample script to write results of html scrape to mysql db?

2005-08-08 Thread yaffa
does anyone have a sample script that writes results of html scraping
to a mysql db?

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


Re: Python framework

2005-08-08 Thread Terry Reedy

>what's the best python framework to create web applications?

Let us try a different question: what is the best way to get help from a 
newsgroup?

Step 1: do some research.  Read throught the past postings still available 
on your newssource for threads on your topic.  And/or, use Google's 
newsgroup archive and search facility to do the same.  There have been lots 
of discussions of web application frameworks, some in the last couple of 
weeks.

Step 2: ask a specific question that has an answer and whose answer would 
be useful to you.  I think you could figure out the answer to the above: 
'it depends'.  It depends of you, your experience, and your specific task. 
Very helpful ;-)

Terry J. Reedy



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


Re: OT: World's largest Python caught!:)

2005-08-08 Thread James Stroud
http://www.afghania.com/News-article-sid-4792-mode-thread.html

3rd hit in google with "world's largest python". The first two hits were your 
email below to the newsgroups.

James

On Sunday 07 August 2005 09:15 pm, Ashok Rajasingh wrote:
> Hi
>
>
>
> Can I please get some information on this python?  I saw a brief news
> clip last year & am very keen to know more.
>
>
>
> Thanks
>
> Ashok Rajasingh
>
> 21 Cumberland street
>
> New Plymouth
>
> New Zealand
>
> +646 7575698 (home)
>
>   7599592 (work)
>
>
>
>
> ##
> Attention:
> The information contained in this message and or attachments is intended
> only for the person or entity to which it is addressed and may contain
> confidential and/or privileged material. Any review, retransmission,
> dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient
> is prohibited. If you received this in error, please contact the sender and
> delete the material from any system and destroy any copies. Please note
> that the views or opinions expressed in this message may be those of the
> individual and not necessarily those of Tegel Foods Ltd.
>
> This email was scanned and cleared by NetIQ MailMarshal.
> ##

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

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


Re: gettext again

2005-08-08 Thread stas
On Mon, 08 Aug 2005 17:39:34 +0200, cantabile wrote:

> BTW stasz,
> Maybe you'll have still some time for the following question. Trying my 
> luck :))
> 
> Suppose I have several units (.py files), say test.py test1.py tets2.py 
> , test.py being my main file.
> I've read I can import gettext and install in the main unit. Then, must 
> I create .po files for each unit or is there a way to make a single .po 
> file for the whole app. ?
Yes there is.

As a reminder, make sure that you install gettext in the namespace
of your toplevel module.
What I mean is this:

test1.py imports test2.py and test3.py
test2.py imports test4.py

Now you have to place the gettext.install call in test1.py and
then the other modules can access it.
If you place the gettext call in, for example, test2.py then only
test2.py and test4.py have access to it.
So when it don't work as you expect make sure to check if every
module has access to the "_" from gettext.

So now for your question about one po/mo file for multiple
modules.
I use this file for a project of mine it also includes some
explanation in case I forget it myself :-)

The project is called "Guido van Robot".
http://gvr.sf.net


The files mentioned inside this file are used in the above project
and serve as an example in this case.
You could replace the files with your own to try it.
The file itself is called "FilesForTrans" so you could put this
file together with your test modules inside a directory and follow
the instructions in side "FilesForTrans".

Stas Z


Contents of "FilesForTrans"
 cut here -
## These files contain i18n strings
## Use: xgettext -f ./FilesForTrans -p /tmp
## The message.po will be located in /tmp
## Now do: msgmerge ./po/nl/gvr.po /tmp/messages.po > /tmp/new_nl.po
## compile the .po to mo (place the .po after editing in ./po/nl/)
## msgfmt ./po/nl/gvr.po -o ./locale/nl/LC_MESSAGES/gvr.mo 

gvr.py
gvrparser.py
world.py
worldMap.py
Editorwindows.py





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


Re: Splitting a string into groups of three characters

2005-08-08 Thread [EMAIL PROTECTED]
Yes i know i made a mistake,
>['Hell','o W','orl','d']
but you know what I mean lol,

I'll probly use
John Machin's

 def nsplit(s, n):
return [s[k:k+n] for k in xrange(0, len(s), n)]

It seems fast, and does not require any imports.

But anyways, thank you for all your help, you rock! :)

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


Re: Splitting a string into groups of three characters

2005-08-08 Thread [EMAIL PROTECTED]
Yes i know i made a mistake,
>['Hell','o W','orl','d']
but you know what I mean lol,

I'll probly use
John Machin's

 def nsplit(s, n):
return [s[k:k+n] for k in xrange(0, len(s), n)]

It seems fast, and does not require any imports.

But anyways, thank you for all your help, you rpck! :)

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread [EMAIL PROTECTED]
That's it: 

got to get the PEEPs involved.

Acronym of the year (AOTY).

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


Re: Is there a better/simpler logging module?

2005-08-08 Thread Michael Hoffman
Alessandro Bottoni wrote:
> I just tried to use the python standard logging module in a small program
> and I found myself lost among all those features, all those configuration
> options and so on.

If you don't want to mess with all this stuff it's easy enough to do:

import logging

logging.warning("my warning")
logging.debug("debug message")

The configuration options are strictly optional.

Personally I use a package I wrote called autolog, which sets up 
configuration from a dot-file in the home directory if it exists, and a 
basic logger for each module automagically. And it does this all using 
the stdlib logging module. :)
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: gettext again

2005-08-08 Thread stas
On Mon, 08 Aug 2005 17:01:21 +0200, cantabile wrote:

> stasz a écrit :

> Wht ! Working at last, after three days... It wasn't the LANG param 
[...]
> Anyways, you made my day my friend !
> Many many thanks !
Your welcome :-)

Stas

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


Re: PEP: Specialization Syntax

2005-08-08 Thread Bengt Richter
On Sun, 07 Aug 2005 21:41:33 -0400, Nicolas Fleury <[EMAIL PROTECTED]> wrote:

>Bengt Richter wrote:
[...]
>> But here the problem is not in the __getitem__ method:
>> 
>>  >>> c.__getitem__(kw='key word arg')
>>  (<__main__.C object at 0x02EF498C>, (), {'kw': 'key word arg'})
>> 
>> It's just that square bracket expression trailer syntax does not
>> allow the same arg list syntax as parenthesis calling trailer syntax.
>
>I totally agree and that's what I mean.  The formulation of the PEP is 
>wrong, I should almost not talk about __getitem__ since as you said it 
>can have any signature.  The PEP is about extending [] syntax to call 
>automtically __getitem__ function with more complex signatures.
>
>>>Should other operators that square brackets be used for
>>>specialization?
>> 
>> Didn't quite parse that ;-) You mean list comprehensions? Or ??
>
>I mean should angle brackets <> like in C++, or another operator, be 
>used instead?

I am getting the feeling that your PEP is about a means to do something C++-like
in python, not necessarily to enhance python ;-) IOW, it seems like you
want the [] to do something like C++  in templates?

(BTW, I have nothing against giving python new capabilities (quite the reverse),
but not by grafting limbs from other animals ;-)

Maybe you want hidden name-mangling of function defs according to arg types
and corresponding dispatching of calls? I am afraid I am still not clear
on the fundamental motivation for all this ;-)

>
>Regards and thx for your feedback,
You're welcome.

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


Re: PEP: Specialization Syntax

2005-08-08 Thread Nicolas Fleury
Kay Schluehr wrote:
> I have to admit that i don't actually understand what you want? The
> problems you try to solve seem trivial to me but it's probably my fault
> and i'm misreading something. You might be correct that your PEP may be
> interesting only if "optional static typing" will be introduced to Py3K
> and then we will suddenly have an immediate need for dealing with
> generic types so that the syntax can be reused for deferred functions (
> the concept of "specialization" is usually coupled with some kind of
> partial evaluation which doesn't take place somewhere in your proposal
> ). But i'm not sure if this makes sense at all. 

Well, the partial evaluation is done when using [].

def getMember[memberName](obj):
 return getattr(obj, memberName)
x = getMember["xyz"]  # specialization
y = x(obj)  # use

I realize the term "specialization" can be confusing, since people might 
think of what is called in C++ "explicit specialization" and "partial 
specialization", while these concepts are not present in the PEP.

The point is that I'm already using static-like typing in frameworks 
interacting with other languages with generic types.  So I would already 
benefit from such a capability, and yes, there's workarounds.  I'm 
clearly in a minority with such a need, but the first point fo the PEP 
is to extend [] syntax, so that it is possible to prototype generic 
types using [] operators.

Regards,
Nicolas

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Paul Rubin
Cliff Wells <[EMAIL PROTECTED]> writes:
> The second presentation (I don't recall the speaker's name) specifically
> covered metaprogramming (writing DSLs) and one of the things I found
> interesting was that despite Ruby having far more syntax than Python in
> general, the resulting Ruby-based DSLs presented had far *less* syntax
> than had they been written in Python.  This is undoubtedly the reason
> why Rails is apparently completely usable even if one knows very little
> Ruby.

Interesting.  But if we can generalize from that, then Lisp should be
ruling the web.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Paul Rubin
"Kay Schluehr" <[EMAIL PROTECTED]> writes:
> > Having a good FFI is certainly an important feature but Python
> > programs should first and foremost be Python programs.
> 
> Python was originally created as an extension language for C. In some
> sense it is an abstraction layer for C libs.

I'd have to respond: that was then, this is now.  As Python has gotten
more powerful, that C extension feature has gotten less central.  That
is to say, the language is growing up, and unwillingness to recognize
that is in some places stunting Python's growth.

> Did you ever check out ctypes? I appreciate it very much.
> 
> http://starship.python.net/crew/theller/ctypes/

I think I did see something about it before.  I should check it out
further.  But mainly I want my Python programs to be Python programs,
not wrappers for C programs.  And frankly I'm more comfortable with
something like SWIG, which turns the C functions into actual Python
modules rather than exposing naked C functions to Python code
(destroying Python's type safety).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to determine that if a folder is empty?

2005-08-08 Thread David Cuthbert
Mike Meyer wrote:
> Just out of curiosity, is there an OS out there where you can have the
> permissions needed to delete a directory without having the
> permissions needed to create it appropriately?

Not an OS, but AFS has a wider set of permissions (RLIDWKA - which, if I 
remember correctly, are read, look, index, delete, write, lock, 
administrate).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Bengt Richter
On Mon, 8 Aug 2005 00:51:04 -0800, "EP" <[EMAIL PROTECTED]> wrote:

>Robert Kern <[EMAIL PROTECTED]> wrote:
>
>> Which is exactly why I said at the beginning that people shouldn't =
>
>> bother with this thread and should instead just get to work.
>> =
>
>
>
>Robert, you are probably right, but I think how we get to work is important=
> as well.
>
>What I posted was a little intellectually thin, but it would be nice to sti=
>r the collective energy toward some common (and useful) objectives.  I thin=
>k that something more than a superior language specification is required fo=
>r a language to get a firm foothold in the IT world (and that is something =
>I would personally like for Python.)
>
>It seems there are people very capable and willing to develop the good appl=
>ications/tools/frameworks on top of Python, but too many of those projects =
>do not gain critical mass; rather we have dozens of competing applications =
>and frameworks that never blossom to their full potential.  I'd love to see=
> a little consensus on what "goodies" should be developed atop the language=
>; what standards, principles, and API/hooks those goodies should provide; a=
>nd then a collaborative effort to get there.  Projects with a broader buy-i=
>n have a greater chance of achieving their potential.
It occurs to me that we have the PEP process for core python, but no PEP process
for the python app/lib environment. What about starting a PEEP process
(Python Environment Enhancement Proposals) modeled on PEPs, where those 
motivated
to formalize their pet projects or feature requests could collaborate to create
a spec to document and guide development?


>
>It does seem that perhaps some ground was gained with the WSGI effort.  I u=
>nderstand Django [http://www.djangoproject.com/], a RoR alternative based o=
>n the WSGI spec, already has some buzz though "the cat got out of the bag a=
> bit early" and Django is "not officially launched just yet."
>
>It makes sense to ask one's fellow developers and Python users what a new o=
>pen source development should look and act like if one wants to develop som=
>ething great.  Open source code denotes sharing, but we should add teamwork=
> and community involvement in the code as connotations if we want our open =
>source to reach its potential.
>
PEEP as a vehicle?

>
>What are the top 5 developments, aside from specification and implementatio=
>n details of the language itself, which Python still needs for greater succ=
>ess in the day to day IT world?
>
>
>
>
>EriPy pyDerson
>
>
>
>
>
>P.S.  In terms of a more concrete suggestion, I propose the Python communit=
>y form an intervention team who are ready to fly in and intercede any time =
>a developer, whose brilliance has been expended in their heroic coding effo=
>rt, goes to name their new module, package, or application with a "py" othe=
>r than to the right of the dot.
>
Probably better to have the PSF hire a patent/trademark lawyer to reserve rights
to py... names and the "py"-prefixing business process ;-/

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread bruno modulix
Eric Pederson wrote:
> Raise your hand if you think the best technology wins!
> 

Those who have raised hands should google for "worse is better"...

-- 
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: How to determine that if a folder is empty?

2005-08-08 Thread Bernhard Herzog
[EMAIL PROTECTED] writes:

> On standard Unix fileystems, one way to check for this is to check that the
> st_nlink of the directory is 2. 

In that case you only know that the directory doesn't have any
subdirectories.  It may still contain ordinary files and other
non-directories.

   Bernhard

-- 
Intevation GmbH http://intevation.de/
Skencil   http://skencil.org/
Thuban  http://thuban.intevation.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI programming, embedding, real time plots, etc.

2005-08-08 Thread Lou Pecora
In article <[EMAIL PROTECTED]>,
 Madhusudan Singh <[EMAIL PROTECTED]> wrote:

> 1. In using matplotlib (my code essentially involved creating a plot and
> show()'ing it inside a loop), the color of the plot changed. Is there a way
> to tell matplotlib to not treat each new invocation as a new plot, but to
> really overwrite the old one ?

You were able to get matplotlib to open a new plot each time (assuming 
you closed the old one, too)?  Can you show a simple example of this?  

Thanks.

-- Lou Pecora  (my views are my own) REMOVE THIS to email me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP: Specialization Syntax

2005-08-08 Thread phil hunt
On 8 Aug 2005 02:26:40 -0700, Kay Schluehr <[EMAIL PROTECTED]> wrote:
>
>I have to admit that i don't actually understand what you want?

Me neither. I don't see the point of this.

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Is there a better/simpler logging module?

2005-08-08 Thread [EMAIL PROTECTED]
If you need some simple logging why not create a logger like one of the
basic examples, see http://docs.python.org/lib/minimal-example.html,
these examples are not that complex.

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


Python framework

2005-08-08 Thread mohammad babaei
hi !
what's the best python framework to create web applications?
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

BayPIGgies: August 11, 7:30pm (Ironport)

2005-08-08 Thread Aahz
The next meeting of BayPIGgies will be Thurs, August 11 at 7:30pm at
Ironport.

Hasan Diwan will present RRsR, a web-based RSS reader written using
feedparser and python CGI.  This is expected to be a short presentation;
afterward, anyone who was at OSCON is invited to summarize what they
saw/heard.

BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://www.baypiggies.net/


Before the meeting, we plan to meet at 6pm for dinner.  Discussion of
dinner plans is handled on the BayPIGgies mailing list.  This week will
probably be at Creperie du Monde, six long blocks from IronPort (i.e.,
walking distance).

Advance notice: The September 8 meeting agenda has not been set.  Please
send e-mail to [EMAIL PROTECTED] if you want to suggest an agenda
(or volunteer to give a presentation).  We already have a speaker for
October.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: gettext again

2005-08-08 Thread cantabile
BTW stasz,
Maybe you'll have still some time for the following question. Trying my 
luck :))

Suppose I have several units (.py files), say test.py test1.py tets2.py 
, test.py being my main file.
I've read I can import gettext and install in the main unit. Then, must 
I create .po files for each unit or is there a way to make a single .po 
file for the whole app. ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Is there a better/simpler logging module?

2005-08-08 Thread Alessandro Bottoni
I just tried to use the python standard logging module in a small program
and I found myself lost among all those features, all those configuration
options and so on.

Is there any better/simpler logging module around?
What do you use for logging in your programs?

Thanks in advance.
---
Alessandro Bottoni
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Terminate a thread that doesn't check for events

2005-08-08 Thread Liu Shuai
Thank you for the help Chris and Jp. Just wanted to let you know that I 
re-wrote a "stoppable" version of the function I was calling in the
thread instead of forcing the thread to terminate. I think it worth the
effort as the solution is now clean and portable.

Thanks again for all your input.

LS
 
> -Original Message-
> From: [EMAIL PROTECTED]
[mailto:python-list-
> [EMAIL PROTECTED] On Behalf Of Chris Lambacher
> Sent: Tuesday, August 02, 2005 12:16 PM
> To: python-list@python.org
> Subject: Re: Terminate a thread that doesn't check for events
> 
> No.  On Linux a separate thread is a separate process with shared
memory.
> You
> can send a signal to a particular process and catch that signal as an
> indication that you need to terminate (perhapse something that is set
up
> before running your long running process so that it is generic).  In
> windows
> threads are separate beasts from processes(almost) and there are
functions
> for
> terminating them (though I don't think gracefully).  Unfortunately I
can't
> comment on other platforms.
> 
> -Chris
> 
> On Tue, Aug 02, 2005 at 11:54:57AM -0400, Liu Shuai wrote:
> > Thanks for the reply Chris.
> >
> > Are you suggesting running the task in a *separate* process instead
of a
> > separate *thread*? Because if that's the case, I will have to share
data
> > (and possible memory) between that new process and my "master"
process
> > since they depend on one other.
> >
> > Yeah I will sure post it if I can find an elegant solution.
> >
> > Thank you,
> > LS
> >
> > > -Original Message-
> > > From: Chris Lambacher [mailto:[EMAIL PROTECTED]
> > > Sent: Tuesday, August 02, 2005 11:50 AM
> > > To: Liu Shuai
> > > Subject: Re: Terminate a thread that doesn't check for events
> > >
> > > Hi,
> > >
> > > There is no cross platform way to do this.  You need to
periodically
> > check
> > > a
> > > quit flag, or perform a platform specific action to terminate it.
On
> > > Linux
> > > you can send the process a signal.  On windows you will need to
use
> > the
> > > win32all package.  If you decide to go the later route, maybe you
> > could
> > > encapsulate the thread termination code in a module and share it
with
> > the
> > > Python community.
> > >
> > > -Chris
> > >
> > > On Tue, Aug 02, 2005 at 09:51:31AM -0400, Liu Shuai wrote:
> > > >Can someone please comment on this?
> > > >
> > > >
> > > >
> > > >
> >
-
> > > -
> > > >
> > > >From: [EMAIL PROTECTED]
> > > >[mailto:[EMAIL PROTECTED] On
Behalf
> > Of
> > > Liu
> > > >Shuai
> > > >Sent: Monday, August 01, 2005 4:29 PM
> > > >To: python-list@python.org
> > > >Subject: Terminate a thread that doesn't check for events
> > > >
> > > >
> > > >
> > > >Hi all,
> > > >
> > > >
> > > >
> > > >I am aware that similar and probably same questions have been
> > posted
> > > many
> > > >times, but I was unable to find a solution after reading a
dozen
> > > threads
> > > >in the archive. So here it goes again.
> > > >
> > > >
> > > >
> > > >I have a thread that does some heavy task (hash calculation,
for
> > > >instance). I need a mechanism that works *across platforms*
to
> > stop
> > > that
> > > >calculation if user decides to exit. How can I do that?
> > > >
> > > >I can not do the standard "periodical checking" way since
there
> > is
> > > only
> > > >one function/step call in my thread.
> > > >
> > > >
> > > >
> > > >Here is a snippet of my thread classes to help illustrate the
> > > problem:
> > > >
> > > >
> > > >
> > > >class Dispatcher():
> > > >
> > > >def __init__(self):
> > > >
> > > >self.__worker = Worker()
> > > >
> > > >
> > > >
> > > >def start(self):
> > > >
> > > >self.__worker.start()
> > > >
> > > >
> > > >
> > > >def stop():
> > > >
> > > >#how do i stop the worker?
> > > >
> > > >
> > > >
> > > >class Worker(threading.Thread):
> > > >
> > > >def __init__(self):
> > > >
> > > >
> > > >
> > > >def run(self):
> > > >
> > > >oneTimeConsumingCall()
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >Thank you in advance for any suggestions/pointers.
> > > >
> > > >
> > > >
> > > >LS
> > >
> > > > --
> > > > http://mail.python.org/mailman/listinfo/python-list
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> --
> http://mail.python.org/mailman/listinfo/python-list


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


Re: How to determine that if a folder is empty?

2005-08-08 Thread Dan Sommers
On Mon, 08 Aug 2005 09:03:39 -0400,
Mike Meyer <[EMAIL PROTECTED]> wrote:

> Just out of curiosity, is there an OS out there where you can have the
> permissions needed to delete a directory without having the
> permissions needed to create it appropriately?

Depending on your definition of "out there," yes, some OS's grant those
privileges separately.  Apollo (eventually bought out by HP) Aegis
(mostly like *nix, but just different enough to trip me up again and
again) used to be one.  The more secure the environment, the more likely
certain privileges do *not* imply others.

Regards,
Dan

-- 
Dan Sommers

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


Re: gettext again

2005-08-08 Thread cantabile
stasz a écrit :

> Your steps seems alright.
> Just a thought; you do start test1.py from a [EMAIL PROTECTED]
> environment do you?
> I mean in a xterm do: export [EMAIL PROTECTED]
> And then start test1.py from there.
> 
> Stas

Wht ! Working at last, after three days... It wasn't the LANG param 
which is [EMAIL PROTECTED] allright. I inadvertantly suppressed the '.mo' part 
of gettext.install(test1.mo') and it just worked.
I guess gettext was looking for a 'test1.mo.mo' file or something.

Anyways, you made my day my friend !
Many many thanks !
-- 
http://mail.python.org/mailman/listinfo/python-list


Extending and altering httplib to handle bad servers

2005-08-08 Thread Michael Ekstrand
In the course of my current project, I've had to deal with connecting
to an HTTP server that isn't fully compliant with the HTTP requirements
for chunked encodings. Rather than sending the end-of-data sentinel
(0-length chunk), it just closes the connection (without even sending
the CRLF at the end of the data).

Because of this, using httplib would always throw nasty errors and not
give me any useful data. Therefore, I've had to modify the httplib.py
code to do something reasonable when the server just closes the
connection.

So, my questions are (my changes follow, against Python 2.3):

- Did I patch the right place to do Something Reasonable in this case
of server non-compliance?

- Is there a better way to handle this case that may be more robust? Or
handle more similar cases?

- Is there anything special I should do (besides obviously diff-ing
against CVS) before submitting a patch for this to SourceForge? (it
seems to me that being tolerant of bad servers is something that would
be of general interest.)

Thanks,
Michael

---8<--- BEGIN CONTEXT DIFF 
*** /usr/lib/python2.3/httplib.py   2005-05-04 02:08:57.0 -0500
--- httplib.py  2005-08-05 10:33:08.0 -0500
***
*** 1,5 
--- 1,7 
  """HTTP/1.1 client library
  
+ Copyright (c) 2001 Python Software Foundation; All Rights Reserved
+ 
  
  
  
***
*** 64,69 
--- 66,75 
  Unread-response_CS_IDLE   
  Req-started-unread-response_CS_REQ_STARTED
  Req-sent-unread-response   _CS_REQ_SENT   
+ 
+ Modified 2005-07-20 by Michael Ekstrand <[EMAIL PROTECTED]> to deal
+ gracefully wtih non-compliant systems which just terminate the connection
+ rather than sending the end-of-data chunk in chunked HTTP responses.
  """
  
  import errno
***
*** 442,448 
  amt -= chunk_left
  
  # we read the whole chunk, get another
! self._safe_read(2)  # toss the CRLF at the end of the chunk
  chunk_left = None
  
  # read and discard trailer up to the CRLF terminator
--- 448,460 
  amt -= chunk_left
  
  # we read the whole chunk, get another
! try:
! self._safe_read(2)  # toss the CRLF at the end of the chunk
! except IncompleteRead:
! # The server just closed on us, without providing appropriate
! # end-of-data things.
! self.close()
! return value
  chunk_left = None
  
  # read and discard trailer up to the CRLF terminator
---8<- END CONTEXT DIFF -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Dave Brueck
Paul Rubin wrote:
> Ruby just doesn't interest me that much though (maybe I'm missing
> something).

I don't think you are. My impression is that if you've never used Python or 
Ruby, you'll generally end up liking whichever of the two you really discover 
first (since the common case is that you're coming from Java/C++/PHP/etc - the 
more mainstream languages).

IIRC, the creator of Ruby got really hung up on the fact that Python was not a 
pure OO language, so he decided to make a new language that was (this was in 
the 
pre-metaclass, old-style class days of Python).

>  I was hoping for a concise explanation of what Rails does

I'd say it's similar to Zope in that

(1) For both, the introductory tutorials make it seem deceptively easy to use, 
but they hide a sometimes steep learning curve

(2) For both, it's hard to find clear, concise documentation midway between 
introductory tutorials and reading the source code

(3) For both, being frameworks, you have to commit yourself to them almost 
entirely and be prepared for some serious lock-in

(4) Oh yeah, they're both web application frameworks :) (ROR has libraries to 
aid in building database-centric web applications: it includes an database ORM, 
a web templating language, libraries for user sessions, etc.)

> and whether it's feasible to do something like it in (say) Python.  I
> did look at the rubyonrails.com site but there were too many marketing
> buzzwords and downloadable videos for me to deal with.

Yes, it's incredibly feasible. I think the Subway project is sort of heading 
down a similar path but using Python instead. I've tried a couple of times to 
use Ruby on Rails and, I have to admit, I had a tough time cutting through the 
hype (also, it seemed like the preferred method of learning about features was 
through downloading large videos).

The ActiveRecord library (for handling mapping objects to the database) seems 
sort of powerful, but the tutorials and demo videos make a huge deal about how 
ROR can generate a web form by inspecting the database table metadata. (Useful? 
Probably. Mind-blowingly cool? Hardly.)

Beyond ActiveRecord, there is some additional stuff to help you build 
Model-View-Controller web UIs, and then lots of the standard web app components 
(user sessions, security, logging, etc.).

I think ROR's big selling point isn't technology-related at all: it's hype 
machine has helped build an active community, and it's a single framework as 
opposed to Python's bazillions. :)

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


epyDoc Questions

2005-08-08 Thread Neil Benn
Hello,

  I can;t find a epyDoc specific mailing list, so I'll try here 
- if you know of a epyDoc mailing list then please let me know (google 
is not my friend, I can only find an announce, devel and commit list 
from 'epydoc mailing list').

I'm working on marking up a class in epyDoc and have a few things 
that I strongly suspect I can do but can't find instructions for in the 
docs - I was hoping that someone has cracked this already:

   1. I want to document the attributes (instance and also class) of a
  class and or module, I know the tags are there - where does they
  go (before/after theclass decleration, top of the module, if
  someone puts in the class doc but misses out the module stuff, how
  will epydoc know that this is meant to be class and not module
  (although someone doing this will probably get shouted at in a
  code review!)?
   2. In the argument to the tag for raises, how can I put a link
  through to the exception?
   3. How would I go about marking up the property docs so that it knows
  what the setter and getter methods are - it links through to the
  methods but the docs arn't in there, they are in the fifth
  argument to the property method (I can manually do this using
  sections but is there a tag I can use?)

Cheers for your help,

Neil

-- 

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Peter Decker
On 8/8/05, Robert Kern <[EMAIL PROTECTED]> wrote:

> What I'm trying to say is that posting to c.l.py is absolutely
> ineffective in achieving that goal. Code attracts people that like to
> code. Tedious, repetitive c.l.py threads attract people that like to
> write tedious, repetitive c.l.py threads. 

+1 QOTW

-- 

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


Re: Embedding a runtime graph in Qt3 designer generated UI

2005-08-08 Thread Adriaan Renting
I find Eric3 very easy to work with when using Qt+Python. It will
generate a Python wrapper for your Qt (Designer designed) form, that you
can the sub-class and use as if it was a Python object.
I'm hoping it will be available (together with PyQt, etc.) for Qt4 soon,
but as I'm not paying a dime for it, I can only hope...

Adriaan Renting| Email: [EMAIL PROTECTED]
ASTRON | Phone: +31 521 595 217
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 597 332
The Netherlands| Web: http://www.astron.nl/~renting/
>>> "Phil Thompson" <[EMAIL PROTECTED]> 08/08/05 9:21 AM >>>
> Hi
>
> Two questions :
>
> 1. Is it possible to use an import command in a qt3 designer code ? (I
> know
> that it is possible to write python inside the braces -- but is it
> possible
> to use an import command for some rather large libraries I wrote that
I
> need to access ?).

You can include import statements in Designer's comment dialog by
prefixing them with "Python: ". This is covered in the PyQt
documentation.

> 2. In the same vein, how does one embed a runtime plot in a qt3 UI ?
It
> will
> need to be a python solution since I am using python libraries to
acquire
> the data.

Have a look at PyQwt which is a set of Python bindings for the Qt-based
Qwt plotting library.

Phil

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

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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Cliff Wells
On Sun, 2005-08-07 at 06:55 -0700, Paul Boddie wrote:
> Eric Pederson wrote:
> > Why is Ruby, and Ruby on Rails, getting such strong play?
> 
> Relentless hype from blogging celebrities?

This is certainly part of it, but I feel it ignores the much deeper
reasons which are the root of this hype.  I recently went to FOSCON (a
free seminar coinciding with OSCON put on by the local Ruby UG here in
Portland) and listened to a few presentations on Ruby and Rails by David
Hansson (the creator of Rails) and others.  By the end it was clear that
Ruby is wonderfully suited to writing domain-specific languages (DSL)
and that Rails is an excellent example of a DSL geared toward writing
database-driven web applications.  A friend of mine is writing a book on
Rails for a large publisher and admitted to me that he barely knows Ruby
(and has used Rails for only around six months).

The second presentation (I don't recall the speaker's name) specifically
covered metaprogramming (writing DSLs) and one of the things I found
interesting was that despite Ruby having far more syntax than Python in
general, the resulting Ruby-based DSLs presented had far *less* syntax
than had they been written in Python.  This is undoubtedly the reason
why Rails is apparently completely usable even if one knows very little
Ruby.

Regards,
Cliff

-- 
[EMAIL PROTECTED]
http://www.develix.com :: Web applications and hosting :: Linux, PostgreSQL and 
Python specialists ::


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


Re: Python -- (just) a successful experiment?

2005-08-08 Thread Kay Schluehr
Paul Rubin schrieb:

> Having a good FFI is certainly an important feature but Python
> programs should first and foremost be Python programs.

Python was originally created as an extension language for C. In some
sense it is an abstraction layer for C libs.

> Compare the
> situation with Java or Common Lisp for example.  Both of those
> languages have better FFI's than Python in every serious
> implementation (consider why SWIG is popular--because Python's C API
> is so clumsy), and yet the specs for those languages are far more
> thorough than the Python docs.

Did you ever check out ctypes? I appreciate it very much.

http://starship.python.net/crew/theller/ctypes/

Kay

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


Re: Oreilly CodeZoo

2005-08-08 Thread Jorge Godoy
richard wrote:

> We (PyPI / Cheese Shop developers) are talking to the CodeZoo people about
> the relationship between the two systems. Things PyPI has:
> 
> 1. python setup.py register
> 2. python setup.py (sdist|bdist|bdist_egg|bdist_wininst|...) upload
> 3. http://cheeseshop.python.org/
> 4. better categorisation (IMO)
> 5. XML-RPC interface
> 6. 852 packages registered

Richard,


Some feedback:


With regards to 6, it would be interesting, though, to separate the
classification using just the software name and not the version.  For
example http://cheeseshop.python.org/pypi?:action=browse&asdf=256 has four
entries to ZODB3, in four different versions.  This would decrease the
amount of packages registered, but would allow a more realistic view of
"packages" and not of "package versions", IMVHO.

A subtree with version numbers could solve the problem of storing
information for old versions when a new one is added.

With regards to 4, I'd like to see the "Topic" category in the beginning of
the page -- this is what most people search, I guess -- and not at the
bottom of it.  I'm usually looking for a software to do  and not
a software that is being planned, is in alpha - beta - production stage,
etc.  

Also, there's a discrepancy on the amount of packages stored.  The
categorization page says there are 679 packages.  The main page says there
are 852.  I believe the categorization page does what I suggested and
disregard different versions of the same software.  I think this (679) is
the correct number.

Ah!  And an RSS feeder would be interesting, to know when there are new
packages or when a package has been upgraded... ;-)  Where's the
"wishlist"? :-)

I hope you see this as a constructive feedback from someone that has just
screened the pages, getting to know it. 


Be seeing you,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

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


Re: gettext again

2005-08-08 Thread stasz
On Mon, 08 Aug 2005 02:56:35 +0200, cantabile wrote:

> stasz a écrit :
>> On Sun, 07 Aug 2005 21:33:21 +0200, cantabile wrote:
>> 
>> 
>>>stasz a écrit :
>>>
On Sun, 07 Aug 2005 11:09:14 +0200, cantabile wrote:



>Hi,
>I'm failing to make it work but can't find out what's wrong. Here's what 
>I do :

[]


>How come ? What's wrong with what I am doing ?

Start with this little howto about gettext.
http://childsplay.sourceforge.net/translate-howto.html

And then do this in your test.py:
http://www.python.org/doc/2.4.1/lib/node330.html

You should read the part about gettext in the Python Library Reference
it's really good :-)

Good luck,
Stas Z


>>>
>>>Well, I must be dumb, because I did exactly that and it still doesn't 
>>>work...
>>>
>>>BTW, I have no pygettext module. I asked here and somebody said it was 
>>>deprecated and now included in xgettext.
>>>And I've read the Python doc about gettext about ten times, but it seems 
>>>quite outdated since it calls pygettext (as staded above)...
>>>
>>>I've read the info pages of gettext too (quite a long work).
>> 
>> Ok, you should use xgettext to create a .po file from your test1.py.
>> Translate that file and use msgfmt to compile it into a .mo file.
>> Copy this .mo file to /usr/share/locale/fr/LC_MESSAGES/
>>  
>> 
>>>Here's my test1.py file again :
>>>
>>>===
>>>import gettext, os, locale
>>>
>>>locale.setlocale(locale.LC_ALL)
>>>gettext.install('test1.py', '/usr/share/locale')
>> 
>> test1.py is wrong, you must give the name of the .mo file.
>> It must be:  gettext.install('test1.mo', '/usr/share/locale')
>> Assuming you have called the mo file like that.
>> 
>> Stas Z
>> 
>> 
> 
> Well, I did this exactly... and still no go.
> 
> Is this sequence correct :
> 1° xgettext test1.py
> 2° mv messages.po messages.pot
> 3° msginit
> 4° Translate msgstr"" in [EMAIL PROTECTED] file
> 5° msgfmt -o test1.mo [EMAIL PROTECTED]
> 6° cp test1.mo /usr/share/locale/LC_MESSAGES
> 7° python test1.py
> 
> 
> This is what I did, without success. Must be bewitched :((
Your steps seems alright.
Just a thought; you do start test1.py from a [EMAIL PROTECTED]
environment do you?
I mean in a xterm do: export [EMAIL PROTECTED]
And then start test1.py from there.

Stas



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


Re: How to determine that if a folder is empty?

2005-08-08 Thread Mike Meyer
James Dennett <[EMAIL PROTECTED]> writes:
> Reinhold Birkenfeld wrote:
>
>> could ildg wrote:
>>
>>>I want to check if a folder named "foldername" is empty.
>>>I use os.listdir(foldername)==[] to do this,
>>>but it will be very slow if the folder has a lot of sub-files.
>>>Is there any efficient ways to do this?
>> try:
>> os.rmdir(path)
>> empty = True
>> except OSError:
>> empty = False
>> should be efficient. A directory (please stop calling them "folders")
>> can only be removed if it's empty.
>> Reinhold
>
> Unfortunately that destroys the directory if it was empty,
> and then you can't recreate it unless (a) you went to the
> trouble of preserving all of its attributes before deleting
> it, and (b) your script has OS-level permissions to recreate
> the directory with its original attributes (such as owners
> and permissions).

It's also buggy, in that there are other things that can cause an
OSError:

>>> import os
>>> os.rmdir("/tmp/x")
Traceback (most recent call last):
  File "", line 1, in ?
OSError: [Errno 1] Operation not permitted: '/tmp/x'
>>> ^D

bhuda% bhuda% ls -a /tmp/x
.   ..

The problem here is that I don't own /tmp/x, so I can't delete it,
hence I get an OSError even though it's empty.

Just out of curiosity, is there an OS out there where you can have the
permissions needed to delete a directory without having the
permissions needed to create it appropriately?

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


PyQt: Problem finding and showing a record in a QDataBrowser

2005-08-08 Thread Jorge Godoy
[I've also posted this to pyqt-pykde list, but I haven't got any answers so
far.  I also thought that someone here might have solved it or have a
different idea to help me :-) Sorry for those that read it twice. ]


Hi.


I have created an interface where I have a QDataBrowser and all of its
editing and navigating controls and one of the displayed controls is in a
QSpinBox.

I have the navigation from current to next and previous records working fine
if I only use the data browser controls.  I also can recover the correct
record if I type in a valid code at the spin box.

For the spin box to work, I'm doing this:


def codAmostra_valueChanged(self, amostra_id):
cursor = self.dbAmostras.sqlCursor()
cursor.select('amostra_id=%s' % amostra_id)
self.dbAmostras.first()
self.dbAmostras.refresh()


(codAmostra is my spinbox, dbAmostras is my QDataBrowser -- just as a
curiosity, "amostra" is the pt_BR for "sample")

I was willing to use "self.dbAmostras.seek()", but it requires that I know
the exact position of the record -- using it I wouldn't need to filter my
data and I think the problem would be solved... -- but I don't know it. 

There can be "holes" in my sequence (otherwise I'd use only the spinbox) and
I'll be having a few million entries (what makes it impossible to go
through each and every record every time I change the value at the spinbox
manually).

I was reading Qt3 docs trying to find out some other mean to recover the
record I need without messing with the filter because if I use the filter,
then I can't paginate through all records anymore.

Any hints on an alternative approach that would allow me to use both
controls?


* Python 2.4
* SIP 4.1.1 (4.1.1-255)
* >>> qt.qVersion()
  '3.3.4'
  >>>


Thanks in advance,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

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


Re: listing users in Plone

2005-08-08 Thread Somesh
plz let me know the proper google group

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


Re: IronPython 0.9 Released

2005-08-08 Thread Luis M. Gonzalez

could ildg wrote:
> Why is iron python runs so fast but jython runs so slow while C# and
> java seem very much the same?

I've been playing with Ironpython since its first release and, in my
experience, it is not faster than Cpython, although this is what they
claim.
Anyway, it is in alpha stage so lets wait until it's mature...

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


Re: Decline and fall of scripting languages ?

2005-08-08 Thread Neil Benn
phil wrote:

>>Kay Schluehr ([EMAIL PROTECTED]) wrote:
>>: No good news for scripting-language fans:
>>
>>: http://www.phpmag.net/itr/news/psecom,id,23284,nodeid,113.html
>>
>>
>>
>
>What incredible horse dooey.
>
>The only thing that NEVER "penetrates the enterprise space"
>is good sense.
>
>Does anyone read history books?  There is no such thing as a large
>corporation that is not doomed.  There are a few names which are
>older than 1/2 a century but the companies and players are
>unrecognizable. We have barbeque joints in Texas older than IBM.
>And noone from 1970 would recognize IBM.
>The "enterprise" is good for one thing.  Devouring each other.
>
>The "enterprise"'s opinion about what is good for the future
>is like this broker I knew in Dallas.  All you had to do was
>find out which stock he was recommending, then short it.
>
>  
>

Err, that's not what is meant by enterprise, it's a catch all term for 
large distributed systems, take a look at the link below for an idea of 
this:

http://java.sun.com/j2ee/faq.html

Obviously there are other variations on this than the Sun stuff but 
enterprise dosn't mean 'very large companies' in this case.

Cheers,

Neil

-- 

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com

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


Re: How to determine that if a folder is empty?

2005-08-08 Thread Peter Hansen
could ildg wrote:
> I want to check if a folder named "foldername" is empty.
> I use os.listdir(foldername)==[] to do this,
> but it will be very slow if the folder has a lot of sub-files.
> Is there any efficient ways to do this?

I'm just curious to know under what circumstances where it's important 
to know whether a directory is empty it's also important that the 
operation occur with lightning speed...

Reinhold's suggestion to delete the folder was interesting in this 
respect... isn't that (prior to deleting a folder) just about the only 
time one cares if it's empty, normally?  And in this case you don't need 
to do the check, as Reinhard shows, so performance isn't an issue.

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


Re: zipped socket

2005-08-08 Thread Peter Hansen
John wrote:
> 
> Is there anyway open a socket so that every send/listen/recv
> goes thru a zipping/unzipping process automatically?

You ought to be able to do this easily by wrapping a bz2 compressor 
around the socket (maybe using socket.makefile() to return a file object 
first) and probably using a generator as well:

http://effbot.org/librarybook/bz2.htm includes relevant examples (not 
specifically with sockets though).

Googling for "python incremental compression" ought to turn up any other 
alternatives.

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


Re: issues with doctest and threads

2005-08-08 Thread jepler
I don't see the problem with your doctest usage, but what makes you believe that
the code you show below produces exactly 9 dots?

strangely enough, re-working the code to this
>>> import time, threading
>>> def example():
... thread.out = []
... for i in range(9): thread.out.append(".")
>>> thread = threading.Thread(None, example)
>>> thread.running = True; thread.start()
>>> time.sleep(.1)
>>> thread.running = False
>>> print thread.out
['.', '.', '.', '.', '.', '.', '.', '.', '.']
makes the test "succeed" (though it can fail for some of the same reasons the
original test isn't guaranteed to give 9 dots either).

Jeff


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

Re: Python -- (just) a successful experiment?

2005-08-08 Thread Peter Hansen
Paul Rubin wrote:
> I dunno about PyGTK but one of the more common complaints about
> wxPython is that it's not Pythonic enough.  And wxPython is probably
> the most popular Python GUI toolkit after Tkinter.  So people don't
> want C wrappers.  I think what they mostly want is a wide choice of
> good looking widgets.  They don't like Tkinter because its widget set
> is limited and what widgets it does have, look like crap.

I not only didn't like the look of Tkinter (but could have lived with it 
if that's all that was wrong with it), but I also simply couldn't figure 
out how to make it do the things I wanted to do.  Fairly simple things, 
I thought, yet things that would have (apparently) required delving 
deeply into the innards or obscure documentation to figure out how to do 
it.  In some cases, after extensive efforts to develop my own, I would 
stumble across an example of what I wanted.  Often I was surprised to 
find that it was relatively simple solution, yet it was always unclear 
to me how I would have figured out something like that on my own.

With wxPython, I don't like the non-Pythonic nature any more than I 
liked the non-Pythonic nature of Tkinter.  I don't use the wider set of 
existing widgets very much, since often I need to roll my own anyway.  I 
can always, however, figure out how to get what I want done, and it 
usually doesn't take me very long to do it.

wxPython fits my brain.  Tkinter didn't.  YMMV.

C wrappers?  Existing widget sets?  Pythonic nature?  None of these were 
really interesting or important to me.**  Getting stuff done, that was 
important.  I was and am able to do that with wxPython while with 
Tkinter I was not.  (And no, folks, this isn't a flame against Tkinter 
at all.  I fully appreciate that the "problem" was me, since many others 
are capable of getting the results they need from the framework.  But 
they weren't sitting next to me when I needed them. ;-)  )

FWIW,
-Peter

** "Pythonic nature" is actually of interest, but it's definitely not an 
overriding concern when you have work to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to determine that if a folder is empty?

2005-08-08 Thread John Machin
Reinhold Birkenfeld wrote:
> could ildg wrote:
> 
>>I want to check if a folder named "foldername" is empty.
>>I use os.listdir(foldername)==[] to do this,
>>but it will be very slow if the folder has a lot of sub-files.
>>Is there any efficient ways to do this?
> 
> 
> try:
> os.rmdir(path)
> empty = True
> except OSError:
> empty = False
> 
> should be efficient.

But it removes the folder if it is empty. Perhaps it's not efficient to 
create the folder again.

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


Re: How to determine that if a folder is empty?

2005-08-08 Thread jepler
On standard Unix fileystems, one way to check for this is to check that the
st_nlink of the directory is 2.  However, even on Unix systems this isn't
guaranteed for all filesystem types.

Of course, finding whether a directory is empty is inherently racy: a file
could be created between the time you decide it's empty and take whatever
action is appropriate for the empty directory...

I'll side with those who say to use 'not os.listdir()' as the test for
emptyness, until you are certain it's not fast enough.

os.listdir("/"):   1 loops, best of 3: 39.3 usec per loop
os.stat("/").st_nlink: 10 loops, best of 3: 7.27 usec per loop

Jeff


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

  1   2   >