Re: Xah's Edu Corner: Examples of Quality Technical Writing

2005-12-07 Thread Gerald Klix
That's the most accurate description of Xah's behaviour I've read so far.

Jon Perez schrieb:
> Sherm Pendley wrote:
> 
> 
>>Xah's a pretty well-known troll in these parts. I suppose he thinks someone
>>is going to take the bait and rush to "defend" the other languages or some
>>such nonsense.
> 
> 
> Actually, I think Xah often has a point, except he can't
> seem to express it without resorting to profanity and
> a controlled manner, thus giving the impression he's a
> troll.
> 
> Also, he seems to be blissfully unaware of the concept
> of netiquette. ;-)
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread Fredrik Lundh
Ian Bicking wrote:

> > I've proposed adding support for semi-automatic linking to external
> > documents, based on a simple tagging model, a couple of times, e.g.
> >
> > http://mail.python.org/pipermail/python-list/2005-May/280751.html
> > http://mail.python.org/pipermail/python-list/2005-May/280755.html
> > http://effbot.org/zone/idea-seealso.htm
>
> I'm unclear what the workflow is that you are proposing.  Given a
>  chunk, how does it get into the documentation?  Do you submit
> it via the bug tracker, and a committer puts it in the repository, and
> the build process puts it into the HTML?

yep.  you can view the seealso file as a collection of all trackbacks you
might have sent.

see andrew's post for an implementation outline.

> Incidentally, I was noticing on microformats.org that they were talking
> about a rev attribute
> (http://www.microformats.org/blog/2005/12/01/rel-vs-rev/) which might
> work like:
>
>   http://python.org/doc/current/lib/module-atexit.html";
> rev="example">
>
> And would be embedded in your page on that module.  Then you might
> simply notify python.org that the page exists, and it would parse out
> the relation to the documentation based on this.  Anyway, I was just
> reading about rev yesterday, so it came to mind, but it's otherwise an
> aside.

the problem with rev is that it's a 1:1 relation between the two pages.

the seealso file is more about linking your pages to a "virtual target
domain", so that anyone that's interested can build their own service
on top of it.  web 2.0, you know...





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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Antoon Pardon
Op 2005-12-06, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>:
>>  Just because a few people dislike something,
>> doesn't make it a defect.
>
> Actually, it does.  Unless you're in the business of building security
> systems.  Then the goals are reversed.
>
> I can accept that you like scope by indent and don't want to see any
> changes gong forward.  That's your choice.
>
>
>> it's somewhat ironic that you have to cite a documented
>> source to back up your point.
>
> Somewhat.  :)
>
>> Do you think that adding braces to Python will mean
>> we can remove part of the existing documentation?
>
> No, it will add a little there.  Where it will cut down is the
> otherwise unending debate over the issue.  Documentation is not just
> what you find on a single web page.

What I don't understand is, that most people who have a problem
with scope by indentation, want to introduce braces. I think
braces are the worst solution.

Python has clear constructs that mark where suites begin. There
is no need for an extra open brace. So if you don't want to
rely on indentation, something to mark the end of a suite
would be sufficient.

I personnaly don't like the forced indentation of python
and its lack of endmarkers for suits/blocks. I also think
it is not that a big deal. Just as I indent my code in
languages that don't enforce it, I generally put in
end markers when I program python.

In the past that was just by using comments like:

  if ...:
...
  #end

But lately I have been wondering about doing the following:

end = None

...

  if ...:
...
  end

IMO it looks better, but I'm reluctant because it suggest
some checking by the compilor, which just doesn't happen.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Antoon Pardon
Op 2005-12-06, Ben Sizer schreef <[EMAIL PROTECTED]>:
> [EMAIL PROTECTED] wrote:
>> >  Just because a few people dislike something,
>> > doesn't make it a defect.
>>
>> Actually, it does.
>
> Whose definition of defect are we using? And how small a sample
> population are we going to require in order to find a 'something' which
> less than 'a few' people dislike?
>
>> Where it will cut down is the
>> otherwise unending debate over the issue.  Documentation is not just
>> what you find on a single web page.
>
> It will cut down debate but it would make the language more complex and
> less consistent. I don't think that's a price worth paying.
>
>> And it might help bring Python into the mainstream.
>
> I'd much rather educate the mainstream to be able to see the benefits
> of this method, than drag Python down to meet them.
>
>> > ...things should be self-documenting and obvious.
>> > You simply can't do that with programming languages.
>>
>> Maybe not completely.  Trust me though, we can do better.
>
> Of course. However I would argue that indented scope is one way of
> doing so. Scope is instantly visible, and no longer a game of 'hunt the
> punctuation character, which is in a different place depending on the
> coder's style'.

There are situations in which indentation is not that visible.

The problem is that situations arise where your code can't be
read continuously. e.g. it can be spread over pages in a book.
It isn't always clear whether the code on the new space is
equally idented as the code on the previous space.

Other situations arise where indentation alone isn't a clear
indication of how many scopes are left.

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


Re: Bitching about the documentation...

2005-12-07 Thread Steve Holden
François Pinard wrote:
> [A.M. Kuchling]
> 
>>On Tue, 6 Dec 2005 00:05:38 -0500, 
>>  François Pinard <[EMAIL PROTECTED]> wrote:
> 
> 
>>>It's a relatively recent phenomenon that maintainers go berzerk, foaming 
>>>at the mouth over forms, borders, colors, and various other mania!  :-)
> 
> 
>>It's largely to ensure that the ideas aren't lost.  E-mail sits around
>>in an inbox until it gets deliberately deleted or gets lost in a disk
>>crash or system upgrade gone wrong.
> 
> 
> Or sorted properly by the recipient, the way he sees best fit, in the 
> tracker of his own choice.
> 
> I know I'm repeating myself, but my point just does not seem to get 
> through.  The maintainer should manage his way as a grown up, instead of 
> expecting the world to learn his ways and manage in his place.
> 
> 
>>You may suggest that I should process my e-mail more promptly.
> 
> 
> No, I'm not suggesting you how to work, no more that I would accept that 
> you force me into working your way.  If any of us wants to force the 
> other to speak through robots, that one is not far from unspeakable...
> 
> 
>>If the message was important, they'll resend it.
> 
> 
> This is despising contributions.  If someone sends me a message which 
> I find important, I do take means so that message does not get lost, and 
> that it will even suvive me for some while.
> 
> 
>>This is why things need to go into public trackers, or wiki pages.
> 
> 
> Whatever means the maintainer wants to fill his preservation needs, he 
> is free to use them.  The problem arises when the maintainer wants 
> imposing his own work methods on others.  Let contributors be merely
> contributors, and learn how to recognise contributions as such and say 
> thank you, instead of trying to turn contributors into maintainers.
> 
François, you talk of "the maintainer" as though each piece of code is 
owned by a single individual. In Python's case this is far from the truth.

So, what you say *seems* to equate to "If there's a problem with Python 
that I think should be fixed, I should be able to mail the person I 
suspect is most likely to maintain that code, and they should be obliged 
to log the bug or enhancement request in the tracking system".

There's also a philosophical question here about who is helping who. One 
might choose to believe that the contributor is assisting the developer, 
by pointing out a defect in the developer's code. One might 
alternatively regard the contributor as a supplicant, who needs the 
assistance of the developer to get a problem fixed. Finally one might 
regard the contributor (who benefits from having Python available) and 
the developer (who gets the kudos of having developed something "cool") 
to be members of a community, prepared to collaborate to achieve 
something that benefits them both.

In the real world people's opinions will have all kinds of other shades 
as well, of course, but as far as *I'm* concerned, if the developers say 
"please contribute bug reports through Sourceforge" then I am happy to 
do so to make sure they don't fall between the cracks and get lost. YMMV.

Obviously the developers are in charge here, but I really don't see how 
putting more load on them by requiring them to collectively be the only 
sources of bug input to the tracking system will help get more work out 
of them.

If you wanted to build a better tracking system than the one on 
SourceForge I could certainly support that, but historically there 
hasn't been much volunteer effort available to switch to something like 
Roundup which might be preferred.

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

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes:
> But lately I have been wondering about doing the following:
> end = None
> ...
>   if ...:
> ...
>   end
> IMO it looks better, but I'm reluctant because it suggest
> some checking by the compilor, which just doesn't happen.

I don't think you can always do that.

try:
  ...
end
except blah:
   ...

looks syntactically invalid.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Force Focus in Tkinter

2005-12-07 Thread Steve Holden
annagel wrote:
> Thanks for the reply and as it turns out no I don't think I really do
> want to do this.  I started working with tkinter after banging my head
> against the wall for a while with wxwindows so the whole thing ended up
> being a last minute change so I am trying to get most at least of the
> bugs out on a tighter scedule than I planned.  Basically coming from wx
> I had it in my head that I had to call a main loop or nothing would
> work and this meant threads which meant all kinds of extra headaches.
> In my desperation I dropped the whole thing and just started opening
> windows and to my utter suprise it worked.
> 
It may well be that you will need to use threads anyway, I'm afraid - 
ultimately if you want computation to keep on happening while the GUI 
remains responsive then it's almost a requirement. However, it's easier 
to make a start when you are actually seeing windows appear on the 
screen, so I'm glad you are making progress.

> Now I just initialize a root window in my import statement withdraw it
> and let the user use a picture viewer I made with a toplevel window, a
> file chooser, folder chooser, and color chooser.  I am still having a
> couple problems though if anyone out there can shed some light I would
> be apreciative.  First the ColorChooser for some reason this dialog
> does not open on its own.  I am running on Mac and calling it gets my
> python icon bouncing but it does not appear till I go click on the
> icon.  Second I am getting phantom window return with the folder and
> file picker.  If I have used one of these before showing the picture
> viewer and then pop that up when I click on the picture window I also
> get the most recent file dialog (filenameopen or directoryopen) as an
> unresponsive window.
> 
It's probable that you are failing to destroy some widget after use, but 
that's about as much as I can say at present.

> Any advice on either of those problems would be great.  Sorry about the
> intial post in my head I knew doing something like that would just be
> evil, but you start to think crazy when your sollution is too
> complicated for the problem.
> 
As Martin has indicated, more detail in the form of code will be 
necessary to investigate specific problems like that.

In practice the choice between Tkinter and wxPython, PyGtk and the like 
is often either a religious issue or a choice based on the first tool 
that could be manipulated to providing the required results. Ideally you 
want to structure your program so that the GUI can be changed without 
too much effect on the rest of the logic, though that's often easier 
said than done.

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

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


Re: Documentation suggestions

2005-12-07 Thread Fredrik Lundh
A.M. Kuchling wrote:

> > I've proposed adding support for semi-automatic linking to external
> > documents, based on a simple tagging model, a couple of times, e.g.
> >
> > http://mail.python.org/pipermail/python-list/2005-May/280751.html
>
> Very interesting.  There could be a manually-maintained list of feed
> URLs stored in a file in the Doc/ subdirectory.  That way, anyone with
> Python SVN access could add a feed, and it's not trapped in some
> database on python.org that half the pydotorg group doesn't know
> about.
>
> A Makefile target could then update the list of available examples,
> and check timestamps to only update the list every 24 hours or so,
> avoiding hitting the feeds every time you do "make lib".  Fred Drake
> would have some "make updatefeed" target for forcing an update when he
> makes the release tarballs.

exactly.

> ISTM getting the example into the HTML is the hard bit.  Maybe the
> simplest solution is to put
>
> % start auto-feeds
> % end auto-feeds
>
> into LaTeX source files, and have a script insert the examples between
> the markers with the right LaTeX markup.

or just add a marker (in some for me unknown way), and postprocess
the HTML files.  I'm not sure the links does necessarily belong in e.g.
PDF renderings of the documentation, but that's of course up to the
documentation maintainers.

> Hm, but then 'svn diff' will show lots of changes.  Maybe an '\input
> -examples could be used instead, storing the examples in a
> separate file.  Something like
> '\InputFileExists{examples/select.tex}'...  Having some examples be
> for'atexit' and some specifically for 'atexit.register' seems
> difficult with this approach.

linking on module level only should definitely be good enough for a first
iteration.

> Assembling a patch for this would make an interesting evening's
> project.

if anyone wants some data to play with, I've posted a simple seealso file
here:

http://effbot.org/librarybook/seealso.xml





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


Re: Documentation suggestions

2005-12-07 Thread Steve Holden
BartlebyScrivener wrote:
> You are correct about the tutorial. Just try to look at the home page
> through the eyes of a curious Windows user who wants to learn
> programming and is trying to decide whether to take up Perl, Ruby,
> Python, or Visual Basic, let's say.
> 
> On the home page, the first link that catches the eye for this user is:
> "Beginner's Guide to Programming -  start here if you're new to
> programming ." That's me. Click.
> 
> Now you are on a page with promising-looking links that all start with
> "BeginnersGuide," but the first three are not warm welcomes, they are
> housekeeping matters about where you can take courses or how to
> download Python for people who don't know whether they want to or not
> yet, or there's one that says "examples" which will take you to the
> ActiveState Cookbook site so you can get really confused.
> 
> Then you hit the link that says "BeginnersGuide/Nonprogrammers" Ah!
> That's me. 
> 
> The first prominent link says: "Python Tutorial" along with a notice at
> the top of the page that tells you if you've never programmed before
> this is the page for you.
> 
> Click on Python Tutorial. Some official business to start off. Then you
> see, "Whetting Your Appetite" Ah, I am ready for that. 
> 
> The first sentence reads:
> 
> "If you ever wrote a large shell script, you probably know this
> feeling: you'd love to add yet another feature, but it's already so
> slow, and so big, and so complicated; or the feature involves a system
> call or other function that is only accessible from C ...Usually the
> problem at hand isn't serious enough to warrant rewriting the script in
> C; perhaps the problem requires variable-length strings or other data
> types (like sorted lists of file names) that are easy in the shell but
> lots of work to implement in C, or perhaps you're not sufficiently
> familiar with C."
> 
> Most of the site has been laid out by programmers, for programmers, who
> apparently want to keep it that way, based upon what I've seen.
> 
I think the Python community as a whole should take this on board as 
fair criticism. It would be really nice if a total beginner did actually 
see a usable path through the web to their first working Python program.

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

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Christophe
Paul Rubin a écrit :
> Antoon Pardon <[EMAIL PROTECTED]> writes:
> 
>>But lately I have been wondering about doing the following:
>>end = None
>>...
>>  if ...:
>>...
>>  end
>>IMO it looks better, but I'm reluctant because it suggest
>>some checking by the compilor, which just doesn't happen.
> 
> 
> I don't think you can always do that.
> 
> try:
>   ...
> end
> except blah:
>...
> 
> looks syntactically invalid.

You shouldn't put "end" before the except but after :

try:
   ...
except blah:
   ...
end
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help on designing a project

2005-12-07 Thread Magnus Lycka
Mardy wrote:
> This works, but my problem is that SQL connections (MySQL or sqlite) don't
> get closed when the script execution finishes, and at the next execution
> of a CGI they may lock the database (this is especially true with sqlite,
> but even mysql on Windows gave me these problems).

You should know that there is a severe performance penalty in
opening and closing database onnections. I actually did a
measurement on something similar yesterday, and with open/close
with each database operation, I got 50 operations per second.
If I only opened and closed once, I could manage 1000 operations
per second.

You might want to have a look at something like
http://sqlrelay.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Ben Sizer
Antoon Pardon wrote:
> Op 2005-12-06, Ben Sizer schreef <[EMAIL PROTECTED]>:
> > Of course. However I would argue that indented scope is one way of
> > doing so. Scope is instantly visible, and no longer a game of 'hunt the
> > punctuation character, which is in a different place depending on the
> > coder's style'.
>
> There are situations in which indentation is not that visible.
>
> The problem is that situations arise where your code can't be
> read continuously. e.g. it can be spread over pages in a book.

Write shorter functions ;)

> Other situations arise where indentation alone isn't a clear
> indication of how many scopes are left.

No, but I find it's only a tiny bit worse than in C++/Java, where I
usually find myself adding a comment at the end of a block anyway, just
so that I remember what exactly is coming to an end at that point.
(Although again, this might be telling me that my function is too big.)
That transfers to Python where necessary.

-- 
Ben Sizer

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Antoon Pardon
Op 2005-12-07, Paul Rubin schreef :
> Antoon Pardon <[EMAIL PROTECTED]> writes:
>> But lately I have been wondering about doing the following:
>> end = None
>> ...
>>   if ...:
>> ...
>>   end
>> IMO it looks better, but I'm reluctant because it suggest
>> some checking by the compilor, which just doesn't happen.
>
> I don't think you can always do that.
>
> try:
>   ...
> end
> except blah:
>...

IMO this is the wrong way to use end.

end should be used to mark the end of a compound statement,
not the end of a suite. If a suite ending is already clear
because the next clause of the compound statement is beginning,
we don't need an extra marker to make that clear.

So the above should be:

  try:
...
  except blah:
...
  end

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


Re: windows installer problems

2005-12-07 Thread saxicek
Thanks for help, I tried to install ActivePerl and have the same
problem so there's probably something wrong with the windows installer.
Unfortunatelly I wasn't able to find out where is the problem from log
file so I'll try to upgrade installer - the windows server installation
is quite old and not updated. :-(

sax

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


Re: XML and namespaces

2005-12-07 Thread Fredrik Lundh
Alan Kennedy wrote:

> [Fredrik Lundh]
> > but isn't libxml2dom just a binding for libxml2?  as I mention above, I had 
> > libxml2
> > in mind when I wrote "widely used", not the libxml2dom binding itself.
>
> No, libxml2dom is Paul Boddie's DOM API compatibility layer on top of
> the cpython bindings for libxml2.

So a binding that just passes things through to another binding is not
a binding?  Alright, let's call it a compatibility layer then.

> > but libxml2 is also widely used, so we have at least two ways to
> > interpret the spec.
>
> Don't confuse libxml2dom with libxml2.

As Paul has said several times, libxml2dom is just a thin API compatibility
layer on top of libxml2.  It's libxml2 that does all the work, and the libxml2
authors claim that libxml2 implements the DOM level 2 document model,
but with a different API.

Maybe they're wrong, but wasn't the whole point of this subthread that
different developers have interpreted the specification in different ways ?





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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Antoon Pardon
Op 2005-12-07, Ben Sizer schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2005-12-06, Ben Sizer schreef <[EMAIL PROTECTED]>:
>> > Of course. However I would argue that indented scope is one way of
>> > doing so. Scope is instantly visible, and no longer a game of 'hunt the
>> > punctuation character, which is in a different place depending on the
>> > coder's style'.
>>
>> There are situations in which indentation is not that visible.
>>
>> The problem is that situations arise where your code can't be
>> read continuously. e.g. it can be spread over pages in a book.
>
> Write shorter functions ;)

This has little to do with long functions. A class can contain
a large number of methods, whitch are all rather short, and your
class will still be spread over several pages.

>> Other situations arise where indentation alone isn't a clear
>> indication of how many scopes are left.
>
> No, but I find it's only a tiny bit worse than in C++/Java, where I
> usually find myself adding a comment at the end of a block anyway, just
> so that I remember what exactly is coming to an end at that point.
> (Although again, this might be telling me that my function is too big.)
> That transfers to Python where necessary.

The fact that your function might be too long, doesn't change that
a proper end marker can make the structure of your program more
clearer for those reading the code.

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


Re: dynamic variable referencing

2005-12-07 Thread bruno at modulix
Michael Williams wrote:
> I would RTM, but I'm not sure exactly what to look for.  Basically, I 
> need to be able to call a variable dynamically.  Meaning something  like
> the following:
> 
> -  I don't want to say OBJECT.VAR  but rather 
> OBJECT. ("string")  and have it retrieve the variable (not the value
> of  it) if in fact it exists. . .

getattr(obj, 'name', defaultvalue)

You can also implement the special methods __getitem__ and __setitem__
to allow indexed access to attributes, ie:

class FalseDict(object):
  def __init__(self, toto, tata):
 self.toto = toto
 self.tata = tata
  def __getitem__(self, name):
 return getattr(self, name)
  def __setitem__(self, name, value):
 setattr(self, name, value)

f = FalseDict('toto', 'tata')
f['toto']
f['tata'] = 42

> 
> The purpose is to create an XML tree myself 

Don't reinvent the wheel. ElementTree (and it's C based brother) are
very good at this.

-- 
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: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steven D'Aprano
On Tue, 06 Dec 2005 00:33:17 +0100, Fredrik Lundh wrote:

> Sybren Stuvel wrote:
> 
>> def somefunc(x): return x*5
>>
>> How is that a multi-line function definition?
> 
> but that's namespace pollution! if you do this, nobody will never ever be
> able to use the name somefunc again! won't somebody please think about
> the children!

All joking aside, when I have names (temporary variables or scaffolding
functions) that I need to initialise a module or data structure, but then
outlive their usefulness, I del the name afterwards. Am I the only one? I
can't say I've seen anyone else doing that, and it feels icky to me (for
no reason I can put my finger on) -- what do others think?



-- 
Steven.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Antoon Pardon
Op 2005-12-07, Christophe schreef <[EMAIL PROTECTED]>:
> Paul Rubin a écrit :
>> Antoon Pardon <[EMAIL PROTECTED]> writes:
>> 
>>>But lately I have been wondering about doing the following:
>>>end = None
>>>...
>>>  if ...:
>>>...
>>>  end
>>>IMO it looks better, but I'm reluctant because it suggest
>>>some checking by the compilor, which just doesn't happen.
>> 
>> 
>> I don't think you can always do that.
>> 
>> try:
>>   ...
>> end
>> except blah:
>>...
>> 
>> looks syntactically invalid.
>
> You shouldn't put "end" before the except but after :
>
> try:
>...
> except blah:
>...
> end

What I was wondering about. Some year back  or longer someone
suggested a module he had written could help those who like
end markers.

He had written a function 'end' you could use as follows and
that would check if it ended the right block.

  if ...:
...
  end('if')

Can anyone recall? I have tried google to find it back, but
no luck. A pointer would be much appreciated.

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


Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Sybren Stuvel
Steven D'Aprano enlightened us with:
> All joking aside, when I have names (temporary variables or
> scaffolding functions) that I need to initialise a module or data
> structure, but then outlive their usefulness, I del the name
> afterwards. Am I the only one?

I don't do that. I tend to split up my code into pretty small
functions, so the temporary names I use have a small scope as is. I
don't see the need to add extra 'del' commands when the 'return' five
lines further down is going to do the same.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Antoon Pardon
Op 2005-12-07, Steven D'Aprano schreef <[EMAIL PROTECTED]>:
> On Tue, 06 Dec 2005 00:33:17 +0100, Fredrik Lundh wrote:
>
>> Sybren Stuvel wrote:
>> 
>>> def somefunc(x): return x*5
>>>
>>> How is that a multi-line function definition?
>> 
>> but that's namespace pollution! if you do this, nobody will never ever be
>> able to use the name somefunc again! won't somebody please think about
>> the children!
>
> All joking aside, when I have names (temporary variables or scaffolding
> functions) that I need to initialise a module or data structure, but then
> outlive their usefulness, I del the name afterwards. Am I the only one? I
> can't say I've seen anyone else doing that, and it feels icky to me (for
> no reason I can put my finger on) -- what do others think?

Well I don't do it, but it has bothered me. The direction I'm thinking
of right now is doing all such initialisation within an initialisation
function, all temporary variables or scaffolding functions, defined
in that function will disappear automatically when the function has
done its job.

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


Re: Wrapping method calls with metaclasses

2005-12-07 Thread Lawrence Oluyede
Il 2005-12-07, Alex Martelli <[EMAIL PROTECTED]> ha scritto:
> I can't reproduce the infinite recursion you observe, by merging said
> recipe and your definition of class Test, w/Python 2.4.2 on Mac OS 10.4.

It seemed that the problem arose because I was not using super() in a new
style class based hierarchy.

class Test(object):
__metaclass__ = LogTheMethods
logMatch = '.*'

def __init__(self, foo):
self.foo = foo

def test(self):
return "test"

class TestChild(Test):
def __init__(self):
# with super this works
Test.__init__(self, "foo")

def test(self):
return "child"

d = {'test': Test,
 'child': TestChild}

class MainTest(object):
__metaclass__ = LogTheMethods
logMatch = '.*'

def create_test(self, key):
return d[key]()

if __name__ == '__main__':
l = MainTest()
print l.create_test("child").test()


look in TestChild's __init__(). Not using super() fails with a 

"""
  File "/home/rhymes/downloads/simple_logger.py", line 55, in __init__
Test.__init__(self, "foo")
  File "/home/rhymes/downloads/simple_logger.py", line 24, in _method
returnval = getattr(self,'_H_%s' % methodname)(*argl,**argd)
TypeError: __init__() takes exactly 1 argument (2 given)
"""

In my project I'm doing deeply nested recursion things and it exceeds the
maximum recursion limit for this problem this way.

I don't get to fully work the metaclass anyway for other weird reasons
(using super() I lose an attribute around?!)  I'm gonna fix this.


-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: pygene - genetic algorithms package

2005-12-07 Thread aum
On Tue, 06 Dec 2005 22:44:39 -0800, Erik Max Francis wrote:

> Peter Hansen wrote:
> 
>> Okay, good, I already knew all that then, except perhaps that key word 
>> "fixed".

One thing I should say here is that pygene is a collection of
inter-related classes for populations, organisms, gametes and genes.

Users are encouraged to subclass off these to address the
problems they're trying to solve.

For instance, the BaseGene class is completely agnostic about the actual
data contained in the gene. Any BaseGene subclass only has to implement
the methods:
 - __add__ - produce phenotype effect of combining a given gene pair
 - mutate - apply a random mutation to the gene
 - randomValue - set the gene's value to a legal random value

As for the gene's value - as long as the above 3 methods are supplied in a
subclass, the gene can hold any object - just as long as one's Organism
subclass' '.fitness()' method can understand what the gene class'
'.__add__()' method returns.

A Gene subclass could even hold an AST for a program to be generated.

It wasn't my original intention to support genetic programming, but in
theory at least, pygene could be extended into a GP system.

Hmm, it's tempting to try a bit of GP, perhaps initially generating
code for a tiny language like BrainFuck, then work up to Forth, Factor and
beyond.

-- 

Cheers
aum


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


Re: hash()

2005-12-07 Thread Steven D'Aprano
On Tue, 06 Dec 2005 15:44:07 +, John Marshall wrote:

> The goal is to be able to keep some meta-data
> for each file/directory of a directory hierarchy
> in a separate directory: one meta-data file per
> file/directory. 

So you are planning on shadowing the entire file system with a single
massive directory? Ouch.

Off the top of my head, you could try shadowing the directory tree:

root
+---directory1
+   +---file1
+   +---file2
+---directory2
+   +---file1
+---+SHADOW-METADATA
+   +---directory1-METADATA
+   +   +---file1-METADATA
+   +   +---file2-METADATA
+   +---directory2-METADATA
+   +   +---file1-METADATA

Then given a pathname, something like this should point to the metadata:

# not tested
def path_realtometa(path):
"""Given a pathname, return the pathname of the metadata."""
if "SHADOW-METADATA" in path:
raise ValueError("Can't shadow a metadata pathname.")
return "SHADOW-METADATA/"+path

I dare say there are complications I haven't thought of, but there are
three major advantages:

- the metadata system is human friendly and not opaque. Your users can
easily clear out dead links, which is difficult to do with the Gnome and
KDE metadata systems.

- your users won't curse the day you were born if they open your metadata
directory with a GUI file manager like Nautilus, as I have done to the
Gnome developers. (Sorry guys, but didn't you ever test Nautilus with a
directory containing 20,000+ thumbnail files?)

- no collisions. 


-- 
Steven.

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


Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steven D'Aprano
On Mon, 05 Dec 2005 19:31:46 -0800, bonono wrote:

> 
> Paul Rubin wrote:
>> > Why use temporary variables when all you have to do is make your
>> > expressions three lines long to avoid "polluting the namespace"?
>>
>> Indeed.  I'd much rather say
>>
>>   x = a + b + (c * d) + e
>>
>> than
>>
>>   temp1 = a + b
>>   temp2 = c * d
>>   temp3 = temp1 + temp2
>>   x = temp3 + e
>>
>> I don't understand why the critics of lambda don't understand that
>> having to use so many temp variables, for either numbers or functions,
>> can work against both concision and clarity.
> 
> For some people, the second form is clearer.

If anybody needs to break an expression with three short terms up into
individual temporary variables in order to understand it, then I suggest
they should re-think their career choice as a programmer.

Having said that, there are some expressions which are sufficiently
complex that they do need to be broken up into smaller pieces. In which
case, you *should* be naming the pieces, and not trying to shoe-horn them
into a one-liner.



-- 
Steven.

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


Re: Wrapping method calls with metaclasses

2005-12-07 Thread Lawrence Oluyede
Il 2005-12-07, Lawrence Oluyede <[EMAIL PROTECTED]> ha scritto:
> I don't get to fully work the metaclass anyway for other weird reasons
> (using super() I lose an attribute around?!)  I'm gonna fix this.

It was a bug of one of the super() in the chain.
Still suffer from deep recursion limit error with that metaclass.
Keep trying.


-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SNMPV3

2005-12-07 Thread Frithiof Andreas Jensen

"Jacek Pop³awski" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Do you have any experience with Python in SNMPv3 area?

SNMP suck per design and SNMPv3 suck even more by adding complexity to that
design IMO.

SNMPv2 sort of works well within the limits of the design of SNMP, so that
is what I would use.

The main difference between SNMPv2 and SNMPv3 is that v3 comes with a
self-contained security system with it's own rules/tools &
yet-another-set-of-credencials-to-control. If you do not need the security,
SNMPv2 will work fine, and you don't need it because you will not change
anything via SNMP anyway.

> I just realized that pySNMP we are using supports only v1 and v2c,
> development version probably supports SNMPv3 but I am unable to find any
>   v3-specific documentation, could you help me?

Not really - I have deployed SNMPv3 in a demo network and gotten a
management system based on SNMPv2 & SNMPv3 to work. This was a long lesson
in how things that are broken by design will remain broken forever.

So, I would not worry about it; informs, polling and probing can be done
adequately with SNMPv2. Most tools do not bother with SNMPv3 either.

Changing configurations by "setting" parameters cannot be made reliable with
SNMP so there is no need for SNMPv3's security features (which are
complicated in themselves and a real pain to manage, probably impossibly so
for more than a few access levels on very few nodes).

SNMPv3 Informs are the worst part: They must be authenticated, which means
that the Username and engineID the trap is sent from must be registered with
the Informsink or the Inform cannot be received. I.O.W: A SMURF attack on
the configuration of the management station (and the manager, who has to
collect/create engineID's manually).


> Is there any other solution than pySNMP?

Well, netconf is working it's way through IETF:
http://www.ietf.org/html.charters/netconf-charter.html ;-) Netconf on top of
XML-RPC would be very Pythonic.

It looks like they got most things right this time - especially the parts
about netconf NOT being self-contained so one can build on already-deployed
and debugged protocols and standards!!


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

Re: Wrapping method calls with metaclasses

2005-12-07 Thread Peter Otten
Lawrence Oluyede wrote:

> look in TestChild's __init__(). Not using super() fails with a
> 
> """
> File "/home/rhymes/downloads/simple_logger.py", line 55, in __init__
> Test.__init__(self, "foo")
> File "/home/rhymes/downloads/simple_logger.py", line 24, in _method
> returnval = getattr(self,'_H_%s' % methodname)(*argl,**argd)
> TypeError: __init__() takes exactly 1 argument (2 given)
> """

The problem with the recipe seems to be that the mangled _H_XXX() method is
always looked up in the child class. One fix may be to store the original
method in the wrapper instead of the class:

def logmethod(methodname, method):
def _method(self,*argl,**argd):
global indent

#parse the arguments and create a string representation
args = []
for item in argl:
args.append('%s' % str(item))
for key,item in argd.items():
args.append('%s=%s' % (key,str(item)))
argstr = ','.join(args)
print >> log,"%s%s.%s(%s) " %
(indStr*indent,str(self),methodname,argstr)
indent += 1
# do the actual method call
returnval = method(self, *argl,**argd)
indent -= 1
print >> log,'%s:'% (indStr*indent), str(returnval)
return returnval

return _method


class LogTheMethods(type):
def __new__(cls,classname,bases,classdict):
logmatch = re.compile(classdict.get('logMatch','.*'))

for attr,item in classdict.items():
if callable(item) and logmatch.match(attr):
classdict[attr] = logmethod(attr, item) # replace method by
wrapper

return type.__new__(cls,classname,bases,classdict)
 
Be warned that I did not thoroughly test that.

Peter

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


Re: Bitching about the documentation...

2005-12-07 Thread Steven D'Aprano
On Mon, 05 Dec 2005 19:36:58 -0800, BartlebyScrivener wrote:

> Well, that might be asking a bit too much of the programmers, who
> perhaps don't exactly enjoy mucking about in the lowlands of English
> grammar and syntax.

Oh come on now! For the kinds of minds who enjoy obfuscated C or Perl,
English is just par for the course.

One of my favourite examples of obfuscated English is this grammatically
correct sentence:

"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo."

And they say English is a hard language to understand :-)

On the other hand, for programmers who don't like obfuscated anything,
English can be as precise and elegant as anything in Lisp or Python. Treat
English as a programming language: learn the rules of syntax and grammar,
and read examples of master writers to learn the best idioms, and you
can't go wrong.

But if you try to learn English from Usenet... *shudders*


-- 
Steven.

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


Re: Bitching about the documentation...

2005-12-07 Thread Fredrik Lundh
Steven D'Aprano wrote:

> "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo."

Did you mean: Badger badger Badger badger badger badger Badger badger Mushroom! 
Mushroom!





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


ElementTree - Why not part of the core?

2005-12-07 Thread doug . bromley
Why is the ElementTree API not a part of the Python core?
I've recently been developing a script for accessing the Miva API only
to find all the core API's provided by Python for parsing XML is messy
and complicated.  Many of the examples I see for parsing the data using
these API's uses a similar additional Class for collapsing the XML data
into a more manageable format.
This is clearly not following the Python-way of clean, simple code and
easy development.

ElementTree on the other hand provides incredibly easy access to XML
elements and works in a more Pythonic way.  Why has the API not been
included in the Python core?

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


Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Steve Holden
Steven D'Aprano wrote:
[...]
> All joking aside, when I have names (temporary variables or scaffolding
> functions) that I need to initialise a module or data structure, but then
> outlive their usefulness, I del the name afterwards. Am I the only one? I
> can't say I've seen anyone else doing that, and it feels icky to me (for
> no reason I can put my finger on) -- what do others think?
> 
I don't generally speaking see the point: unless the name is referencing 
something potentially large (like the results of a database query) and 
won't be going out of scope soon (which typically happens at the end of 
the current method or function) I just leave it to happen automatically. 
If it doesn't happen (because the name exists at module scope) thwn what 
the heck.

You must be some kind of Python neatnik! If I need the external 
appearance of a module to be tidy I just use __all__.

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

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


Re: Bitching about the documentation...

2005-12-07 Thread Steven D'Aprano
On Mon, 05 Dec 2005 21:05:46 -0800, rurpy wrote:

> If one is required to buy a book to use free software, 

One is *not* required to buy a book to use free software. It isn't
compulsory.

> it is not really free, is it?

What part of "you may use this FREE software for FREE" is too difficult
for you to understand?

If you want to calculate the total cost of ownership for (say) using
Python, then by all means include the cost of labour, electricity to run
your computer, depreciation on that computer, courses to learn how to
program, etc. All these are valid costs.

But none of them are the cost of Python, which is free. It really isn't a
scam, nobody is going to come knocking at your door with a surprise bill
for using Python.



-- 
Steven.

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


Re: Python riddle

2005-12-07 Thread Steven D'Aprano
On Mon, 05 Dec 2005 22:58:42 -0800, Dan Bishop wrote:

 class CapOutput:
> ...def __init__(self, fileobj):
> ...   self._file = fileobj
> ...def write(self, text):
> ...   self._file.write(text.capitalize())
> ...
 sys.stdout = CapOutput(sys.stdout)
 print 'why?'
> Why?


That's ... brilliant. Brilliant and evil.

But mostly evil.


*grin*


-- 
Steven.

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


Re: Calculating Elapsed Time

2005-12-07 Thread malv
"Note that even though the time is always returned as a floating point
number, not all systems provide time with a better precision than 1
second." says the doc.
Can anything be said about precision if indeed your system returns
figures after the decimal point?
Thx.
malv

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


Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
> > All joking aside, when I have names (temporary variables or scaffolding
> > functions) that I need to initialise a module or data structure, but then
> > outlive their usefulness, I del the name afterwards. Am I the only one? I
> > can't say I've seen anyone else doing that, and it feels icky to me (for
> > no reason I can put my finger on) -- what do others think?

I do that too sometimes.  I think it's a Python weakness that you
can't declare a local var like in other languages, to go out of scope
at the end of the current block, e.g.:

  if cond:
my x = 7# make a new scope for x, goes out of scope at end of if

> I don't generally speaking see the point: unless the name is
> referencing something potentially large (like the results of a
> database query) and won't be going out of scope soon (which typically
> happens at the end of the current method or function) I just leave it
> to happen automatically. If it doesn't happen (because the name exists
> at module scope) thwn what the heck.

Well, that makes the code a little bit confusing.  If you say

   x = some_intermediate_result(...)
   do_something_with (x)

do you know for sure whether x will be needed again?  Are you sure you
didn't use the name x further up in the function for something that's
still needed?

This is one of the areas where there's tension between Python the
scripting language, that gains by saving a few keystrokes when
throwing together a quick hack, and Python the language for developing
long-lasting applications that have to be maintained by multiple people.

In Haskell you can even have temporary variables inside an expression:

   x = y + y*y + 3 where y=5

sets x to 33.  I believe (not absolutely sure) that the scope of y is
limited to that expression.
-- 
http://mail.python.org/mailman/listinfo/python-list


A more dynamic Python Library Reference index

2005-12-07 Thread Skip Montanaro

I broke down and wrote a dynamic global module index for the Python library
reference manual last night using Myghty.  It's something I've wanted for
quite awhile and as I'm just learning to use Myghty I thought it would be a
good tool to experiment with (better I think than Moin, which was my
original thought).  At any rate, it's available on a trial basis at

http://staging.musi-cal.com/modindex/

The idea is that it fetches and caches the the global module index from

http://www.python.org/dev/doc/devel/modindex.html

(note: that's the development version of the libref manual global index) and
rewrites most links to feed through a hit counter/redirector.  When the
above module index page is requested, it displays the 20 most frequently
requested modules at the top of the page.

Give it a try and let me know what you think.

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


zipfile and soft links

2005-12-07 Thread Jim
Hello,

I'm trying to unzip archives  that have soft links in them (that is,
were created on unix with a -y option).  I'm not finding that ZipFile
will do that.  That I can see, it creates the link file, and that file
has the right contents, but it is not a soft link in the directory
structure.  (I've both tested it interactively and looked at the
zipfile.py source, and didn't see the behaviour in either place.)

If I have that wrong, I'd greatly appreciate it if some kind soul could
correct me.

If it does not do soft links, I wonder if someone has tried patching
it?  That I can see the specs are on the web, at
ftp://ftp.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip , so I
wondered if someone who is a better programmer than I (not hard!) had
already done it.  The alternative is to shell out, which happens to be
quite involved in the context that I am using (e.g., what if the soft
link is to '/bin/ls' ?).

Thanks,
Jim Hefferon

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Steven D'Aprano
On Mon, 05 Dec 2005 05:16:04 -0800, JohnBMudd wrote:

> From "The Design of Everyday Things", docs are a sign of poor design.
> Even a single word, such as the word "Push" on the face of a door, is
> an indication that the design can be improved.

I find it ironic that you are using a book that documents design
principles as evidence that using documentation is an indication of poor
design.

-- 
Steven.

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


Re: Documentation suggestions

2005-12-07 Thread skip

Adam> I don't expect everything to make the transition.  Are discussions
Adam> of "atoms" and fragments of BNF really better than calling them
Adam> expressions and linking to CPython's Grammar file?

Actually, yes.  The actual Grammar file isn't designed for explanation
(mostly it's more complex, but it also has extra productions) and is
somewhat (maybe a lot) different than the BNF in the ref manual.

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


Re: Bitching about the documentation...

2005-12-07 Thread skip

>> This is why things need to go into public trackers, or wiki pages.

François> Whatever means the maintainer wants to fill his preservation
François> needs, he is free to use them.  The problem arises when the
François> maintainer wants imposing his own work methods on others.

François, that's not it at all.  It's not our fault that SF doesn't support
email-based tracker interaction.  It's our fault that we chose SF, but it
was the best overall choice at the time (there were more considerations than
just bug tracking) and now we're sort of stuck with it because for a number
of reasons we've been unable to move away from it.

Here's the scenario we have to use today to collect emailed requests and put
them in SF:

* Kind user notices a problem and posts a message somewhere, maybe to c.l.py
  or to another Python-related list or by direct email to a developer.

* Someone - maybe nobody, but maybe more than one person - notices the
  request and thinks, "better add that to SF so it doesn't get lost".

* That person visits SF and submits a ticket.

Now, consider some of the problems this scheme is fraught with:

* Maybe nobody notices it at all.  It might have been buried deep in another
  thread that no Python developer happened to read in its entirety.  Bummer.
  It's been lost until the next time someone notices and posts a similar
  request.

* Maybe more than one person notices.  Bummer.  Now we have duplicates.
  Worse yet, some might have been posted as feature requests, some as bug
  reports.  It also may not be obvious that they are duplicate without
  careful checking.

* The multiple reports might contain different useful perspectives on the
  problem.  Bummer.  SF doesn't allow you to easily merge two requests.  You
  have to manually transfer the information from one to the other and close
  the one.

* Maybe the original post generates further responses in that venue that
  would have been useful to have with the original report.  Most will
  probably never find their way to the tracker.  Bummer.  They got lost.

* Maybe the original requester's email gets missed in the process (or the
  problem isn't addressed immediately and the user has discarded the
  original address because it's spammed so heavily and moved on to a new
  one) and the Python developers need more info but they can't contact the
  requester.  Bummer.  The problem isn't adequately addressed.

* Finally, instead of one person spending a couple minutes submitting a
  report, several people will have spent their volunteer time, and there's a
  good chance that the report is not any better (perhaps even worse) than if
  the original requester had simply submitted the request directly to SF.

I know, we have to take these steps occasion.  When bug reports have to be
moved from another tracker to the Python tracker some of these issues arise.
We've incorportated bug reports from the Debian bug tracker that way and
have migrated python-mode requests from the Python project to the
python-mode project (both on SF).  It can be a pain.

The Python developers are not being lazy.  I would love it if there was an
email interaction mode with the SF trackers, but there isn't.  I'll repeat
what I wrote yesterday in response to an earlier message in this thread:

I wish either a) SourceForge supported email interaction with their
trackers or b) someone would finish off the Roundup issue tracker
 for python.org.  I doubt if anyone
here can do anything about the first barrier, but if you know something
about Roundup (or would like to learn about it) and would like to
contribute something non-documentational that would really have a
direct, positive impact on the Python community, send a note to
[EMAIL PROTECTED]

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


Re: Documentation suggestions

2005-12-07 Thread Iain King
> The library reference has so many modules that the table of contents
> is very large.  Again, not really a problem that we can fix; splitting
> it up into separate manuals doesn't seem like it would help.

I like the Global Module Index in general - it allows quick access to
exactly what I want.
I would like a minor change to it though - stop words starting with a
given letter rolling over to another column (for example, os.path is at
the foot of one column, while ossaudiodev is at the head of the next),
and provide links to each initial letter at the top of the page.

Iain

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


Re: Bitching about the documentation...

2005-12-07 Thread Simon Brunning
On 12/7/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> But none of them are the cost of Python, which is free. It really isn't a
> scam, nobody is going to come knocking at your door with a surprise bill
> for using Python.

Well, there is the PSU's "Spanish Inquisition" division. Last week
they barged into my office, quite unexpectedly, armed with cushions
and
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread skip

>> The library reference has so many modules that the table of contents
>> is very large.  Again, not really a problem that we can fix;
>> splitting it up into separate manuals doesn't seem like it would
>> help.

Iain> I like the Global Module Index in general - it allows quick access
Iain> to exactly what I want.  I would like a minor change to it though
Iain> - stop words starting with a given letter rolling over to another
Iain> column (for example, os.path is at the foot of one column, while
Iain> ossaudiodev is at the head of the next), and provide links to each
Iain> initial letter at the top of the page.

I know it's not what you asked for, but give

http://staging.musi-cal.com/modindex/

a try.  See if by dynamically migrating the most frequently requested
modules to the front of the section it becomes more manageable.

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


Re: option argument length

2005-12-07 Thread Ritesh Raj Sarraf
On Tue, 6 Dec 2005, Peter Otten wrote:

> Ritesh Raj Sarraf wrote:
>
>> I'm using this for "option arguments" which are mutually inclusive.
>> But I want the user to pass atleast one "option argument" for the program
>> to function properly.
>>
>> For example, I have an option "--fetch-update" which requires a file "foo"
>> to check what it has to fetch. If the file is provided as an argument, it
>> uses it, else I add a parser.set_defaults("foo") which makes the program
>> to look for it in the current working directory.
>>
>> WHen the program see the "--fetch-update" option, it should execute the
>> required code. Now how do I check if at least one option has been passed
>> at the command-line ?
>> I have multiple options but I have parser.set_defaults() for each of them.
>
> I'm sorry I don't understand your example. Wouldn't you need at least two
> options to demonstrate "mutually inclusive" options? The set_default()
> method seems to accept only keyword arguments -- but even it were used
> correctly I'm still unclear why you would need it at all.
>
> Perhaps you can post a few sample invocations (both correct and illegal) of
> your script together with a description (in English, not code) of how the
> script should react?
>
> Peter, puzzled
>
>


try:
 version = "0.6b"
 reldate = "03/10/2005"
 copyright = "(C) 2005 Ritesh Raj Sarraf - RESEARCHUT 
(http://www.researchut.com/)"

 #FIXME: Option Parsing
 # There's a flaw with either optparse or I'm not well understood with 
it
 # Presently you need to provide all the arguments to it to work.
 # No less, no more. This needs to be converted to getopt sometime.

 #parser = OptionParser()
 #parser = optparse.OptionParser()
 parser = optparse.OptionParser(usage="%prog [OPTION1, OPTION2, ...]", 
version="%prog " + version)
 parser.add_option("-d","--download-dir", dest="download_dir", 
help="Root directory path to save the downloaded files", action="store", 
type="string")
 parser.set_defaults(download_dir="foo")
 parser.add_option("-s","--cache-dir", dest="cache_dir", help="Root 
directory path where the pre-downloaded files will be searched. If not, give a 
period '.'",action="store", type="string", metavar=".")
 parser.set_defaults(cache_dir=".")
 #parser.set_defaults(cache_dir=".")
 #parser.add_option("-u","--uris", dest="uris_file", help="Full path of 
the uris file which contains the main database of files to be 
downloaded",action="store", type="string")

 # We'll have additional options
 # --set-update - This will extract the list of uris which need to be 
fetched
 # --fetch-update - This will fetch the list of uris which need for 
update.
 # --install-update - This will install the fetched database files
 # The same will happen for upgradation.
 # --set-upgrade - This will extract the list of uris which need to be 
fetched
 # --fetch-upgrade - This will fetch the list of uris which need for 
upgrade
 # --install-upgrade - This will install the fetched database files
 parser.add_option("","--set-update", dest="set_update", help="Extract 
the list of uris which need to be fetched for _updation_", action="store", 
type="string", metavar="foo")
 parser.set_defaults(set_update="foo")
 parser.add_option("","--fetch-update", dest="fetch_update", 
help="Fetch the list of uris which are needed for _updation_.", action="store", 
type="string", metavar="foo")
 parser.set_defaults(fetch_update="foo")
 parser.add_option("","--install-update", dest="install_update", 
help="Install the fetched database files ", action="store", type="string", 
metavar="foo.zip")
 parser.set_defaults(install_update="foo.zip")
 parser.add_option("","--set-upgrade", dest="set_upgrade", 
help="Extract the list of uris which need to be fetched ", action="store", 
type="string", metavar="foo.dat")
 parser.set_defaults(set_upgrade="foo.dat")
 parser.add_option("","--fetch-upgrade", dest="fetch_upgrade", 
help="Fetch the list of uris which are needed ", action="store", type="string", 
metavar="foo.dat")
 parser.set_defaults(fetch_upgrade="foo.dat")
 parser.add_option("","--install-upgrade", dest="install_upgrade", 
help="Install the fetched packages ", action="store", type="string", 
metavar="foo-fetched.zip")
 parser.set_defaults(install_ugprade="foofetched.zip")
 (options, args) = parser.parse_args()
 #parser.check_required("-d", "-s", "-u")
 #if len(arguments) != 2:
 #parser.error("Err! Incorrect number of arguments. Exiting")
 if len(options) != 1 or len(options) > 2:
 print len(args)
 parser.error("No arguments were passed\n")
 sys.exit(1)
 elif not options.set_upgrade and options.upgrade_type:
 parser.er

Re: ElementTree - Why not part of the core?

2005-12-07 Thread jelle
Doug,

I agree with you, ElementTree is fast & pythonic.
Certainly does make sense to me.

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


Re: Documentation suggestions

2005-12-07 Thread Iain King

[EMAIL PROTECTED] wrote:
> >> The library reference has so many modules that the table of contents
> >> is very large.  Again, not really a problem that we can fix;
> >> splitting it up into separate manuals doesn't seem like it would
> >> help.
>
> Iain> I like the Global Module Index in general - it allows quick access
> Iain> to exactly what I want.  I would like a minor change to it though
> Iain> - stop words starting with a given letter rolling over to another
> Iain> column (for example, os.path is at the foot of one column, while
> Iain> ossaudiodev is at the head of the next), and provide links to each
> Iain> initial letter at the top of the page.
>
> I know it's not what you asked for, but give
>
> http://staging.musi-cal.com/modindex/
>
> a try.  See if by dynamically migrating the most frequently requested
> modules to the front of the section it becomes more manageable.
>
> Skip

Well, the point of the GMI is to lookup whatever module you are
currently having to use for the first time (at least it is for me).
Giving easy access to the modules I've already had to look up (because
they are common) doesn't really help - I've already accessed those.
It'll be nice when I have to find some obscure feature I haven't used
in them before, but really, all I'd like is an easy to use index :)

Iain

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


Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Dan Sommers
On 07 Dec 2005 03:25:53 -0800,
Paul Rubin  wrote:

> Steve Holden <[EMAIL PROTECTED]> writes:

>> > All joking aside, when I have names (temporary variables or
>> > scaffolding functions) that I need to initialise a module or data
>> > structure, but then outlive their usefulness, I del the name
>> > afterwards. Am I the only one? I can't say I've seen anyone else
>> > doing that, and it feels icky to me (for no reason I can put my
>> > finger on) -- what do others think?

> I do that too sometimes.  I think it's a Python weakness that you
> can't declare a local var like in other languages, to go out of scope
> at the end of the current block, e.g.:

>   if cond:
> my x = 7# make a new scope for x, goes out of scope at end of if

For a dissenting opinion:  I *like* Python's three-scope setup.  The
last thing I want is to get into an if statement (or two) inside a for
statement inside a method definition inside a class definition and to
have to wonder if "x" is local to the if-suite (or the outer if-suite),
the for-suite, the method definition, the class definition, or the
module.  And allowing multiple "x"'s in all these different scopes to
shadow each other just makes it worse.

IMO, if my suites, methods, classes, and modules are sufficiently large,
and their documentation and my text editor sufficiently weak, that I
can't figure out a "good" local name to use at any given point in the
code, or that I have to wonder which "x" I really want at that point, or
that I have to worry about creating a sub-suite (with no extra scoping)
and clobbering an important name, then I've already done something
enormously wrong.

> Well, that makes the code a little bit confusing.  If you say

>x = some_intermediate_result(...)
>do_something_with (x)

> do you know for sure whether x will be needed again?  Are you sure you
> didn't use the name x further up in the function for something that's
> still needed?

I never know for sure whether x will be needed again.  But if the
function from which you took that snippet is large enough that there's
any question about it, then perhaps it's too large already.  And if
there's a chance that x might be useful elsewhere, then I should have
called it something other than x (or immediately rename it as soon as I
start to think about using its contents again).

(Okay, now I sound like a curmudgeon, but I'm not.  At least I don't
think I am.  I'm just trying to present an alternate view, one in which
the issue of needing more scoping controls isn't an issue.)

Regards,
Dan

-- 
Dan Sommers

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


Re: shelve seg error

2005-12-07 Thread Philippe C. Martin
OK, Thanks

On Tue, 06 Dec 2005 15:41:08 +0100, Fredrik Lundh wrote:

> Philippe C. Martin wrote:
> 
>> Can I ask anydb which db it's using ?
> 
> the page says
> 
> If the database file already exists, the whichdb module is used to 
> determine its
> type and the appropriate module is used; if it does not exist, the first 
> module
> listed above that can be imported is used
> 
> where "above" refers to the list
> 
> dbhash (requires bsddb), gdbm, or dbm. If none of these modules is 
> installed,
> the slow-but-simple implementation in module dumbdbm will be used.
> 
> so the culprit in your case is either whichdb itself, or dbhash/bsddb...
> 
> 

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


Re: Usenet falsehoods (was Re: Bitching about the documentation...)

2005-12-07 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

>   Real people have real names.  Using your real name on the net makes
>   you less virtual to the people you communicate with.

on the other hand,

http://www.python.org/doc/Humor.html#timbot2

 



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


Re: Bitching about the documentation...

2005-12-07 Thread Jon Perez
Tony Meyer wrote:

> This makes no sense.  If you want to complain about Python, try a  
> Perl list.  Why would a list dedicated to discussion about/help with  
> a language need complaints about the language?

Huh?!?  Usually people complain because they need help or feel
that things can be improved.

> You might want to consider the difference between complaining and  
> constructive criticism and suggestions, and which are likely to get  
> better responses.

In the case of programming languages, I don't see any real difference
between something being a 'constructive criticism' and a 'complaint'.

Why, oh why, do so many programmers insist on elevating software tools
they are using to the status of a *religion* such that they feel personally
offended when someone badmouths the language or tool they are using???

Anyone can badmouth Python and things associated with all they want, the
only time it would even begin to bother me is only if these were false
accusations or there is a dishonest agenda behind it.

If the complaints are untrue, then I'd just be laughing at others'
ignorance, not be offended by it.  If it is an honest complaint
arising out of personal experience with the language, then certainly
there is a need to examine what can be improved.

I generally don't see any need to feel uncomfortable with strident
whining against Python because the only thing being attacked here is a
software tool, not persons.

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


Re: Documentation suggestions

2005-12-07 Thread Adam Olsen
On 12/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Adam> I don't expect everything to make the transition.  Are discussions
> Adam> of "atoms" and fragments of BNF really better than calling them
> Adam> expressions and linking to CPython's Grammar file?
>
> Actually, yes.  The actual Grammar file isn't designed for explanation
> (mostly it's more complex, but it also has extra productions) and is
> somewhat (maybe a lot) different than the BNF in the ref manual.

IMO the only people who are going to appreciate BNF used for
explanation are those working on language implementations, and they'll
need to understand the Grammar file anyway.  The rest of us need a
simpler explanation involving examples.

Having a large and detailed language specification, although an
admirable ideal, is a waste of time when the target audience is
perhaps a few dozen people.  Make it useful for everybody and it'll be
worth maintaining.

--
Adam Olsen, aka Rhamphoryncus
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread skip

Iain> Well, the point of the GMI is to lookup whatever module you are
Iain> currently having to use for the first time (at least it is for
Iain> me).  Giving easy access to the modules I've already had to look
Iain> up (because they are common) doesn't really help - I've already
Iain> accessed those.  It'll be nice when I have to find some obscure
Iain> feature I haven't used in them before, but really, all I'd like is
Iain> an easy to use index :)

Reorganizing the global module index isn't all that straightforward.  It is
generated by latex2html.  To change its layout would probaly require some
additional markup and mods to latex2html (not a pretty piece of code as I
understand it).

OTOH, I find myself returning to the same module docs over and over again to
look up function arguments, regular expression syntax, that sort of thing.
Having to page down past dozens and dozens of modules I don't care about to
click on "sys" or "datetime" motivated me to write my little hack.

Skip

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


Re: Documentation suggestions

2005-12-07 Thread skip

Adam> Having a large and detailed language specification, although an
Adam> admirable ideal, is a waste of time when the target audience is
Adam> perhaps a few dozen people.

Just because that audience is small doesn't mean they are unimportant.
There are currently four actively maintained/developed implementations of
Python.  A common language reference manual is important for them, and
indirectly for the people who use the four implementations.

I'm not trying to discount the value of a good Users Guide.

Skip

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


Re: Documentation suggestions

2005-12-07 Thread Iain King

[EMAIL PROTECTED] wrote:
> Iain> Well, the point of the GMI is to lookup whatever module you are
> Iain> currently having to use for the first time (at least it is for
> Iain> me).  Giving easy access to the modules I've already had to look
> Iain> up (because they are common) doesn't really help - I've already
> Iain> accessed those.  It'll be nice when I have to find some obscure
> Iain> feature I haven't used in them before, but really, all I'd like is
> Iain> an easy to use index :)
>
> Reorganizing the global module index isn't all that straightforward.  It is
> generated by latex2html.  To change its layout would probaly require some
> additional markup and mods to latex2html (not a pretty piece of code as I
> understand it).
>
> OTOH, I find myself returning to the same module docs over and over again to
> look up function arguments, regular expression syntax, that sort of thing.
> Having to page down past dozens and dozens of modules I don't care about to
> click on "sys" or "datetime" motivated me to write my little hack.
>
> Skip

Argh, you made me look at the html again - at least now I know *why* it
is so disgusting.  I understand there's a new version coming out soon,
hopefully in html 4 strict or xhtml.  I'm sure at that point it'll be
easier to use.  I can wait. :)

Iain

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


python: how to get an executable archive?

2005-12-07 Thread giangiammy
Hi all,

I'm starting to approch python: I find it a powerful language,
but, I'd like to get, ad result of my program, something
containing every python lib necessary to run (on linux systems):

i.e.: my application should be bounbled with the python
interpreter and the needed python modules: the
result should run on linux systems.

Is there something like thin in linux world?

thanks
giammy

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-07 Thread jmdeschamps

malv wrote:
> This is probably a fair answer.
> My experience: Two years ago I started with Boa till I discovered eric.
> I have been with eric ever since. Eric uses Qt as GUI. I think both Qt
> and wx enable you to do pretty much the same thing. I like the work
> F.Lundh did on Tkinter, but every time I try, I get bogged down in the
> tcl mess that it builds on. Take the example of the indispensible
> datagrid: a piece of cake in both Qt and wxWidgets, a nightmare
> otherwise.
>
> Since a couple of weeks I made the tour of wing-ide, komodo and PyDev.
> PyDev appears really to be a top heavy kludge. Perhaps OK for java
> lovers but very laborious to set up and work with, this in spite of the
> abundant hype & spam on this board. Wing-ide's debugger stops on
> imagined errors where eric and komodo do allright. I could not get the
> designer to run on komodo. So I'm back at eric. On eric you use the
> superb Qt designer. If you run linux, you get Qt and PyQt with KDE. You
> can keep on running gnome if you want. For windows, Qt4 is supposed to
> be free. Further, very extensive and attractive extensions exist: qwt
> and qwt3d for graphics.
>
> This is my experience. If I find better, I'll change.
> malv

Eclipse with Pydev is great with Tkinter apps.
I try to stick with Tkinter so Boa, Eric are not my cup of tea.

Some mainstream free IDE have problems with Tkinter's mainloop:
PythonWin IDLE, that I know of, may be others.

Eclipse with Pydev has been behaving excellently with Tkinter apps,
never freezing up, giving me the debugger, etc. Great stuff!

PS  Yes, a Tkinter datagrid would be nice (sigh)

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


Re: Documentation suggestions

2005-12-07 Thread Adam Olsen
On 12/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Adam> Having a large and detailed language specification, although an
> Adam> admirable ideal, is a waste of time when the target audience is
> Adam> perhaps a few dozen people.
>
> Just because that audience is small doesn't mean they are unimportant.
> There are currently four actively maintained/developed implementations of
> Python.  A common language reference manual is important for them, and
> indirectly for the people who use the four implementations.

What I meant is that a small audience is not going to draw enough
attention to get the effort it requires.  I agree absolutely that the
material it contains is important.  That's why I feel it should be
merged with the other documents, to ensure that it really does get
maintained.

--
Adam Olsen, aka Rhamphoryncus
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dynamic variable referencing

2005-12-07 Thread Michael Williams
Bruno,Thanks, but the whole reason I need it is to create objects in the tree on the fly.  Every implementation I've seen of Element tree manually assigns values to the nodes and manually places them.  All I care about is that any tags they have are in my list of "valid_tags".  Otherwise they can be in any order, etc.  For instance they could have:	the good one	ted	1945or	1945	the good one	tedI want to avoid the line by line assignments like this:if name == "book":	# do book stuffif name == "title":	#do title stuffI want to assign objects on the fly:if name in valid_tags:	object = Element(name)	if condition:		object = SubElement(Super, object)I'd still need an algorithm that walked the tree and created it for me.  That way, if in fact I decide to allow more XML tags in the future, it's simply a matter of adding a few "valid_tags" to the list and it automatically allows them to be created.  Does that make any sense?Thanks again,MichaelOn Dec 7, 2005, at 5:20 AM, [EMAIL PROTECTED] wrote:Michael Williams wrote: I would RTM, but I'm not sure exactly what to look for.  Basically, I  need to be able to call a variable dynamically.  Meaning something  like the following:              -  I don't want to say     OBJECT.VAR      but rather      OBJECT. ("string")      and have it retrieve the variable (not the value of  it) if in fact it exists. . .  getattr(obj, 'name', defaultvalue)  You can also implement the special methods __getitem__ and __setitem__ to allow indexed access to attributes, ie:  class FalseDict(object):   def __init__(self, toto, tata):      self.toto = toto      self.tata = tata   def __getitem__(self, name):      return getattr(self, name)   def __setitem__(self, name, value):      setattr(self, name, value)  f = FalseDict('toto', 'tata') f['toto'] f['tata'] = 42   The purpose is to create an XML tree myself   Don't reinvent the wheel. ElementTree (and it's C based brother) are very good at this.  --  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: python: how to get an executable archive?

2005-12-07 Thread Fredrik Lundh
"giangiammy" wrote:

> I'm starting to approch python: I find it a powerful language,
> but, I'd like to get, ad result of my program, something
> containing every python lib necessary to run (on linux systems):
>
> i.e.: my application should be bounbled with the python
> interpreter and the needed python modules: the
> result should run on linux systems.
>
> Is there something like thin in linux world?

there are plenty of bundling tools available for python.  for pointers
to some of them, see

http://effbot.org/zone/python-compile.htm

 



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


movie module

2005-12-07 Thread giangiammy
hi all,

tryng python with pygame, I get the followinf error:

faberdanaio.py:28: RuntimeWarning: use movie: No module named movie
  animation = pygame.movie.Movie("images/film.mpeg")
Traceback (most recent call last):
  File "faberdanaio.py", line 28, in ?
animation = pygame.movie.Movie("images/film.mpeg")
  File "/usr/lib/python2.3/site-packages/pygame/__init__.py", line 52,
in __getattr__
raise NotImplementedError, MissingPygameModule
NotImplementedError: movie module not available

I'm missing the movie module: where can I find it?
I searched both python and pygame site with no succes :-(

thanks
giammy

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


uuDecode problem

2005-12-07 Thread py
Hi,
  I am encoding a string such as...

[code]
data = someFile.readlines()
encoded = []
for line in data:
encoded.append(binascii.b2a_uu(stringToEncode))
return encoded
[/code]

...I then try to decode this by...

[code]
def decode(data):
result = []
for val in data:
result.append(binascii.a2b_uu(val))
return result
[/code]

this seems to work sometimesfor example a list which has a short
string in it like ["this is a test"]

however if the list of data going into the decode function contains a
bunch of elements I get the following error...

result.append(binascii.a2b_uu(val))
binascii.Error: Trailing garbage

..any idea why this is happening?  Anyone successfully use the uu to
encode/decode strings of varying length (even larger strings, more than
a few hundred characters)?

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


What is the difference

2005-12-07 Thread enas khalil
hello      i want to know what the iterator type differs from  list type   also if youplease advice me a tutorial on how to use Unicode and different string methods as encode ,decode     thanks
		 Yahoo! Personals 
Single? There's someone we'd like you to meet. 
Lots of someones, actually. Yahoo! Personals-- 
http://mail.python.org/mailman/listinfo/python-list

Question about start using ZServerSSL on win box...

2005-12-07 Thread Thomas G. Apostolou
Hello all,

Dear Ng Pheng Siong,
thank you for your great job with M2Crypto.

I have got and build 0.15 version on a win xp box recently and was reading
your "ZServerSSL HOWTO" document so that i can start using https,
xmlprc-over-https etc.

I have to tell that i have installed from Plone 2.0.5 binary for windows
witch comes with Zope 2.7.0 and Python 2.3.3 (i have patched
SimpleHTTPServer.py as corrected for 2.3.5).

As reading your "ZServerSSL HOWTO" i suppose that the corresponding $ZOPE is
my "C:\Program Files\Plone 2\Zope\lib\python" because only there i can find
$ZOPE/ZServer. Correct me if i am wrong with this...

What i also need to know is that since i have installed so that Zope server
runs as a service what is the corresponding steps for me in the section
where you say :

  1.. Copy $ZSSL/z2s.py into $ZOPE.

  2.. Depending on your operating system, modify $ZOPE/start or
$ZOPE/start.bat to invoke $ZOPE/z2s.py, instead of $ZOPE/z2.py. The files
$ZSSL/starts and $ZSSL/starts.bat serve as examples.

I do not have any $ZOPE/start or $ZOPE/start.bat or $ZOPE/z2.py, i only have
a file named PythonService.exe into "C:\Program Files\Plone 2\Zope\bin"

Do i HAVE to reinstall Plone and set it not to run as service?

Thank you in advance...

Thomas G. Apostolou



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


question about extracting value from a string

2005-12-07 Thread nephish
hey there,

i have looked at the string module and re.
i was looking for advice on what would be the best way to pull a value
out of a small string.

for example, i have a string
$.+.09 JAR
   and all i want out of it is the +.09

likewise, i have
$-.04 TIN kt
  and all i want is the -.04

what would be my best bet here ?
do i need a full blown re comparison? 

thanks

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


Re: Bitching about the documentation...

2005-12-07 Thread Christopher Subich
Fredrik Lundh wrote:
> Steven D'Aprano wrote:
> 
> 
>>"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo."
> 
> 
> Did you mean: Badger badger Badger badger badger badger Badger badger 
> Mushroom! Mushroom!

Thank you, I really needed that stuck in my head. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Michael Schneider
[EMAIL PROTECTED] wrote:
  ,, 

  However there is one thing I don't like in python,
> that is, scoping by indentation. But it would not annoy me so much that
> make me decide to implement a new language^_^.
> 
> 
> Regards,
> 
> Limin
> 


I find these comments interesting.  It is very common for people to 
complain about indentation.

I have helped several very large companies create C++ coding
standards.

One common requirement is very fixed indentation rules.  These
rules are often encoded into lint-like tools.  These tools
treat indentation errors like compile time errors.


These are often the same people that don't want to use python because
it uses indentation ..

It is humorous if stand back and look from a distance greater then 10 
feet :-)

Mike


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ping in Python?

2005-12-07 Thread Michael Schneider
I telnet to port 13 (returns time)

Hope this is helpful,
Mike

Nico Grubert wrote:
> Hi there,
> 
> I could not find any "ping" Class or Handler in python (2.3.5) to ping a 
> machine.
> I just need to "ping" a machine to see if its answering. What's the best 
> way to do it?
> 
> Kind regards,
> Nico


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: pygene - genetic algorithms package

2005-12-07 Thread Peter Hansen
Erik Max Francis wrote:
> If you went into detail I could probably tell you whether or not what 
> you're doing is "obviously" a genetic algorithm, or "obviously" an 
> instance of genetic programming, or somewhere in between.  Without 
> internal structure it's probably more likely closer to genetic algorithms.

You're certainly correct there.  The leap to GP is much farther than my 
stuff is from GA.

>... for many problems, it
> seems that genetic programming has a greater ability to produce 
> solutions to much more complex problems (where often you do not even 
> know the high-level form that they will take -- something you need to 
> decide to put together a genetic algorithm).

I agree, and I look forward to seeing Psi some time, if just to help me 
learn more in the area.  Thanks again for the comments.

-Peter

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


Re: Bitching about the documentation...

2005-12-07 Thread Grant Edwards
On 2005-12-07, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Mon, 05 Dec 2005 19:36:58 -0800, BartlebyScrivener wrote:
>
>> Well, that might be asking a bit too much of the programmers, who
>> perhaps don't exactly enjoy mucking about in the lowlands of English
>> grammar and syntax.
>
> Oh come on now! For the kinds of minds who enjoy obfuscated C or Perl,
> English is just par for the course.
>
> One of my favourite examples of obfuscated English is this grammatically
> correct sentence:
>
> "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo."

Why the goofy-looking capitalization?  Are the 2nd and 3rd
occurances of "Buffalo" referring to the city?

-- 
Grant Edwards   grante Yow!  All of life is a blur
  at   of Republicans and meat!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread A.M. Kuchling
On Tue, 06 Dec 2005 10:29:33 -0800, 
Michael Spencer <[EMAIL PROTECTED]> wrote:
> not that helpful.  "Miscellaneous Services", in particular, gives no clue to 
> treasures it contains.  I would prefer, for example, to see the data 
> structure modules: collections, heapq, array etc... given their own section. 
> Documentation/testing, cmd/options might be other candidates to draw together
> currently related material more meaningfully.

You're right; "Miscellaneous Services" is a grab-bag of stuff, and so
are 'Generic OS Services' and 'Optional OS Services'.  These chapters
should be rearranged into more, smaller chapters.  

A patch for a draft reorganization is at http://www.python.org/sf/1375417

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Zeljko Vrba
On 2005-12-07, Antoon Pardon <[EMAIL PROTECTED]> wrote:
>
> What I don't understand is, that most people who have a problem
> with scope by indentation, want to introduce braces. I think
> braces are the worst solution.
>
Braces are very convenient to match block start and end. Open a C program
in the VI editor, and press % in command mode on some brace.. It will take
you to its matching brace. How do you do something like that with python code
(or any code that is based purely on indentation..)

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


Re: Force Focus in Tkinter

2005-12-07 Thread annagel
OK some sample Code.  First from the module that I am importing. I
won't post anything because the vast majority of stuff is way outside
the scope of this problem and has to do with image and sound
manipulation.

First the imports I use:

import sys
import os
import user
import traceback
import time
import Numeric
import struct
from Image import *
from threading import *
from math import sqrt
import cStringIO
from Tkinter import *
from Queue import *
import thread
import ImageTk
import tkFileDialog
import tkColorChooser
import pygame

#Now some initialization
ver = "1.1"
pygame.mixer.pre_init(22050, -16, False)
pygame.init()
defaultFont = pygame.font.SysFont("times", 24)

top = Tk()

mediaFolder = user.home + os.sep


#Some global functions that use the file and color dialogs

def pickAFile(**options):
path = tkFileDialog.askopenfilename()
return path

def pickAFolder(**options):
global mediaFolder
folder = tkFileDialog.askdirectory()
if folder == '':
folder = mediaFolder
return folder

def pickAColor(**options):
color = tkColorChooser.askcolor()
newColor = Color(color[0][0], color[0][1], color[0][2])
return newColor

# the color object is just a container for the r, g, b values that can
also do things like
# lighten and darken it

#Finally my picture class (abreviated)

class Picture:
def __init__(self):
self.title = "Unnamed"
self.dispImage = None

def createImage(self, width, height):
self.surf = pygame.Surface((width, height))
self.pixels = pygame.surfarray.pixels3d(self.surf)
self.filename = ''
self.title = 'None'

def getImage(self):
data = pygame.image.tostring(self.surf, "RGB", 0)
image = fromstring("RGB", (self.getWidth(), self.getHeight()), 
data)
return image

def loadImage(self,filename):
global mediaFolder
if not os.path.isabs(filename):
filename = mediaFolder + filename
self.surf = pygame.image.load(filename)
self.pixels = pygame.surfarray.pixels3d(self.surf)
self.filename = filename
self.title = getShortPath(filename)

def repaint(self):
self.dispImage = ImageTk.PhotoImage(self.getImage())
self.item = self.canvas.create_image(0, 0, image=self.dispImage,
anchor='nw')

def show(self):
self.frame = Toplevel()
self.canvas = Canvas(self.frame, width=self.getWidth(),
height=self.getHeight())
self.dispImage = ImageTk.PhotoImage(self.getImage())
self.item = self.canvas.create_image(0, 0, image=self.dispImage,
anchor='nw')
self.canvas.pack()

#For this the Pixel class is a reference directly into the image data
so a user can modify
#the image in a pixel by pixel maner

#Convenience global function

def makePicture(filename):
picture = Picture()
picture.loadImage(filename)
try:
w = picture.getWidth()
return picture
except:
print "Was unable to load the image in " + filename +"\nMake 
sure
it's a valid image file."

Now the code I run and the results

>>>from media import *
>>>pic = makePicture(pickAFile())
>>>pic.show()

When I do this I get my image window to pop-up and it works fine is
responsive to everything I do, but when I click on it I get the old
filePicker with my selection still made in it.  I can't do anything at
all with this window though I still have complete control over the
picture window but nothig over this new window.

Finally the colorPicker

>>>col = pickAColor()

this starts my python icon jumping around but the picker does not
appear until after I click the jumping window and then click back to my
command prompt (I am using osx 10.4)

If anyone wants more information I would be happy to send it along.  I
just did not want to post all of the code because the whole file is 900
lines long and I really do not think that most of it should matter at
all to what is going on with the windows since none of the sound stuff
used windows at all and Color and Pixel use it in that they interact
with Picture but not for any other reason.

Thanks again for any help

Andrew

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


Re: question about extracting value from a string

2005-12-07 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote:

> hey there,
> 
> i have looked at the string module and re.
> i was looking for advice on what would be the best way to pull a value
> out of a small string.
> 
> for example, i have a string
> $.+.09 JAR
>and all i want out of it is the +.09
> 
> likewise, i have
> $-.04 TIN kt
>   and all i want is the -.04
> 
> what would be my best bet here ?
> do i need a full blown re comparison? 

You can do it by pure string operations, if you wish -- e.g., if your
examples exhaust the possible issues, astring[1:5] will work for both.
It's hard to say whether it's best to use REs instead without having any
idea of the variety of formats your "value" can take and how differently
it might be placed inside the string, of course.

Once you do get the value, either by string slicing or REs, you'll have
a string -- if what you want is a float, call e.g. float(astring[1:5]);
or for a decimal number, decimal.Decimal(astring[1:5]) (after importing
module decimal from Python's standard library); and so on.


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


Re: Calculating Elapsed Time

2005-12-07 Thread Peter Hansen
malv wrote:
> "Note that even though the time is always returned as a floating point
> number, not all systems provide time with a better precision than 1
> second." says the doc.
> Can anything be said about precision if indeed your system returns
> figures after the decimal point?

A few things.

1. "Precision" is probably the wrong word there.  "Resolution" seems 
more correct.

2. If your system returns figures after the decimal point, it probably 
has better resolution than one second (go figure).  Depending on what 
system it is, your best bet to determine why is to check the 
documentation for your system (also go figure), since the details are 
not really handled by Python.  Going by memory, Linux will generally be 
1ms resolution (I might be off by 10 there...), while Windows XP has 
about 64 ticks per second, so .015625 resolution...

-Peter

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


Re: uuDecode problem

2005-12-07 Thread Alex Martelli
py <[EMAIL PROTECTED]> wrote:
   ...
> encoded.append(binascii.b2a_uu(stringToEncode))

binascii.b2a_uu only works for up to 45 bytes at once; but if you were
feeding it more than 45 bytes, this should raise a binascii.Error
itself.

> ..any idea why this is happening?  Anyone successfully use the uu to
> encode/decode strings of varying length (even larger strings, more than
> a few hundred characters)?

Definitely not, given the above limit.  But I still don't quite
understand the exact mechanics of the error you're getting.


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


Re: Bitching about the documentation...

2005-12-07 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote:

> On Mon, 05 Dec 2005 19:36:58 -0800, BartlebyScrivener wrote:
> 
> > Well, that might be asking a bit too much of the programmers, who
> > perhaps don't exactly enjoy mucking about in the lowlands of English
> > grammar and syntax.
> 
> Oh come on now! For the kinds of minds who enjoy obfuscated C or Perl,
> English is just par for the course.

As it happens, there appears to be pretty weak correlation between
proficiency in programming and proficiency in writing -- SOME excellent
programmers are great writers too, but, I would guess, just roughly the
same percentage as in the general popularion (i.e., deucedly few).


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


Re: Documentation suggestions

2005-12-07 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> Iain> I like the Global Module Index in general - it allows quick access
> Iain> to exactly what I want.  I would like a minor change to it though
> Iain> - stop words starting with a given letter rolling over to another
> Iain> column (for example, os.path is at the foot of one column, while
> Iain> ossaudiodev is at the head of the next), and provide links to each
> Iain> initial letter at the top of the page.
> 
> I know it's not what you asked for, but give
> 
> http://staging.musi-cal.com/modindex/
> 
> a try.  See if by dynamically migrating the most frequently requested
> modules to the front of the section it becomes more manageable.

That's pretty cool.  What I don't know is how it would look after 
thousands of people using it.  I know that I probably only have 10 
modules or so that I consistently need to check the docs for.  Your hack 
above would conveniently place those all at the top if I was the only 
user.  But are those 10 modules the same 10 modules that other folks 
need?  I don't know...

Of course, the only way to find out is to try...

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread Alex Martelli
Zeljko Vrba <[EMAIL PROTECTED]> wrote:

> On 2005-12-07, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> >
> > What I don't understand is, that most people who have a problem
> > with scope by indentation, want to introduce braces. I think
> > braces are the worst solution.
> >
> Braces are very convenient to match block start and end. Open a C program
> in the VI editor, and press % in command mode on some brace.. It will take
> you to its matching brace. How do you do something like that with python code
> (or any code that is based purely on indentation..)

By programming % to match indentation (in Python syntax mode) when the
character under the cursor when % is hit is not a parenthesis, of
course; much the same approach as you use to have it jump between
opening and closing tags when you're editing an XML or HTML file, except
that matching indentation may be somewhat easier.  You can find many vim
programming tips at www.vim.org much more easily than in this group (you
CAN program vim with Python if you wish, rather than having to use vim's
own scripting language, but for that you need to build VIM with Python
scripting enabled in the first place).


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


Re: question about extracting value from a string

2005-12-07 Thread nephish
the second line was not a typo , and thanks for that.
these values may vary somewhat over time. So i may have to rewrite this
part of the script.

a string is fine for right now, because it is just going to be pumped
into a database. i can change it later if necessary.

thanks for the help gents, i am going to just go with string functions,
seems like it will be easier both to code now. and later if and when
the format of this stuff may change.

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


Re: XML and namespaces

2005-12-07 Thread Alan Kennedy
[Fredrik Lundh]
> It's libxml2 that does all the work, and the libxml2
> authors claim that libxml2 implements the DOM level 2 document model,
> but with a different API.

That statement is meaningless.

The DOM is *only* an API, i.e. an interface. The opening statement on 
the W3C DOM page is

"""
What is the Document Object Model?

The Document Object Model is a platform- and language-neutral interface 
that will allow programs and scripts to dynamically access and update 
the content, structure and style of documents.
"""

http://www.w3.org/DOM/

The interfaces that make up the different levels of the DOM are 
described in CORBA IDL - Interface Definition Language.

DOM Implementations are free to implement the methods and properties of 
the IDL interfaces as they see fit. Some implementations might maintain 
an object model, with separate objects for each node in the tree, 
several string variables associated with each node, i.e. node name, 
namespace, etc. But they could just as easily store those data in 
tables, indexed by some node id. (As an aside, the non-DOM-compatible 
Xalan Table Model does exactly that: 
http://xml.apache.org/xalan-j/dtm.html).

So when the libxml2 developers say (copied from http://www.xmlsoft.org/)

"""
To some extent libxml2 provides support for the following additional 
specifications but doesn't claim to implement them completely:

 * Document Object Model (DOM) 
http://www.w3.org/TR/DOM-Level-2-Core/ the document model, but it 
doesn't implement the API itself, gdome2 does this on top of libxml2
"""

They've completely missed the point: DOM is *only* the API.

> Maybe they're wrong, but wasn't the whole point of this subthread that
> different developers have interpreted the specification in different ways ?

What specification? Libxml2 implements none of the DOM specifications.

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread JohnBMudd
So...

Python is already flexible.  It supports use of (1) tabs, (2) space or
(3) a mix of tabs and space to indicate scope.

Some people think this is too flexible.  It should be cut back to tabs
or spaces.  The fewer people comfortable with Python, the better.  It's
better to be "right" than popular.

Some people like it just as it is.  Don't change ANYTHING!

Some people (a lot of the ones that don't give Python a chance) want
one more choice, braces.  Is that so much to ask for?

Does that pretty well sum it up?

Thanks for the responses.  I've been educated.

John

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


Re: How to ping in Python?

2005-12-07 Thread Laszlo Zsolt Nagy
Michael Schneider wrote:

>I telnet to port 13 (returns time)
>
The problem is that most modern up-to-date servers use firewalls. They 
only open the ports that are absolutely necessary. Usually the time 
service is part of inetd, which is disabled by default, on most of the 
servers. PING ICMP may work, but sometimes it does not either. In the 
worst case, all port are closed and you have no way to tell if there is 
a computer or not.

Can you tell more about what kind of server do you need to "ping"?

Example: if you need to know if a web server is alive, you should 
connect to port 80 (http). If the connection was successful, you can 
close the connection immeditelly. You can expect a HTTP server to open 
the HTTP port, but all other ports may be closed.

   Les



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


Validate a xml file with DTD from python

2005-12-07 Thread Julio Alberto
Hi. I need a way to reach a goal like this in python 2.3:This is a informal way to said it:  
result = validateXmlWithDTD(XmlFilePath, DTDFilePath)
#where result could be True,False or some exception
 
I'm not interested in a one specific sintaxis or way to do this. I try to find a  simple and transparent design to validate the xml's, dynamic, with a specific   DTD. The module xml.sax.handler with DTDHandler() it does not report clarity 
to me. But the way, i needed optimal, because the other specifications for the application that i develop.
If you can help me in this topic please use: [EMAIL PROTECTED]For any help i'll be grateful.(excuse my english, is not my native language)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to ping in Python?

2005-12-07 Thread Michael Schneider
Les,

I only ping internal machines.  You are right about shutting down ports.

When we disable telent, we also disable ping.  Many people may not though,

good luck,
Mike

Laszlo Zsolt Nagy wrote:

> Michael Schneider wrote:
>
>> I telnet to port 13 (returns time)
>>
> The problem is that most modern up-to-date servers use firewalls. They 
> only open the ports that are absolutely necessary. Usually the time 
> service is part of inetd, which is disabled by default, on most of the 
> servers. PING ICMP may work, but sometimes it does not either. In the 
> worst case, all port are closed and you have no way to tell if there 
> is a computer or not.
>
> Can you tell more about what kind of server do you need to "ping"?
>
> Example: if you need to know if a web server is alive, you should 
> connect to port 80 (http). If the connection was successful, you can 
> close the connection immeditelly. You can expect a HTTP server to open 
> the HTTP port, but all other ports may be closed.
>
>   Les
>
>
>
>


-- 
The greatest performance improvement occurs on the transition of from the 
non-working state to the working state.

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


Re: ElementTree - Why not part of the core?

2005-12-07 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> ElementTree on the other hand provides incredibly easy access to XML
> elements and works in a more Pythonic way.  Why has the API not been
> included in the Python core?

While I fully agree that ElementTree is far more Pythonic than the 
dom-based stuff in the core, this issue has been discussed on 
python-dev[1].  Fredrik Lundh's response:

 shipping stable versions of ElementTree/cElementTree (or PIL, or
 python-doc, or exemaker, or what else you might find useful) with
 official Python releases is perfectly okay.

 moving the main trunk and main development over to the Python CVS is
 another thing, entirely.

I think some people were hoping that instead of adding these things to 
the standard library, we would come up with a better package manager 
that would make adding these things to your local library much simpler.

STeVe

[1]http://www.python.org/dev/summary/2005-06-01_2005-06-15.html#reorganising-the-standard-library-again
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calculating Elapsed Time

2005-12-07 Thread Jean Johnson
Thanks to everyone for their e-mails.  I am using
Fredrik's strptime/mktime solution to calculate my
elapsed time.



__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

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


Re: Documentation suggestions

2005-12-07 Thread Rocco Moretti
A.M. Kuchling wrote:

> There's another struggle within the LibRef: is it a reference or a
> tutorial?  Does it list methods in alphabetical order so you can look
> them up, or does it list them in a pedagogically useful order?  I
> think it has to be a reference; if each section were to be a tutorial,
> the manual would be huge.  Here I think the solution is to encourage
> separate tutorials and HOWTOs, and link to them from the LibRef.

I actually like the conversational, tutorial style the current LibRef 
has -- in fact I consider that style one of the Python Docs strengths.

All too often I see manuals that consist of only fuction by fuction & 
class by class breakdowns. That's fine if the module is just a 
collection of independant functions, but falls short whenever you want 
to use multiple functions & classes in a module together. Function by 
function documentation tends to ignore the "big picture," how all the 
functions & classes work together, and the philosophy behind their use. 
*That's* what I feel it is important to document - if I want to know 
parameters, return values and side-effects, I'll just look at the doc 
strings.

Certainly you could go for the User Manual/Reference Manual dichotomy, 
but in my experience, the User Manual tends to get short shrift - the 
experts writing it tend to think that it's just for "n00bs", and leave 
out the complex and esoteric items, thinking that the Reference Manual 
suffices. Unfortunately, the background and philosophy are needed *more* 
for the complex/esoteric functions than for the simple ones, merely 
because you're less likely to understand them from a "takes a,b,c, sets 
the froz flag, and returns x,y,z" type description.

And to expand on what Michael Spencer said, a lot of the time when I'm 
digging throught the LibRef, I'm looking for a module that'll help me do 
'X'. Most of the "Reference Manuals" I've seen tend to assume you know 
what fuction you're looking for, and don't give you any direction in the 
forest of function descriptions. With the current tone/level and 
categorical grouping of the LibRef, it's easy to browse through and look 
for things that might help (at least easier than it would be with, say, 
a strict alphabetical list).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML and namespaces

2005-12-07 Thread Alan Kennedy
[Alan Kennedy]
>>Don't confuse libxml2dom with libxml2.

[Paul Boddie]
> Well, quite, but perhaps you can explain what I'm doing wrong with this
> low-level version of the previously specified code:

Well, if your purpose is to make a point about minidom and DOM standards 
compliance in relation to serialisation of namespaces, then what you're 
doing wrong is to use a library that bears no relationship to the DOM to 
make your point.

Think about it this way: Say you decide to create a new XML document 
using a non-DOM library, such as the excellent ElementTree.

So you make a series of ElementTree-API-specific calls to create the 
document, the elements, attributes, namespaces, etc, and then serialise 
the whole thing.

And the end result is that you end up with a document that looks like this

"""


"""

It is not possible to use that ElementTree code to make inferences on 
how minidom should behave, because the syntax and semantics of the 
minidom API calls and the ElementTree API calls are different.

Minidom is constrained to implement the precise semantics of the DOM 
APIs, because it claims standards compliance.

ElementTree is free to do whatever it likes, e.g. be pythonic, because 
it has no standard to conform to: it is designed solely according to the 
experience and intuition of its author, who is free change it at any 
stage if he feels like it.

s/ElementTree/libxml2/g

If I've completely missed your point and you were talking something else 
entirely, please forgive me. I'd be happy to help with any questions if 
I can.

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about extracting value from a string

2005-12-07 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote:
   ...
> thanks for the help gents, i am going to just go with string functions,
> seems like it will be easier both to code now. and later if and when
> the format of this stuff may change.

I agree -- "to each day are sufficient the evils thereof".  Many
programmers fall into the temptation to overgeneralize and fail to
follow the AGNI principle ("Ain't Gonna Need It"...;-).


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


Re: Calculating Elapsed Time

2005-12-07 Thread Fredrik Lundh
Peter Hansen wrote:

> Going by memory, Linux will generally be 1ms resolution (I might be
> off by 10 there...), while Windows XP has about 64 ticks per second,
> so .015625 resolution...

here's a silly little script that measures the difference between
two distinct return values, and reports the maximum frequency
it has seen this far:

import time

def test(func):
mm = 0
t0 = func()
while 1:
t1 = func()
if t0 != t1:
m = max(1 / (t1 - t0), mm)
if m != mm:
print m
mm = m
t0 = t1

test(time.time)
# test(time.clock)

if I run this on the Windows 2K box I'm sitting at right now, it settles
at 100 for time.time, and 1789772 for time.clock.  on linux, I get 100
for time.clock instead, and 262144 for time.time.





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


Re: Ant (with Python extensions) good replacement for distutils?

2005-12-07 Thread Michael Schneider
I would vote against ant because java must be installed to run it.


The bootstrap install should be very simple.  If you make python usage
dependent on:

1) download java
2) install java
3) add java to path
4) download ant
5) install ant
6) add ant to path
7) download ptyhon
8) install python
9) add python to path
10) download package
11) run ant to install package

just food for thought,
Mike

[EMAIL PROTECTED] wrote:
> I know distutils well but don't know anything about Ant except that it
> is a build
> tool from Apache project.
> 
> Could it possible be better or as good as distutils?
> (There are extensions for Python.)
> 
> Chris
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread D H
[EMAIL PROTECTED] wrote:
> Some people like it just as it is.  Don't change ANYTHING!

search for NIMPY

> Some people (a lot of the ones that don't give Python a chance) want
> one more choice, braces.  Is that so much to ask for?

If you like curly brace style, there are always other scripting 
languages like javascript (rhino for the jvm) or groovy or others.

If you like "end" statements style, there is always ruby or one
of the basic dialects like visual basic or gambas, or see rexx dialects 
too like netrexx or oorexx.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: option argument length

2005-12-07 Thread Peter Otten
Ritesh Raj Sarraf wrote:

>  parser.add_option("-d","--download-dir", dest="download_dir",
>  help="Root directory path to save the downloaded files",
>  action="store", type="string")
>  parser.set_defaults(download_dir="foo")

This can be simplified to

parser.add_option("-d", "--download-dir", default="foo", 
help="Root directory path to save the downloaded files")

which seems to be the reason why I've never seen the set_defaults() call
before.

>  if len(options) != 1 or len(options) > 2:

It doesn't matter much as it won't work anyway, but

len(options) > 2 implies len(options) != 1, so

if len(options) != 1: 
#...

would suffice here.

Now to the actual problem: I think you didn't understand my previous
question. I cannot infer from your non-working code what it actually should
do. I asked for examples of how your script would be used. E. g,
assuming the code above is in a file called sarraf.py, what should the
following invocations

./sarraf.py --fetch-update bar
./sarraf.py --fetch-update bar --the-mutually-inclusive-option baz

do? Would the first terminate with an error message that another option must
also be given? Would it use the default? Would the second be accepted? Try
to describe it as simple and clear as possible. Imagine you were talking to
someone who has never written a line of code.

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


Re: Documentation suggestions

2005-12-07 Thread Aahz
In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:
>
>OTOH, I find myself returning to the same module docs over and over
>again to look up function arguments, regular expression syntax, that
>sort of thing.  Having to page down past dozens and dozens of modules I
>don't care about to click on "sys" or "datetime" motivated me to write
>my little hack.

That's why I use Lynx!  ;-)  ("/]re" takes me right to regex docs)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-07, Peter Hansen <[EMAIL PROTECTED]> wrote:

> 2. If your system returns figures after the decimal point, it
>probably has better resolution than one second (go figure).
>Depending on what system it is, your best bet to determine
>why is to check the documentation for your system (also go
>figure), since the details are not really handled by
>Python. Going by memory, Linux will generally be 1ms
>resolution (I might be off by 10 there...),

In my experience, time.time() on Linux has a resolution of
about 1us.  The delta I get when I do

  print time.time()-time.time()

is usually about 2-3us, but some of that is probably due to the
overhead involved.

-- 
Grant Edwards   grante Yow!  TAILFINS!!...click...
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-07 Thread A.M. Kuchling
On Wed, 7 Dec 2005 09:36:24 +0100, 
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> or just add a marker (in some for me unknown way), and postprocess
> the HTML files.  I'm not sure the links does necessarily belong in e.g.
> PDF renderings of the documentation, but that's of course up to the
> documentation maintainers.

I'm just scared of hacking the LaTeX2HTML translator customizations,
and would rather do things to the LaTeX input.

> if anyone wants some data to play with, I've posted a simple seealso file
> here:

Thanks!  I've written a little parser and output script; they're in
Python SVN at sandbox/trunk/seealso.  (Browseable at
http://svn.python.org/view/sandbox/trunk/seealso/).

With a patch to the Makefile and the module's *.tex file, it's
possible to use these scripts to pull in examples.  Modifying all the
*.tex files is tedious, but I suspect we can make it an automatic part
of the seealso environment.  I'll talk to Fred about it and begin
assembling a patch.

--amk

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


Re: uuDecode problem

2005-12-07 Thread py
Alex Martelli wrote:
> binascii.b2a_uu only works for up to 45 bytes at once; but if you were
> feeding it more than 45 bytes, this should raise a binascii.Error
> itself.
> Definitely not, given the above limit.  But I still don't quite
> understand the exact mechanics of the error you're getting.
>
>
> Alex

here is an example.

def doSomething():
data = aFile.readlines()
result = []
for x in data:
result.append(encode(x))
return result

def printResult(encodedData):
"""encodedData is a list of strings which are uu encoded"""
print decode(encodedData)

encode(data):
"""data is a string"""
if len(data) > 45:
tmp = []
for c in data:
tmp.append(binascii.b2a_uu(c))
return ''.join(tmp)
else:
return binascii.b2a_uu(data)


decode(data):
"""data is a list of strings"""
result = []
for val in data
if len(val) > 45:
response = []
for x in val:
response.append(binascii.a2b_uu(x))
result.append(response)
else:
result.append(binascii.a2b_uu(val))
return ''.join(result)

...i would use those functions like

data = doSomething()
printResult(data)

Now i get this...
"response.append(binascii.a2b_uu(x))
java.lang.StringIndexOutOfBoundsException:
java.lang.StringIndexOutOfBoundsExcep
tion: String index out of range: 1"

So the error is in the decode method .this is in Jython...perhaps
Jython doesn't handle binascii.a2b_uu ?  or perhaps since the actual
data is being encoded in python, then read in and decoded in my jython
script..that could be the problem?

thanks.

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


Re: Bitching about the documentation...

2005-12-07 Thread Jon Perez
[EMAIL PROTECTED] wrote:

> FWIW I find Python's docs to be OK at best, with some horrible
> parts, and a lot of mediochre to poor parts.

I myself have no big beef about Python's docs, but you're certainly
not the first one to complain about them.  Xah Lee rants very
heavily against the quality against Python's docs and considers
many sections of it as written in a manner more to show-off one's
knowledge of jargon rather than to explain things properly.

I don't really notice that but this could be because I'm already
quite comfortable with jargon at the level it is used in the
Python docs (or maybe I'm one of those highfalutin' chaps as well
;-D).  Seriously though, sometimes jargon is necessary in order to
put across a point concisely and accurately so its use cannot always
be considered gratuitous.

The only problem I have with Python docs is that for most of
the the standard library API documentation, the function calls
are not organized very well (i.e. I don't believe they are
alphabetized or ordered in any intutive manner).

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


Implementing deepcopy

2005-12-07 Thread Mr.Rech
Hi all,
I'm writing a class with some attributes which deepcopy can't cope
with, and I need some more clarifications. Sorry for my newbie
questions, but I'm a newbie indeed (or a sort of).

Suppose one of the attributes of my class is a dictionary whose values
are callable functions, such as:

>>>def foo():
.pass
>>>def bar():
.pass

>>>adict = dict(a = foo, b = bar)

Now if I try:

>>> anotherdict = copy.deepcopy(adict)   # It doesn't work

however:

>>> anotherdict = copy.copy(adict) # works as expected

My question is: anotherdict is really a copy of adict? If so, what is
the difference between its definition and the following:

>>> yanotherdict = dict(adict)

??

Thanks in advance,
 Andrea.

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


  1   2   3   >