replace words

2005-10-26 Thread [EMAIL PROTECTED]
What is the way for replacing in a string from . to . the sentence?
for example:
"been .taken.  it may be .left. there,
even if the .live coals were not. cleared"
I want to do this-> replace(\.(.*)\.,\.start (1) end\.)
result:
"been .start taken end.  it may be .start left end. there,
even if the .start live coals were not end. cleared"

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


Re: Microsoft Hatred FAQ

2005-10-26 Thread Peter T. Breuer
In comp.os.linux.misc David Schwartz <[EMAIL PROTECTED]> wrote:

> "Peter T. Breuer" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]

> I don't know what drugs you're on, but the McDonald's corporation most 
> certainly is in the business of the wholesale distribution of burger 
> patties. One key reason to become a franchisee is to access their wholesale 
> distribution network.

Then they are not in the wholesale business. So lock the drugs cabinet.

(What they are marketting is a "brand", complete with clowns and
arches, and a secret formula for making up patties in buns).


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


Re: How to statically link Python with ncurses and readline?

2005-10-26 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote:
> What do you mean? A static-only build does somehow exclude that I had
> static libraries before?

No, it doesn't. I misunderstood. It is quite unclear still what you had
been doing: e.g. did you have shared versions of db and Tcl or not?
Did you have linker scripts in place? What was your specific command
line you have used to link the entire interpreter?

In the absence of details, we have to take guesses on Usenet. Sometimes,
the guesses are right, and sometimes they are wrong.

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


Re: XML Tree Discovery (script, tool, __?)

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

> just namespace + tag

here's an ElementTree-based example:

# http://effbot.org/tag/elementtree
import elementtree.ElementTree as ET

FILE = "example.xml"

path = ()
path_map = {}

for event, elem in ET.iterparse(FILE, events=("start", "end")):
if event == "start":
path = path + (elem.tag,)
else:
path_map.setdefault(path, []).append(elem)
path = path[:-1]
elem.clear() # won't need the contents any more

for path in path_map:
print "/".join(path), len(path_map[path])

given this document:



chapter 1


chapter 2



the above script prints

document 1
document/chapter 2
document/chapter/title 2

the script uses universal names for tags that live in a namespace.  for
information on how to decipher such names, see:

http://www.effbot.org/zone/element.htm#xml-namespaces

hope this helps!





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


Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-26 Thread uid09012_ti
Hi,

yes of course the traceback could be helpfull so here it is...

Traceback (most recent call last):
  File "App1.py", line 6, in ?
  File "Frame1.pyc", line 16, in ?
  File "brain.pyc", line 4, in ?
  File "xml\dom\ext\reader\__init__.pyc", line 20, in ?
LookupError: unknown encoding: utf-8


-Martin.

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


Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-26 Thread uid09012_ti
Hi,

which file names do you mean?

-Martin.

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


Re: more than 100 capturing groups in a regex

2005-10-26 Thread Joerg Schuster
> if you want to know why 100 is a reasonable and non-random choice, I
> suggest checking the RE documentation for "99 groups" and the special
> meaning of group 0.

I have read everything I found about Python regular expressions. But I
am not able to understand what you mean. What is so special about 99?

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


a Haskell a Day

2005-10-26 Thread Xah Lee
A Haskell A Day: Manifesto

This is my learning notes on Haskell. I call it a-Haskell-a-day. I've
been programing since 1992, and am a top expert at the Mathematica↗
language. I've long wanted to learn Haskell. It is my habit to write
down what i'm learning. I will send out a small tip of what i have
learned every day. If you are experienced industrial programer,
especially if you also have experience in a functional language, this
group may be useful to you. I hope you will join me in learning
Haskell.

Note: this is not a tutorial. The daily notes serve best as a
motivation for your own learning processes. Links to appropriate
sections in other reliable texts will usually be included daily.

Daily tips will be gradually collected and organized at:
http://xahlee.org/haskell/haskell.html My goal is to eventually form a
example-based tutorial.

I'm running a mailing list at Yahoo.com. To see the mailing list, go
to: http://groups.yahoo.com/group/haskell-a-day

To subscribe, send a email to: haskell-a-day-subscribe @
yahoogroups.com

 Xah
 [EMAIL PROTECTED]
∑ http://xahlee.org/

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

Re: Weird import behavior

2005-10-26 Thread Fredrik Lundh
"Tommytrojan" wrote:

> thanks for your quick reply. I guess I should have included the output.
> I thought I was clear in the error description.
> The problem is that I never assign to 'string'. I only reference it (as
> the error message correctly states). If you comment out the import
> statement in the except clause the program runs fine. Now notice that
> the exception hander never gets executed! Any explanation?

the language reference has the full story:

http://docs.python.org/ref/naming.html

"If a name is bound in a block, it is a local variable of that
block." /.../

"The following constructs bind names: formal parameters
to functions, import statements, class and function definitions
(these bind the class or function name in the defining block),
and targets that are identifiers if occurring in an assignment,
for loop header, or in the second position of an except
clause header. The import statement of the form "from ...
import *" binds all names defined in the imported module,
except those beginning with an underscore. /.../

A target occurring in a del statement is also considered bound
for this purpose (though the actual semantics are to unbind
the name). /.../

If a name binding operation occurs anywhere within a code block,
all uses of the name within the block are treated as references to
the current block."





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


Re: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Antoon Pardon
Op 2005-10-25, Christopher Subich schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2005-10-25, Christopher Subich schreef <[EMAIL PROTECTED]>:
>> 
>
>>>Which is exactly why a < b on sets returns True xor False, but cmp(a,b) 
>>>throws an exception.
>> 
>> 
>> I don't see the conection.
>> 
>> The documentation states that cmp(a,b) will return a negative value if
>> a < b. So why should it throw an exception?
>
> Because it's useful that cmp(a1, a2) should either (return a value) or 
> (throw an exception) for any element a1, a2 within type(a1) cross 
> type(a2).  If cmp sometimes is okay and sometimes throws an exception, 
> then it leads to weird borkage in things like trees.

Oh no, not "we have to protect the programmer" argument again.

This kind of behaviour will manifest itself soon enough in testing.
Almost eacht time some addition is suggested that could help
with finding bugs, it gets rejected that because such bugs will be
found soon enough with proper testing.

And in order to protect one specific case, you limit programmers
the use in all other cases where it could be usefull.

> With that in mind, not all sets are comparable.  {a} and {b} have no 
> comparison relationship, as you've pointed out, aside from not-equal. 
> I'll get to why "not-equal" is a bad idea below.
>
>>>cmp(a,b) asks for their relative rankings in some total ordering.
>> 
>> 
>> The documentation doesn't state that. I also didn't find anything in
>> the documentation on how the programmer should code in order to
>> enforce this.
>
> Most programmers are simply programmers; they haven't had the benefit of 
> a couple years' pure-math education, so the distinction between "partial 
> order" and "total order" is esoteric at best.

So. these people are not familiar with higher order functions either.
Do you think we should make python a language only for the not too
educated. 

> With that in mind, compare should conform, as best as possible, to 
> "intuitive" behavior of comparison.  Since comparisons are mostly done 
> on numbers, an extension of comparisons should behave "as much like 
> numbers" as possible.

IMO cmp(set([0]), set([0,1])) giving a result of -1, is much more
number like behaviour than throwing an exception. With numbers
we have that a < b implies cmp(a,b) < 0. So the most number like
behaviour for sets would also be that a < b would imply cmp(a,b) < 0.

>> Maybe the original idea was that cmp provided some total ordering,
>> maybe the general idea is that cmp should provide a total ordering,
>> but that is not documented, nor is there any documentation in
>> helping the programmer in this. 
>
> I doubt that anyone was thinking about it in such depth.  My bet is that 
> the thought process goes this way:

Which seems to be my biggest frustration with python. Things are
often enough not thought out in depth.

>from decimal import Decimal
>Zero = Decimal(0)
>cmp( ( ) , Zero)
>> 
>> -1
>> 
>cmp(Zero, 1)
>> 
>> -1
>> 
>cmp(1, ( ) )
>> 
>> -1
>
> I'd argue that the wart here is that cmp doesn't throw an exception, not 
> that it returns inconsistent results.  This is a classic case of 
> incomparable objects, and saying that 1 < an empty tuple is bordering on 
> meaningless.

I wont argue with you here, but it is what python gives as now.
Changing this behaviour is not going to happen.

>>>For a 
>>>space that does not have a total ordering, cmp(a,b) is meaningless at 
>>>best and dangerous at worst.
>> 
>> 
>> The current specs and implemantation are.
>> 
>> I see nothing wrong with a function that would provide four kinds of
>> results when given two elements. The same results as cmp gives now
>> when it applies and None or other appropiate value or a raised
>> exception when not.
>> 
>> Given how little this functionality differs from the current cmp,
>> I don't see why it couldn't replace the current cmp.
>
> My biggest complaint here is about returning None or IncomparableValue; 
> if that happens, then all code that relies on cmp returning a numeric 
> result will have to be rewritten.

I don't know. There are two possibilities.

1) The user is working with a total order. In that case the None
or IncomparableValues won't be returned anyway so nothing about
his code has to change.

2) The user is working with a partial order. In that case cmp
doesn't provide consistent results so the use of cmp in this
case was a bug anyway.

> Comparing incomparables is an exceptional case, and hence it should 
> raise an exception.
>
> As for saying that cmp should return some times and raise an exception 
> other times, I just find it squicky.

But cmp already behaves this way. The only difference would be that
the decision would be made based on the values of the objects instead
of only their class.

> Admittedly, this is entirely up to 
> the class designer, and your proposed guideline wouldn't change cmp's 
> behavior for clases that /are/ totally ordered.
>
> Then again, sets excepted, you

Re: a Haskell a Day

2005-10-26 Thread usenet
Xah Lee wrote:
> I hope you will join me in learning Haskell.

I think the folks here are more interested in Perl. There's a reason
why this newsgroup is called lc("comp.lang.PERL.misc").

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


Re: a Haskell a Day

2005-10-26 Thread usenet
Xah Lee wrote:
> I hope you will join me in learning Haskell.

I think the folks here are more interested in Perl. There's a reason
why this newsgroup is called lc("comp.lang.PERL.misc").

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


Re: p2exe using wine/cxoffice

2005-10-26 Thread Jon Perez
James Stroud wrote:

> "better". The only reason I want this functionality is to make my software
> available to windoze users--despite their unfortunate ignorance, they are
> people too. That's what I always say.

Actually, I think it's many unix/linux users who are ignorant of just
how nice, stable and productive Windows can be as a desktop environment.

... and I really mean that.  ;-).



Ever since Win2K got rid of the constant blue screens, the reasons for
switching over to Linux have grown less and less urgent.

The 'Nix desktop environments are growing visibly more mature with each
passing year, but device support in Linux is still decidedly inferior and
it still takes far too much time to do some things you take for granted
under Windoze.

I'm experienced enough with Linux that I can customize a distribution
like Slackware to a fair extent, but for desktop work, I stay in Windows
almost exclusively.

I have this bunch of Linux zealots in a mailing list to thank for
encouraging me to realize how good Windows can be.

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


Listen in promiscuous mode (Sniffer) on UDP port 162 and copy packets to another port

2005-10-26 Thread Henko Gouws (H)








Dear reader

 

An application A opens UDP port 162 and listens for incoming
packets.  We have another application B that wants to receive the same
information from UDP port 162 but this application cannot open the port 162
because it is already opened by application A.  We want both A and B to
receive information from port 162.

 

Does anyone know how to implement such a solution using
Python or give relevant advice?  Alternatively does anyone know about any
postings that involved Ethernet sniffers or Python programs listening to network
traffic in promiscuous mode?

 

Thank you

 

regards

Henko Gouws (Pr. Eng.)

Senior Engineer: Technical Product Development

Telkom Development Lab

Tel:  +27 12 529 7385

Fax: +27 12 548 0065

 







~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at 
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Microsoft Hatred FAQ

2005-10-26 Thread David Blomstrom
Time for my two cents regarding this "debate."

I started working on an anti-Microsoft website at
http://www.freedomware.us/ some time ago. I never
really finished it, for several reasons. I was new to
PHP, so it was kind of slow going to begin with. Then
I made some big mistakes that I still haven't found
time to fix.

Another reason is that I was simply overwhelmed by
Bill Gates' crimes. I've lived in Seattle and worked
in its public schools foor nearly two decades. I
became a political activist a few years ago and have
even run for public office several times. Trust me,
the more you learn about Bill Gates, the greater the
stench.

Still another reason my website is unfinished is that
I was one of many teachers who got laid off in the
wake of the 9/11 terrorist attacks. Since then I've
been too busy scrambling to survive to devote much
time to politics.

I can't prove that Bill Gates had anything to do with
it, but I had heard through the grapevine just a year
or two earlier that Bill Gates - who apparently
regards public education as  a Microsoft subsidiary -
wanted to get rid of a bunch of teachers, for reasons
known only to Gates.

I experienced some shocking dirty tricks during my
first bid for public office at the hands of Bill
Gates' father. At the time, I couldn't figured out why
he would care about a school board campaign. That was
before I realized how important students are to Bill
Gates' bank account.

How sleazy is Bill Gates' father? He's a founding
partner of Preston, Gates & Ellis - the lobbying firm
masquerading as a law firm that recently made
front-page headlines as the empoloyer of Jack
Abramoff. But Abramoff isn't the only sleazebag who
associates with Bill Gates, Sr. He may not even be the
only murderer (assuming he's eventually convicted of
murder).

I find it very symbolic that the late pedophile judge,
Gary Little, was a teacher at the Lakeside School for
Boys - perhaps while Bill Gates and Paul Allen were
students there. I wouldn't be at all surprised if
Little and Bill Gates' father were chums, before
Little committed suicide.

The bottom line: I get sick of the tired old argument
that Bill Gates is guilty of nothing more than
excelling at the game of capitalism AND he's one
helluva philanthropist besides.

Bill Gates is a bucket of sleaze, period. He's
obviously intelligent and a hard worker and has
certainly earned million dollars. But he isn't worthy
of billionaire status. That can be attributed to his
disdain for both the law and ethics and to his silent
partner, his father.

And Bill Gates' "philanthropy" is nothing more than
public relations, advertising, tax-writeoffs, bribes.
The jackass even screwed Seattle taxpayers out of
millions of dollars in choosing a home for the Bill
and Melinda Gates Foundation!

To put it in perspective, think about the legacies of
past multi-billionaires, like the Carnegies and
Rockefellers. They left us great institutions, like
libraries. If Bill Gates died to today, what would his
legacy be? "Microsoft Auditorium" in the Seattle
Public Library. A building named "Mary Gates Hall" at
the University of Washington. Schools that get worse
every year, staffed by teachers who can scarcely
afford to live in the city in which they work.

The high-tech community typically disdains politics,
caring little about more than an operating system that
runs the way it should. But politics are all around
us. As one of many examples, people should be worried
about an extrmely powerful and amoral individual named
Bill Gates gaining control of the Internet. Just look
at what the b*stard has alrady done to our schools.





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-26 Thread David Blomstrom
A bit off topic, but it amazes me that people in the
web design/Internet industry don't take a more active
stance against Microsoft.

Think about it: The health care industry has been
privatized in the U.S. I spent sixteen years in
education, another institution that has been
privatized. (It has largely become another Microsoft
subsidiary.)

So here we have web designers, who are among the
freest people in the world, able to choose their
specialties, hours, fees and even where they work. Yet
they surrender to Microsoft's "standards" without a
fight.

Frankly, I think every self-respecting webmaster ought
to be campaigning against Microsoft on their websites.
Tiny, simple messages like "Microsoft-Free" or "If you
like George AWOL Bush, you'll love Bill Gates," could
go a long ways in educating the public.




__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top-quoting defined [was: namespace dictionaries ok?]

2005-10-26 Thread Duncan Booth
James Stroud wrote:

> On Tuesday 25 October 2005 00:31, Duncan Booth wrote:
>> P.S. James, *please* could you avoid top-quoting
> 
> Were it not for Steve Holden's providing me with a link off the list,
> I would have never known to what it is you are referring. I have read
> some relevant literature to find that this is more widely known as
> "top-posting". I'll go with majority rules here, but I would like to
> say that my lack of "netiquette" in this matter comes from
> practicality and not malice.

No, I didn't think it was malice which is why I just added what I 
considered to be a polite request at the end of my message. I assumed that 
most people either knew the phrase or could find out in a few seconds using 
Google so there wasn't much point in rehashing the arguments. Probably I 
should have equally lambasted Ron for the heinous crime of bottom-quoting. 

In general, there are three ways to quote a message: top-quoting, which 
forces people to read the message out of order; bottom-quoting which is 
nearly as bad because it hides the new comments; and proper quoting in 
context where you trim the message and put specific points under brief bits 
of context.

The thread in question had a horrific mix of top and bottom quoting, so 
that when I tried to reply at what I thought was an appropriate point in 
the thread (<[EMAIL PROTECTED]>) I think the 
order it went was something like:

> quote from James (4)
comment from Ron (5)
>>> quote from James (2)
>> comment from Ron (3)
>>> quote from James (2)
 quote from Ron (1)

I spent a while trying to trim that down to relevant context, and in 
particular trying to work out in what order the original statements had 
been made. In the end I gave up and replied to an earlier message which was 
more easily trimmable.

> Also, here is a well written synopsis of the arguments in 
> favor of top-posting and they may even be strong enough to legitimize the 
> practice:

The arguments are mostly sound, but I would draw slightly different 
conclusions:

Follow the conventions of the particular newsgroup or mailing list, but 
with that in mind, for all replies, Middle Post. Respond to each point in 
turn with lots of snipping.

He's right though, its not a religious issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How best to reference parameters.

2005-10-26 Thread David Poundall
Nice - I like that Tony.  I had seen it around before but I didn't
catch on.  Thanks for the clear example..

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


Re: more than 100 capturing groups in a regex

2005-10-26 Thread Fredrik Lundh
Joerg Schuster wrote:

> > if you want to know why 100 is a reasonable and non-random choice, I
> > suggest checking the RE documentation for "99 groups" and the special
> > meaning of group 0.
>
> I have read everything I found about Python regular expressions. But I
> am not able to understand what you mean. What is so special about 99?

it's the largest number than can be written with two decimal digits.





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


Re: a Haskell a Day

2005-10-26 Thread Erik Max Francis
Xah Lee wrote:

> This is my learning notes on Haskell. I call it a-Haskell-a-day.

Another day, another community to completely piss of, huh, Xah?

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Never take a stranger's advice / Never let a friend fool you twice
   -- Florence, _Chess_
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: more than 100 capturing groups in a regex

2005-10-26 Thread Joerg Schuster
So what?

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


Re: Listen in promiscuous mode (Sniffer) on UDP port 162 and copy packetsto another port

2005-10-26 Thread Gerald Klix
Hi Henko,
the proper solution to this problem ist to use on libpcap's python bindings,
like for example Billy The Kid.

Here are some pointers:
http://home.student.utwente.nl/g.v.berg/btk/
http://pycap.sourceforge.net/
http://monkey.org/~dugsong/pypcap/
http://www.tcpdump.org/ (libpcap)

HTH Gerald

- Original Message -
From: Henko Gouws (H)
To: python-list@python.org
Sent: Tuesday, October 25, 2005 10:26 AM
Subject: Listen in promiscuous mode (Sniffer) on UDP port 162 and copy
packetsto another port


Dear reader

An application A opens UDP port 162 and listens for incoming packets.  We
have another application B that wants to receive the same information from
UDP port 162 but this application cannot open the port 162 because it is
already opened by application A.  We want both A and B to receive
information from port 162.

Does anyone know how to implement such a solution using Python or give
relevant advice?  Alternatively does anyone know about any postings that
involved Ethernet sniffers or Python programs listening to network traffic
in promiscuous mode?

Thank you

regards
Henko Gouws (Pr. Eng.)
Senior Engineer: Technical Product Development
Telkom Development Lab
Tel:  +27 12 529 7385
Fax: +27 12 548 0065

~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~





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

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


Re: more than 100 capturing groups in a regex

2005-10-26 Thread Iain King

Fredrik Lundh wrote:
> Iain King wrote:
>
> > Anyway, back to the OP: in this specific case, the cap of 100 groups in
> > a RE seems random to me, so I think the rule applies.
>
> perhaps in the "indistinguishable from magic" sense.
>
> if you want to know why 100 is a reasonable and non-random choice, I
> suggest checking the RE documentation for "99 groups" and the special
> meaning of group 0.
>
> 

Ah, doh!  Of course.  Oh well then...  still, doesn't python's RE
engine support named groups?  That would be cumbersome, but would allow
you to go above 100...

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


Re: a Haskell a Day

2005-10-26 Thread Keith Thompson
"Xah Lee" <[EMAIL PROTECTED]> writes:
[snip]

  ___
  /|  /|  |  |
  ||__||  |  Please do   |
 /   O O\__ NOT  |
/  \ feed the|
   /  \ \ trolls |
  /   _\ \ __|
 /|\\ \ ||
/ | | | |\/ ||
   /   \|_|_|/   \__||
  /  /  \|| ||
 /   |   | /||  --|
 |   |   |// |  --|
  * _|  |_|_|_|  | \-/
   *-- _--\ _ \ //   |
 /  _ \\ _ //   |/
   *  /   \_ /- | - |   |
 *  ___ c_c_c_C/ \C_c_c_c

-- 
Keith Thompson (The_Other_Keith) [EMAIL PROTECTED]  
San Diego Supercomputer Center <*>  
We must do something.  This is something.  Therefore, we must do this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Antoon Pardon
Op 2005-10-25, Christopher Subich schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>
>> I also think there is the problem that people aren't used to partial
>> ordering. There is an ordering over sets, it is just not a total
>> ordering. But that some pairs are uncomparable (meaning that neither
>> one is smaller or greater) doesn't imply that comparing them is
>> ill defined.
>
> It depends on your definition of "comparison."  Admittedly, <, =, !=, 
> and > can be defined for a partial ordering, but classical mathematics, 
> as understood by most people (even programmers), assumes that unless a 
>== b, a > b or a < b.
>
> The comparisons, as defined this way, are done on a totally ordered set, 
> yes.  But since most comparisons ever done -are- done on a totally 
> ordered set (namely the integers or reals), it's entirely fair to say 
> that "a programmer's expectation" is that comparisons should work more 
> or less like a totally ordered list.
>
>
> With that caevat in mind, comparison on a partially ordered domain /is/ 
> ill-defined; it can give inconsistent results from the "a < b or a > b 
> or a == b" rule.

Against people expectations is not the same as inconsistent.

>> 
>> Well it is a wrong assumption is general. There is nothing impure about
>> partial ordering. 
>
> Impure? Probably not.  Useless from many perspective when "comparisons" 
> are needed, to the point where it's probably safer to throw an exception 
> than define results.
>
>> That is IMO irrelevant. The subset relationship is an ordering and as
>> such has all characteristics of other orderings like "less than",
>> except that the subset relationship is partial and the less than
>> relationship is total. How it is called "subset" vs "less than" is
>> IMO irrelevant. It is about mathematical characteristics.
>
> Still accident.  < wouldn't be used for sets if we had a subset symbol 
> on the standard keyboard, APL fans notwithstanding.

That is only because people usualy work with numbers and sets at the
same time and using different symbols helps making the distinction.

But using <= for subset is mathematical completely correct. If you
want to go purely formal, numbers are just a particular family of
sets where the less than or equal relation of numbers coincides with
the subset relation of sets in that family.

People use the multiplication symbol for multiplying matrices although
matrix multiplication is something different from number multiplication.

If the multiplications of matrices is enough like the multiplication of
numbers to use the same symbol, I see nothing wrong in using the same
symbol for the (strict) subset relation as is used for the less than
(or equal) relation on numbers.

> Simce programmers 
> familiar with Python understand that < on sets isn't a "real" comparison 
> (i.e. provide a total order), they don't expect unique, consistent 
> results from something like sort (or a tree, for that matter).

>> 
>>>By analogy, one can ask, "is the cat inside the box?" and get the answer
>>>"No", but this does not imply that therefore the box must be inside the
>>>cat.
>> 
>> 
>> Bad analogy, this doesn't define a mathematical ordering, the subset
>> relationship does.
>
> Yes, it does.  Consider "in" as a mathematical operator:

My appologies, I though you were going in the "I can in my coat,
my coat can in the box" kind of direction.

> For the set (box, cat-in-box)
>
> box in box: False
> box in cat-in-box: False
> cat-in-box in box: True
> cat-in-box in cat-in-box: False
>
> For the set (box, smart-cat) # cat's too smart to get in the box
>
> box in box: False
> box in smart-cat: False
> smart-cat in box: False
> smart-cat in smart-cat: False
>
> In both these cases, the "in" operator is irreflexive, asymmetric, and 
> transitive (extend to mouse-in-cat if you really care about transitive), 
> so "in" is a partial order sans equality.  A useless one, but a partial 
> order nonetheless.

I don't know if it is useless. This kind of relationship seems very
common in political geography.

This village is in this county, this county is in this state, this state
is in this nation.

Also magizines that test certain equipment to give advice on the best
buy, usualy work with methods that result in partial orderings.

>>>Notice that L1 and L2 contain the same elements, just in different orders.
>>>Sorting those two lists should give the same order, correct?
>> 
>> 
>> No. Since we don't have a total ordering, sorting doesn't has to give
>> the same result. For as far as sorting is defined on this kind of
>> object, the only thing I would expect is that after a sort the
>> following condition holds.
>> 
>> for all i,j if i < j then not L[i] > L[j]
>
> Highly formal, aren't you?

I like the precision it provides.

> Again, common programming allows for "not a > b"
> == "a <= b", so your condition becomes the more familiar:
>
> for all i,j in len(list), if i < j then L[i] <= L[j]

So, should we limit our programming to t

Re: a Haskell a Day

2005-10-26 Thread Martin Ambuhl
Xah Lee wrote:
> This is my learning notes on Haskell. I call it a-Haskell-a-day.

No one in any of
   comp.lang.perl.misc,
   comp.lang.python,
   comp.lang.c,
   comp.lang.java.programmer,
   comp.unix.programmer
gives a damn about your adventures in Haskell.
If you must mastubate, please do so in private.
-- 
http://mail.python.org/mailman/listinfo/python-list


Pickle to source code

2005-10-26 Thread Gabriel Genellina
Hello

I want to convert from pickle format to python source code. That is,
given an existing pickle, I want to produce a textual representation
which, when evaluated, yields the original object (as if I had
unpickled the pickle).
I know of some transformations pickle/xml (Zope comes with one such
tool, gnosis xml is another) so I believe I could build something based
on them.
But I dont want to reinvent the wheel, I wonder if anyone knows of a
library which could do what I want?

Thanks,
Gabriel Genellina
Softlab SRL

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


Re: more than 100 capturing groups in a regex

2005-10-26 Thread André Malo
* "Iain King" <[EMAIL PROTECTED]> wrote:

> Ah, doh!  Of course.  Oh well then...  still, doesn't python's RE
> engine support named groups?  That would be cumbersome, but would allow
> you to go above 100...

The named groups are built on top of numbered captures. They are mapped by the
parser and the match instance's group method. The regex matcher itself never
sees these names.

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


Re: select.select() on windows

2005-10-26 Thread Maksim Kasimov

you have to use non-block readining.

http://docs.python.org/lib/module-select.html:
A time-out value of zero specifies a poll and never blocks.

jas wrote:
> I am currently using subprocess to execute a command.  Then I read from
> it's stdout...however, this is hanging on a read..waiting for more
> bytes.  So what I would like is to timeout...and select.selec() seems
> to be what I need.  Except I don't have a socket, i have stdout.
> 
> Any suggestions on how to do a timeout like select.select with stdout?
> 
> Thanks
> 


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-26 Thread Eike Preuss
David Schwartz wrote:
>>
>>But if *every* vendor has to make that same choice, there is no place for 
>>that other 5% to go to buy another operating system.  So the other 
>>operating system(s) die off.  And those 5% become customers of Microsoft 
>>since there's no other choice left.  And *that* is where the legal 
>>problems start:  they gained market share by preventing consumers from 
>>finding competing products.
> 
> 
> Right, except that's utterly absurd. If every vendor takes their tiny 
> cut of the 95%, a huge cut of the 5% is starting to look *REALLY* good.
> 

Sure, that would be true if the market would be / would have been really
global. In practice if you have a shop you have a limited 'region of
influence'. Optimally you are the only shop in this region that sells
the stuff, or perhaps there are a few shops that compete with you. Lets
say in your region are two shops competing with you, and you must decide
wether to sell product A (95%) or B (5%), but you may not sell both.
Decision 1: Sell A, share the 95% of the local market with two -> about
32% of the local market for all of you, if all perform equally good
Decision 2: Sell B -> you get the 5% of the market, the others 47% each

This calculation is probably still a very bad approximation of the
truth, but things are definitely not as easy as you state them.

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


Re: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Antoon Pardon
Op 2005-10-25, Steven D'Aprano schreef <[EMAIL PROTECTED]>:
> On Tue, 25 Oct 2005 10:09:29 -0400, Christopher Subich wrote:
>
By analogy, one can ask, "is the cat inside the box?" and get the answer
"No", but this does not imply that therefore the box must be inside the
cat.
>>> 
>>> 
>>> Bad analogy, this doesn't define a mathematical ordering, the subset
>>> relationship does.
>> 
>> Yes, it does.  Consider "in" as a mathematical operator:
>>
>> For the set (box, cat-in-box)
>> 
>> box in box: False
>> box in cat-in-box: False
>> cat-in-box in box: True
>> cat-in-box in cat-in-box: False
>> 
>> For the set (box, smart-cat) # cat's too smart to get in the box
>> 
>> box in box: False
>> box in smart-cat: False
>> smart-cat in box: False
>> smart-cat in smart-cat: False
>> 
>> In both these cases, the "in" operator is irreflexive, asymmetric, and 
>> transitive (extend to mouse-in-cat if you really care about transitive), 
>> so "in" is a partial order sans equality.  A useless one, but a partial 
>> order nonetheless.
>
> What do you mean "in" is a useless ordering? It makes a huge difference
> whether "nuclear bomb in New York" is true or not.
>
> In fact, I'm quite surprised that Antoon should object to "in" as "this
> doesn't define a mathematical ordering, the subset relationship does" when
> "subset" is just "in" for sets: set S is a subset of set T if for all
> elements x in S, x is also in T. Informally, subset S is in set T.

I was misunderstaning where Christopher was heading to.

> Can somebody remind me, what is the problem Antoon is trying to solve here?

Well there are two issues. One about correct behaviour and one about
practicallity.

The first problem is cmp. This is what the documentation states:

cmp(x, y)
Compare the two objects x and y and return an integer according to
the outcome. The return value is negative if x < y, zero if x == y
and strictly positive if x > y. 

The problem is, that if someone implements a partial ordered class,
with the rich comparisons, cmp doesn't behave correct. It can't
behave correct because it will always give an number as a result
and such a number implies one of three relations between two
elements, but with partial ordered classes, it is possible none
of these relations exist between those two elements. So IMO cmp
should be changed to reflect this. This can be done either by cmp
returning None or UnequalValues.  or by cmp raising UnequalValues
in such a case.

The second part is one of practicallity. Once you have accepted cmp,
should reflect this possibility, it makes sense that the __cmp__
method should get the same possibilities, so that where it is more
pratical to do so, the programmer can implement his partial order
through one __cmp__ method instead of having to write six.


In my opinion such a change would break no existing code. This
is because there are two possibilities.

1) The user is using cmp on objects that form a total order.
In such circumstances the behaviour of cmp doesn't change.

2) The user is using cmp on objects that don't form a total
order. In such circumstances cmp doesn't give consistent
results, so the code is already broken.

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


Re: more than 100 capturing groups in a regex

2005-10-26 Thread Joerg Schuster
My first test program was far too naive. Evil things do happen. Simply
removing the code that restricts the number of capturing groups to 100
is not a solitution.

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


Re: more than 100 capturing groups in a regex

2005-10-26 Thread Joerg Schuster
... solution

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


Re: p2exe using wine/cxoffice

2005-10-26 Thread Thomas Heller
Jon Perez <[EMAIL PROTECTED]> writes:

> James Stroud wrote:
>
>> "better". The only reason I want this functionality is to make my software
>> available to windoze users--despite their unfortunate ignorance, they are
>> people too. That's what I always say.
>
> Actually, I think it's many unix/linux users who are ignorant of just
> how nice, stable and productive Windows can be as a desktop environment.
>
> ... and I really mean that.  ;-).

I was waiting for someone to say that.

+1.

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


Looping Problem (Generating files - only the last record generates a file)

2005-10-26 Thread vasilijepetkovic
Hello All,

I have a problem with the program that should generate x number of txt
files (x is the number of records in the file datafile.txt).

Once I execute the program (see below) only one file (instead of x
files) is created. The file created is based on the last record in
datafile.txt.

The program is as follows:

#!  python

HEADER = "This page displays longitude-latitude information"
SUBHEADER = "City"

for line in open("datafile.txt"):


town, latlong = line.split('\t')

f = open(town + ".txt", "w+")

f.write(HEADER + "\n")
f.write(SUBHEADER + ": " + town + "\n")
f.write("LAT/LONG" + ": " + latlong + "\n")
f.close()


# end





The datafile.txt is as follows (tab separated columns):


NYC -
Lima-
Rome-



Once executed, the program will create a single file (named Rome.txt)
and it would not create files NYC.txt and Lima.txt as I would expect it
to do.

I'd appreciate if you can pinpoint my error. 

Best, 

Vasa

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


Re: select.select() on windows

2005-10-26 Thread Ben Sizer

jas wrote:
> I am currently using subprocess to execute a command.  Then I read from
> it's stdout...however, this is hanging on a read..waiting for more
> bytes.  So what I would like is to timeout...and select.selec() seems
> to be what I need.  Except I don't have a socket, i have stdout.
>
> Any suggestions on how to do a timeout like select.select with stdout?

I am not too familiar with any asynchronous I/O facilities in Python
beyond select, so in your situation I would use the threading module,
with the blocking read in one thread and your time-out in the main
thread. You could perhaps use an Event object here, which has the
time-out functionality for you.

-- 
Ben Sizer

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


Re: Looping Problem (Generating files - only the last record generates a file)

2005-10-26 Thread Iain King

[EMAIL PROTECTED] wrote:
> Hello All,
>
> I have a problem with the program that should generate x number of txt
> files (x is the number of records in the file datafile.txt).
>
> Once I execute the program (see below) only one file (instead of x
> files) is created. The file created is based on the last record in
> datafile.txt.
>
> The program is as follows:
> 
> #!  python
>
> HEADER = "This page displays longitude-latitude information"
> SUBHEADER = "City"
>
> for line in open("datafile.txt"):
>
>
> town, latlong = line.split('\t')
>
> f = open(town + ".txt", "w+")
>
> f.write(HEADER + "\n")
> f.write(SUBHEADER + ": " + town + "\n")
> f.write("LAT/LONG" + ": " + latlong + "\n")
> f.close()
>
>
> # end
> 
>
>
>
>
> The datafile.txt is as follows (tab separated columns):
> 
>
> NYC   -
> Lima  -
> Rome  -
>
> 
>
> Once executed, the program will create a single file (named Rome.txt)
> and it would not create files NYC.txt and Lima.txt as I would expect it
> to do.
>
> I'd appreciate if you can pinpoint my error.
> 
> Best, 
> 
> Vasa

Did you try indenting the last five lines?

Iain

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


Re: Looping Problem (Generating files - only the last record generates a file)

2005-10-26 Thread [EMAIL PROTECTED]
You have only indented the first line in the for-loop, so for each line
in the file you split the line into town and latlong. Then after you
have split the last line in the file you write a new file with the last
result in the for-loop.

What you want is probably something like this:

#!  python

HEADER = "This page displays longitude-latitude information"
SUBHEADER = "City"

for line in open("datafile.txt"):
town, latlong = line.split('\t')
f = open(town + ".txt", "w+")
f.write(HEADER + "\n")
f.write(SUBHEADER + ": " + town + "\n")
f.write("LAT/LONG" + ": " + latlong + "\n")
f.close() 

# end 

/Johan

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


Re: Looping Problem (Generating files - only the last record generates a file)

2005-10-26 Thread John Abel
[EMAIL PROTECTED] wrote:

>Hello All,
>
>I have a problem with the program that should generate x number of txt
>files (x is the number of records in the file datafile.txt).
>
>Once I execute the program (see below) only one file (instead of x
>files) is created. The file created is based on the last record in
>datafile.txt.
>
>The program is as follows:
>
>#!  python
>
>HEADER = "This page displays longitude-latitude information"
>SUBHEADER = "City"
>
>for line in open("datafile.txt"):
>
>
>town, latlong = line.split('\t')
>
>f = open(town + ".txt", "w+")
>
>f.write(HEADER + "\n")
>f.write(SUBHEADER + ": " + town + "\n")
>f.write("LAT/LONG" + ": " + latlong + "\n")
>f.close()
>
>  
>
These lines need to be within your loop.

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


Re: Looping Problem (Generating files - only the last record generates a file)

2005-10-26 Thread Marcus Ekelund
[EMAIL PROTECTED] wrote:
> Hello All,
>
> I have a problem with the program that should generate x number of txt
> files (x is the number of records in the file datafile.txt).
>
> Once I execute the program (see below) only one file (instead of x
> files) is created. The file created is based on the last record in
> datafile.txt.
>
> The program is as follows:
> 
> #!  python
>
> HEADER = "This page displays longitude-latitude information"
> SUBHEADER = "City"
>
> for line in open("datafile.txt"):
>
>
> town, latlong = line.split('\t')
>
> f = open(town + ".txt", "w+")
>
> f.write(HEADER + "\n")
> f.write(SUBHEADER + ": " + town + "\n")
> f.write("LAT/LONG" + ": " + latlong + "\n")
> f.close()
>
>
> # end
> 
>
>
>
>
> The datafile.txt is as follows (tab separated columns):
> 
>
> NYC   -
> Lima  -
> Rome  -
>
> 
>
> Once executed, the program will create a single file (named Rome.txt)
> and it would not create files NYC.txt and Lima.txt as I would expect it
> to do.
>
> I'd appreciate if you can pinpoint my error.

Since the lines that handle writing to the file aren't indented as far
as the line that splits the data, they are not part of the loop. They
are only executed  once after the loop has completed, with town and
latlong set to the values they got at the last iteration of the loop.

It should look more like this:

for line in open("datafile.txt"):
town, latlong = line.split('\t')

f = open(town + ".txt", "w+")
f.write(HEADER + "\n")
f.write(SUBHEADER + ": " + town + "\n")
f.write("LAT/LONG" + ": " + latlong + "\n")
f.close()

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


Re: Microsoft Hatred FAQ

2005-10-26 Thread Iain King

David Blomstrom wrote:
> A bit off topic, but it amazes me that people in the
> web design/Internet industry don't take a more active
> stance against Microsoft.
>
> Think about it: The health care industry has been
> privatized in the U.S. I spent sixteen years in
> education, another institution that has been
> privatized. (It has largely become another Microsoft
> subsidiary.)
>
> So here we have web designers, who are among the
> freest people in the world, able to choose their
> specialties, hours, fees and even where they work. Yet
> they surrender to Microsoft's "standards" without a
> fight.
>
> Frankly, I think every self-respecting webmaster ought
> to be campaigning against Microsoft on their websites.
> Tiny, simple messages like "Microsoft-Free" or "If you
> like George AWOL Bush, you'll love Bill Gates," could
> go a long ways in educating the public.
>

Or, you know, just code your website to be W3C compliant, which IE will
invariably choke on. 

Iain

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


Re: Looping Problem (Generating files - only the last record generates a file)

2005-10-26 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> Once I execute the program (see below) only one file (instead of x
> files) is created. The file created is based on the last record in
> datafile.txt.

> #!  python
> 
> HEADER = "This page displays longitude-latitude information"
> SUBHEADER = "City"
> 
> for line in open("datafile.txt"):
> 
> 
> town, latlong = line.split('\t')
 
In Python whitespace is significant. For the following to be executed in the
for-loop it has to be indented to the same level as the line above. 

> f = open(town + ".txt", "w+")
> 
> f.write(HEADER + "\n")
> f.write(SUBHEADER + ": " + town + "\n")
> f.write("LAT/LONG" + ": " + latlong + "\n")
> f.close()
> 
> 
> # end
> 

The effect of aligning it with the for-statement is that it is executed only
once /after/ the loop has run to completion. At that point town and latlong
are still bound to the values they were assigned in the last iteration
(with an empty datafile.txt the loop would never be executed and you would
get a NameError).

Peter

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


Printing a document in the default network printer under Windows

2005-10-26 Thread Maravilloso
Hi all:

I'm getting mad trying to find the way for making a standard
document (Word file, Postscript document, JPEG file...) to be
sent/printed in the default network printer from a python script that
runs on Win2K.

Any idea?

Thanks in advance.

Maravilloso

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


RE: Printing a document in the default network printer under Windows

2005-10-26 Thread Tim Golden
[Maravilloso]

> I'm getting mad trying to find the way for making a standard
> document (Word file, Postscript document, JPEG file...) to be
> sent/printed in the default network printer from a python script that
> runs on Win2K.

Is this of any use?

http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: replace words

2005-10-26 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> What is the way for replacing in a string from . to . the sentence?
> for example:
> "been .taken.  it may be .left. there,
> even if the .live coals were not. cleared"
> I want to do this-> replace(\.(.*)\.,\.start (1) end\.)
> result:
> "been .start taken end.  it may be .start left end. there,
> even if the .start live coals were not end. cleared"

Use \1 to refer to the group in the substitution expression.
You also need to change the regex to non-greedy match (the trailing ?).
Otherwise you only get one big match from .taken ... not.

import re
s = ("been .taken.  it may be .left. there, "
 "even if the .live coals were not. cleared")

r = re.compile(r"\.(.*?)\.")
print r.sub(r".start \1 end.", s)

Peter

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


RE: p2exe using wine/cxoffice

2005-10-26 Thread Tim Golden

> James Stroud wrote:
>> "better". The only reason I want this functionality is to make my
software
>> available to windoze users--despite their unfortunate ignorance, they
are
>> people too. That's what I always say.


Jon Perez <[EMAIL PROTECTED]> writes:
> Actually, I think it's many unix/linux users who are ignorant of just
> how nice, stable and productive Windows can be as a desktop
environment.
>
> ... and I really mean that.  ;-).

> Thomas Heller:
> I was waiting for someone to say that.
> +1.

Well, I'm with you. I'm sure a lot of people will chime in to
point out just how flexible and useful and productive Linux
is as a workstation, but every time I try to use it -- and
I make an honest effort -- I end up back in Windows where
I've been at home for 10 years and more. I don't claim
that Windows has some overall superiority; I merely claim
that -- as a professional programmer -- I find Windows at
least as easy and comfortable and productive for my tasks
as Linux.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Printing a document in the default network printer under Windows

2005-10-26 Thread Maravilloso
Perfect, thanks!

I owe you now some PyBeers :-)

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


Re: Pickle to source code

2005-10-26 Thread Benjamin Niemann
Gabriel Genellina wrote:

> I want to convert from pickle format to python source code. That is,
> given an existing pickle, I want to produce a textual representation
> which, when evaluated, yields the original object (as if I had
> unpickled the pickle).
> I know of some transformations pickle/xml (Zope comes with one such
> tool, gnosis xml is another) so I believe I could build something based
> on them.
> But I dont want to reinvent the wheel, I wonder if anyone knows of a
> library which could do what I want?

If all objects correctly implement the __repr__ method (true for built-in
stuff like list, dict, set...):
Just unpickle it and call repr() on the resulting object.


-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pickle to source code

2005-10-26 Thread Maksim Kasimov


As far i know, in pickle-file there are only attributes values of a pickled 
object, but not an object itself.

It is possible to unpickle object only if you have the sourse of the class that 
object you have pickled.
So, if you have class code and attribute values of the class instance, there is 
no problem to produce a textual representation of the object. Isn't it?

(sorry for my English)

Gabriel Genellina wrote:
> Hello
> 
> I want to convert from pickle format to python source code. That is,
> given an existing pickle, I want to produce a textual representation
> which, when evaluated, yields the original object (as if I had
> unpickled the pickle).
> I know of some transformations pickle/xml (Zope comes with one such
> tool, gnosis xml is another) so I believe I could build something based
> on them.
> But I dont want to reinvent the wheel, I wonder if anyone knows of a
> library which could do what I want?
> 
> Thanks,
> Gabriel Genellina
> Softlab SRL
> 


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


assignment to reference

2005-10-26 Thread Loris Caren
If

a = 'apple'
b = 'banana'
c = 'cabbage'

How can I get something like:-

for i in 'abc':
r = eval(i)
if r == 'cabbage': r = 'coconut'

actually change the object referenced by r rather
than creating a new object temporarily referenced by it?

I've tried playing with eval and exec without the desired
effect.
-- 
http://mail.python.org/mailman/listinfo/python-list


Double replace or single re.sub?

2005-10-26 Thread Iain King
I have some code that converts html into xhtml.  For example, convert
all  tags into .  Right now I need to do to string.replace calls
for every tag:

html = html.replace('','')
html = html.replace('','')

I can change this to a single call to re.sub:

html = re.sub('<([/]*)i>', r'<\1em>', html)

Would this be a quicker/better way of doing it?

Iain

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


Re: p2exe using wine/cxoffice

2005-10-26 Thread Sybren Stuvel
Jon Perez enlightened us with:
> Actually, I think it's many unix/linux users who are ignorant of
> just how nice, stable and productive Windows can be as a desktop
> environment.

I thought the same thing after spending two hours removing some adware
I found.

> Ever since Win2K got rid of the constant blue screens, the reasons
> for switching over to Linux have grown less and less urgent.

One thing in Linux (Gnome actually) that I miss in Windows, is that in
the latter you need to grab the title bar of a window to move it, and
the edge to resize it. In Gnome, I can press the ALT key and drag the
window with the left mouse button and resize it by dragging with the
right mouse button. When moving, it doesn't matter where your cursor
is, as long as it's inside the window. For resizing, it grabs the
closest corner and moves that.

It's like having a scrollwheel on your mouse. If you've never used
such a thing you don't miss it, but if you're used to it, it's a major
annoyance when it's gone.

> The 'Nix desktop environments are growing visibly more mature with
> each passing year, but device support in Linux is still decidedly
> inferior and it still takes far too much time to do some things you
> take for granted under Windoze.

When I replaced my CPU, motherboard and RAM, I had to reinstall
Windows and all applications. Linux just booted. When I upgrade my
video card, Linux just accepts it without even a single message. On
Windows I have to do a reinstall of the video drivers.

I think that everybody is influenced by their own experience. Here are
a few of my reasons to run Linux, besides the ones already mentioned:

- Window management in Linux is separate from the application.
  That means that a non-responsive (crashed or just very busy)
  application can still be minimized or moved.

- If I log in and my desktop is shown, I can start working
  immediately. No need to wait for all sorts of things in the
  system tray to start up first.

- Software installation on Linux usually works via the
  distribution's package manager, so it's one application for
  almost every software install. It also automatically downloads
  and installs all required libraries etc.

- No need to defragment my harddisk.

- No viruses/spyware.

There are only two downsides I notice:

- There are some games I want to play which aren't available on
  Linux. That's the only reason I run Windows, btw.

- I have to be a little more picky about the hardware I buy.


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: p2exe using wine/cxoffice

2005-10-26 Thread Sybren Stuvel
Tim Golden enlightened us with:
> Well, I'm with you. I'm sure a lot of people will chime in to point
> out just how flexible and useful and productive Linux is as a
> workstation, but every time I try to use it -- and I make an honest
> effort -- I end up back in Windows

I'm curious, what do you mean with "it" in the part "every time I try
to use it"?

There are different distributions of Linux, and putting them all on
one big pile is like saying "I've tried Windows, and I really don't
like it's user interface" and referring to the interface of Windows
3.1.

Many people use Fedora (from RedHat) and don't like it. I agree with
them - I don't like it either. For those people: give Ubuntu Linux a
go. It's my favourite - and my girlfriend's too btw.

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: assignment to reference

2005-10-26 Thread Sybren Stuvel
Loris Caren enlightened us with:
> If
>
> a = 'apple'
> b = 'banana'
> c = 'cabbage'
>
> How can I get something like:-
>
> for i in 'abc':
> r = eval(i)
> if r == 'cabbage': r = 'coconut'
>
> actually change the object referenced by r rather
> than creating a new object temporarily referenced by it?

Use:

x = {
'a': 'apple',
'b': 'banana',
'c': 'cabbage'
}

for key, value in x.iteritems():
if value == 'cabbage':
x[key] = 'coconut'

NOTE: I haven't tested this code

> I've tried playing with eval and exec without the desired effect.

If you notice yourself using such functions, it's ususally a lot
better to simply stash your data in a dictionary, and use that
instead.

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: assignment to reference

2005-10-26 Thread Fredrik Lundh
Loris Caren wrote:

> a = 'apple'
> b = 'banana'
> c = 'cabbage'
>
> How can I get something like:-
>
> for i in 'abc':
> r = eval(i)
> if r == 'cabbage': r = 'coconut'
>
> actually change the object referenced by r rather
> than creating a new object temporarily referenced by it?

if you need a container, you should use a container object instead of
the local namespace.  in this case, a dictionary is what you want:

stuff = {
'a': 'apple',
'b': 'banana',
'c': 'cabbage'
}

for i in "abc":
if stuff[i] == "cabbage":
stuff[i] = "coconut"

(tweak as necessary)





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


Re: a Haskell a Day

2005-10-26 Thread Roedy Green
On 26 Oct 2005 00:38:23 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote,
quoted or indirectly quoted someone who said :

>A Haskell A Day: Manifesto
This is the wrong newsgroup. Had you done the same for Java,
comp.lang.java.help would be the place to post it.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Log rolling question

2005-10-26 Thread NickC
If you're on Python 2.4, then consider whether or not you can use a
TimedRotatingLogFileHandler from the logging module to handle this for
you:
http://www.python.org/doc/2.4.1/lib/node344.html

Of course, that only works if defining a "month" as 30 days is
acceptable. If you genuinely need calendar months, then you still need
to do it manually.

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


Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Tim Golden
[Sybren Stuvel]

Tim Golden enlightened us with:
> > Well, I'm with you. I'm sure a lot of people will chime in to point
> > out just how flexible and useful and productive Linux is as a
> > workstation, but every time I try to use it -- and I make an honest
> > effort -- I end up back in Windows

> I'm curious, what do you mean with "it" in the part "every time I try
> to use it"?

Fair question. I have, over the years, installed and used Gentoo,
Vector, RH, Ubuntu Breezy (my current choice) and various other 
flavours and distros. When I "use it" I mean typically that I use 
whatever desktop-type thing presents itself to me -- Gnome or XFCE 
or Fluxbox, say -- one or more editors (I tend to try things out to
see if they suit), and one or more command shells.

Aside from using Firefox & Thunderbird I'm usually only doing 
small-scale development things under Linux: perhaps reworking
Python code for my web sites which are hosted on Cornerhost's
Linux servers, or playing around with up-and-coming tools for
Python, a (very) few of which only work easily -- or at all --
under Linux.

> There are different distributions of Linux, and putting them all on
> one big pile is like saying "I've tried Windows, and I really don't
> like it's user interface" and referring to the interface of Windows
> 3.1.

Not quite fair. Not only would I avoid saying something with a
redundant apostrophe ;) but the Windows user interface, at least
for my purposes, didn't change such a huge amount between Win9x and
Win2K,
and if you turn off the bells and whistles in XP (which I do!) isn't
so terribly different there. Which, I imagine, is by design. People
like familiarity. Linux distros (and the appearance they choose) seem
to vary far more widely than versions of Windows.

As it happens, (and I suspect I'll have to don my flameproof suit here),
I prefer the Windows command line to bash/readline for day-to-day use, 
including in Python. Why? Because it does what I can't for the life of 
me get readline to do: you can type the first few letters of a 
previously-entered command and press F8. This brings up (going backwards

with further presses) the last command which starts like that. And
*then* 
you can just down-arrow to retrieve the commands which followed it. 
If someone can tell me how to do this with bash/readline I will be 
indebted to them and it will increase my chances of switching to Linux 
a bit! (Although not at work where I have no choice!)

It's obvious that everyone has a different way of working, and that I'm
more comfortable in Windows because all sorts of small familiarities I
can hardly articulate: the way the focus works; the shortcuts I've
developed;
the ability to drag files over things and have them respond. I'm very 
happy with many things in Linux, and I do use it from time to time, 
but it's never quite been enough to pull me away from Windows. Of
course,
I'm lucky enough to have a legal version of Windows to use; if someone
wants to avoid shelling out then of course Linux is even more
attractive.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread [EMAIL PROTECTED]
Tim Golden wrote:
> As it happens, (and I suspect I'll have to don my flameproof suit here),
> I prefer the Windows command line to bash/readline for day-to-day use,
> including in Python. Why? Because it does what I can't for the life of
> me get readline to do: you can type the first few letters of a
> previously-entered command and press F8. This brings up (going backwards
>
> with further presses) the last command which starts like that. And
> *then*
> you can just down-arrow to retrieve the commands which followed it.
> If someone can tell me how to do this with bash/readline I will be
> indebted to them and it will increase my chances of switching to Linux
> a bit! (Although not at work where I have no choice!)
I use XP as my main desktop(because of many fine details) then VNC/X
into my linux box. But command line in Windows is in no way in the same
league as *nix shell. Use  for command completion and up/down
arrow or  to search for history.
_

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


Re: Top-quoting defined [was: namespace dictionaries ok?]

2005-10-26 Thread Iain King

Duncan Booth wrote:
> James Stroud wrote:
>
> > On Tuesday 25 October 2005 00:31, Duncan Booth wrote:
> >> P.S. James, *please* could you avoid top-quoting
> >
> > Were it not for Steve Holden's providing me with a link off the list,
> > I would have never known to what it is you are referring. I have read
> > some relevant literature to find that this is more widely known as
> > "top-posting". I'll go with majority rules here, but I would like to
> > say that my lack of "netiquette" in this matter comes from
> > practicality and not malice.
>
> No, I didn't think it was malice which is why I just added what I
> considered to be a polite request at the end of my message. I assumed that
> most people either knew the phrase or could find out in a few seconds using
> Google so there wasn't much point in rehashing the arguments. Probably I
> should have equally lambasted Ron for the heinous crime of bottom-quoting.
>
> In general, there are three ways to quote a message: top-quoting, which
> forces people to read the message out of order; bottom-quoting which is
> nearly as bad because it hides the new comments; and proper quoting in
> context where you trim the message and put specific points under brief bits
> of context.
>

Just to continue this off-topic argument :)  -

I've never heard the terms top-quoting, bottom-quoting.  I've heard
top-posting and bottom-posting before (lots).  But regardless of
however many people use top-quoting and bottom-quoting, surely you're
using them the wrong way around?  If I top-post, then that means that
the quote is at the bottom, no?

To quote someone's sig block:
 "To top-post is human, to bottom-post and snip is sublime."

Iain

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread darren kirby
quoth the Tim Golden:
> As it happens, (and I suspect I'll have to don my flameproof suit here),
> I prefer the Windows command line to bash/readline for day-to-day use,
> including in Python. Why? Because it does what I can't for the life of
> me get readline to do: you can type the first few letters of a
> previously-entered command and press F8. This brings up (going backwards
>
> with further presses) the last command which starts like that. And
> *then*
> you can just down-arrow to retrieve the commands which followed it.
> If someone can tell me how to do this with bash/readline I will be
> indebted to them and it will increase my chances of switching to Linux
> a bit! (Although not at work where I have no choice!)

Try ctrl-r in bash, then type your first few letters...

-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972


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

Re: p2exe using wine/cxoffice

2005-10-26 Thread Steve Holden
Jon Perez wrote:
> James Stroud wrote:
> 
> 
>>"better". The only reason I want this functionality is to make my software
>>available to windoze users--despite their unfortunate ignorance, they are
>>people too. That's what I always say.
> 
> 
> Actually, I think it's many unix/linux users who are ignorant of just
> how nice, stable and productive Windows can be as a desktop environment.
> 
> ... and I really mean that.  ;-).
> 
> 
> 
> Ever since Win2K got rid of the constant blue screens, the reasons for
> switching over to Linux have grown less and less urgent.
> 
> The 'Nix desktop environments are growing visibly more mature with each
> passing year, but device support in Linux is still decidedly inferior and
> it still takes far too much time to do some things you take for granted
> under Windoze.
> 
> I'm experienced enough with Linux that I can customize a distribution
> like Slackware to a fair extent, but for desktop work, I stay in Windows
> almost exclusively.
> 
> I have this bunch of Linux zealots in a mailing list to thank for
> encouraging me to realize how good Windows can be.
> 
I too am a regular Windows user, despite a dislike for Microsoft's 
marketing shenanigans. If you need a Linux/UNIX-like system there's 
Cygwin, and if nothing but a real Linux kernel will do there's coLinux, 
which I started using recently. The major pain with coLinux is that most 
of the developers are Linux types, so reliable information about 
integration into the Windows environment can be hard to come by. But I'm 
getting there ...

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: Client/Server socket send user input

2005-10-26 Thread jas
Dennis,
   Thanks.  That certainly looks like it could work.  I understand
about the interactive shell and my app going back and forth with the
reads/writes.  When my program runs it won't be used in an interactive
python shell, but that is the only way I know of to really test it.

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Sybren Stuvel
Tim Golden enlightened us with:
> Not quite fair. Not only would I avoid saying something with a
> redundant apostrophe ;) but the Windows user interface, at least for
> my purposes, didn't change such a huge amount between Win9x and
> Win2K,

Hence my reference to windows 3.1.

> It's obvious that everyone has a different way of working, and that
> I'm more comfortable in Windows because all sorts of small
> familiarities

So what I read in your post is that you simply don't want to leave
your familiar environment. Fair enough.

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


OT: Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Jeremy Jones
Tim Golden wrote:


>As it happens, (and I suspect I'll have to don my flameproof suit here),
>I prefer the Windows command line to bash/readline for day-to-day use, 
>including in Python. Why? Because it does what I can't for the life of 
>me get readline to do: you can type the first few letters of a 
>previously-entered command and press F8. This brings up (going backwards
>
>with further presses) the last command which starts like that. And
>*then* 
>you can just down-arrow to retrieve the commands which followed it. 
>If someone can tell me how to do this with bash/readline I will be 
>indebted to them and it will increase my chances of switching to Linux 
>a bit!
>

Others have recommended ctrl-r in bash.  People's tastes vary, but that 
has an awkward feel for me.  In zsh, you just type in as many letters as 
you care to match and hit the "up" arrow.  But, honestly, this is a bit 
annoying to me.  If I've begun to type in a command, realize it's not 
what I want, but instead, I want to go back in my history a couple of 
commands, I hit the "up" arrow to find to my irritation that it's 
pattern matching rather than going directly back in my history.  I guess 
it comes in handy at times, though

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


RE: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Tim Golden
Tim Golden wrote:
> As it happens, (and I suspect I'll have to don my flameproof suit
here),
> I prefer the Windows command line to bash/readline for day-to-day use,
> including in Python. Why? Because it does what I can't for the life of
> me get readline to do: you can type the first few letters of a
> previously-entered command and press F8. This brings up (going
backwards
>
> with further presses) the last command which starts like that. And
> *then*
> you can just down-arrow to retrieve the commands which followed it.
> If someone can tell me how to do this with bash/readline I will be
> indebted to them and it will increase my chances of switching to Linux
> a bit! (Although not at work where I have no choice!)

[EMAIL PROTECTED]
> But command line in Windows is in no way in the same
> league as *nix shell. Use  for command completion and up/down
> arrow or  to search for history.

[darren kirby]
> Try ctrl-r in bash, then type your first few letters...

Thanks to both of you. But that much I already knew. It's not
that I have *no* knowledge about readline: I did at least
read the manuals when I got stuck! But as far as I can tell
from my experience and from the docs -- and I'm not near a 
Linux box at the mo -- having used ctrl-r to recall line x 
in the history, you can't just down-arrow to recall x+1, x+2 etc. 
Or can you?

(Sorry guys; I realise this is more stuff for comp.os.linux or
comp.commandlineshells.bash or whatever it's called. But if
someone *did* know the answer, I'd be really happy!)

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread [EMAIL PROTECTED]
oops, stand corrected. As I don't use the feature more than ctrl-r and
up/down arrow.

Tim Golden wrote:
> Thanks to both of you. But that much I already knew. It's not
> that I have *no* knowledge about readline: I did at least
> read the manuals when I got stuck! But as far as I can tell
> from my experience and from the docs -- and I'm not near a
> Linux box at the mo -- having used ctrl-r to recall line x
> in the history, you can't just down-arrow to recall x+1, x+2 etc.
> Or can you?
>
> (Sorry guys; I realise this is more stuff for comp.os.linux or
> comp.commandlineshells.bash or whatever it's called. But if
> someone *did* know the answer, I'd be really happy!)
>
> TJG
>
> 
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> 

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


Re: Pickle to source code

2005-10-26 Thread Gabriel Genellina
Benjamin Niemann ha escrito:

> Gabriel Genellina wrote:
>
> > I want to convert from pickle format to python source code. That is,
> > given an existing pickle, I want to produce a textual representation
> > which, when evaluated, yields the original object (as if I had
>
> If all objects correctly implement the __repr__ method (true for built-in
> stuff like list, dict, set...):
> Just unpickle it and call repr() on the resulting object.

Unfortunately I need a more general approach...

Gabriel Genellina
Softlab SRL

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


Re: Windows vs Linux

2005-10-26 Thread Thomas Heller
"Tim Golden" <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED]
>> But command line in Windows is in no way in the same
>> league as *nix shell. Use  for command completion and up/down
>> arrow or  to search for history.
>
> [darren kirby]
>> Try ctrl-r in bash, then type your first few letters...
>
> Thanks to both of you. But that much I already knew. It's not
> that I have *no* knowledge about readline: I did at least
> read the manuals when I got stuck! But as far as I can tell
> from my experience and from the docs -- and I'm not near a 
> Linux box at the mo -- having used ctrl-r to recall line x 
> in the history, you can't just down-arrow to recall x+1, x+2 etc. 
> Or can you?

I don't know.  When I discovered this I uninstalled the (windows)
readline module from my Python installation.

> (Sorry guys; I realise this is more stuff for comp.os.linux or
> comp.commandlineshells.bash or whatever it's called. But if
> someone *did* know the answer, I'd be really happy!)

;-)

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


tool for syntax coloring in html

2005-10-26 Thread Xah Lee
in some online documentations, for examples:

http://perldoc.perl.org/perlref.html
http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html
http://www.haskell.org/hawiki/HaskellDemo

the codes are syntax colored.

Is there a tool that produce codes in html with syntax coloring?

Thanks.

 Xah
 [EMAIL PROTECTED]
∑ http://xahlee.org/

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

Re: Pickle to source code

2005-10-26 Thread Gabriel Genellina

Maksim Kasimov ha escrito:

> As far i know, in pickle-file there are only attributes values of a pickled 
> object, but not an object itself.
>
> It is possible to unpickle object only if you have the sourse of the class 
> that object you have pickled.
> So, if you have class code and attribute values of the class instance, there 
> is no problem to produce a textual representation of the object. Isn't it?

Yes, but I need it for many different objects, some of them written by
other people. Please see my next post for clarification.

Gabriel Genellina
Softlab SRL

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


Re: tool for syntax coloring in html

2005-10-26 Thread Maciej Dziardziel
Xah Lee wrote:

> in some online documentations, for examples:
> 
> http://perldoc.perl.org/perlref.html
> http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html
> http://www.haskell.org/hawiki/HaskellDemo
> 
> the codes are syntax colored.
> 
> Is there a tool that produce codes in html with syntax coloring?

It is and its called highlight (available in most linux distributions)

-- 
Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
www.fiedzia.prv.pl

Gravity isn't MY fault--I voted for velcro!
-- 
http://mail.python.org/mailman/listinfo/python-list


WinXP vs. Win98

2005-10-26 Thread sidanko
I use Python 2.3.3 (Enthought edition) with wxPython and it is
installed on both WinXP and Win98. On Win98 machine I have the
following error:

Traceback (most recent call last):
  File
"C:\PYTHON23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
  File "C:\My Documents\Programs\Python\SDV.py", line 2, in ?
from chaco.wxplot import *
  File "C:\PYTHON23\lib\site-packages\chaco\wxplot.py", line 17, in ?
from wxplot_window import PlotWindow, PlotTraitSheet
  File "C:\PYTHON23\lib\site-packages\chaco\wxplot_window.py", line 5,
in ?
from wxplot_window_agg import *
  File "C:\PYTHON23\lib\site-packages\chaco\wxplot_window_agg.py", line
27, in
from kiva.agg   import CAP_BUTT
  File "C:\PYTHON23\lib\site-packages\kiva\agg\__init__.py", line 1, in
?
from agg import *
  File "C:\PYTHON23\lib\site-packages\kiva\agg\agg.py", line 734, in ?
import freetype
  File "C:\PYTHON23\lib\site-packages\freetype\__init__.py", line 6, in
?
from freetype import FreeType
  File "C:\PYTHON23\lib\site-packages\freetype\freetype.py", line 10,
in ?
from font_lookup import default_font_info
  File "C:\PYTHON23\lib\site-packages\freetype\font_lookup.py", line
24, in ?
font_dirs.append(os.path.join(os.environ[ 'systemroot' ],'fonts'))
  File "C:\PYTHON23\lib\os.py", line 417, in __getitem__
return self.data[key.upper()]
KeyError: 'SYSTEMROOT'
>>>
---
Hovewer running very the same script on WinXP machine I have no
problems at all. What's wrong? Kiva package (as well as others) is
installed properly. Where to dig?

AS

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


Re: tool for syntax coloring in html

2005-10-26 Thread Gerhard Häring
Xah Lee wrote:
> in some online documentations, for examples:
> 
> http://perldoc.perl.org/perlref.html
> http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html
> http://www.haskell.org/hawiki/HaskellDemo
> 
> the codes are syntax colored.
> 
> Is there a tool that produce codes in html with syntax coloring?

I use SilverCity and this recipe to produce colored code listings for 
the pysqlite documentation: 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252170

This is the documentation source:
http://initd.org/svn/pysqlite/pysqlite/trunk/doc/usage-guide.txt

This is the result:
http://initd.org/pub/software/pysqlite/doc/usage-guide.html

HTH,

-- Gerhard

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


RE: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Tim Golden
[Sybren Stuvel]

[Tim Golden]
> > It's obvious that everyone has a different way of working, and that
> > I'm more comfortable in Windows because all sorts of small
> > familiarities

> So what I read in your post is that you simply don't want to leave
> your familiar environment. Fair enough.

Well yes. I think the (only slightly) wider point I was
making was that -- despite goodwill and several attempts 
on my part -- Linux still has not overpowered me with its
usefulness. Extending from this, where I am someone who's
a competent computer user (indeed, a professional software
developer of some years' standing) and who has honestly 
tried, it seems that switching to Linux is not quite such 
a no-brainer as people sometimes make out.

Just occasionally you read posts from people who say
(synthesised) "The Windows command line is rubbish",
"Windows crashes all the time", "All Windows machines
are overrun with adware and generate spam willy-nilly".
And you just wonder whether such people have actually
*used* a properly set up Windows machine recently.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Windows vs Linux

2005-10-26 Thread Bernhard Herzog
"Tim Golden" <[EMAIL PROTECTED]> writes:

> But as far as I can tell
> from my experience and from the docs -- and I'm not near a 
> Linux box at the mo -- having used ctrl-r to recall line x 
> in the history, you can't just down-arrow to recall x+1, x+2 etc. 
> Or can you?

You can.  It works fine on this box, at least.
GNU bash, version 2.05a.0(1)-release (i386-pc-linux-gnu)
libreadline 4.2a

   Bernhard

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


Re: Top-quoting defined [was: namespace dictionaries ok?]

2005-10-26 Thread Ron Adam


Duncan Booth wrote:

> No, I didn't think it was malice which is why I just added what I 
> considered to be a polite request at the end of my message. I assumed that 
> most people either knew the phrase or could find out in a few seconds using 
> Google so there wasn't much point in rehashing the arguments. Probably I 
> should have equally lambasted Ron for the heinous crime of bottom-quoting. 

I usually try to keep things in reasonable context and or order.  I tend 
to bottom quote only when either the message is short enough to fit on a 
single page, or when I'm adding new content that isn't a direct response 
to an individual item but builds on the above ideas.  Sometimes deciding 
what to trim out of various really good replies is difficult. ;-)

In any case, I don't take offense to any suggested improvements. I 
wouldn't be surprised if many of my posts were considered hard to follow 
at times.  A chronic sleeping disorder combined with dyslexia can 
sometimes make expressing my thoughts in words rather challenging on 
some (most) days.


>>quote from James (4)
> 
> comment from Ron (5)
> 
quote from James (2)
>>>
>>>comment from Ron (3)
>>>
quote from James (2)

>quote from Ron (1)
> 
> I spent a while trying to trim that down to relevant context, and in 
> particular trying to work out in what order the original statements had 
> been made. In the end I gave up and replied to an earlier message which was 
> more easily trimmable.

I was undecided weather to trim the later (earlier) responses or not, 
but decided to leave them in.


>>Also, here is a well written synopsis of the arguments in 
>>favor of top-posting and they may even be strong enough to legitimize the 
>>practice:
 >
> The arguments are mostly sound, but I would draw slightly different 
> conclusions:
> 
> Follow the conventions of the particular newsgroup or mailing list, but 
> with that in mind, for all replies, Middle Post. Respond to each point in 
> turn with lots of snipping.

In general I find a well written top post in a friarly prompt *email* to 
be fine.  What I refer to as well written in this case, is where the 
author restates the question, points, or issues in their own word first, 
and then follow that up with their response and or conclusions. 
Especially if it's any sort of official or at least non casual 
interchange.  In that case the quotes appended to the end serves as 
history that can be referenced if needed.

But in news groups, it's best to try and keep things conversational with 
as you call middle posts.  It allows people to add to the conversation 
as if they were all present at the same time, even though they may 
actually be replying at varying different times.  I tend to try not to 
break up paragraphs if possible though, and attempt to break my posts up 
into short paragraphs to leave spaces for others to insert their 
replies.  But I wouldn't claim I'm completely consistent on these issues 
myself.


 > He's right though, its not a religious issue.

Yep, I agree with this also.  ;-)

Cheers,
Ron


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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Sybren Stuvel
Tim Golden enlightened us with:
> But as far as I can tell from my experience and from the docs -- and
> I'm not near a Linux box at the mo -- having used ctrl-r to recall
> line x in the history, you can't just down-arrow to recall x+1, x+2
> etc.  Or can you?

With bash as well as the Python interactive shell:

- ^R followed by a partial string to search
- Hit ^R again to get the previous match, repeat as required
- Hit ^A/^E to move the cursor to the beginning/end of the line,
  stopping the "search mode". This allows you to use arrow up/down
  from that point in the readline history.

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: tool for syntax coloring in html

2005-10-26 Thread Michele Simionato
Gerhard wrote:
> http://initd.org/pub/software/pysqlite/doc/usage-guide.html

Can I suggest you to use a larger font for the code?It is pretty
difficult to parse with my
current screen resolution. BTW, pysqlite2 is pretty cool ;)

   Michele Simionato

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


RE: Windows vs Linux

2005-10-26 Thread Tim Golden
"Tim Golden" <[EMAIL PROTECTED]> writes:

> But as far as I can tell
> from my experience and from the docs -- and I'm not near a 
> Linux box at the mo -- having used ctrl-r to recall line x 
> in the history, you can't just down-arrow to recall x+1, x+2 etc. 
> Or can you?

[Bernhard Herzog]
> You can.  It works fine on this box, at least.
> GNU bash, version 2.05a.0(1)-release (i386-pc-linux-gnu)
> libreadline 4.2a

Thanks. I'll take another look at it when I get a chance.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


RE: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Tim Golden
Tim Golden enlightened us with:
> But as far as I can tell from my experience and from the docs -- and
> I'm not near a Linux box at the mo -- having used ctrl-r to recall
> line x in the history, you can't just down-arrow to recall x+1, x+2
> etc.  Or can you?

[Sybren]
With bash as well as the Python interactive shell:

[.. explanation snipped ..]

Thanks very much.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Giovanni Dall'Olio

Tim Golden ha scritto:


> As it happens, (and I suspect I'll have to don my flameproof suit here),
> I prefer the Windows command line to bash/readline for day-to-day use,
> including in Python. Why? Because it does what I can't for the life of
> me get readline to do: you can type the first few letters of a
> previously-entered command and press F8. This brings up (going backwards
>
> with further presses) the last command which starts like that. And
> *then*

Argh!! ;)
How about reading a simple tutorial on bash?
You can use even '!' to recall other commands in history.
For example, you can type '!p' and it will call the last command
starting with 'p', without having to search for it (and if you want,
you can use CTRL+r)
You can use '!!' to recall the last command, or '!-#' for the other
ones. You can define single arguments, like !-#:2, to call only parts
of a old command.
With bash, you can repeat instructions (using 'for', 'while', and so
on) and use some basic logic to determine if launching them. You can
call easily any program installed in the computer, or in other ones,
too.
Really, are you joking? ;) Do you know that you can use the '' key
to auto-fill a command? isn't this useful? I tried to use the windows
command line sometimes, but I found it so slow and uncorfortable, that
I thought that noone can use it. I really don't understand what you
want to say with this topic!

p.s. if you want a tip, leave using desktop manager and begin using the
command line. You will like it.

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


Re: tool for syntax coloring in html

2005-10-26 Thread Stephen Hildrey
Xah Lee wrote:
> Is there a tool that produce codes in html with syntax coloring?

I'm sure there's a million-and-one tools that will do what you want, and 
suggest you search Google.

Personally, I've used vim to do this in the past. The following 
generates marked-up code:

 :runtime syntax/2html.vim

Regards,
Steve
-- 
Stephen Hildrey
E-mail: [EMAIL PROTECTED]   / Tel: +442071931337
Jabber: [EMAIL PROTECTED] / MSN: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tool for syntax coloring in html

2005-10-26 Thread propell
I use Silvercity for my web site. SilverCity is a Python interface to
the Scintilla lexers. It's available at
http://silvercity.sourceforge.net/

I find the output from silvercity a bit verbose, so I have written a
few Python classes for cleaning up the output. The code is available at
http://fauskes.net/nb/syntaxhighlighting/

- Kjell Magne Fauske

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


Re: Pickle to source code

2005-10-26 Thread Gabriel Genellina
> I want to convert from pickle format to python source code. That is,
> given an existing pickle, I want to produce a textual representation
> which, when evaluated, yields the original object (as if I had
> unpickled the pickle).
> I know of some transformations pickle/xml (Zope comes with one such
> tool, gnosis xml is another) so I believe I could build something based
> on them.
> But I dont want to reinvent the wheel, I wonder if anyone knows of a
> library which could do what I want?

An example to make things clear:

class MyClass:
def __init__(self,a,b):
self.a=a
self.b=b
def foo(self):
self.done=1
# construct an instance and work with it
obj = MyClass(1,2)
obj.foo()
# save into file
pickle.dump(obj,file('test.dat','wb'))

Then, later, another day, using another process, I read the file and
want to print a block of python code equivalent to the pickle saved in
the file.
That is, I want to *generate* a block of code like this:

xxx = new.instance(MyClass)
xxx.a = 1
xxx.b = 2
xxx.done = 1

Or perhaps:

xxx = new.instance(MyClass, {'a':1,'b':2,'done':1})

In other words, I need a *string* which, being sent to eval(), would
return the original object state saved in the pickle.
As has been pointed, repr() would do that for simple types. But I need
a more general solution.

The real case is a bit more complicated because there may be references
to other objects, involving the persistent_id mechanism of pickles, but
I think it should not be too difficult. In this example, if xxx.z
points to another external instance for which persistent_id returns
'1234', would suffice to output another line like:
xxx.z = external_reference('1234')

I hope its more clear now.

Thanks,
Gabriel Genellina
Softlab SRL

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


Re: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Ron Adam


Antoon Pardon wrote:

> Op 2005-10-25, Steven D'Aprano schreef <[EMAIL PROTECTED]>:

>>Can somebody remind me, what is the problem Antoon is trying to solve here?
> 
> 
> Well there are two issues. One about correct behaviour and one about
> practicallity.
> 
> The first problem is cmp. This is what the documentation states:
> 
> cmp(x, y)
> Compare the two objects x and y and return an integer according to
> the outcome. The return value is negative if x < y, zero if x == y
> and strictly positive if x > y. 
> 
> The problem is, that if someone implements a partial ordered class,
> with the rich comparisons, cmp doesn't behave correct. It can't
> behave correct because it will always give an number as a result
> and such a number implies one of three relations between two
> elements, but with partial ordered classes, it is possible none
> of these relations exist between those two elements. So IMO cmp
> should be changed to reflect this. This can be done either by cmp
> returning None or UnequalValues.  or by cmp raising UnequalValues
> in such a case.

Instead of changing cmp, why not just have several common versions to 
choose from instead of trying to make one tool do it all?

> The second part is one of practicallity. Once you have accepted cmp,
> should reflect this possibility, it makes sense that the __cmp__
> method should get the same possibilities, so that where it is more
> pratical to do so, the programmer can implement his partial order
> through one __cmp__ method instead of having to write six.
> 
> 
> In my opinion such a change would break no existing code. This
> is because there are two possibilities.
 >
> 1) The user is using cmp on objects that form a total order.
> In such circumstances the behaviour of cmp doesn't change.
> 
> 2) The user is using cmp on objects that don't form a total
> order. In such circumstances cmp doesn't give consistent
> results, so the code is already broken.


Adding complexity to cmp may not break code, but it could probably slow 
down sorting in general.  So I would think what ever improvements or 
alternatives needs to be careful not to slow down existing sorting cases.

Cheers,
Ron

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


How do I access the property info in this example ?

2005-10-26 Thread David Poundall
How do I access the property information in this example ?

class C(object):
def getx(self): return self.__x
def setx(self, value): self.__x = value
def delx(self): del self.__x
x = property(getx, setx, delx, "I'm the 'x' property.")

I would like to get at ...

"I'm the 'x' property."

... if at all possible.

TIA

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


Re: a Haskell a Day

2005-10-26 Thread Mike Meyer
Erik Max Francis <[EMAIL PROTECTED]> writes:
> Xah Lee wrote:
>> This is my learning notes on Haskell. I call it a-Haskell-a-day.

Interesting. Xah Lee's orginals don't show up in the Python
newsgroup. No big loss.

In any case, please help google find Xah Lee under the proper search
terms. Add a link to his website with the anchor "stupider than spam".
A typical usage might be:

And pointing out that some people are http://xahlee.org/";>stupider than spam.

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


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

2005-10-26 Thread Cameron Laird
QOTW: "Using Unix for 20+ years probably warps one's perception
of what's obvious and what isn't." -- Grant Edwards

"... windoze users--despite their unfortunate ignorance, they are
people too." -- James Stroud


"The Widget Construction Kit (WCK) is an extension API that allows
you to implement custom widgets in pure Python."  A typical recent
enhancemennt is slightly more efficient anti-aliased drawing under
Windows:
http://online.effbot.org/2005_10_01_archive.htm#20051022 

Mike Meyer and others demonstrate the paranoia and propensity to
abstraction of the experienced when thinking about something as
simple as replacement of one string for another:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/98f0d93332748af9/

Similarly, Bengt Richter illustrates that "a month" is a far 
more complicated idea than first appears:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/68b08f36ca516aa2/

"The deadline for PyCon 2006 submissions is now only a week away."
http://www.python.org/pycon/2006/cfp

Is there a good way to manage Python installations on multiple
(Windows) hosts?  There are several:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1343f89416f8f783/



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
The old Python "To-Do List" now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse
http://python.sourceforge.net/peps/pep-0042.html
 
The online Python Journal is posted at pythonjournal.cognizor.com.
[EMAIL PROTECTED] and [EMAIL PROTECTED]
welcome submission of material that 

Re: wxPython import error

2005-10-26 Thread Michele Petrazzo
[EMAIL PROTECTED] ha scritto:
> I have tried several times to install wxPython on Fedora Core 2.  The
> installation seems to go fine (from sources), but when I try to import the
> wx module I keep getting the following error:
> 

<-cut->

> Any help or explanation would be greatly appreciated.

For a my customer I had tried a lot of time, but without success to 
compile and install wx 2.6.x
But luckily there is a precompiled package on wxpython.org.
Have you try it?

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


Re: Double replace or single re.sub?

2005-10-26 Thread Mike Meyer
"Iain King" <[EMAIL PROTECTED]> writes:

> I have some code that converts html into xhtml.  For example, convert
> all  tags into .  Right now I need to do to string.replace calls
> for every tag:
>
> html = html.replace('','')
> html = html.replace('','')
>
> I can change this to a single call to re.sub:
>
> html = re.sub('<([/]*)i>', r'<\1em>', html)
>
> Would this be a quicker/better way of doing it?

Maybe. You could measure it and see. But neither will work in the face
of attributes or whitespace in the tag.

If you're going to parse [X]HTML, you really should use tools that are
designed for the job. If you have well-formed HTML, you can use the
htmllib parser in the standard library. If you have the usual crap one
finds on the web, I recommend BeautifulSoup.

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


Re: How do I access the property info in this example ?

2005-10-26 Thread Sybren Stuvel
David Poundall enlightened us with:
> class C(object):
> def getx(self): return self.__x
> def setx(self, value): self.__x = value
> def delx(self): del self.__x
> x = property(getx, setx, delx, "I'm the 'x' property.")
>
> I would like to get at ...
>
> "I'm the 'x' property."

As usual: C.x.__doc__

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: Would there be support for a more general cmp/__cmp__

2005-10-26 Thread Christopher Subich
Antoon Pardon wrote:
> Op 2005-10-25, Christopher Subich schreef <[EMAIL PROTECTED]>:
>>
>>My biggest complaint here is about returning None or IncomparableValue; 
>>if that happens, then all code that relies on cmp returning a numeric 
>>result will have to be rewritten.
> 
> 
> I don't know. There are two possibilities.
> 
> 1) The user is working with a total order. In that case the None
> or IncomparableValues won't be returned anyway so nothing about
> his code has to change.
> 
> 2) The user is working with a partial order. In that case cmp
> doesn't provide consistent results so the use of cmp in this
> case was a bug anyway.

Case 3) The user is working with an unknown class, using duck typing, 
and expects a total order.  If cmp suddenly returned Incomparable or 
None, the code would break in Unexpected Ways, with Undefined Behavior.

This is a classic "exception versus error code" argument; in this case, 
returning None would be the error flag.  It's almost always better to 
just throw the exception, because then this allows error-checking at a 
more natural level.

>>As for saying that cmp should return some times and raise an exception 
>>other times, I just find it squicky.
> 
> 
> But cmp already behaves this way. The only difference would be that
> the decision would be made based on the values of the objects instead
> of only their class.
> 
> 
>>Admittedly, this is entirely up to 
>>the class designer, and your proposed guideline wouldn't change cmp's 
>>behavior for clases that /are/ totally ordered.
>>
>>Then again, sets excepted, your guideline doesn't seem very applicable 
>>in standard library code.
> 
> 
> Well AFAIAC this isn't specific about library code.

A change that cmp return a 4th possible "value" (None or Incomparable) 
is a fundamental language change.  Because this would break large 
amounts of existing code, it's a bad idea.

A change that cmp throw an exception iff the two objects, rather than 
the two classes, were incomparable (allowing comparisons of( 1+0j and 
2+0j) and ({a} and {a,b}) but not (1+1j and 2+0j) and ({a} and {b})) is 
a stylistic guideline, since it's already possible to write your own 
classes this way.  The only place this change would matter is in the 
standard library code, and in just a few places at that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I access the property info in this example ?

2005-10-26 Thread David Poundall
Thanks - I was trying to do 

c = C()
print c.x.__doc__ 

my mistake.

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Sybren Stuvel
Tim Golden enlightened us with:
> Well yes. I think the (only slightly) wider point I was making was
> that -- despite goodwill and several attempts on my part -- Linux
> still has not overpowered me with its usefulness.

I have yet to see any OS that overpowers me with its usefulness.

> Extending from this, where I am someone who's a competent computer
> user (indeed, a professional software developer of some years'
> standing) and who has honestly tried, it seems that switching to
> Linux is not quite such a no-brainer as people sometimes make out.

I think it's harder to switch for professional computer users than it
is for relative laymen. After all, you have to give up a lot of things
you've accumulated over the years. A newbie can just sit behind the
computer and click some icons, and will be happy when things work
properly.

> Just occasionally you read posts from people who say (synthesised)
> "The Windows command line is rubbish",

It is. Let me give an example. I have the following files:

SomeFileA.txt
SomeFileB.txt
SomeFileC.txt
.SomeFileA.txt.swp

That last one is a swap file created by VIM, because I'm editing
SomeFileA.txt. Now, if I want to use the TAB key to get filename
completion, and I type "Som", the first "match" it finds is
".SomeFileA.txt.swp". What is that? I don't want a file starting with
".Som", I want a file starting with "Som".

There is also no proper terminal support in the "DOS" box, you can't
resize it horizontally, and the TAB key can only do dubm filename
completion (no smart option completion like only completing with
directory names after a "cd" command)

> "Windows crashes all the time"

Fortunately, no longer true. It is true that a problem in one program
has a bigger influence on your desktop as a whole in Windows that it
has in Linux, though, so the effect of a badly behaving program is
"felt" stronger.

> "All Windows machines are overrun with adware and generate spam
> willy-nilly".

Not all, indeed. There are _lots_ of Windows zombie machines, though.
Then again, when I was moving, I didn't pay enough attention to my
Linux box, was too late in patching a leak, and it started spamming
too.

> And you just wonder whether such people have actually *used* a
> properly set up Windows machine recently.

I have.

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


suggestions between these two books

2005-10-26 Thread John Salerno
Hi all. I'm fairly new to programming and I thought I'd like to try 
Python. I'm trying to decide between these two books:

Learning Python (O'Reilly)
Beginning Python: From Novice to Professional (APress)

and I was hoping you might have some suggestions. LP seems to be a good 
intro, but the other was published only a month ago and covers 2.4. So 
one question would be, is 2.2 different enough from 2.4 to warrant 
getting the newer book for that reason?

I might end up getting both eventually, but to start with I'm not sure 
which to choose.

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


Re: Double replace or single re.sub?

2005-10-26 Thread Iain King

Mike Meyer wrote:
> "Iain King" <[EMAIL PROTECTED]> writes:
>
> > I have some code that converts html into xhtml.  For example, convert
> > all  tags into .  Right now I need to do to string.replace calls
> > for every tag:
> >
> > html = html.replace('','')
> > html = html.replace('','')
> >
> > I can change this to a single call to re.sub:
> >
> > html = re.sub('<([/]*)i>', r'<\1em>', html)
> >
> > Would this be a quicker/better way of doing it?
>
> Maybe. You could measure it and see. But neither will work in the face
> of attributes or whitespace in the tag.
>
> If you're going to parse [X]HTML, you really should use tools that are
> designed for the job. If you have well-formed HTML, you can use the
> htmllib parser in the standard library. If you have the usual crap one
> finds on the web, I recommend BeautifulSoup.
>

Thanks.  My initial post overstates the program a bit - what I actually
have is a cgi script which outputs my LIveJournal, which I then
server-side include in my home page (so my home page also displays the
latest X entries in my livejournal).  The only html I need to convert
is the stuff that LJ spews out, which, while bad, isn't terrible, and
is fairly consistent.  The stuff I need to convert is mostly stuff I
write myself in journal entries, so it doesn't have to be so
comprehensive that I'd need something like BeautifulSoup.  I'm not
trying to parse it, just clean it up a little.

Iain

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


Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-26 Thread Ron Adam


[EMAIL PROTECTED] wrote:

> Hi,
> 
> which file names do you mean?
> 
> -Martin.


I've ran across a case where I copied a module from the python libs 
folder to my source directory, it would work fine before I built with 
py2exe, but afterwards it would give a file not found error.  I haven't 
quite figures out why in this case.

To get around it, I renamed the file in my directory, by putting an 
underscore in front of it and importing '_name as name' in my program. 
Everything worked fine after that.

Another case is where I inadvertently had a file name in the file path 
with the same name as a file I was trying to import.  In this case the 
file would import in place of the library file, but then issue errors 
for objects or sub modules not being found.

So if the modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName' are in a 
package, and you have a file in your source folder (or search path) with 
the same name as the directory or file they are in, you could be 
importing the wrong file and then not be finding the sub modules.

Like I said this is a guess, but I thought it might be worth mentioning 
if nothing else to rule out file path problems like these.

Cheers,
Ron





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


Re: tool for syntax coloring in html

2005-10-26 Thread Philippe C. Martin
I use gvim.

regards,

Philippe



Xah Lee wrote:

> in some online documentations, for examples:
> 
> http://perldoc.perl.org/perlref.html
> http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html
> http://www.haskell.org/hawiki/HaskellDemo
> 
> the codes are syntax colored.
> 
> Is there a tool that produce codes in html with syntax coloring?
> 
> Thanks.
> 
>  Xah
>  [EMAIL PROTECTED]
> ? http://xahlee.org/

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


Re: Pickle to source code

2005-10-26 Thread Jean-Paul Calderone
On 26 Oct 2005 06:15:35 -0700, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>> I want to convert from pickle format to python source code. That is,
>> given an existing pickle, I want to produce a textual representation
>> which, when evaluated, yields the original object (as if I had
>> unpickled the pickle).
>> I know of some transformations pickle/xml (Zope comes with one such
>> tool, gnosis xml is another) so I believe I could build something based
>> on them.
>> But I dont want to reinvent the wheel, I wonder if anyone knows of a
>> library which could do what I want?
>
>An example to make things clear:
>
>class MyClass:
>def __init__(self,a,b):
>self.a=a
>self.b=b
>def foo(self):
>self.done=1
># construct an instance and work with it
>obj = MyClass(1,2)
>obj.foo()
># save into file
>pickle.dump(obj,file('test.dat','wb'))
>
>Then, later, another day, using another process, I read the file and
>want to print a block of python code equivalent to the pickle saved in
>the file.
>That is, I want to *generate* a block of code like this:
>
>xxx = new.instance(MyClass)
>xxx.a = 1
>xxx.b = 2
>xxx.done = 1
>
>Or perhaps:
>
>xxx = new.instance(MyClass, {'a':1,'b':2,'done':1})
>
>In other words, I need a *string* which, being sent to eval(), would
>return the original object state saved in the pickle.
>As has been pointed, repr() would do that for simple types. But I need
>a more general solution.
>
>The real case is a bit more complicated because there may be references
>to other objects, involving the persistent_id mechanism of pickles, but
>I think it should not be too difficult. In this example, if xxx.z
>points to another external instance for which persistent_id returns
>'1234', would suffice to output another line like:
>xxx.z = external_reference('1234')
>
>I hope its more clear now.

You may find twisted.persisted.aot of some use.  Here is an example:

>>> class Foo:
... def __init__(self, x, y):
... self.x = x
... self.y = y
...
>>> a = Foo(10, 20)
>>> b = Foo('hello', a)
>>> c = Foo(b, 'world')
>>> a.x = c
>>> from twisted.persisted import aot
>>> print aot.jellyToSource(a)
app=Ref(1,
  Instance('__main__.Foo',
x=Instance('__main__.Foo',
  x=Instance('__main__.Foo',
x='hello',
y=Deref(1),),
  y='world',),
y=20,))
>>> 

AOT is unmaintained in Twisted, and may not support some newer features of 
Python (eg, datetime or deque instances).  If this seems useful, you may want 
to contribute patches to bring it up to the full level of functionality you 
need.

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


  1   2   3   >