desktop computer

2007-12-31 Thread Richi
Sahara Desktop AMD Sempron 3400 Processor-  Powered by AMD Sempron,
Sahara PC help you get more out of life. Be it redefining connectivity
or just the sheer joy of being in touch with the world. Its all...
just a click away, With Sahara PC by your side, you will always find
newer ways to say Hello to life, International quality with complete
support assurance, just a call away, Tested and certified by ERTL
India more

For more information visit - http://www.homeshop18.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ElementTree should parse string and file in the same way

2007-12-31 Thread Stefan Behnel
Peter Pei wrote:
> One bad design about elementtree is that it has different ways parsing a
> string and a file, even worse they return different objects:
> 1) When you parse a file, you can simply call parse, which returns a
> elementtree, on which you can then apply xpath;

ElementTree doesn't support XPath. In case you mean the simpler ElementPath
language that is supported by the find*() methods, I do not see a reason why
you can't use it on elements.


> 2) To parse a string (xml section), you can call XML or fromstring, but
> both return element instead of elementtree. This alone is bad. To make
> it worse, you have to create an elementtree from this element before you
> can utilize xpath.

a) how hard is it to write a wrapper function around fromstring() that wraps
the result Element in an ElementTree object and returns it?

b) the same as above applies: I can't see the problem you are talking about.

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


Re: Cheat sheet

2007-12-31 Thread Gabriel Genellina
En Sat, 29 Dec 2007 06:58:27 -0200, ZeD <[EMAIL PROTECTED]> escribi�:

> Michele Simionato wrote:
>
>> Nowadays file is no more an alias for open.
>
> curious... maybe it's me, but I can't find a "What's New in Python" where
> this is said...

See Misc/NEWS:
- Patch #1479181: split open() and file() from being aliases for each  
other.

> also, in 2.6 docs (and also in 2.5) remains this footer:
> http://docs.python.org/dev/library/stdtypes.html#id14
> http://www.python.org/doc/2.5/lib/bltin-file-objects.html#foot4449
>
> file() is new in Python 2.2. The older built-in open() is an alias for
> file().

I can't see that footer in the current docs. But in some places it says  
"if the file was created with the open() built-in function, then..." that  
now might be confusing.

Being open!=file, each one can have a different docstring. open() just  
wraps file(), they have the same behavior [but open is a function and file  
is a type]

-- 
Gabriel Genellina

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

Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread [EMAIL PROTECTED]
Hi,

Is there a string function to trim all non-ascii characters out of a
string?
Let say I have a string in python (which is utf8 encoded), is there a
python function which I can convert that to a string which composed of
only ascii characters?

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


M'I.5'P ersecution Moles tation du ring Trave l

2007-12-31 Thread efvemimiv

MI5 Persecution:. Molestation during Travel

MI5s persecution of me varies in intensity. Since 1990 it has. been steady
for perhaps 80% of the time; there was. a notable quiet period in 1993, and
another quiet period in Jan-Feb 1995, as. well as a hiatus in the first two
months of 1999. It puzzles me that. they cease and restart, seemingly
without any logic. or reason. But one aspect of MI5s activities against me
which is relatively predictable is this weeks articles. topic, which is
Molestation during Travel. Almost every time I cross the. Atlantic, go to
the Continent or even try to enjoy a holiday in this country,. you can bet
that MI5 will be there doing their utmost. to wreck it all.

This aspect. of the harassment is particularly relevant as I will be
travelling to Europe again in a months time,. with naturally the Minidisc
recorder in. tow; so it will be interesting to see if I can record the
abuse which will. almost certainly take place, either on the Tube going to
the airport, at the. airport, on the flight, in the terminal building - MI5
have. previously instituted instances of abuse at each of these locations,
so well see how much taxpayers money they waste this time, and. whether it
will prove possible to capture their abuse. on minidisc.

Read about the MI5 Persecution. on the Web

June 1992. in Polands mountain resort of Zakopane

The persecution started in June 1990, and for the. first two years I stayed
in the UK apart from a couple of brief day trips to. Calais. By the summer
of 1992 Id had enough of being cooped up. in England with abusive fellow
employees egged. on by an abusive secret police service, and decided to
spend 10 days in southern Poland, on what was intended to be a holiday. at
the mountain resort. town of Zakopane.

Unfortunately the psychopaths of the Security. Service were not willing to
allow me. to enjoy a holiday in peace and quiet. The journey to Zakopane
was by. coach from the meeting point at Londons Victoria coach station
(National Express). followed by ferry followed by another coach across
Europe. As we left Victoria a youth and his girlfriend started a. loud
tirade of abuse directed at "this bloke", where the "bloke". was never
named,. but it was very clear that the "bloke" was myself. The youth said
"they" had "found somebody from his. school, and he was always really
stressed at school,. a real psycho". Again, the label "they" was not
elaborated on, but it. was clear that "they" = the persecutors from
MI5. The boy also said, "he was in a bed and breakfast for only. one night
and they got. him". By a not unexpected coincidence I had been in a B&B in
Oxford a week previously,. which had been booked from work; other things
lead me to the conclusion. that the company's offices were bugged for most
of the. 2 1/2 years that I was there, so "they" would have known a room in
the B&B had been booked. After a. few minutes of this I went back to where
they were sitting and asked where they were. travelling. The boy named a
village in France, and the girl's giggling. suddenly ceased; presumably it
permeated to her brain cell what the purpose of the. boy's abuse was.

It is now. very clear to me that MI5 were trying to have me incarcerated,
assaulted or killed on this trip. across Europe. The degree of verbal
violence inescapably leads to this conclusion. When we arrived. at our
destination, it became clear that many. people, both in our tour group and
its guide, and among the ordinary residents of the town,. knew there was a
movement under way to. "get" me. MI5 employed many people and significant
resources for an action which. they knew would only take a maximum of ten
days. A commercial operation would never have felt. able to waste such
resources on such an unproductive and. temporary action; only a
state-sponsored, taxpayer-funded entity like. the Security Service would be
able. to be so wasteful.

To give some examples of what happened in those ten. days; I was walking in
some woods outside the town, when. a Polish woman, looking at me, said the
English "shit" in a. strongly Polish-accented voice. For the first three
years 1990-92 MI5 had been. trying to force this word on me. Another
example; I was walking near my. "hotel" when a mother said laughing to her
child, "a wiesz ze to prawdziwy wariat" which means. "you know hes a real
madman". And the "TV reacting" happened there too; on Polish TV, a. bemused
looking journalist said to another, "to jest. sprawa Anglikow", which means
"its the concern of the English", in other words, none. of our business,
despite what the English are trying to force down. our throats.

Just before we left for. home, I went with some others from our group to a
nearby bar. There a man. shouted at me the same sexual obscenity which MI5
have constantly thrown at me these last three years. I think MI5 try. to
justify their various terms of abuse by repeating. them at me until I say
them, either while conscious or while talking in. my sleep; a

TK 8.5

2007-12-31 Thread Leon
Hello,

First of all, I beg you pardon for my poor english...

You probably know it, but a new version of Tcl/TK has arrived : 
http://groups.google.fr/group/comp.lang.tcl/browse_frm/thread/747fcc9df3274310/

With TK8.5, I found the look and feel better that in the past :
http://wiki.tcl.tk/13636

It would be great to have the same look with TkInter...

1) Did you know if a future version of Python/Tkinter will use Tk 8.5 ? 
And when ?

2) Is it a way to use Tk 8.5 with the present version of Python (2.5) ?

3) Or may be it's possible to already have a similar and good look with 
the present version of TK[inter] included in the last version of Python 
(2.5.1) ?

Can you give me informations (or links, etc...) about this three 
questions ?

Thanx in advance !!!

Leon


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


Re: Tab indentions on different platforms?

2007-12-31 Thread Thorsten Kampe
* Steven D'Aprano (Sun, 30 Dec 2007 23:28:50 -)
> On Sun, 30 Dec 2007 20:33:19 +, Thorsten Kampe wrote:
> > * Steven D'Aprano (Sun, 30 Dec 2007 00:37:32 -)
> >> On Sat, 29 Dec 2007 15:29:25 +, Thorsten Kampe wrote:
> >> > I'd personally go for spaces because:
> >> > 
> >> > 1. I don't like things I cannot see (control characters)
> >> 
> >> You can see spaces but not tabs? Your editor is pretty weird. In all
> >> the editors I've every used, both spaces and tabs show up as empty
> >> white space.
> > 
> > That's because the editor displays those invisible tab control
> > characters as something they're not: spaces.
> 
> Editors display tab characters as "indent to next tab stop". That's what 
> they're for, and any editor that doesn't behave that way is buggy. 
> 
> Tab characters are no more invisible than space characters. How can you 
> see space characters but not tabs? Why aren't space characters invisible 
> too? Why do you dislike tabs *specifically* because they are invisible, 
> but like invisible spaces?

If you can't see spaces then that's your problem. I can see (identify) 
spaces (at least at the beginning of a line).

> >> > 2. I never had problems with spaces but plenty with tabs
> >> 
> >> What problems have you had with tabs that aren't related to buggy
> >> applications or users that mix tabs and spaces?
> > 
> > Fortunately I don't remember every incident when I stumbled about
> > something weird behaving or looking. One thing I do remember is reading
> > python source code (not my own) with a pager. The source code was badly
> > indented. The pager was not "buggy".
> 
> Given the constraints of the typical pager one-line display, and the 
> tendency of pagers I've seen to arbitrarily drop leading whitespace *of 
> any sort* from the start of lines, I'd like to know how you could tell 
> the indentation was wrong.

It was obvious because the blocks didn't make sense.

The problem with tabs is that they're interpreted: by Python and by 
the editor or pager to display them. Spaces are just spaces.

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


Re: Help please with code to find and move files.

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 05:09:37 -0200, <[EMAIL PROTECTED]> escribió:

> I am sorry if I was not clear in what I was trying to achieve. All I
> wanted was simple way to achieve what windows does when you use search
> for Files or Folders,  and all the files that mach two words like foo
> and bar in the file name to be moved or copied to a specified folder,
> duplicates should not be copied just skipped.

I think John Machim comments addressed most -if not all- your potential  
problems. You should be able to modify your script to met your goals; just  
do it one step at a time. Omit the actual file copy at first, just print  
what you would do. See what happens, fix the iteration if needed, once you  
print the right set of files try to actually copy them.

-- 
Gabriel Genellina

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


M-I, 5`Pers ecution - MI5 are Afra id to Ad mit Theyre B ehind the Persecut ion

2007-12-31 Thread fievmfvf

MI5 are Afraid to Admit They're Behind the. Persecution

MI5 have issued a formal denial of any involvement in my life to. the
Security Service. Tribunal, as you might expect them to; but, more
importantly, the persecutors have never denied that theyre. from the
Security Service, despite several years of accusations from my corner. on
usenet. and in faxed articles. I am not surprised that the Security Service
Tribunal found "no determination in your favour". I am however. a little
surprised. that the persecutors have refused to confirm my identification
of them; by doing so, they implicitly admit. that my guess was right.

"No determination in your favour" says the. Security Service Tribunal

In 1997,. I made a complaint to the Security Service Tribunal, giving only
the bare outlines of my case. I do. not think it would have made very much
difference if Id made a much more. detailed complaint, since the Tribunal
has no ability to perform. investigatory functions. It can only ask MI5 if
they have an interest in a subject, to. which MI5 are of course free to be
"economical with. the truth". A couple of months after my complaint the
Tribunal replied. that;

The Security Service Tribunal have now investigated your. complaint and
have asked me to inform. you that no determination in your favour has been
made on. your complaint.

Needless to say this reply didnt surprise me. in the slightest. It is a
well established fact that the. secret service are a den of liars and the
Tribunal a toothless watchdog,. so to see them conforming to these
stereotypes might be disappointing. but unsurprising.

It is noteworthy that the Tribunal never gives. the plaintiff information
on whether the "no determination in your favour" is. because MI5 claims to
have no interest. in him, or whether they claim their interest is
"justified".. In the 1997 report of the Security Service Commissioner he
writes that "The ambiguity of the terms in. which the notification of the
Tribunals decision is expressed is. intentional", since a less ambiguous
answer. would indicate to the plaintiff whether he were indeed under MI5
surveillance. But I. note that the ambiguity also allows MI5 to get away
with lying to the question of their interest. in me; they can claim to the
Tribunal. that they have no interest, but at a future date, when it becomes
clear that they did indeed place me under surveillance and. harassment,
they can claim their interest was "justified" - and. the Tribunal will
presumably not admit that in their previous reply MI5 claimed to have. no
interest.

"He doesnt know who we. are"

In early January 1996. I flew on a British Airways jet from London to
Montreal; also present. on the plane, about three or four rows behind me,
were two young men,. one of them fat and voluble, the other silent. It was
quite clear that these two had been planted. on the aircraft to "wind me
up". The. fat youth described the town in Poland where I had spent
Christmas, and made some unpleasant personal. slurs against me. Most
interestingly, he. said the words, "he doesnt know who we are".

Now I find. this particular form of words very interesting, because while
it. is not a clear admission, it is only a half-hearted attempt at denial
of my guess that "they" = "MI5". Had my guess been wrong, the. fat youth
would surely have said. so more clearly. What he was trying to do was to
half-deny. something he knew to be true, and he was limited to making
statements which he knew to be not false; so he. made a lukewarm denial
which on the face of it means nothing, but in fact acts as. a confirmation
of my guess of. who "they" are.

On one of the other occasions when I saw the persecutors. in person, on the
BA flight to Toronto in June 1993, one of the group of four. men said, "if
he tries to run away well find him". But the other three. stayed totally
quiet and avoided eye contact. They did so. to avoid being apprehended and
identified - since if they. were identified, their employers would have
been revealed,. and it would become known that it was the secret services
who were behind. the persecution.

Why are MI5 So. Afraid to admit their involvement?

If you think. about it, what has been going on in Britain for the last nine
years is simply beyond belief. The. British declare themselves to be
"decent" by definition, so when they engage. in indecent activities such as
the persecution of a mentally ill person, their decency "because. were
British" is still in the forefront. of their minds, and a process of mental
doublethink kicks in,. where their antisocial and indecent activities are
blamed on the victim. "because its his fault were persecuting him", and
their self-regard and self-image. of decency remains untarnished. As
remarked in another article some time ago, this process. is basically the
same as. a large number of Germans employed fifty years ago against Slavic
"untermenschen" and the Jewish "threat". - the Germans declared, "Germans
are known  to be de

Re: Tab indentions on different platforms?

2007-12-31 Thread Thorsten Kampe
* Steven D'Aprano (Mon, 31 Dec 2007 00:05:15 -)
> On Sun, 30 Dec 2007 20:41:09 +, Thorsten Kampe wrote:
> > Anyway: the consequence of your well done argumentation is that
> > someone editing Python code has to use a specialised editor to prevent
> > screwing up tab indented code - and that's bad.
> 
> You just need to use an editor that inserts tab characters when the tab 
> key is pressed, just like you use an editor that inserts s characters 
> when the s key is pressed. If people didn't insist on using spaces where 
> tabs are called for, there would be no problem, and you wouldn't need a 
> specialized editor to prevent screwing up space-indented code.

You completely miss the point. Ben (and me answering him) was talking 
about tab indented code that gets screwed up by spaces by people who 
can't see the tabs. Read Ben's article again.

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


Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Dan Bishop
On Dec 31, 2:20 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?
>
> Thank you.

def ascii_chars(string):
return ''.join(char for char in string if ord(char) < 128)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread abhishek
On Dec 31, 1:20 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?
>
> Thank you.

Use this function --

def omitNonAscii(nstr):
sstr=''
for r in nstr:
if ord(r)<127:
sstr+=r
return sstr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread John Machin
On Dec 31, 7:20 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?
>


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


M'I.5,Persecution No Justi ce fo r the Vi ctims of MI5

2007-12-31 Thread mivefifim

MI5 Persecution. Update: Friday 11 June, 1999

Harassment. in a pub in Clapham, Tuesday lunchtime

Once a month, or once every other month, I meet a Polish friends of. mine
who lives in Clapham North, and sometimes we go to. a particular pub near
where he lives. The last time. was some two months ago; I did not have my
minidisc-walkman. with me, and consequently was seriously harassed by
people MI5 had instructed to harass me, in the. pub.

This Tuesday, 8 June 1999, we again went to the same pub for. a pre-meal
drink. This time I did have my minidisc-walkman with. me. As you can guess,
we were followed into the pub. by a couple of young people (Im getting
older and. older - isnt it funny how the MI5 agents all look young these
days?). They started talking about my situation,. in particular some travel
I had booked the previous day. Unfortunately, they were talking. fairly
quietly,. and my minidisc didnt pick up their speech.

MI5s schizophrenic reasoning is that simultaneously I am very. important
and worthy of their acts of persecution,. and I am also totally unimportant
and their abuse of. me "doesnt matter". Perhaps they should test their
agents and managers. for obsessive personalities or psychotic features in
the same way. as employees are drug-tested. MI5 might lose their "worst
cases" employees if. some psychological testing were applied to their
recruitment. procedure.

Toothless. Watchdogs. What a Surprise.

Recently I have been. engaging in communications with two watchdogs, the
Security Service Tribunal which deals. with complaints against the security
service (and always clears. MI5 of any wrongdoing), and the Data Protection
Registrar, which is mandated to investigate misuse. of personal data held
on. computer.

In. a letter to Nick Brooks, Security Service Tribunal secretary, dated 20
April, I asked him if the Tribunal, as. an allegedly independent body, had
the means to investigate complaints against MI5 other than asking MI5. to
themselves investigate. complaints. To my disappointment, his reply two
weeks later answered the question only indirectly,. in the
negative. Whatever the reader might. think of the merits of the case I have
been. putting before you in faxed articles this last year and half, you
will surely recognise that it is a significant anomaly for. the Tribunal to
have no independent. means of investigating complaints, particularly given
the view expressed even. by previous home secretaries that the security
services. are untrustworthy.



MI5 Persecution:. No Justice for the Victims of MI5

In a previous article I detailed the similarities. between the current MI5
Persecution in England, and other historical instances of. similar
persecution, notably that. by the Nazi Germans in the thirties and
forties. The Germans persecuted first the. mentally ill, the epileptics and
those. suffering from schizophrenia, then moved on to racial groups; in
todays Britain the persecution is again directed at. those with mental
illness, which the. British in their cowardice find easier than taking on
racial groups. as the Germans did. But just as in Thirties Germany there
was no recourse against a malign and omnipotent state, so the. MI5 Secret
Police in the modern British Fascist State allow. no justice for their
victims.

No Recourse Against the Security Services. Illegal Harassment

It has become apparent to me over the last nine years just how loaded. the
dice are in todays Britain, a. fundamentally fascist country which
masquerades as a democracy. Britain is a democracy in name only;. the
Establishment, the defence and MI5 secret police are always. there,
regardless of which party has been voted into power most. recently - and
from "New Labours" conduct in office one. finds it difficult to tell them
apart from Old Tories,. in their crackdowns on the sick and vulnerable in
society.

In thirties Germany the victims of the Nazi regime. had no legal recourse
against their State oppressors; and in todays Fascist. British state, the
victims of the Establishment and. its MI5 Secret Police similarly have no
recourse against the illegal. state-funded and organised oppression. There
is supposed to. be a mechanism for dealing with MI5 crimes, in the shape of
the Security Service Tribunal and Commissioner;. yet these have never found
favour of a plaintiff. One might. as well ask the Nazi SS to investigate
crimes against epileptics or Jews as ask the. Security Service Tribunal to
investigate MI5 crimes. against British citizens; it is quite obvious what
the answer is going to be, regardless of what you say to. them, and what
evidence you provide.. The Tribunal and Commissioner are a mere formality,
a whitewashing body to give the Secret Services a veneer. beneath which
they. hide their shabby criminality.

"Institutional Racism" and Bigotry. in the Metropolitan Police

The recent inquiry into the racist murder. of Stephen Lawrence found clear
evidence of systematic and deliberate racism in the. Metro

Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread John Machin
On Dec 31, 7:20 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?
>

OK, I'll bite: why do you want to throw data away?

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


M`I'5.Persecu tion - M I5 Hav e System atically Dest royed My Li fe

2007-12-31 Thread ivime

MI5. Have Systematically Destroyed My Life

This is getting depressing. From the feedback Ive received, the. recipients
of these faxes are tired of hearing my complaints,. and in truth I am tired
of sending them.. The reason I havent yet ceased sending faxes is because I
cannot think of any other effective means. of replying to MI5s actions
against me, and I feel I have to. do something to try to defend
myself. Three/four. years ago I got the MI5 harassment out of my system by
posting about it on Internet newsgroups,. and for a few months this tactic
was quite effective - I received (and indeed still do today). support from
newsgroup. regulars, and felt I could make my voice heard and break the MI5
monopoly on access to the. British media. But that was years ago, and today
nobody gives a tinkers cuss about my internet posts - so I. have sought to
escalate matters by communicating directly with the. politicians who
allegedly say how this country is supposed. to be run.

Of course, its quite expensive to. keep up a campaign of fax messages for
many weeks. Each set of faxes. takes approx 50 hours to send over the
weekend, and costs perhaps 35. My phone bill for the last. quarter was
350. These. figures are naturally insignificant compared to what MI5 have
been. spending against me over a similar period. It also takes a lot of
time and energy to create a new article every week, and try. and find new
and fresh aspects and viewpoints on MI5s persecution of me. I. am beginning
to run out of. both new topics and energy to write these articles.

So I have a suggestion to put before the MI5 persecutors who. have been
wrecking my life since 1990. In a few days time. I will be going on holiday
to Poland and. Germany, for a couple of weeks. Previously, almost every
time I have travelled by plane, or gone. anywhere on holiday, the MI5
"wreckers" have been most assiduous. in destroying these trips. My
suggestion is; if. MI5 leave me alone on this next trip, I will cease
transmitting these articles. If, however, there are any clear. instances of
harassment (and I am very capable of recognising. MI5 harassment when I see
it), then I will make. public these instances and publish any recordings I
may make of them, and, unwillingly. and unhappily, continue the articles.

Read about the MI5 Persecution on the. Web

Keith Hill MP (Labour - Streatham),. my elected representative, as ever
refuses. to help.


MI5 Refuse to Allow me to have. a Normal Life

Its kind of difficult to contemplate having. a normal existence when you
know your entire. house is bugged from top to bottom, for audio and, very
unpleasantly, video; when your employment is systematically. destroyed,
over and over again; when every time you. leave the country your travel is
disrupted by MI5 plants on the plane yelling abuse at you.. you get the
idea. I would like to have. some semblance of a normal life, like my Polish
and English friends do. But MI5 have made this. impossible, and they have
leached massive resources from the taxpayer to institute a. life not worthy
of the name. on me.

A few years ago MI5 were very open about their aims in. persecuting
me. They were shouting "suicide" at me, both in Canada where. I lived at
the time, and during my occasional visits to London. You. cant get much
clearer than that.. There have been instances as recently as a few weeks
ago. of this intention being voiced by their side; on 15 April 1999, a
woman at the. next ticket counter at the Royal Festival Hall said;

"it would kill it,. you know, it would just be overkill... they can't stop
can. they"

meaning that "they" were. trying to "kill it" i.e. me and they "cant
stop". The. audio file is at;


I wonder why they "cant stop".. Nobody (who doesnt know already) believes
my claims -. so what difference would it make, if they were to
"stop" persecuting me? Perhaps what this persons remarks. indicates, is the
depth of the obsession MI5 have with this. case. They have chosen at random
a person. from the general population, and done their worst to ruin my
life. What is wrong with these people,. that they persecute a national of
the country whose citizens they are supposed to. protect?

No. Chance of a Harassment-Free Job

Since the harassment started in 1990 I have had. three jobs, the first near
Guildford, the second in Oxford, and the. third overseas in Canada. All
three jobs have been systematically destroyed by MI5.. It is so ironic that
MI5 employs a team of. agents, each well compensated for their efforts, to
persecute just one person paid a mere fraction of what. they get for their
"work". In fact, it. is a joke that MI5 is allocated resources for this
sort of effort. If. this area of government were run along commercial lines
then MI5 would be very rapidly closed down, they. produce nothing of any
value, instead spending their. time obsessed with the bugging and
surveillance of their. former employees like Shayler, dangerous subversives
like Straw and Mandelson, 

Re: evolution-python

2007-12-31 Thread Egon Frerich
eloi-ribeiro.blogspot.com schrieb:
> Hi everyone,
> 
> I would like to use a python script to export (save as...) all my
> contacts in Evolution to VCard format (.vcf). I am a beginner so I
> don't knock how to use evolution-python module. The second part of the
> script would be to make inserts to a database, at these second part, I
> think I can menage my self.
> 
> Thanks in advance and happy new year to everyone,
> 
> Eloi

You can use  /usr/lib/evolution/2.12/evolution-addressbook-export

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


M-I 5.Pe rsecution . Ha rassment throu gh the Ra dio

2007-12-31 Thread fvfmfi

MI5 Persecution. Update: Friday 9 July, 1999

Harassment in Poland,. July 1999

And still it continues in my last fax I said. that provided MI5 made no
attempts at. harassment during my two-week holiday this summer, or after I
returned to England, then. I would discontinue these faxes. Unfortunately
MI5 have continued to harass me, both. during the holiday and after my
return to London. I really dont want to continue these. articles, since
they take. up so much time and effort, not to mention expense; but the
Security Service. wont even let me have a holiday in peace and quiet, so I
have to make. further efforts to bring their activities out into the open.

In early July I visited my aunt and. her family in Poland. On Saturday 3
July 1999, I went to a family barbecue at. an allotment outside the
city.. One of my aunts family has previously shown himself to be in the
"enemy" camp, by saying the. Polish equivalent of "something wrong with
him", and various other unprovoked insults.. It is disappointing that one
of my family could forsake. the usual ties of blood and take part in the
actions against me, but thats the way it is. This. guy turned up at the
barbecue,. and started making insults against me. In particular, he started
to say something about the. video camera which I had brought along on the
trip, and the relevance of the video-camera to my fight. against the
persecution. It. seemed pretty obvious to me that my enemies had told him
to turn up. to this occasion, and most likely schooled him in precisely
what words to say; since hes an  unintelligent person. and would not be
able to think for himself what insults. to make against me.

Harassment in. London, week ending Friday 9 July 1999

Got back to. London Wednesay afternoon. Two incidents on the Underground
returning from the airport. Unfortunately I. wasnt recording because I
wasnt expecting trouble, so these slipped through the net. One. of these
was verbal sexual abuse, of the type Ive heard many,. many times before
these last three-and-a-half. years.

Yesterday, Thursday 8/July/1999, I switched on. Heart FM which had never
"got at" me before. and the presenter started making jokes about "mad,
crazy" etc. Again, wasnt recording this because Id. never had any trouble
from this. radio station and wasnt expecting any.

Also yesterday, on a bus (155?) from Balham to Clapham, a. couple of girls
started harassing me with taunts of "crazy". By. now I was expecting
trouble and recorded an audio file of this instance of abuse, at web. URL;


The cynical reader might think my demeanour or behaviour had given. rise to
the taunts of "crazy" recorded above. But I assure you. my behaviour on the
bus would not have made anyone think I was ill; and the. taunts the
previous day were the same sexual. words as previously; so I'm quite sure
that. these incidents are either deliberately staged, or indicative of an
overall high level of. awareness among the London public, particularly in
the. part of London where I live.

Keith Hill MP (Labour - Streatham), my elected. representative, as ever
refuses. to help.


MI5 Persecution: Harassment through the. Radio

One. of the aspects of the MI5 persecution has been harassment through the
broadcast. and print media; and one of the aspects of harassment through
the broadcast media. is being "got at" by radio presenters. This being "got
at" from the radio takes various forms, the most. obvious form being
through overt or hidden words and insults. But there. are other, subtler
forms. In Canada a couple of years ago, I used to listen to the. local
radio stations every morning driving to. work, and listened to the music
only, switching. between radio station presets rapidly as soon as a
presenters voice came on, so that I would. not be subjected to any verbal
harassment by. the D.J.s. But they found a way around this; they kept on
playing the same song, every bl**dy morning. at the same time, which had
the words. "all coming back to me"; the perceptive reader will remember
that the words "coming back" have special. meaning (see the Private Eye
cover at. web URL; for the
hidden. meaning).

And thats not. the only time theyve allowed the songs themselves to be used
as abuse against me; many. years ago Radio-1 in the UK did exactly the
same, and the DJ even made it explicitly clear by. saying, "dont you
sometimes. feel as if the songs were made just for you".

"We should be done for. attempted manslaughter" says Chris Tarrant

Capital Radio DJs have been "in on it" from the start. One of. the first
things I heard in the summer of 1990 was from a Capital DJ. who said, "If
he listens to Capital then he can't be. all bad" (supportive, you
see. We're not bastards). Much of. what came over the radio in 1990 is now
so far away the precise. details have been obliterated by time. No diary
was kept. of the details, and although archives if they exist may give
pointers, the ambiguity of what broadcasters said would leave that open.

Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Paul McGuire
On Dec 31, 2:54 am, abhishek <[EMAIL PROTECTED]> wrote:
>
> Use this function --
>
> def omitNonAscii(nstr):
>     sstr=''
>     for r in nstr:
>         if ord(r)<127:
>             sstr+=r
>     return sstr


Learn the ways of the generator expression you must.

See Dan Bishop's post.

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


M'I`5 Pers ecution Thr ee Year s of MI5 Persecution Fa xes

2007-12-31 Thread fefvmimvm

Three Years of. "MI5 Persecution" Faxes

Ten Thousand Faxes,. and Still No Breakthrough

In the last three years I have sent. at least 5,301 faxes directly from my
computer, and 4,478 faxes through Demons extremely. useful TPC.INT service,
to politicians and the media, in. the subject of the "MI5
Persecution". This has obviously cost me quite. a lot of money, not to
mention time and effort. The aim of all this communication has been. to try
to put discussion of the "MI5 persecution" into. the public
arena; unfortunately,. this aim has not been achieved, yet.

This fax will be my last transmission. for the time being, since the summer
recess is almost upon. us. Depending on what the persecutors do between now
and the autumn, I may or may not resume. faxing later this year. In the
article dated 18/6/99 I said Id stop the articles if. MI5 left me
alone; but they seem to have no fear of. these articles, since they kept
pursuing me in Poland and after my return to the. UK. Again, if they leave
me alone this summer then I wont have to. resume the articles in the
autumn; but I think its fairly obvious that MI5 have nothing better to. do
with their time than to. go after me, and its almost pointless to make this
offer when I know they wont cease harassing. me.

TPC.INT 1996,. 1997, 1998.

Three years ago I was living in Canada, and. the only economic way of
sending faxes to the UK. was through the international email-to-fax gateway
TPC.INT. This. highly useful and totally free service converts emails
(which. may have Postscript-formatted attachments) into faxes which it
delivers to any number within the UK.. Using the telephone book, I
constructed a computer database of. M.P.s fax numbers, and used this
database. to deliver copies of the "FAQ - frequently asked
questions" article. which Id written some time earlier.

This service is still operational, but given that I have. resided in London
for the last year, I do not need to use Demons service when. I can send
articles directly from my own computer using its fax/modem,. which is what
I. have been doing since 1998. However, instead of just sending the FAQ
article, Ive been composing. articles on various aspects of MI5s treatment
of me. Since their activities have been going. on for nine years now, and
there have been various aspects to their actions;. they have harassed me at
work, at home, through the media, etc; I have so far not run. out of things
to say, particularly since their harassment of me is still. ongoing, and I
have been able to record the actual words used by their. paid agents on my
minidisc-walkman. Since mid-March 1999 I. have been sending these articles
pretty much every. weekend.

Anyway, as. mentioned above, I intend this to be the final transmission
before the. summer recess, and it would be nice not to have to continue
these articles in the autumn. But thats something that depends. on them,
not me, and their attitude is. unfortunately clear.

Why am. I sending these articles?

Because I want. the harassment to stop. The cynical reader might think from
these articles that I "thrive on adversity" and. would be lost without the
harassment to complain about; but. that is not the case. In a perfect world
I would like to return to work, in. a job unsullied by MI5s attempts to
ruin it; I would like to live in a. house which wasnt bugged, with my words
being repeated at me wherever I go; I would like a normal life.. I do not
particularly thrive on adversity; I am beaten. down by adversity; the
purpose of these faxes is to. try to bring the whole matter out into the
public arena, where. the rights and wrongs would be visible to all, and
once that were to happen, the adversity might cease. I have had. something
approaching a. normal life a couple of times in the last nine years, but
always, in the end, MI5 turn up and ruin it. I just want these people. out
of. my life, permanently, and the only way of doing that is to kick this
business into the public. arena, and shame MI5 so that they are incapable
of. doing me further damage.

Having said that, unfortunately it seems. fairly obvious by now that these
faxed articles are not going to achieve that aim. Some of. the recipients
know what I am saying is true; but. they choose to stay quiet - wisely,
because if they were to admit the truth. of these articles, then they would
bring the wrath of MI5 down on their heads. Presumably. most recipients do
not know these. articles are true; their reaction to me is the same as my
reaction to the other apparently. deluded people who have sent me email
after. reading my webpage to tell me it happened to them too; the reaction
being, "leave me alone, I dont want to know". Its sad that many M.P.s. have
given. me this reaction, because my case genuinely is different; I
genuinely am telling the truth, and the harassment genuinely is. happening
to. me, and some recipients of this fax know this to be true.

"Write to. your own M.P."

My local M.P. is Mr Keith Hill, L

Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Duncan Booth
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?
> 
> Thank you.

Yes, just decode it to unicode (which you should do as the first thing for 
any encoded strings) and then encode it back to ascii with error handling 
set how you want:

>>> s = '\xc2\xa342'
>>> s.decode('utf8').encode('ascii', 'replace')
'?42'
>>> s.decode('utf8').encode('ascii', 'ignore')
'42'
>>> s.decode('utf8').encode('ascii', 'xmlcharrefreplace')
'£42'
-- 
http://mail.python.org/mailman/listinfo/python-list


at what complexity, a comparison fails ?

2007-12-31 Thread Stef Mientki
hello,

I had a program that worked perfectly well.
In this program modules were dynamically added,
just by putting the file in a predefined directory.

Now one of the interface mechanisms was to see if some parameter was 
changed in a an instance,
by comparing the value from the instance with its previous value

This went all well, untill I added a too complex variable,
then the program stopped working, without generating exceptions.

So it seems that comparing a too complex value isn't allowed.
the variable was something like:

  A = [ , , ..., [,,...], [, 
, ... ] ]

So what I need was something like:
if  A != A_prev :
... do something
A_prev = A

And this crashes, or at least it doesn't work but also doesn't generate 
exceptions.
It does seems to work, if A only contains 1 array.

Why am I not allowed to compare A and A_prev ??
And in general, how complex might a list be to make a valid comparison,
or what are the rules ?

thanks,
Stef Mientki


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


Re: Bizarre behavior with mutable default arguments

2007-12-31 Thread Odalrick
On 30 Dec, 17:26, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote:
>
> > Here's the answer to the 
> > question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-...
>
> > It looks like Guido disagrees with me, so the discussion is closed.
>
> Note that the FAQ mainly explains *what* happens, not *why* was this
> decision taken. Although it shows an example where "this feature can
> be useful", it's neither the only way to do it nor is memoization as
> common as wanting fresh default arguments on every call.
>

I'm surprised noone has said anything about the why of default
mutables. I think it is becasue it isn't easy to do it an other way.

def some_function( an_integer=1,pointless_list=[],
random_fuction_value=random_function()):
pass

To you and me it is obvious that this is an integer, a list and a
function call, but to python it is just 3 objects. Python'd have to
check each argument carefully to determine if it is mutable or not. Or
always copy each object, adding additional overhead to function calls,
and making passing arguments to functions expensive.

Even if these problems were solved, it would only make the problem
less common, not extinct.

# hypothetical
def another_function( still_alive=([],) ):
still_alive[0].append('spam')
print still_alive

>>> another_function()
(['spam'],)
>>> another_function()
(['spam', 'spam'],)

(Could of course be solved by always making deep copies of all
arguments.)

While I would welcome making mutable defaults work differently, I
don't see any way to make such a change without making unacceptable
tradeoffs.


--

Incidentally, I wrote a program a while back, with a bug caused by
mutable defaults. Never bothered to change it, it was the behaviour I
wanted, just not the one I thought I had implemented. -- Python, so
good even the bugs make the program better.

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


M`I,5.Persec ution ` MI 5 W ant Me to Se nd Y ou t hese Faxes

2007-12-31 Thread mevfv

MI5 Want Me to Send You these. Faxes


MI5. seem to Want to Spin this Business out for as Long as Possible

The MI5 persecution has. now been going on, starting from June 1990, for
well over nine years. If I. knew how to put an end to it then I would do
so. Of course MI5 have indicated how they wish. to finish the matter, by
finishing me off; they indicated this very. clearly years ago when they
were shouting "suicide" at. me.

But. a deeper truth is that the MI5 agents carrying out the persecution
rely on. it for their income and their livelihood. They have absolutely no
interest in anything other than spinning out the whole. business, because
that is how they will maximise their earnings. from their employer for the
"work". they do against me.

A vital part of. the fantasy structure MI5 have created about me is that I
am. somehow a worthwhile target. If you bother to read these faxes, if you
browse my website, or perhaps read my posts on the uk.misc newsgroup,. you
will have by now twigged. that I am a totally insignificant person who in a
proper dictatorship like East Germany would not merit. five minutes of
Stasi time. But Britain is improper in the methods of its. corruption, and
the. Security Service seeks to present me as being a an evil fascist, an
evil communist, an evil something-else, and even. a "national institution".

It occurs. to me that to some extent I am playing into their hands, into
their. scheme of things, by writing these articles and sending these
faxes. By doing these. things, I elevate my profile, and fuel MI5s paranoid
obsession with me. But to. stop sending faxes would be to give up the only
hope I have of seeing their campaign "outed". and justice done. Certainly
there is no. point going to the police again; and as remarked in a previous
article, the Security Service Tribunal routinely. whitewashes every
complaint. that is placed before it.

So although MI5 seems to want me to continue sending. these faxes, doing
this is the only real chance of getting this business out. into the
open. And so Ill. continue trying to kick down their house of cards. At
least my. situation is less serious than that of some other victims of the
secret services; unlike Shayler I am not broke and exiled;. unlike Fayed I
have not lost a son to the posited activities of the secret. services. All
I have lost is some of my health,. some of my life, and some of my possible
career.

MI5s Abuse of me is. without Cause or Reason

It constantly puzzles me that MI5 refuse to leave me alone,. wherever I go
and. whatever I do, or rather, whatever I dont do, since Im not a very
socially or otherwise active person. When I am. in England, they chase me
all. over the place, and once theyve found me, they pay people to shout
rude words at me. When I am in Europe, they again chase me all over. the
place, and as. usual pay people to shout obscenities at me. When I am in
Canada or visiting the States, they. faithfully chase me all over the
place, and when they find me, pay people to. shout obscenities at me.

It is hard to avoid the conclusion that these MI5 operatives who. chase me
are total lunatics. You will remember from a previous. articles the
assessment "MI5. Agents are Clinical Psychopaths". They have tried to blame
me for. what they do and what they say; yet their lies have been
wafer-thin, and are clearly seen to be oiled by the. money which they
acquire from the Government, and ultimately from. the taxpayer.

They have tried various lies to put the blame on me;. "we have to abuse him
because hes a nutter", as. if there werent many tens of thousands of other
people with schizophrenia in the United. Kingdom. Their choice of abuse
words is telling; subconsciously. perhaps they realise that it is they who
are the "nutters", and. they try to project their own illness onto their
target.

MI5 Operatives have Nothing. Else to Do With Their Time

Ive seen the same "Alan Holdsworth". person three or four times over a
period of several years. I. saw him at the Civic Hospital in Ottawa in the
Emergency Ward, where he falsely declared his name to be "Tad"; at. Ottawa
airport in summer 1998; and on board. another flight in 1995.

So. what we see from the above paragraph is, the same people are delegated
to watch me for many years. Without me, they wouldnt have a. job. They
literally have nothing else. to do with their time, except indulge their
voyeurism against me. With this observation, we come to. the core of MI5s
campaign against me; these people are not fit for any. job other than the
exercise of voyeurism against. me, and if sanity were to land on MI5 then
they would be out of a job. If sanity were truly to. land then these people
and their employers would be. prosecuted for offences under the Protection
from Harassment legislation, which they are clearly. breaking.

It is one of the ironies of their campaign that MI5. have been trying to
make me an object of ridicule for completely trivial things I have. done,
whil

Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Steven D'Aprano
On Mon, 31 Dec 2007 01:09:09 -0800, John Machin wrote:

> On Dec 31, 7:20 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Is there a string function to trim all non-ascii characters out of a
>> string?
>> Let say I have a string in python (which is utf8 encoded), is there a
>> python function which I can convert that to a string which composed of
>> only ascii characters?
>>
>>
> OK, I'll bite: why do you want to throw data away?

Maybe he has to send the data to a device that can't deal with more than 
7-bit ASCII.

Maybe he's sick of seeing text with "missing character" squares all over 
from all the characters that his fonts can't display.

Maybe the string ends up as a file name on an operating system that 
doesn't support unicode.

Or maybe he's just a curmudgeon who thinks life was better when there 
were only 128 characters available.


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


Re: at what complexity, a comparison fails ?

2007-12-31 Thread Marc 'BlackJack' Rintsch
On Mon, 31 Dec 2007 11:45:55 +0100, Stef Mientki wrote:

> Now one of the interface mechanisms was to see if some parameter was 
> changed in a an instance,
> by comparing the value from the instance with its previous value
> 
> This went all well, untill I added a too complex variable,
> then the program stopped working, without generating exceptions.
> 
> So it seems that comparing a too complex value isn't allowed.

Then you get the wrong impression.

> the variable was something like:
> 
>   A = [ , , ..., [,,...], [, 
> , ... ] ]
> 
> So what I need was something like:
> if  A != A_prev :
> ... do something
> A_prev = A
> 
> And this crashes, or at least it doesn't work but also doesn't generate 
> exceptions.
> It does seems to work, if A only contains 1 array.
> 
> Why am I not allowed to compare A and A_prev ??

You are allowed and you do in the above code.

> And in general, how complex might a list be to make a valid comparison,
> or what are the rules ?

There are no rules about the complexity.  Lists are compared element wise.
If the lists are of the same length and all elements at the corresponding
indexes compare equal, the lists are considered equal.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread John Machin
On Dec 31, 7:20 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?
>

You actually asked TWO different questions, and have got answers
mainly to the first one. Here's a very simple answer to the second
question, which has the advantage of no loss of information:

repr(your_utf8_string.decode('utf8'))
or merely
repr(your_utf8_string)

Cheers,
John

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


Re: TK 8.5

2007-12-31 Thread marcpenninga
On 31 dec, 09:41, Leon <[EMAIL PROTECTED]> wrote:
> 2) Is it a way to use Tk 8.5 with the present version of Python (2.5) ?
>
> Can you give me informations (or links, etc...) about this three
> questions ?

These links might help:

http://tkinter.unpythonic.net/wiki/TileWrapper
http://tkinter.unpythonic.net/wiki/UsingTile
http://www.thescripts.com/forum/thread569032.html
http://groups.google.nl/group/comp.lang.python/browse_thread/thread/6d55b53f8a4ee0ea/a4ac5ea08bf00521?hl=nl#a4ac5ea08bf00521

Caveat: I collected these links, but haven't yet tried the described
techniques...use at yout own risk!

Best regards,
Marc
-- 
http://mail.python.org/mailman/listinfo/python-list


M, I.5'Persec ution MI5 In sist tha t the se F axes mu st Con tinue

2007-12-31 Thread vfmivmiv

MI5 Persecution. Update: Friday 31 March, 2000

22,544 Faxes Delivered in Three Years, and Still No. Breakthrough

In the last three. years I have sent at least 22,544 faxes to recipients in
the UK, of. which at least 13,974 have gone to Westminster. Last weekend
alone I sent 832 completed faxes to. politicians, the media and various
others,. on the subject of MI5s mistreatment of me these last ten years.

I believe some of the recipients know of. MI5s actions against me in the
last decade; yet they maintain. strict "omerta" in fear of the security
services persecution actions. being made public.

MI5 Insist that these Faxes. must Continue

Between September 1999. and mid-January 2000, the persecutors, whoever they
might be, mostly left me alone. I counted only three incidents. in almost
five months - which is. a lower rate than at any time since June 1990, when
this. business started.

By. leaving me alone for several months, the "oppressors" were making an
implicit assurance that they would. continue to leave me alone in the
future. On 11 January. I posted to an internet newsgroup accepting what I
saw as their assurance of no further harassment, stating that I. would
cease sending these faxes - which is the only thing I do in my defence. -
if they continued to leave me alone.. And for two weeks I did indeed
refrain from distributing these. articles.

But MI5 acted in bad faith. From the last week of January until. the
beginning of March, they resumed. their hate campaign against me with a
vengeance. They even put people in my road three times in. February, one
instance of which I recorded. They. resumed their normal behaviour of
bugging. my phone and house, listening to where I would go, and then
placing people in that. location to "aggravate and annoy" me.

What MI5 did in February is plainly. a contravention of the Protection from
Harassment Act 1997, since it has caused me. "alarm and distress" as
specified in the Act. But it is a waste of time going to. the police with a
complaint, since the police have done, and will. do, absolutely nothing. I
complained to the Metropolitan Police in 1995,. and they refused to take my
complaint. When I complained again in 1999, the. detective sergeant laughed
at. my complaint, with the words, "It's an absolute load of rubbish. I
don't investigate rubbish. I can't be more blunt or to. the point than
that." It is useful. to remember that the Met also treated Stephen
Lawrences parents with similar discourtesy; police prejudices are. similar
in my case, so I can take some comfort from that case. and hope that one
day I will get a fair. hearing.

MI5 acted in bad faith,. but they also acted with arrogance. They do not
care if I send 800 faxes every weekend, since they know I. cannot prove my
claims, and. the recent Shayler case shows how weak external oversight is
of. the secret services. But they acted with more than arrogance - the MI5
agents actually want my faxes to continue, they insist that these. faxes
continue, since my communications give them an excuse to continue. their
activities, and continue in. the paid employ of the secret service. Despite
their use of diverse. proxies over the last ten years, it is the same MI5
officers behind the campaign all the time - I have seen. one of them on
three occasions in Canada over a. period of years, and it is a safe belief
that that same person continues to be paid for his "work" in. harassing me
in London now.. The average cost of an MI5 employee is some 75,000 per
annum, so one may infer that their officers. are amply compensated; their
insistence that "hostilities" are maintained is understandable when. placed
in. this light.

12152


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
  --->>http://www.NewsDem
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unexpected __metaclass__ method behavior

2007-12-31 Thread anne . nospam01
Well, you see, I have some database functions that deal with "things"
which are either classes or instances thereof. I though polymorphism
would be a nice way to handle them identically, like:

def do(thing): thing.Foo()
do(t)
do(Test)

But never mind, I now understand that Test.__dict__ can contain only
one entry for 'Foo', and that this must be matched.

Kind regards,
Sebastian
-- 
http://mail.python.org/mailman/listinfo/python-list


M.I 5-Perse cution ` 22,5 44 + 837 = 23 ,381

2007-12-31 Thread fivfm

MI5. Persecution Update: Friday 7 April, 2000

22,544 +. 837 = 23,381

Last weekend I delivered another 837 faxes to politicians and the. media on
the subject. of the security service conspiracy which has destroyed my
life.. This brings the total in the last three years to at least
23,381. These totals do not include. partially delivered faxes.

Some. of the recipients of these faxes must know that what I say is
true; and I hope to motivate those people to acknowledge the reality. of
the. harassment which has followed me for ten years. It takes much time to
transmit these. articles, but as OCG MD Simpson-Wells said to me in 1992,
you have to be a good. communicator if you are to succeeed.

Harassment in. February 2000

Following a quiet. period of almost five months, the persecution resumed
with a vengeance in. late January/February 2000. At this time I was at home
in Clapham, London and was. a relatively easy target for the
persecutors. They have my house bugged, for audio. and I believe video in
some. rooms as well; so they can find out easily where I will be going on a
particular day, and place people in. that location to mouth words of abuse
at me. (I know the last sentence. sounds like classic paranoia, but it
happens to. be true, and some of the people reading this know it to be
true.)

On Friday 11 February 2000 I went shopping in Croydon, to buy a. watch at
H. Samuels jewellers in the Whitgift Centre. While I was. there two youths
came into the shop, one of them quietly uttered an obscenity at me,. and
they immediately walked out.. They showed no interest in the shop.

That Sunday I met with a friend in Clapham, who started needling. me about
"do you know anything about the CIA. and FBI?". Rather unsubtle, and
worrying considering Ive known this guy for. 20 years. From the words and
demeanour. of this "friend" and others in February, I saw that the
persecutors have again been trying. to separate from me what remains of my
social. life.

Incidents in. my Road in February

MI5 very. rarely place people in my home road to harass me, but such was
their persecutory fervour in February that they did so on three. separate
occasions. On the first such occasion,. I was met my two youths who,
grinning, said a deeply offensive sexual obscenity. at me - at which I
coughed at them, so. they called me a "wanker". This incident is safely
recorded on minidisc-walkman, but because of the. offensive nature of their
abuse the recording will. not be made public.

Another. incident very early in the morning of Sunday 20/Feb/2000 occurred
outside my home, following an evening in Croydon with. some
schoolfriends.. Again there were two youths - for some reason the
persecutors always. travel in twos or threes, very rarely is there just one
of them - perhaps they need. a group to bolster their courage, perhaps just
one of them wouldnt have the guts to say something unpleasant. One. of the
youths said quietly, and bitterly, "shitty, very. shitty".

Anyway, in March there were no further incidents near my house. in in my
road, and. our neighbours are very well disposed towards us, so let us hope
that the current quiet. continues.

13814


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
  --->>http://www.NewsDem
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Michael Ströder
[EMAIL PROTECTED] wrote:
> 
> Is there a string function to trim all non-ascii characters out of a
> string?
> Let say I have a string in python (which is utf8 encoded), is there a
> python function which I can convert that to a string which composed of
> only ascii characters?

I'd recommend to rethink this approach.
In the worst case the result is an empty string... ;-)

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


Re: TK 8.5

2007-12-31 Thread Christian Heimes
Leon wrote:
> 1) Did you know if a future version of Python/Tkinter will use Tk 8.5 ? 
> And when ?

We are planing to use Tcl/Tk 8.5 for Python 2.6 and 3.0. The topic is
currently being discussed but nothing has been decided yet.

> 2) Is it a way to use Tk 8.5 with the present version of Python (2.5) ?

No, not yet. It may be possible to back port Tcl Tk 8.5 support from 2.6
to 2.5 once we have finished the migration to 8.5.

Christian

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


using super

2007-12-31 Thread iu2
Hi

I'm trying to make a method call automatically to its super using this
syntax:

class A:
chained = ['pr']
def pr(self):
print 'Hello from A'

class B(A):
def pr(self):
print 'Hello from B'

chain(B, A)
b = B()
b.pr()

b.pr() will print
Hello from B
Hello from A

I'm doing it using the 'chained' attribute in class A, and with this
function:

def chain(cls, sup):
for m in dir(cls):
if callable(getattr(cls, m)) and m in cls.chained:
cm = getattr(cls, m)
def m2(*p):
cm(*p)
return getattr(sup, m)(*p)
setattr(cls, m, m2)
return cls

which seeks for all 'chained' methods and adjusts them accordingly.
(had there been class decorators the syntax would have been simpler,
something like

class A:
  @make_chained
  def pr():
print 'Hello from A'

@chained
class B:
  def pr():
print 'Hello from B'
)


My problem is this: Currently I pass the base class to 'chain' -
chain(B, A)

I prefer to write
chain(B)

and let 'chain' use the super of B.

So:
def chain(cls):
for m in dir(cls):
if callable(getattr(cls, m)) and m in cls.chained:
print 'chaning', cls, m
cm = getattr(cls, m)
def m2(*p):
cm(*p)
return getattr(super(cls), m)(*p)
setattr(cls, m, m2)

This is probably wrong because I don't give the object instance to
super (I don't have it!) and I also get the error
TypeError: super() argument 1 must be type, not classobj

Can you please help me with this?

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


Re: at what complexity, a comparison fails ?

2007-12-31 Thread Steven D'Aprano
On Mon, 31 Dec 2007 11:45:55 +0100, Stef Mientki wrote:

> hello,
> 
> I had a program that worked perfectly well. In this program modules were
> dynamically added, just by putting the file in a predefined directory.
> 
> Now one of the interface mechanisms was to see if some parameter was
> changed in a an instance,
> by comparing the value from the instance with its previous value
> 
> This went all well, untill I added a too complex variable, then the
> program stopped working, without generating exceptions.

What do you mean "stopped working"?


> So it seems that comparing a too complex value isn't allowed. the
> variable was something like:
> 
>   A = [ , , ..., [,,...], [,
> , ... ] ]

Doesn't seem complex to me, and I daresay probably not to Python either 
-- although a lot depends on what "ndarray" and "colour" are.


> So what I need was something like:
> if  A != A_prev :
> ... do something
> A_prev = A
> 
> And this crashes, or at least it doesn't work but also doesn't generate
> exceptions.

It "crashes"? Explain please.



> It does seems to work, if A only contains 1 array.
> 
> Why am I not allowed to compare A and A_prev ?? And in general, how
> complex might a list be to make a valid comparison, or what are the
> rules ?

As complicated as you like.



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


if you want do business on the internet .pls go, if you want buy much popular and inexpensive price pls go

2007-12-31 Thread yhnetstore6
if you want do business on  the internet .pls go,if you want buy much
popular and inexpensive price pls go

2008 new year, 2008 Good news www.yhnetstore.com

In order to greet the new year the arrival, company in new year grand
preferential policy:
1. The shopping full 500USD customer, may enjoy the company to provide
90% discount the preferential benefit, primary proxy.
2. The shopping full 1000USD customer, may enjoy the company to
provide 80% discount the preferential benefit, the company
simultaneously provides the intermediate proxy website, for your
country region this city minute agent.
3. The shopping full 2000USD customer, may enjoy the company to
provide 70% discount the preferential benefit, the company
simultaneously provides the high-level proxy website, for your country
region this city general agent. This agent only provides a quota of
people in this urban company.

Hello.every one, our company have much cheap product . please visit
our web,  http://www.clothserver-yhnetstore.cn
And chose the product of your like ,let go ,hope you shiping
happy ,Go
  http://www.clothserver-yhnetstore.cn


Nike Air Jordan 1 ,Nike Air Jordan 2 Shoes,Nike Air Jordan 3,Nike Air
Jordan 4 Shoes ,Nike Air Jordan 5 Chaussure Shoes,Nike Air Jordan 6
Catalog ,Nike Air Jordan 7 Shoes Catalog ,
Nike Air Jordan 8 Customized ,Nike Air Jordan 9 Shoes
Customized ,Nike
Air Jordan 10 Wholesalers,Nike Jordan 11 Shoes Wholesalers,Nike Air
Jordan 12 retailer,Nike Air Jordan 13 Shoes Factory ,Nike Air Jordan
14 Shoes Sell,Nike Air Jordan 16 Exporter ,Nike Air Jordan 17 Shoes
Exporter, Nike Air Jordan 18 Offer, Nike Air Jordan 19 Shoes
Offer,Nike Air Jordan 20 Manufacture,Nike Jordan 21 Shoes
Manufacture,Nike Jordan 22 CUSTOMIZED ,
We Import&Export&Trading&Retail&sell&buy&distribution& Wholesale Nike
footwear and Nikes Sneakers Jordans Sneakers to this market:
USA,America,US,United States,UK,England,United Kingdom,IT,Italy,
NT,Netherlands,China,Chinese,Germany,DE,Greece,GR,France,
FR,Spain,Portugal,Switzerland,Switzerland,Brazil,Chile,Peru,C
Korea,Australia,Hongkong,Canada,Mexico,Etc
Nike shoes | china nike shoes | air jordan sneakers | cheap gucci
shoes | cheap prada sneakers | gucci sneakers | mix jordan sneakers |
chanel sandals | gucci sandals | dior sandals | wholesale jordan
sneakers |  nike running shoes | nike stock shoes | air jordan at
whlesale price | nike shoes air jordan supplier from in china |
Lacoste Trainers | puma trainers | louis vuitton purse | prada purse
|
gucci handbags | chanel purse | coach purse | nike bas kerball shoes
|
Nike Sneakers| cheap nike sneakers | nike shoes from china | nike
replica | copy nike sneakers |  nike factory stores |  nike stores
Nike wholesale - Nike shoes wholesale
nike jordan sneakers wholesalehttp://www.clothserver-yhnetstore.cn
We (http: // )
Wholesale Cheap Jordan
Shoes,Michael
Jordan Shoes,Nike Jordan Basketball shoes, ... Jordan Shoes,Air
Jordan
Sneakers,Air Jordan Wholesale All of the Air Jordan sneakers have
Nike
Air in the shoes.Authentic quality Jordan Sneakers Custom Jordan
Sneakers Wholesale Jordan Sneakers gucci sneakers prada sneakers in
 ,lv
chanel coach dior DG DSQUARED2 DIESEL,miumiu handbags
sneakers,shoes,t-
shirts,jeans,jackets.We sale new Nike Sneakers,Air Jordan
Sneakers,AIR
FORCE 1S,Nike Dunks SB,Bape Sta from nike outlets and factory
stores,also Nike wholesale-Jordan Shoes,sneakers! china online store!
Cheap Lacoste Trainers Please,Lacoste Trainers for Women,Lacoste
Shoes
Online,Lacoste Shoes for Women,Buy Lacoste Trainers Online,Lacoste
Sneakershttp://www.clothserver-yhnetstore.cn
Lacoste Footwear,Black Lacoste Trainers,Lacoste Trinity
Trainershttp://www.clothserver-yhnetstore.cn
Lacoste Leisure Shoe, cheap nike dunks,cheap gucci
sneakershttp://www.clothserver-yhnetstore.cn
cheap sunglasses factory,wholesale nike  tshirts,cheap air jordans
http://www.clothserver-yhnetstore.cn
nike sb china wholesale,cheap puma sneakers,sneaker wholesale
china,jordans sneakers,gucci shirts wholesale,cheap bape
trainers,shoe
wholesalers in china,cheap nike sneakers,DISCOUNT nike
SNEAKERS,Tennis
Sneakers,gucci Sneakers, Prada Sneakers,Shoes Jordan's +
Wholesale,jordan wholesale manufacturers,nike customes,cheap
wholesale
jordans nike,cheap tiffany necklace,gucci shoes shop,Wholesale
Distributor Authentic Nike Shoes,wholesale air forces and
jordans,dsquared manufacturers,dsquared womens shoes,dsquared2
jeans,dsquared2
shoes
ed hardy caps,ed hardy caps cheap,ed hardy for cheap,ed hardy hats
for
cheap
addidas wholesalers distributorhttp://www.clothserver-yhnetstore.cn
bulk air force ones for salehttp://www.clothserver-yhnetstore.cn
Burberry Handbags made in Chinahttp://www.clothserver-yhnetstore.cn
BUY ARMANI SHOEShttp://www.clothserver-yhnetstore.cn
Buy holesale from china GUCCIhttp://www.clothserver-yhnetstore.cn
buy jordans made in chinahttp://www.clothserver-yhnetstore.cn
buy nike shoes at wholesale pricehttp://www.clothserver-yhnetstore.cn
-- 
http://mail.python.org/mailman

Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Torsten Bronger
Hallöchen!

Paul McGuire writes:

> On Dec 31, 2:54 am, abhishek <[EMAIL PROTECTED]> wrote:
>>
>> Use this function --
>>
>> def omitNonAscii(nstr):
>>     sstr=''
>>     for r in nstr:
>>         if ord(r)<127:
>>             sstr+=r
>>     return sstr
>
> 
> Learn the ways of the generator expression you must.
> 

Stupid me!  How could I miss such a lovely feature in the language?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using super

2007-12-31 Thread Steven D'Aprano
On Mon, 31 Dec 2007 05:47:31 -0800, iu2 wrote:

> Hi
> 
> I'm trying to make a method call automatically to its super using this
> syntax:

[snip code]


I'm not sure if this is your only problem or not, but super() only works 
with new-style classes, not with classic classes. You must inherit from 
object, or it cannot possibly work.

Change "class A" to "class A(object)".

However, I suspect your approach may be too complicated. Try this:


def chain(meth):  # A decorator for calling super.
def f(self, *args, **kwargs):
result = meth(self, *args, **kwargs)
S = super(self.__class__, self)
getattr(S, meth.__name__)(*args, **kwargs)
return result
f.__name__ = "chained_" + meth.__name__
return f



class A(object):
def foo(self, x):
print "I am %s" % self
return x

class B(A):
@chain
def foo(self, x):
print "This is B!!!"
return x + 1



>>> a = A()
>>> a.foo(5)
I am <__main__.A object at 0xb7cf676c>
5
>>> b = B()
>>> b.foo(5)
This is B!!!
I am <__main__.B object at 0xb7cf68ac>
6



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


Python Trajectory Module?

2007-12-31 Thread [EMAIL PROTECTED]
Greetings,

I was wondering if there was a python Module/Library out there that
handles some trajectory/physics stuff like moving an object along a
straight path in an X,Y 2D (or 3D) plane or calculating parabolic
arcs. I'd really settle for just the moving of an object along a
straight line.

I know it's not terribly difficult to implement this on your own, but
I'd rather not re-invent the wheel if someone else already did a good
job of it the first time.

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


Re: TK 8.5

2007-12-31 Thread Kevin Walzer
Christian Heimes wrote:
> Leon wrote:
> 
>> 2) Is it a way to use Tk 8.5 with the present version of Python (2.5) ?
> 
> No, not yet. It may be possible to back port Tcl Tk 8.5 support from 2.6
> to 2.5 once we have finished the migration to 8.5.

Actually, you can. I'm using a custom-built Python that links to 8.5 
with no problem. However, you do have to use some additional modules 
(referenced in another post) to get things working properly.

--Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


usage of file separator

2007-12-31 Thread [EMAIL PROTECTED]
in my code i am iterating thru a list of  filenames (like 'image1.jpg'
etc) and appending them to fully qualified directory names

for x in imagefilenames:
 imgfile=folder+"/"+x
  newimgfilenamelist.append(imgfile)

sothat finally i can get items like c:/mycode/image1.jpg  etc from the
newimgfilenamelist

on windows this will work..but how do i make it work on other os?
Being a beginner i couldn't figure out how to solve this using
os.path  can anyone help?

sorry if this is a silly qn
dn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using super

2007-12-31 Thread Scott David Daniels
Steven D'Aprano wrote:
> ...
> I'm not sure if this is your only problem or not, but super() only works 
> with new-style classes, not with classic classes. You must inherit from 
> object, or it cannot possibly work.
> 
> Change "class A" to "class A(object)".
Absolutely correct.

However, the suggested simpler code cannot work on any released Python:

> def chain(meth):  # A decorator for calling super.
> def f(self, *args, **kwargs):
> result = meth(self, *args, **kwargs)
> S = super(self.__class__, self)
This line is the problem.  The class parameter needs to be the class
name (B in this case) in which the chaining method is defined, not that
of the object itself.

> getattr(S, meth.__name__)(*args, **kwargs)
> return result
> f.__name__ = "chained_" + meth.__name__
> return f
> 
> 
> class A(object):
> def foo(self, x):
> print "I am %s" % self
> return x
> 
> class B(A):
> @chain
> def foo(self, x):
> print "This is B!!!"
> return x + 1

You'll see the problem once you figure out what goes wrong with:
   class C(B):
   @chain
   def foo(self, x):
   print "This is C!!!"
   return x + 2

   C().foo(5)


As to the original idea, better to give it up.
Typically code for a "chained" method "foo" that
returns a result will want to (in some way) use
the result from that call in forming its result.
Python's super allows you to place that call where
it belongs in your code (perhaps after some logging
is enabled, for example) and not just "at the spot
the guru insists the chaining happens."  The recursion-
like call to the super method is placed explicitly
in Python so you can see how it works.  If super is
too tough to explain, I expect single inheritance is
all you are using.  simply remind people to call
A.foo(self, ) within the definition of foo in
B.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using super

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 12:08:43 -0200, Steven D'Aprano  
<[EMAIL PROTECTED]> escribi�:

> On Mon, 31 Dec 2007 05:47:31 -0800, iu2 wrote:
>
>> I'm trying to make a method call automatically to its super using this
>> syntax:
>
>
> def chain(meth):  # A decorator for calling super.
> def f(self, *args, **kwargs):
> result = meth(self, *args, **kwargs)
> S = super(self.__class__, self)
> getattr(S, meth.__name__)(*args, **kwargs)
> return result
> f.__name__ = "chained_" + meth.__name__
> return f
>
>
>
> class A(object):
> def foo(self, x):
> print "I am %s" % self
> return x
>
> class B(A):
> @chain
> def foo(self, x):
> print "This is B!!!"
> return x + 1

If you later inherit from B and try to @chain a method, nasty things  
happen... The problem is that the two arguments to super (current class,  
and actual instance) are *both* required; you can't fake the first using  
self.__class__. But you can't refer to the current class inside the  
decorator, because it doesn't exist yet. You could use the decorator to  
just "mark" the function to be chained, and then -with the help of a  
metaclass- do the actual decoration when the class is created.

def chain(meth):
 """Mark a method to be "chained" later"""
 meth.chained = True
 return meth

def chain_impl(cls, meth):
 """The original decorator by SD'A"""
 def f(self, *args, **kwargs):
 result = meth(self, *args, **kwargs)
 S = super(cls, self)
 getattr(S, meth.__name__)(*args, **kwargs)
 return result
 f.__name__ = "chained_" + meth.__name__
 return f

class ChainedType(type):
 def __new__(meta, name, bases, dic):
 cls = super(ChainedType, meta).__new__(meta, name, bases, dic)
 # replace functions marked "to be chained" with its decorated  
version
 for name, value in dic.iteritems():
 if getattr(value, 'chained', False):
 setattr(cls, name, chain_impl(cls, value))
 return cls

class A(object):
 __metaclass__ = ChainedType
 def foo(self, x):
 print "I am %s" % self
 return x

class B(A):
 @chain
 def foo(self, x):
 print "This is B!!!"
 return x + 1

class C(B):
 @chain
 def foo(self, x):
 print "This is C!!!"
 return x + 2

py> a = A()
py> a.foo(5)
I am <__main__.A object at 0x00A3C690>
5
py> b = B()
py> b.foo(5)
This is B!!!
I am <__main__.B object at 0x00A3CA90>
6
py> c = C()
py> c.foo(5)
This is C!!!
This is B!!!
I am <__main__.C object at 0x00A3C830>
7

The approach above tries to stay close to the chain decorator as  
originally posted. There are other ways that you can search for in the  
Python Cookbook.

-- 
Gabriel Genellina

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

PyPy-Sprint 12th-19th January Leysin, Switzerland

2007-12-31 Thread Carl Friedrich Bolz
=
  PyPy Leysin Winter Sprint (12-19th January 2008)
=
.. image:: http://www.ermina.ch/002.JPG

The next PyPy sprint will be in Leysin, Switzerland, for the
fifth time.  This is a fully public sprint: newcomers and
topics other than those proposed below are welcome.

--
Goals and topics of the sprint
--

* Like previous winters, the main side goal is to have fun in winter
   sports :-) We can take a couple of days off for ski; at this time of
   year, ski days end before 4pm, which still leaves plenty of time
   to recover (er, I mean hack).

* the overall idea of the sprint is to continue working on making PyPy
   ready for general use.  A few more specific tasks:

   - app-level ctypes: getting to a basically usable point
 would be really nice.

   - JIT: there is a long-standing timeshifter refactoring,
 towards making the JIT be more interpreter-like.  Starting
 it during the sprint might be a good way to share some of
 the knowledge of how the JIT really works.  Alternatively,
 we can work on supporting ootype in the timeshifter.

   - Testing: e.g. we run various nightly test runs but the
 results are not summarized in a single page yet.

   - LLVM: llvm 2 is now at version 2.1 and nicely stable
 again.  Our llvm backend has improved in the last few
 months, but refactoring it together with the genc backend
 to share code more directly would be a nice task.

* We are open to all sorts of other tasks during the sprint, just
   propose something.

---
Location & Accomodation
---

Leysin, Switzerland, "same place as before".  Let me refresh your
memory: both the sprint venue and the lodging will be in a very spacious
pair of chalets built specifically for bed & breakfast:
http://www.ermina.ch/.  The place has a good ADSL Internet connexion
with wireless installed.  You can of course arrange your own lodging
anywhere (so long as you are in Leysin, you cannot be more than a 15
minute walk away from the sprint venue), but I definitely recommend
lodging there too -- you won't find a better view anywhere else (though
you probably won't get much worse ones easily, either :-)

I made pre-reservations in the Chalet, so please *confirm* quickly that
you are coming so that we can adjust the reservations as appropriate.
The rate so far has been around 60 CHF a night all included in 2-person
rooms, with breakfast.  There are larger rooms too (less expensive) and
maybe the possibility to get a single room if you really want to.

Please register by svn:


http://codespeak.net/svn/pypy/extradoc/sprintinfo/leysin-winter-2008/people.txt

or on the pypy-sprint mailing list if you do not yet have check-in rights:

   http://codespeak.net/mailman/listinfo/pypy-sprint

You need a Swiss-to-(insert country here) power adapter.  There will be
some Swiss-to-EU adapters around - bring a EU-format power strip if you
have one.

---
Exact times
---

Officially, 12th-19th January 2008.  Both dates are flexible, you can
arrive or leave earlier or later.  We will give introductions and
tutorials depending on who needs them, either on the 13th or the 14th.

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


Newbie: Why doesn't this work

2007-12-31 Thread ct60
Hi Python Community:

Despite my new-ness to Python  I have alreadhy been able to do some (I
think) amazing things.  It is a truly elegant and smart language.

Yet, I can not seem to get a handle on something simple.

I would like to make a class which has private varaiables fName and
lName.  It should have a property "name" which can get or set a name.
Something like as follows:

class Person:
def __init__(self, fName="", lName=""):
self.__fName = fName
self.__lName = lName

def __getattr__(self, attr):
if attr == "name":
return self.__fName + " " + self.__lName

def __setattr__(self, attr, value):
# this assumes that value is a tuple of first and last name
if attr == "name":
self.__fName, self.__lName = value


P = Person()

P.name = ("Joe", "Smith")

print P.name

This fails with the following note:

>>>
Traceback (most recent call last):
  File "C:\Python\testObject.py", line 20, in 
print P.name
  File "C:\Python\testObject.py", line 8, in __getattr__
return self.__fName + " " + self.__lName
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

I don't understand why this fails.  I thought perhaps I need to make
the __getattr__ function like this

def __getattr__(self, attr):
if attr == "name":
return self.__fName + " " + self.__lName
elif attr == "__fName":
return self.__fName
elif attr == "__lName":
return self.__lName

But that still fails.

Can someone please tell me what I am doing wrong?

Thansk in advance,

Chris ([EMAIL PROTECTED])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sub-classing unicode: getting the unicode value

2007-12-31 Thread Martin v. Löwis
>>> How does my object get its own value?
>>   def __unicode__(self):
>> return unicode(self)
> 
> I get an endless recursion with this.

I see. That worked fine in Python 2.4, but give a stack overflow
in Python 2.5.

Depending on your exact class definition, something like

   return super(unicode, self).__getitem__(slice(0,len(self)))

should work.

> I must admit, though, that I probably overestimate the costs
> connected with unicode(my_excerpt) because Gabriel is probably right
> that no real conversion takes place.  A mere attribute lookup may
> still be cheaper, but only very slightly.

I don't understand that remark. To implement the conversion in the
way you want it to be, it definitely needs to produce a copy of
self.

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


Re: help building python installer

2007-12-31 Thread Martin v. Löwis
> Now i want to build an msi installer out of this. What's procedure
> that I should follow for this ??

See Tools/msi. Notice that this (*) isn't supported, so you are on your
own; you probably need to change msi.py

Regards,
Martin

(*) Packaging a Python installer that was built with MSVC 8.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: usage of file separator

2007-12-31 Thread Thomas Wittek
[EMAIL PROTECTED]:
> for x in imagefilenames:
>  imgfile=folder+"/"+x
>   newimgfilenamelist.append(imgfile)
> 
> [..] how do i make it work on other os?

from os.path import join
#..
imgfile=join(folder, x)

-- 
Thomas Wittek
Web: http://gedankenkonstrukt.de/
Jabber: [EMAIL PROTECTED]
GPG: 0xF534E231
-- 
http://mail.python.org/mailman/listinfo/python-list


dont loose packages

2007-12-31 Thread Oguz Yarimtepe

Hi,

I am trying to write a program that will work on a machine which is 
between a client and a server. What i want is to simulate the bridging 
process. So the program should take the packages and able to send them 
to the other interface. I dont want to loose package and i want 
efficiency. I tried to write a program in a multithreaded way but i 
couldnt get an effciency. I used scapy and its sniff method to sniff 
packages.

I am not sure the right way to solve the problem with Python. I will be 
happy if you help me with your ideas?


-- 
Oğuz Yarımtepe
www.yarimtepe.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Dec 31)

2007-12-31 Thread Gabriel Genellina
QOTW:   "I find the best approach is to use multiple languages." - Roger Binns

"All generators can be re-written with classes using the iterator
protocol." -  Jean-Paul Calderone


Mutable default arguments revisited:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/33b7b1a1f62c9d91/

itertools.dropwhile/takewhile might be deprecated:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/8e19a68c0047430a/

Getting n items at a time from a generator:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4696a3b3e1a6d691/

A design decision: have an Article class, want a list of all Articles:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/9be37092d1c3c465/

Looking for a common API for parallel processing:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/57ef7cf6fc5e49b2/

Why is pythonXX.dll installed in a system directory, and not
besides the python executable?

http://groups.google.com/group/comp.lang.python/browse_thread/thread/1c165cabaa7208eb/



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.

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish "the efforts of Python enthusiats":
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the "Planet" sites:
http://planetpython.org
http://planet.python.org

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

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher 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

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
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

Many Python conferences around the world are in preparation.
Watch this space for links to them.

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.
 

Re: at what complexity, a comparison fails ?

2007-12-31 Thread Zentrader
On Dec 31, 2:45 am, Stef Mientki <[EMAIL PROTECTED]> wrote:
> So what I need was something like:
> if  A != A_prev :
> ... do something
> A_prev = A
If A_prev is not declared prior to the if statement, you will get an
error when you try to compare the non-existing variable to A.  This
code will work, at least for the snippet you provided.
 A_prev=""
 if  A != A_prev :
 ... do something
 A_prev = A
Please cut and paste the exact error message in the future.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: at what complexity, a comparison fails ?

2007-12-31 Thread Hans Nowak
Stef Mientki wrote:
> hello,
> 
> I had a program that worked perfectly well.
> In this program modules were dynamically added,
> just by putting the file in a predefined directory.
> 
> Now one of the interface mechanisms was to see if some parameter was 
> changed in a an instance,
> by comparing the value from the instance with its previous value
> 
> This went all well, untill I added a too complex variable,
> then the program stopped working, without generating exceptions.
> 
> So it seems that comparing a too complex value isn't allowed.
> the variable was something like:
> 
>  A = [ , , ..., [,,...], [, 
> , ... ] ]
> 
> So what I need was something like:
>if  A != A_prev :
>... do something
>A_prev = A
> 
> And this crashes, or at least it doesn't work but also doesn't generate 
> exceptions.
> It does seems to work, if A only contains 1 array.
> 
> Why am I not allowed to compare A and A_prev ??
> And in general, how complex might a list be to make a valid comparison,
> or what are the rules ?

I suspect that some of the objects in A have either undefined (or ill-defined) 
comparison methods, so that the overall list comparison does not do what you 
expect.  I'm not sure what ndarray and color are, but check their comparison 
methods (you know, __cmp__, __lt__, __eq__, etc).  (If that isn't clear, please 
see http://effbot.org/pyref/__lt__.htm.)

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


Re: Python Trajectory Module?

2007-12-31 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb:
> Greetings,
> 
> I was wondering if there was a python Module/Library out there that
> handles some trajectory/physics stuff like moving an object along a
> straight path in an X,Y 2D (or 3D) plane or calculating parabolic
> arcs. I'd really settle for just the moving of an object along a
> straight line.
> 
> I know it's not terribly difficult to implement this on your own, but
> I'd rather not re-invent the wheel if someone else already did a good
> job of it the first time.

Maybe the ODE library and it's Python-wrapping PyODE are useful for you.

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


Re: Python Trajectory Module?

2007-12-31 Thread Paul McGuire
On Dec 31, 9:40 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I was wondering if there was a python Module/Library out there that
> handles some trajectory/physics stuff like moving an object along a
> straight path in an X,Y 2D (or 3D) plane or calculating parabolic
> arcs. I'd really settle for just the moving of an object along a
> straight line.
>
> I know it's not terribly difficult to implement this on your own, but
> I'd rather not re-invent the wheel if someone else already did a good
> job of it the first time.
>
> Thanks!

Try VPython.

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


Re: Bizarre behavior with mutable default arguments

2007-12-31 Thread Arnaud Delobelle
On Dec 31, 10:58 am, Odalrick <[EMAIL PROTECTED]> wrote:
> On 30 Dec, 17:26, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> > On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote:
>
> > > Here's the answer to the 
> > > question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-...
>
> > > It looks like Guido disagrees with me, so the discussion is closed.
>
> > Note that the FAQ mainly explains *what* happens, not *why* was this
> > decision taken. Although it shows an example where "this feature can
> > be useful", it's neither the only way to do it nor is memoization as
> > common as wanting fresh default arguments on every call.
>
> I'm surprised noone has said anything about the why of default
> mutables. I think it is becasue it isn't easy to do it an other way.

[...]

There is an easy enough way: evaluate default values when the function
is called rather than when it is defined.  This behaviour comes with
its own caveats as well I imagine, and it's not 'as easy' to implement
as the current one.

What's good about the current behaviour is that it is easy to reason
with (once you know what happens), even though you almost have to get
bitten once.  But using this to have static variable is extremely ugly
IMHO.

--
Arnaud

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


Re: Newbie: Why doesn't this work

2007-12-31 Thread Jeff McNeil
Perhaps you'd be better off using a standard property?  Within your Person
class, you can define a property 'name' to handle what you're trying to do:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "copyright", "credits" or "license()" for more information.


Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


IDLE 1.2
>>>

>>> class Person(object):
def __init__(self, fname, lname):
self.fname = fname
self.lname = lname
def get_name(self):
return '%s %s' % (self.fname, self.lname)
def set_name(self, name):
self.fname, self.lname = name
name = property(get_name, set_name)

>>> p = Person('first', 'last')
>>> p.name
'first last'
>>> p.name = ('first2', 'last2')
>>> p.name
'first2 last2'
>>>


I found http://users.rcn.com/python/download/Descriptor.htm#properties to be
a pretty good reference.

Thanks,

Jeff


On 12/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi Python Community:
>
> Despite my new-ness to Python  I have alreadhy been able to do some (I
> think) amazing things.  It is a truly elegant and smart language.
>
> Yet, I can not seem to get a handle on something simple.
>
> I would like to make a class which has private varaiables fName and
> lName.  It should have a property "name" which can get or set a name.
> Something like as follows:
>
> class Person:
> def __init__(self, fName="", lName=""):
> self.__fName = fName
> self.__lName = lName
>
> def __getattr__(self, attr):
> if attr == "name":
> return self.__fName + " " + self.__lName
>
> def __setattr__(self, attr, value):
> # this assumes that value is a tuple of first and last name
> if attr == "name":
> self.__fName, self.__lName = value
>
>
> P = Person()
>
> P.name = ("Joe", "Smith")
>
> print P.name
>
> This fails with the following note:
>
> >>>
> Traceback (most recent call last):
>   File "C:\Python\testObject.py", line 20, in 
> print P.name
>   File "C:\Python\testObject.py", line 8, in __getattr__
> return self.__fName + " " + self.__lName
> TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
>
> I don't understand why this fails.  I thought perhaps I need to make
> the __getattr__ function like this
>
> def __getattr__(self, attr):
> if attr == "name":
> return self.__fName + " " + self.__lName
> elif attr == "__fName":
> return self.__fName
> elif attr == "__lName":
> return self.__lName
>
> But that still fails.
>
> Can someone please tell me what I am doing wrong?
>
> Thansk in advance,
>
> Chris ([EMAIL PROTECTED])
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Why doesn't this work

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 14:56:02 -0200, <[EMAIL PROTECTED]> escribi�:

> Hi Python Community:
>
> Despite my new-ness to Python  I have alreadhy been able to do some (I
> think) amazing things.  It is a truly elegant and smart language.
>
> Yet, I can not seem to get a handle on something simple.
>
> I would like to make a class which has private varaiables fName and
> lName.  It should have a property "name" which can get or set a name.
> Something like as follows:
>
> class Person:
> def __init__(self, fName="", lName=""):
> self.__fName = fName
> self.__lName = lName
>
> def __getattr__(self, attr):
> if attr == "name":
> return self.__fName + " " + self.__lName
>
> def __setattr__(self, attr, value):
> # this assumes that value is a tuple of first and last name
> if attr == "name":
> self.__fName, self.__lName = value

__getattr__ gets called when an attribute lookup fails in the "standard"  
places. Your version, when attr is not "name", does nothing - effectively  
returning None for *any* other attribute.
You should raise an AttributeError instead: add this line after the if:
 raise AttributeError, attr
__setattr__, on the other hand, is called with *any* attempt to set an  
attribute. Your version effectively makes Person "read only"; the only  
attribute you can set is "name". We could fix that, but there are better  
ways. Forget about __getattr__ and __setattr__ and use a property:

class Person(object):
 def __init__(self, fName="", lName=""):
 self._fName = fName
 self._lName = lName

 def getName(self):
 return "%s %s" % (self._fName, self._lName)

 def setName(self, value):
 self._fName, self._lName = value

 name = property(getName, setName)

Note that:
- I've inherited Person from object. Person is then a "new-style" class,  
and only "new-style" classes support properties (and other goodies).

- I've used _fName instead of __fName. The single _ is an indication to  
the outside "warning, this is an implementation detail, don't play with  
it". (Two underscores are (rarely) used when you want to minimize name  
collisions with subclasses.)

- name is now a property, associated to the two functions getName and  
setName. It works the way you want:

py> p = Person("John", "Smith")
py> p.name
'John Smith'
py> p.name = "Tom", "Sawyer"
py> p.name
'Tom Sawyer'

Something I don't like in this design, is that you can't assign the  
property to itself; p.name = p.name fails because the "set" expects a  
tuple and the "get" returns a single string.

-- 
Gabriel Genellina

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

Re: Newbie: Why doesn't this work

2007-12-31 Thread Tim Chase
A couple items of note:

> class Person:

This should be "class Person(object)" to take advantage of some
of the features that new-style classes offer...particularly in
this case.

> def __init__(self, fName="", lName=""):
> self.__fName = fName
> self.__lName = lName
> 
> def __getattr__(self, attr):
> if attr == "name":
> return self.__fName + " " + self.__lName
> 
> def __setattr__(self, attr, value):
> # this assumes that value is a tuple of first and last name
> if attr == "name":
> self.__fName, self.__lName = value

if the attr isn't "name", no default behavior gets called here.
The common way, with new-style classes is to add

  else:
parent(Person, self).__setattr__(attr, value)

Do be aware that this has some odd behaviors when what you put in
and what you get out are different types:

>>> p1.name = ("Joe", "Smith")
>>> p2.name = p1.name
Traceback (most recent call last):
  File "x.py", line 22, in ?
p2.name = P.name
  File "x.py", line 13, in __setattr__
self.__fName, self.__lName = value
ValueError: too many values to unpack

(slightly munged traceback as it actually came from the test
input file rather than the interactive prompt)

-tim



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


What's the limit of variables size in pyhton?

2007-12-31 Thread هنداوى
Python allow you to only take care about variable name and ignore it's
size because pyhton dynamicly allocate it
so what's the limit in the allocated size in the memory
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Why doesn't this work

2007-12-31 Thread ct60
Thanks you Gabriel and Timm for your thoughtful responses.  I am very
appreciative.

I had heard about the properties function, but wanted to understand
the old syntax first before I tried that.  Thanks to your responses, I
was able to see what the problem was.

Here is a solution I came up with:

class Person():
def __init__(self, fName="", lName=""):
self.__fName = fName
self.__lName = lName

def __getattr__(self, attr):
if attr == "name":
return self.__fName + " " + self.__lName
else:
return self.__dict__[attr]

def __setattr__(self, attr, value):
# this assumes that value is a tuple of first and last name
if attr == "name":
self.__fName, self.__lName = value
else:
self.__dict__[attr] = value


P = Person("Joe", "Smith")

print P.name

P.name = ("Jane", "Doe")

print P.name

This works as expected printing "Joe Smith" and then "Jane Doe".

To be honest, I think the above old syle (I guess) method is pretty
cool and elegant.

Thanks again and have a GREAT NEW YEAR!!

Chris ([EMAIL PROTECTED])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Why doesn't this work

2007-12-31 Thread Jeff McNeil
I didn't actually answer your question, my apologies!

The reason you're failing is due to your use of the __setattr__ call.
Remember, when you override __setattr__, you need to handle *all* of the
logic behind setting object attributes.  You're only attempting to do so
when handling the 'name' property.   Your __setattr__ method is going to be
called on all assignments, even those internal to the object referencing
self.

For example:

>> class Example(object):
__hidden = 1
nothidden = 2
def __getattr__(self, attr):
print 'getting %s' % attr
if attr == '__hidden':
return self.__hidden
elif attr == 'fakeme':
return 'fakeme+%s' % self.__hidden
def __setattr__(self, attr, value):
print 'setting %s to %s' % (attr, value)
if attr == 'fakeme':
self.__hidden = value


The initial value of 'fakeme' is as defined:

>>> e = Example()
>>> e.fakeme
getting fakeme
'fakeme+1'
>>>

Now, we try to set it to something new using the overridden __setattr__
method:

>>> e.fakeme = 10
setting fakeme to 10
setting _Example__hidden to 10
>>>

Ah! Two calls to __setattr__!  First, our explicit 'e.fakeme = 10' executes
it. Next, it's triggered again recursively when 'self.__hidden = value' is
called.

Your __init__ method itself is triggering a __setattr__ call, so the
corresponding attributes are never actually set:

>>> class Example(object):
def __init__(self, hidden=1):
self.__hidden = hidden
def __getattr__(self, attr):
print 'getting %s' % attr
if attr == '__hidden':
return self.__hidden
elif attr == 'fakeme':
return 'fakeme+%s' % self.__hidden
def __setattr__(self, attr, value):
print 'setting %s to %s' % (attr, value)
if attr == 'fakeme':
self.__hidden = value

>>> e = Example()
setting _Example__hidden to 1
>>> type (e._Example__hidden)
getting _Example__hidden



Hope that helps,

Jeff

On 12/31/07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
>
> Perhaps you'd be better off using a standard property?  Within your Person
> class, you can define a property 'name' to handle what you're trying to do:
>
> Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
> [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
> Type "copyright", "credits" or "license()" for more information.
>
>
> 
> Personal firewall software may warn about the connection IDLE
> makes to its subprocess using this computer's internal loopback
> interface.  This connection is not visible on any external
> interface and no data is sent to or received from the Internet.
> 
>
> IDLE 1.2
> >>>
>
>
> >>> class Person(object):
> def __init__(self, fname, lname):
> self.fname = fname
> self.lname = lname
> def get_name(self):
> return '%s %s' % (self.fname, self.lname)
>  def set_name(self, name):
> self.fname, self.lname = name
> name = property(get_name, set_name)
>
>
> >>> p = Person('first', 'last')
> >>> p.name
> 'first last'
> >>> p.name = ('first2', 'last2')
> >>> p.name
> 'first2 last2'
> >>>
>
>
> I found http://users.rcn.com/python/download/Descriptor.htm#properties to
> be a pretty good reference.
>
>
> Thanks,
>
>
> Jeff
>
>
>
> On 12/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > Hi Python Community:
> >
> > Despite my new-ness to Python  I have alreadhy been able to do some (I
> > think) amazing things.  It is a truly elegant and smart language.
> >
> > Yet, I can not seem to get a handle on something simple.
> >
> > I would like to make a class which has private varaiables fName and
> > lName.  It should have a property "name" which can get or set a name.
> > Something like as follows:
> >
> > class Person:
> > def __init__(self, fName="", lName=""):
> > self.__fName = fName
> > self.__lName = lName
> >
> > def __getattr__(self, attr):
> > if attr == "name":
> > return self.__fName + " " + self.__lName
> >
> > def __setattr__(self, attr, value):
> > # this assumes that value is a tuple of first and last name
> > if attr == "name":
> > self.__fName, self.__lName = value
> >
> >
> > P = Person()
> >
> > P.name = ("Joe", "Smith")
> >
> > print P.name
> >
> > This fails with the following note:
> >
> > >>>
> > Traceback (most recent call last):
> >   File "C:\Python\testObject.py", line 20, in 
> > print P.name
> >   File "C:\Python\testObject.py", line 8, in __getattr__
> > return self.__fName + " " + self.__lName
> > TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
> >
> > I don't understand why this fails.  I thought perhaps I need to make
> > the __getattr__ function like this
> >
> > def __getattr__(self, attr):
> > if attr == "name":
> > return self.__fName + " " + self.__lName
> > elif attr == "__fName":
> > return self.__fName
> > elif attr == "__lName":
> > return self.__lName
> >
> > But that still fails.
> >
> > Can someone pl

Re: evolution-python

2007-12-31 Thread eloi-ribeiro.blogspot.com
Thanks a lot Egon it really helped me,

I have used evolution-addressbook-export --format=vcard --
output=file_name.txt

by,

Eloi

On Dec 31, 10:47 am, Egon Frerich <[EMAIL PROTECTED]> wrote:
> eloi-ribeiro.blogspot.com schrieb:
>
> > Hi everyone,
>
> > I would like to use a python script to export (save as...) all my
> > contacts in Evolution to VCard format (.vcf). I am a beginner so I
> > don't knock how to use evolution-python module. The second part of the
> > script would be to make inserts to a database, at these second part, I
> > think I can menage my self.
>
> > Thanks in advance and happy new year to everyone,
>
> > Eloi
>
> You can use  /usr/lib/evolution/2.12/evolution-addressbook-export
>
> Egon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: at what complexity, a comparison fails ?

2007-12-31 Thread Robert Kern
Stef Mientki wrote:
> hello,
> 
> I had a program that worked perfectly well.
> In this program modules were dynamically added,
> just by putting the file in a predefined directory.
> 
> Now one of the interface mechanisms was to see if some parameter was 
> changed in a an instance,
> by comparing the value from the instance with its previous value
> 
> This went all well, untill I added a too complex variable,
> then the program stopped working, without generating exceptions.
> 
> So it seems that comparing a too complex value isn't allowed.
> the variable was something like:
> 
>   A = [ , , ..., [,,...], [, 
> , ... ] ]
> 
> So what I need was something like:
> if  A != A_prev :
> ... do something
> A_prev = A
> 
> And this crashes, or at least it doesn't work but also doesn't generate 
> exceptions.
> It does seems to work, if A only contains 1 array.
> 
> Why am I not allowed to compare A and A_prev ??
> And in general, how complex might a list be to make a valid comparison,
> or what are the rules ?

Remember that numpy arrays use rich comparisons. (ndarray1 != ndarray2) gives
another array, not a boolean value. The resulting array cannot be used in an
"if" clause.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: os.fork leaving processes behind

2007-12-31 Thread Falcolas
On Dec 28, 12:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> I'd try to use any of the existing server implementations in
> SocketServer.py, but if you insist on using your own, look at the
> ForkingMixin class as an example of using waitpid() to avoid having zombie
> processes.
>
> --
> Gabriel Genellina

Thanks for the excellent advice. I went with the SocketServer, and I'm
quite happy with the results. I had not considered it earlier due to
the atrocious documentation on the Python site. Google helped with
that immensely.

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


Re: Unexpected __metaclass__ method behavior

2007-12-31 Thread Arnaud Delobelle
On Dec 31, 12:06 pm, [EMAIL PROTECTED] wrote:
> Well, you see, I have some database functions that deal with "things"
> which are either classes or instances thereof. I though polymorphism
> would be a nice way to handle them identically, like:
>
> def do(thing): thing.Foo()
> do(t)
> do(Test)
>
> But never mind, I now understand that Test.__dict__ can contain only
> one entry for 'Foo', and that this must be matched.
>
> Kind regards,
> Sebastian

Of course you can do this.  The trick is *not* to use metaclasses!

class Bar(object):
def foo(self): return 'instance foo'
@classmethod
def classfoo(cls): return 'class foo'

def do(x):
if isinstance(x, type):
return x.classfoo()
else:
return x.foo()

Then:

>>> bar = Bar()
>>> do(bar)
'instance foo'
>>> do(Bar)
'class foo'

HTH

--
Arnaud



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


Re: What's the limit of variables size in pyhton?

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 15:40:31 -0200, هنداوى <[EMAIL PROTECTED]> escribi�:

> Python allow you to only take care about variable name and ignore it's
> size because pyhton dynamicly allocate it
> so what's the limit in the allocated size in the memory

As big as would fit on available memory.

-- 
Gabriel Genellina

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

if you want do business on the internet .pls go, if you want buy much popular and inexpensive price pls go

2007-12-31 Thread yhnetstore1
if you want do business on  the internet .pls go,if you want buy much
popular and inexpensive price pls go


In order to greet the new year the arrival, company in new year grand
preferential policy:
1. The shopping full 500USD customer, may enjoy the company to provide
90% discount the preferential benefit, primary proxy.
2. The shopping full 1000USD customer, may enjoy the company to
provide 80% discount the preferential benefit, the company
simultaneously provides the intermediate proxy website, for your
country region this city minute agent.
3. The shopping full 2000USD customer, may enjoy the company to
provide 70% discount the preferential benefit, the company
simultaneously provides the high-level proxy website, for your country
region this city general agent. This agent only provides a quota of
people in this urban company.

Hello.every one, our company have much cheap product . please visit
our web,  http://www.elecserver-yhnetstore.cn
And chose the product of your like ,let go ,hope you shiping
happy ,Go
  http://www.elecserver-yhnetstore.cn


Nike Air Jordan 1 ,Nike Air Jordan 2 Shoes,Nike Air Jordan 3,Nike Air
Jordan 4 Shoes ,Nike Air Jordan 5 Chaussure Shoes,Nike Air Jordan 6
Catalog ,Nike Air Jordan 7 Shoes Catalog ,
Nike Air Jordan 8 Customized ,Nike Air Jordan 9 Shoes
Customized ,Nike
Air Jordan 10 Wholesalers,Nike Jordan 11 Shoes Wholesalers,Nike Air
Jordan 12 retailer,Nike Air Jordan 13 Shoes Factory ,Nike Air Jordan
14 Shoes Sell,Nike Air Jordan 16 Exporter ,Nike Air Jordan 17 Shoes
Exporter, Nike Air Jordan 18 Offer, Nike Air Jordan 19 Shoes
Offer,Nike Air Jordan 20 Manufacture,Nike Jordan 21 Shoes
Manufacture,Nike Jordan 22 CUSTOMIZED ,
We Import&Export&Trading&Retail&sell&buy&distribution& Wholesale Nike
footwear and Nikes Sneakers Jordans Sneakers to this market:
USA,America,US,United States,UK,England,United Kingdom,IT,Italy,
NT,Netherlands,China,Chinese,Germany,DE,Greece,GR,France,
FR,Spain,Portugal,Switzerland,Switzerland,Brazil,Chile,Peru,C
Korea,Australia,Hongkong,Canada,Mexico,Etc
Nike shoes | china nike shoes | air jordan sneakers | cheap gucci
shoes | cheap prada sneakers | gucci sneakers | mix jordan sneakers |
chanel sandals | gucci sandals | dior sandals | wholesale jordan
sneakers |  nike running shoes | nike stock shoes | air jordan at
whlesale price | nike shoes air jordan supplier from in china |
Lacoste Trainers | puma trainers | louis vuitton purse | prada purse
|
gucci handbags | chanel purse | coach purse | nike bas kerball shoes
|
Nike Sneakers| cheap nike sneakers | nike shoes from china | nike
replica | copy nike sneakers |  nike factory stores |  nike stores
Nike wholesale - Nike shoes wholesale
nike jordan sneakers wholesalehttp://www.elecserver-yhnetstore.cn
We (http: // )
Wholesale Cheap Jordan
Shoes,Michael
Jordan Shoes,Nike Jordan Basketball shoes, ... Jordan Shoes,Air
Jordan
Sneakers,Air Jordan Wholesale All of the Air Jordan sneakers have
Nike
Air in the shoes.Authentic quality Jordan Sneakers Custom Jordan
Sneakers Wholesale Jordan Sneakers gucci sneakers prada sneakers in
 ,lv
chanel coach dior DG DSQUARED2 DIESEL,miumiu handbags
sneakers,shoes,t-
shirts,jeans,jackets.We sale new Nike Sneakers,Air Jordan
Sneakers,AIR
FORCE 1S,Nike Dunks SB,Bape Sta from nike outlets and factory
stores,also Nike wholesale-Jordan Shoes,sneakers! china online store!
Cheap Lacoste Trainers Please,Lacoste Trainers for Women,Lacoste
Shoes
Online,Lacoste Shoes for Women,Buy Lacoste Trainers Online,Lacoste
Sneakershttp://www.elecserver-yhnetstore.cn
Lacoste Footwear,Black Lacoste Trainers,Lacoste Trinity
Trainershttp://www.elecserver-yhnetstore.cn
Lacoste Leisure Shoe, cheap nike dunks,cheap gucci
sneakershttp://www.elecserver-yhnetstore.cn
cheap sunglasses factory,wholesale nike  tshirts,cheap air jordans
http://www.elecserver-yhnetstore.cn
nike sb china wholesale,cheap puma sneakers,sneaker wholesale
china,jordans sneakers,gucci shirts wholesale,cheap bape
trainers,shoe
wholesalers in china,cheap nike sneakers,DISCOUNT nike
SNEAKERS,Tennis
Sneakers,gucci Sneakers, Prada Sneakers,Shoes Jordan's +
Wholesale,jordan wholesale manufacturers,nike customes,cheap
wholesale
jordans nike,cheap tiffany necklace,gucci shoes shop,Wholesale
Distributor Authentic Nike Shoes,wholesale air forces and
jordans,dsquared manufacturers,dsquared womens shoes,dsquared2
jeans,dsquared2
shoes
ed hardy caps,ed hardy caps cheap,ed hardy for cheap,ed hardy hats
for
cheap
addidas wholesalers distributorhttp://www.elecserver-yhnetstore.cn
bulk air force ones for salehttp://www.elecserver-yhnetstore.cn
Burberry Handbags made in Chinahttp://www.elecserver-yhnetstore.cn
BUY ARMANI SHOEShttp://www.elecserver-yhnetstore.cn
Buy holesale from china GUCCIhttp://www.elecserver-yhnetstore.cn
buy jordans made in chinahttp://www.elecserver-yhnetstore.cn
buy nike shoes at wholesale pricehttp://www.elecserver-yhnetstore.cn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Why doesn't this work

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 16:01:38 -0200, <[EMAIL PROTECTED]> escribi�:

> Thanks you Gabriel and Timm for your thoughtful responses.  I am very
> appreciative.
>
> I had heard about the properties function, but wanted to understand
> the old syntax first before I tried that.  Thanks to your responses, I
> was able to see what the problem was.
>
> Here is a solution I came up with:
>
> class Person():
> def __init__(self, fName="", lName=""):
> self.__fName = fName
> self.__lName = lName
>
> def __getattr__(self, attr):
> if attr == "name":
> return self.__fName + " " + self.__lName
> else:
> return self.__dict__[attr]
>
> def __setattr__(self, attr, value):
> # this assumes that value is a tuple of first and last name
> if attr == "name":
> self.__fName, self.__lName = value
> else:
> self.__dict__[attr] = value
>

Almost. __getattr__ is called *after* searching the name in the standard  
places, including self.__dict__, so there is no point in looking there  
again as it will fail certainly (with a KeyError instead of the right  
AttributeError).

 def __getattr__(self, attr):
 if attr == "name":
 return self.__fName + " " + self.__lName
 raise AttributeError, attr

(__getattr__ and __setattr__ despite their names, are not very symmetrical)

> To be honest, I think the above old syle (I guess) method is pretty
> cool and elegant.

If you have one or two special attributes, may be fine. But when you want  
to define many properties, it becomes unmanageable.
And notice that the mere existence of those methods slows down A LOT *all*  
attribute accesses, not just the ones related to your special names.

> Thanks again and have a GREAT NEW YEAR!!

You too!

-- 
Gabriel Genellina

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

Re: What's the limit of variables size in pyhton?

2007-12-31 Thread James Matthews
However some Debuggers will not show you variable's that are too big!

On Dec 31, 2007 7:38 PM, Gabriel Genellina <[EMAIL PROTECTED]> wrote:

> En Mon, 31 Dec 2007 15:40:31 -0200, هنداوى <[EMAIL PROTECTED]>
> escribi�:
>
> > Python allow you to only take care about variable name and ignore it's
> > size because pyhton dynamicly allocate it
> > so what's the limit in the allocated size in the memory
>
> As big as would fit on available memory.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python for web...

2007-12-31 Thread James Matthews
The issue is finding a host with mod_python installed for cheap!

On Dec 31, 2007 7:57 AM, David Van Mosselbeen <
[EMAIL PROTECTED]> wrote:

> on Tue, 25 Dec 2007 20:42:03 -0800 (PST), [EMAIL PROTECTED] <
> [EMAIL PROTECTED]> wrote:
> >
> > Hi everyone,
> >
> > I have to develop a web based enterprise application for my final year
> > project. Since i am interested in open source, i searched the net.
> > Almost 90% of them were PHP and MySQL. Cant we use python for that ? I
> > tried several sites, but there is not enough tutorial for beginners
> > [mod_python, PSP etc]. I couldnt find any detailed book, not even a
> > single book :( All the python books are covering only CGI part)
> >
> > Any suggestions? Any recommended book?
> >
> > Execuse my English.
> >
> > Thushanthan.
>
> You can also take a look to `webpy` and `cherrypy`. These where not yet
> mentioned.
>
> --
> David Van Mosselbeen
> http://dvm.zapto.org:8080/
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree should parse string and file in teh same way

2007-12-31 Thread James Matthews
When dealing with files you pass it an object! So make your string an object
and then it should work!

On Dec 31, 2007 8:17 AM, Paddy <[EMAIL PROTECTED]> wrote:

> On Dec 31, 3:42 am, "Peter Pei" <[EMAIL PROTECTED]> wrote:
> > One bad design about elementtree is that it has different ways parsing a
> > string and a file, even worse they return different objects:
> > 1) When you parse a file, you can simply call parse, which returns a
> > elementtree, on which you can then apply xpath;
> > 2) To parse a string (xml section), you can call XML or fromstring, but
> both
> > return element instead of elementtree. This alone is bad. To make it
> worse,
> > you have to create an elementtree from this element before you can
> utilize
> > xpath.
>
> I haven't tried this, but you should be able to wrap your text string
> so that it looks like a file using the stringio module and pass that
> to elementtree:
>
> http://blog.doughellmann.com/2007/04/pymotw-stringio-and-cstringio.html
>
> - Paddy.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

pexpect ssh login and ls | grep

2007-12-31 Thread crybaby
I need to ssh into a remote machine and check if mytest.log file is
there.  I have setup ssh keys to handle login authentications.

How do I determine if mytest.log is there by using Pexpect. What I
have done so far is spawned a child for ssh.

1) Now what do I do to execute shell_cmd(ls and grep), spawn another
child?

2) Can I use the same child that was spawned for ssh, if so how?

3) After executing the ls -l|grep mystest.log, how do I get the value
from pexpect?

shell_cmd = 'ls -l | grep mytest.log'
child = pexpect.spawn ('ssh [EMAIL PROTECTED]')
#child.sendline(shell_cmd)

>>> child.sendline("ls")
3
>>> print child.before
:~[
>>> child.after
'[EMAIL PROTECTED] '

>>> child.sendline('/bin/bash', ['-c',shell_cmd])
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: sendline() takes at most 2 arguments (3 given)

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


Re: Bizarre behavior with mutable default arguments

2007-12-31 Thread Odalrick
On 31 Dec, 18:22, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Dec 31, 10:58 am, Odalrick <[EMAIL PROTECTED]> wrote:
>
> > On 30 Dec, 17:26, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote:
>
> > > > Here's the answer to the 
> > > > question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-...
>
> > > > It looks like Guido disagrees with me, so the discussion is closed.
>
> > > Note that the FAQ mainly explains *what* happens, not *why* was this
> > > decision taken. Although it shows an example where "this feature can
> > > be useful", it's neither the only way to do it nor is memoization as
> > > common as wanting fresh default arguments on every call.
>
> > I'm surprised noone has said anything about the why of default
> > mutables. I think it is becasue it isn't easy to do it an other way.
>
> [...]
>
> There is an easy enough way: evaluate default values when the function
> is called rather than when it is defined.  This behaviour comes with
> its own caveats as well I imagine, and it's not 'as easy' to implement
> as the current one.
>

Adding overhead to *all* function calls, even the ones without mutable
defaults. That doesn't sound like an attractive tradeoff.

> What's good about the current behaviour is that it is easy to reason
> with (once you know what happens), even though you almost have to get
> bitten once.  But using this to have static variable is extremely ugly
> IMHO.
>
> --
> Arnaud

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


Re: Python Trajectory Module?

2007-12-31 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
> Greetings,
> 
> I was wondering if there was a python Module/Library out there that
> handles some trajectory/physics stuff like moving an object along a
> straight path in an X,Y 2D (or 3D) plane or calculating parabolic
> arcs. I'd really settle for just the moving of an object along a
> straight line.
> 
> I know it's not terribly difficult to implement this on your own, but
> I'd rather not re-invent the wheel if someone else already did a good
> job of it the first time.
> 
> Thanks!

If you combine the advice of Diez B. Roggish and Paul McGuire:
Download and install VPython.
Download and install PyODE.
Get and run VPython Contributed program:
http://www.vpython.org/contributed/visualjoints.py
which shows a weight on a hinge with another attached to the ball;
quite believable dynamics.  Although the code is really not
carefully written, looking at it may give you a sense of how
little work you'll have to do to get some physics action going.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP: How to implement listing al 'Employees'.

2007-12-31 Thread Mike Orr
On Dec 29, 1:53 am, Petar <[EMAIL PROTECTED]> wrote:

> Let me explain how I got to this question. I had written een Article
> class which handled the articles that I had. On a certain page I
> wanted to show all the articles. That got me wondering about what to
> do. Should I make a method in my Article.class which returned multiple
> articles, or should I just use my current Article.class and fill a
> list (with a loop) with articles. The first solution thus meaning
> writing another method, the latter method to just use the current
> Article.class and call it multiple times.

A class method would be ideal for this if you have no other reason to
create an Articles class:

@classmethod
def all(class_):
ret = []
for a in THE_ARTICLES:
article = class_(a)
ret.append(article)
return ret

Definitely don't use an instance method, which is expected to operate
on one article without making additional Article instances.

Mark 'Blackjack' Rintsch wrote:
> Then maybe it should not be a class.  Maybe a function returning
> `Article`\s would be enough.  This is not Java, not everything
> has to be stuffed into classes.

True, but this function is logically related to the Article class, so
it's convenient to put them together.  Then the user can just "from __
import Article" rather than "from __ import Article, get_all_articles,
what_was_that_other_function?".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bizarre behavior with mutable default arguments

2007-12-31 Thread Chris Mellon
On Dec 31, 2007 2:08 PM, Odalrick <[EMAIL PROTECTED]> wrote:
> On 31 Dec, 18:22, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> > On Dec 31, 10:58 am, Odalrick <[EMAIL PROTECTED]> wrote:
> >
> > > On 30 Dec, 17:26, George Sakkis <[EMAIL PROTECTED]> wrote:
> >
> > > > On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote:
> >
> > > > > Here's the answer to the 
> > > > > question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-...
> >
> > > > > It looks like Guido disagrees with me, so the discussion is closed.
> >
> > > > Note that the FAQ mainly explains *what* happens, not *why* was this
> > > > decision taken. Although it shows an example where "this feature can
> > > > be useful", it's neither the only way to do it nor is memoization as
> > > > common as wanting fresh default arguments on every call.
> >
> > > I'm surprised noone has said anything about the why of default
> > > mutables. I think it is becasue it isn't easy to do it an other way.
> >
> > [...]
> >
> > There is an easy enough way: evaluate default values when the function
> > is called rather than when it is defined.  This behaviour comes with
> > its own caveats as well I imagine, and it's not 'as easy' to implement
> > as the current one.
> >
>
> Adding overhead to *all* function calls, even the ones without mutable
> defaults. That doesn't sound like an attractive tradeoff.
>

And also removing the only way you can currently do early binding in
Python. I agree that it's a gotcha, but unless someone comes up with
an answer to the following questions, I'll stick with the status quo
(Note that this is not blind Python group-think as a previous poster
implied, but a pragmatic decision that this is the most practical
solution):

a) If we don't evaluate default arguments at function compilation,
when do we do it?
b) If you do it at call time, how do you implement early binding?
c) If you want to introduce new syntax for the current behavior, what
is it and can you justify it?
d) What are the performance implications of your proposal versus the
current behavior?

Note that the desired behavior can be implemented under the current
behavior, at the expense of verbosity - using factories and sentinel
values as the default arguments, and then expanding them in the
function. It's not possible to implement the current behavior of
early-bound arguments if default arguments are evaluated with every
call. This alone is a good reason to keep the current behavior until
someone actually has a good alternative that covers the current use
cases and isn't just upset by the behavior.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing a new language

2007-12-31 Thread Tim Roberts
Xah Lee <[EMAIL PROTECTED]> wrote:
>
>Let me tell you, since you know PHP, that PHP and Perl are practically
>identical in their high-levelness or expressiveness or field of
>application (and syntax), and, Perl and Python are pretty much the
>same except their syntax.

I agree with the fundamental sentiment here, but it's important to note
that the syntax difference between Perl and Python is an enormous
consideration.

The biggest problem with Perl's syntax, in my view, is that it is darned
near impossible to write Perl code that can be read and understood later,
by anyone, including the author.  I've used both languages extensively, and
even with all of that experience, it takes considerable effort for me to go
back to the Perl scripts I wrote 4 or 5 years ago and grasp what they
actually do.

With Python, on the other hand, much of the source code reads like English
prose.  It's certainly possible to code "write-only" sequences by abusing
comprehensions and generators, but obfuscations like that are the exception
rather than the rule.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the limit of variables size in pyhton?

2007-12-31 Thread هنداوى
On Dec 31, 11:26 am, "James Matthews" <[EMAIL PROTECTED]> wrote:
> However some Debuggers will not show you variable's that are too big!
>
> On Dec 31, 2007 7:38 PM, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>
> > En Mon, 31 Dec 2007 15:40:31 -0200, هنداوى <[EMAIL PROTECTED]>
> > escribi�:
>
> > > Python allow you to only take care about variable name and ignore it's
> > > size because pyhton dynamicly allocate it
> > > so what's the limit in the allocated size in the memory
>
> > As big as would fit on available memory.

Is that mean that i can deal with files with size more than 2GB only
if the available memory allow
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Choosing a new language

2007-12-31 Thread Achim Schneider
Tim Roberts <[EMAIL PROTECTED]> wrote:

> Xah Lee <[EMAIL PROTECTED]> wrote:
> >
> >Let me tell you, since you know PHP, that PHP and Perl are
> >practically identical in their high-levelness or expressiveness or
> >field of application (and syntax), and, Perl and Python are pretty
> >much the same except their syntax.
> 
> I agree with the fundamental sentiment here, but it's important to
> note that the syntax difference between Perl and Python is an enormous
> consideration.
> 
> The biggest problem with Perl's syntax, in my view, is that it is
> darned near impossible to write Perl code that can be read and
> understood later, by anyone, including the author.  I've used both
> languages extensively, and even with all of that experience, it takes
> considerable effort for me to go back to the Perl scripts I wrote 4
> or 5 years ago and grasp what they actually do.
> 
> With Python, on the other hand, much of the source code reads like
> English prose.  It's certainly possible to code "write-only"
> sequences by abusing comprehensions and generators, but obfuscations
> like that are the exception rather than the rule.

Should I start a flame war? Shouldn't I?

It's New Year's Eve, after all, fits quite nicely.

Perl excels on executing braindumps. Python is quite good in that area,
too.

Haskell, too, but only if you think Haskell. And Haskell has style.
Good style. Very good style, to be exact. 

In the end that means that you can't read your Perl and Python programs
'cos your brain was a bit muddy at the time you wrote it.

Well, with Haskell this would never happen, as you wouldn't have ever
been able to write such atrocious code in the first place.

You would rather think about the problem in detail, get disabused by
old aunty typecheck, abstract, and write completely unintelligent code
_after_ understanding that your brainmuddiness was actually complete
clarity, it was the language you were trying to implement it in that
made it muddy.

And now please all stop posting and let me get completely drunk in
relative peace.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the limit of variables size in pyhton?

2007-12-31 Thread [EMAIL PROTECTED]
On Dec 31, 4:05 pm, "هنداوى" <[EMAIL PROTECTED]> wrote:
> On Dec 31, 11:26 am, "James Matthews" <[EMAIL PROTECTED]> wrote:
>
> > However some Debuggers will not show you variable's that are too big!
>
> > On Dec 31, 2007 7:38 PM, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>
> > > En Mon, 31 Dec 2007 15:40:31 -0200, هنداوى <[EMAIL PROTECTED]>
> > > escribi�:
>
> > > > Python allow you to only take care about variable name and ignore it's
> > > > size because pyhton dynamicly allocate it
> > > > so what's the limit in the allocated size in the memory
>
> > > As big as would fit on available memory.
>
> Is that mean that i can deal with files with size more than 2GB only
> if the available memory allow

No, files can be often be dealt with in manageable
chunks. Instead of reading the entire file into
memory, often it suffices to read in a line at a
time.
-- 
http://mail.python.org/mailman/listinfo/python-list

argv[0] and __file__ inconsistency

2007-12-31 Thread Hai Vu
I currently use ActivePython 2.5.1. Consider the following code which
I saved as cmdline.py:
import sys
print sys.argv[0]
If I invoke this code as 'python cmdline.py', then the output is:
cmdline.py
If I invoke it as 'cmdline.py', then the output is:
C:\Users\hai\src\python\cmdline.py

The same happens for __file__. My question: do you have any
suggestions for a more consistent way to figure out the full path of
your script?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the limit of variables size in pyhton?

2007-12-31 Thread Gabriel Genellina
En Mon, 31 Dec 2007 20:05:41 -0200, هنداوى <[EMAIL PROTECTED]> escribi�:
> On Dec 31, 11:26 am, "James Matthews" <[EMAIL PROTECTED]> wrote:
>> However some Debuggers will not show you variable's that are too big!
>>
>> On Dec 31, 2007 7:38 PM, Gabriel Genellina <[EMAIL PROTECTED]>  
>> wrote:
>>
>> > En Mon, 31 Dec 2007 15:40:31 -0200, هنداوى <[EMAIL PROTECTED]>
>> > escribi�:
>>
>> > > Python allow you to only take care about variable name and ignore  
>> it's
>> > > size because pyhton dynamicly allocate it
>> > > so what's the limit in the allocated size in the memory
>>
>> > As big as would fit on available memory.
>
> Is that mean that i can deal with files with size more than 2GB only
> if the available memory allow

To be more precise, that depends on the OS. On Windows there is a limit of  
2GB adressable memory per process (this is unrelated to the amount of  
physical memory). You may increase that limit to 3GB. I think Python can  
handle all the memory the OS is able to provide.
But do you actually have to keep the whole file in memory?

-- 
Gabriel Genellina

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

Re: argv[0] and __file__ inconsistency

2007-12-31 Thread John Machin
On Jan 1, 9:31 am, Hai Vu <[EMAIL PROTECTED]> wrote:
> I currently use ActivePython 2.5.1. Consider the following code which
> I saved as cmdline.py:
> import sys
> print sys.argv[0]
> If I invoke this code as 'python cmdline.py', then the output is:
> cmdline.py
> If I invoke it as 'cmdline.py', then the output is:
> C:\Users\hai\src\python\cmdline.py
>
> The same happens for __file__. My question: do you have any
> suggestions for a more consistent way to figure out the full path of
> your script?

use os.path.abspath
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pexpect ssh login and ls | grep

2007-12-31 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
crybaby  <[EMAIL PROTECTED]> wrote:
>I need to ssh into a remote machine and check if mytest.log file is
>there.  I have setup ssh keys to handle login authentications.
>
>How do I determine if mytest.log is there by using Pexpect. What I
>have done so far is spawned a child for ssh.
>
>1) Now what do I do to execute shell_cmd(ls and grep), spawn another
>child?
>
>2) Can I use the same child that was spawned for ssh, if so how?
>
>3) After executing the ls -l|grep mystest.log, how do I get the value
>from pexpect?
>
>shell_cmd = 'ls -l | grep mytest.log'
>child = pexpect.spawn ('ssh [EMAIL PROTECTED]')
>#child.sendline(shell_cmd)
>
 child.sendline("ls")
>3
 print child.before
>:~[
 child.after
>'[EMAIL PROTECTED] '
>
 child.sendline('/bin/bash', ['-c',shell_cmd])
>Traceback (most recent call last):
>  File "", line 1, in ?
>TypeError: sendline() takes at most 2 arguments (3 given)
.
.
.
You might like to experiment with this:

import pexpect

prompt = '\$ '
filename = "mytest.log"
password = "xx"

child = pexpect.spawn('ssh -l %s %s ' (user, host))
child.expect([pexpect.TIMEOUT, '[Pp]assword: '])
child.sendline(password)
child.expect([pexpect.TIMEOUT, prompt])
child.sendline("ls %s > /dev/null 2>&1; echo $?" % filename)
child.expect([pexpect.TIMEOUT, prompt])
result = child.before
# You'll typically see "0" or "2" here, depending on 
# whether filename exists or not.
print result.split('\r\n')[1]

Does this leave any questions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: argv[0] and __file__ inconsistency

2007-12-31 Thread Hai Vu
> use os.path.abspath

Bingo! This is just what the doctor ordered. Thank you.
Hai
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using super

2007-12-31 Thread Steven D'Aprano
On Mon, 31 Dec 2007 08:03:22 -0800, Scott David Daniels wrote:

> Steven D'Aprano wrote:
>> ...
>> I'm not sure if this is your only problem or not, but super() only
>> works with new-style classes, not with classic classes. You must
>> inherit from object, or it cannot possibly work.
>> 
>> Change "class A" to "class A(object)".
> Absolutely correct.
> 
> However, the suggested simpler code cannot work on any released Python:
> 
>> def chain(meth):  # A decorator for calling super.
>> def f(self, *args, **kwargs):
>> result = meth(self, *args, **kwargs)
>> S = super(self.__class__, self)
> This line is the problem.  The class parameter needs to be the class
> name (B in this case) in which the chaining method is defined, not that
> of the object itself.

One minor correction: the class parameter needs to be the class *itself*, 
not the class *name* (which would be the string "B").

I don't quite understand your description though. What do you mean "the 
chaining method is defined"? chain() is defined outside of a class.


[snip]

> You'll see the problem once you figure out what goes wrong with:
>class C(B):
>@chain
>def foo(self, x):
>print "This is C!!!"
>return x + 2
> 
>C().foo(5)


Hmmm... obviously I did insufficient testing. That's certainly a problem.



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


Re: argv[0] and __file__ inconsistency

2007-12-31 Thread Benjamin M. A'Lee
On Mon, Dec 31, 2007 at 02:31:39PM -0800, Hai Vu wrote:
> I currently use ActivePython 2.5.1. Consider the following code which
> I saved as cmdline.py:
> import sys
> print sys.argv[0]
> If I invoke this code as 'python cmdline.py', then the output is:
> cmdline.py
> If I invoke it as 'cmdline.py', then the output is:
> C:\Users\hai\src\python\cmdline.py
> 
> The same happens for __file__. My question: do you have any
> suggestions for a more consistent way to figure out the full path of
> your script?

How about::

from os.path import abspath
scriptname = abspath(sys.argv[0])


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: using super

2007-12-31 Thread Scott David Daniels
Steven D'Aprano wrote:
> On Mon, 31 Dec 2007 08:03:22 -0800, Scott David Daniels wrote:
>> Steven D'Aprano wrote: ...
>>> def chain(meth):  # A decorator for calling super.
>>> def f(self, *args, **kwargs):
>>> result = meth(self, *args, **kwargs)
>>> S = super(self.__class__, self)
>> This line is the problem.  The class parameter needs to be the class
>> (B in this case) in which the chaining method is defined, not that
>> of the object itself.
> One minor correction: the class parameter needs to be the class *itself*, 
> not the class *name* (which would be the string "B").
Point taken.

> I don't quite understand your description though. What do you mean "the 
> chaining method is defined"? chain() is defined outside of a class.
The class where f (the chaining method) is defined; equivalently, the
class in which the @chain is used.

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


Re: [OT] minimalist web server

2007-12-31 Thread Daniel Fetchinson
> Using DSL (Damn Small Linux) try apache! Or you can try litehttpd
>
>
> > Hi list,
> >
> > This is way off topic but maybe somebody knowledgeable can help.
> >
> > I'm looking for the most minimalist web server ever that does nothing
> > else than return a fixed static page for every request. Regardless of
> > what the request is, it just needs to be an HTTP request to port 80,
> > the web server should return always the same html document. What would
> > be the best choice for this? The goal is of course to minimize system
> > resources in terms of memory, cpu, etc, etc.
> >
> > Cheers,
> > Daniel

I've written a *really* minimalistic web server that only serves blank
pages. It's not python but C, if anyone interested:
http://code.google.com/p/kwakd

Happy new year to every python lover!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ElementTree should parse string and file in the same way

2007-12-31 Thread Peter Pei
You are talking shit. It is never about whether it is hard to write a 
wrapper. It is about bad design. I should be able to parse a string and a 
file in exactly same way, and that should be provided as part of the 
package.

Looks like you are just a code monkey not a designer, so I forgive you. You 
didn't understand the issue I described? That's your issue. You are not at 
the same level to talk to me, so chill.
===


"Stefan Behnel" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Peter Pei wrote:
>> One bad design about elementtree is that it has different ways parsing a
>> string and a file, even worse they return different objects:
>> 1) When you parse a file, you can simply call parse, which returns a
>> elementtree, on which you can then apply xpath;
>
> ElementTree doesn't support XPath. In case you mean the simpler 
> ElementPath
> language that is supported by the find*() methods, I do not see a reason 
> why
> you can't use it on elements.
>
>
>> 2) To parse a string (xml section), you can call XML or fromstring, but
>> both return element instead of elementtree. This alone is bad. To make
>> it worse, you have to create an elementtree from this element before you
>> can utilize xpath.
>
> a) how hard is it to write a wrapper function around fromstring() that 
> wraps
> the result Element in an ElementTree object and returns it?
>
> b) the same as above applies: I can't see the problem you are talking 
> about.
>
> Stefan 

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


Re: ElementTree should parse string and file in the same way

2007-12-31 Thread Peter Pei
To be preise, XPath is not fully supported. Don't be a smart asshole.
=
"Stefan Behnel" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Peter Pei wrote:
>> One bad design about elementtree is that it has different ways parsing a
>> string and a file, even worse they return different objects:
>> 1) When you parse a file, you can simply call parse, which returns a
>> elementtree, on which you can then apply xpath;
>
> ElementTree doesn't support XPath. In case you mean the simpler 
> ElementPath
> language that is supported by the find*() methods, I do not see a reason 
> why
> you can't use it on elements.
>
>
>> 2) To parse a string (xml section), you can call XML or fromstring, but
>> both return element instead of elementtree. This alone is bad. To make
>> it worse, you have to create an elementtree from this element before you
>> can utilize xpath.
>
> a) how hard is it to write a wrapper function around fromstring() that 
> wraps
> the result Element in an ElementTree object and returns it?
>
> b) the same as above applies: I can't see the problem you are talking 
> about.
>
> Stefan 

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


Re: using super

2007-12-31 Thread Steven D'Aprano
On Mon, 31 Dec 2007 16:19:11 -0800, Scott David Daniels wrote:

> Steven D'Aprano wrote:
>> On Mon, 31 Dec 2007 08:03:22 -0800, Scott David Daniels wrote:
>>> Steven D'Aprano wrote: ...
 def chain(meth):  # A decorator for calling super.
 def f(self, *args, **kwargs):
 result = meth(self, *args, **kwargs)
 S = super(self.__class__, self)
>>> This line is the problem.  The class parameter needs to be the class
>>> (B in this case) in which the chaining method is defined, not that of
>>> the object itself.
>> One minor correction: the class parameter needs to be the class
>> *itself*, not the class *name* (which would be the string "B").
> Point taken.
> 
>> I don't quite understand your description though. What do you mean "the
>> chaining method is defined"? chain() is defined outside of a class.
>
> The class where f (the chaining method) is defined; equivalently, the
> class in which the @chain is used.

So why doesn't self.__class__ work? That's the class in which @chain is 
used.

I can clearly see that it doesn't work, I just don't understand why. I'd 
be inclined to chalk it up to super() being a mysterious black box that 
makes no sense *wink* except that the following decorator also doesn't 
work:


def chain(meth):  # A decorator for not calling super.
def f(self, *args, **kwargs):
result = meth(self, *args, **kwargs)
S = self.__class__.__base__
getattr(S, meth.__name__)(self, *args, **kwargs)
return result
return f



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


Re: pexpect ssh login and ls | grep

2007-12-31 Thread crybaby
1) what are these characters:
\x1b]0;
~\x07\x1b[?1034h

in line '\x1b]0;[EMAIL PROTECTED]:[EMAIL PROTECTED] ~]'?

2) Also, how come I don't get 0 or 2(excuting ls command exit code)
from result.split('\r\n')[0] or result.split('\r\n')[1] ?

This is what I get:
>>> import pexpect
>>> child=pexpect.spawn('ssh [EMAIL PROTECTED]')
>>> child.sendline("ls mytest.log > /dev/null 2>&1; echo $?")
41
>>> child.before
>>> print child.before
None
>>> print child.after
None
>>> child.expect([pexpect.TIMEOUT, '\$ '])
1
>>> result=child.before
>>> print result.split('\r\n')[1]
[EMAIL PROTECTED] ~]
>>> print result.split('\r\n')[0]
Last login: Mon Dec 31 20:52:09 2007 from com1
>>> print result.split('\r\n')
['Last login: Mon Dec 31 20:52:09 2007 from com1\r',
'\x1b]0;[EMAIL PROTECTED]:[EMAIL PROTECTED] ~]']

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


Re: ElementTree should parse string and file in the same way

2007-12-31 Thread Steven D'Aprano
On Tue, 01 Jan 2008 01:53:47 +, Peter Pei wrote:

> You are talking shit. It is never about whether it is hard to write a
> wrapper. It is about bad design. I should be able to parse a string and
> a file in exactly same way, and that should be provided as part of the
> package.

Oh my, somebody decided to start the new year with all guns blazing.

Before abusing anyone else, have you considered asking *why* ElementTree 
does not treat files and strings the same way? I believe the writer of 
ElementTree, Fredrik Lundh, frequents this newsgroup.

It may be that Fredrik doesn't agree with you that you should be able to 
parse a string and a file the same way, in which case there's nothing you 
can do but work around it. On the other hand, perhaps he just hasn't had 
a chance to implement that functionality, and would welcome a patch.

Fredrik, if you're reading this, I'm curious what your reason is. I don't 
have an opinion on whether you should or shouldn't treat files and 
strings the same way. Over to you...



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


Re: dont loose packages

2007-12-31 Thread Bjoern Schliessmann
Oguz Yarimtepe wrote:
> I am trying to write a program that will work on a machine which
> is between a client and a server. What i want is to simulate the
> bridging process. So the program should take the packages and able
> to send them to the other interface. I dont want to loose package
> and i want efficiency. 

Okay, you just want to simulate? For efficiency, you'd best use
kernel packet filtering, e. g. netfilter (for GNU/Linux).

> I tried to write a program in a multithreaded way 

Why? There isn't even any concurrency, just reading and writing
packets in a linear fashion.

> I am not sure the right way to solve the problem with Python. I
> will be happy if you help me with your ideas?

I think the most direct way would be using raw sockets. You could
need to have root/administrator privileges.

Regards,


Björn

-- 
BOFH excuse #126:

it has Intel Inside

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


Re: getting n items at a time from a generator

2007-12-31 Thread NickC
On Dec 27 2007, 11:31 pm, Kugutsumen <[EMAIL PROTECTED]> wrote:
> On Dec 27, 7:24 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
>
>
>
> > > "Kugutsumen" == Kugutsumen  <[EMAIL PROTECTED]> writes:
>
> > Kugutsumen> On Dec 27, 7:07 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>
> > >> On Dec 27, 11:34 am, Kugutsumen <[EMAIL PROTECTED]> wrote:
>
> > >> > I am relatively new the python language and I am afraid to be missing
> > >> > some clever construct or built-in way equivalent to my 'chunk'
> > >> > generator below.
>
> > Kugutsumen> Thanks, I am going to take a look at itertools.  I prefer the
> > Kugutsumen> list version since I need to buffer that chunk in memory at
> > Kugutsumen> this point.
>
> > Also consider this solution from O'Reilly's Python Cookbook (2nd Ed.) p705
>
> > def chop(iterable, length=2):
> > return izip(*(iter(iterable),) * length)
>
> > Terry
> > [snip code]
>
> > Try this instead:
>
> > import itertools
>
> > def chunk(iterator, size):
> > # I prefer the argument order to be the reverse of yours.
> > while True:
> > chunk = list(itertools.islice(iterator, size))
> > if chunk: yield chunk
> > else: break
>
> Steven, I really like your version since I've managed to understand it
> in one pass.
> Paul's version works but is too obscure to read for me :)
>
> Thanks a lot again.

To work with an arbitrary iterable, it needs an extra line at the
start to ensure the iterator items are consumed correctly each time
around the loop. It may also be better to ensure the final item is the
same length as the other items - if that isn't the case (you want to
know where the data really ends) then leave out the parts relating to
adding the padding object.

import itertools

def chunk(iterable, size, pad=None):
iterator = iter(iterable)
padding = [pad]
while True:
chunk = list(itertools.islice(iterator, size))
if chunk:
yield chunk + (padding*(size-len(chunk)))
else:
break

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


Re: using super

2007-12-31 Thread Scott David Daniels
Steven D'Aprano wrote:
> On Mon, 31 Dec 2007 16:19:11 -0800, Scott David Daniels wrote:
> 
>> Steven D'Aprano wrote:
>>> On Mon, 31 Dec 2007 08:03:22 -0800, Scott David Daniels wrote:
 Steven D'Aprano wrote: ...
> def chain(meth):  # A decorator for calling super.
> def f(self, *args, **kwargs):
> result = meth(self, *args, **kwargs)
> S = super(self.__class__, self)
 This line is the problem.  The class parameter needs to be the class
 (B in this case) in which the chaining method is defined, not that of
 the object itself.
>>> One minor correction: the class parameter needs to be the class
>>> *itself*, not the class *name* (which would be the string "B").
>> Point taken.
>>
>>> I don't quite understand your description though. What do you mean "the
>>> chaining method is defined"? chain() is defined outside of a class.
>> The class where f (the chaining method) is defined; equivalently, the
>> class in which the @chain is used.
> 
> So why doesn't self.__class__ work? That's the class in which @chain is 
> used.

OK, here's a simple 3-class example:

 class A(object):
 def meth(self): print 'A.meth:', self.__class__, '---'
 def pn(self): return ''

 class B(A):
 def meth(self):
 super(B, self).meth()
 print 'B.meth:', self.__class__, super(B, self).pn()
 def pn(self): return ''

 class C(B):
 def meth(self):
 super(C, self).meth()
 print 'C.meth:', self.__class__, super(C, self).pn()
 def pn(self): return ''

 c = C()
 c.meth()
 # Figure out why it printed what it did.

 # If not clear yet, how about this:
 for class_ in C, B:
 print class_.__name__, super(class_, c).pn()

 # And a bigger example (re-using A) to show why we
 class B0(A):
 def meth(self):
 super(B0, self).meth()
 print 'B0.meth:', self.__class__, super(B0, self).pn()
 def pn(self): return ''

 class B1(B0):
 def meth(self):
 super(B1, self).meth()
 print 'B1.meth:', self.__class__, super(B1, self).pn()
 def pn(self): return ''

 class B2(B0):
 def meth(self):
 super(B2, self).meth()
 print 'B2.meth:', self.__class__, super(B2, self).pn()
 def pn(self): return ''

 class C1(B1, B2):
 def meth(self):
 super(C1, self).meth()
 print 'C1.meth:', self.__class__, super(C1, self).pn()
 def pn(self): return ''

 class D1(C1):
 def meth(self):
 super(D1, self).meth()
 print 'D1.meth:', self.__class__, super(D1, self).pn()
 def pn(self): return ''

 d = D1()
 d.meth()
 # Figure out why it printed what it did.

 for class_ in D1, C1, B1, B2, B0:
 print class_.__name__, super(class_, d).pn()
 # Now (after much cogitation) might that do it?

 # finally, just a fillip, predict this before you run it:
 class E(D1, C):
 def meth(self):
 super(E, self).meth()
 print 'E.meth:', self.__class__, super(E, self).pn()
 def pn(self): return ''

 e = E()
 e.meth()
 for class_ in E, D1, C1, B1, B2, B0, C, B:
 print class_.__name__, super(class_, e).pn()


> I can clearly see that it doesn't work, I just don't understand why. I'd 
> be inclined to chalk it up to super() being a mysterious black box that 
> makes no sense *wink* 

super (and mro) work to get to all the superclasses in an order that 
produces subtypes before their supertypes.  The diamond inheritance 
examples "show" why its needed.

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


Re: Bizarre behavior with mutable default arguments

2007-12-31 Thread NickC
On Jan 1, 3:22 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Dec 31, 10:58 am, Odalrick <[EMAIL PROTECTED]> wrote:
>
> > I'm surprised noone has said anything about the why of default
> > mutables. I think it is becasue it isn't easy to do it an other way.
>
> [...]
>
> There is an easy enough way: evaluate default values when the function
> is called rather than when it is defined.  This behaviour comes with
> its own caveats as well I imagine, and it's not 'as easy' to implement
> as the current one.

As Odalrick notes, there is no way to give different calls to a
function their own copies of mutable default arguments without re-
evaluating the defaults every time the function is called. The
horrendous performance implications mean that that simply isn't going
to happen. So the status quo, where the defaults are calculated once
when the function is defined and the result cached in the function
object is unlikely to change.

> What's good about the current behaviour is that it is easy to reason
> with (once you know what happens), even though you almost have to get
> bitten once.  But using this to have static variable is extremely ugly
> IMHO.

The only thing it doesn't give you is a static variable that isn't
visible to the caller. Py3k's keyword-only arguments (PEP 3102) will
make those cases a little tidier, since it won't be possible to
accidentally replace the static variables by providing too many
positional arguments.

I believe the suggestion of permitting static variables after the **
entry in a function's parameter list was raised during the PEP 3102
discussions, but never gained much traction over a '_cache={}' keyword-
only argument approach (and the latter has the distinct advantage of
being *much* easier to test, since you can override the cache from the
test code to ensure it is being handled correctly).

Cheers,
Nick.

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


Re: usage of file separator

2007-12-31 Thread [EMAIL PROTECTED]

>
> from os.path import join
> #..
>     imgfile=join(folder, x)
>
> --
> Thomas Wittek
>

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


Re: pdf library.

2007-12-31 Thread Shriphani
On Dec 30 2007, 5:08 am, Waldemar Osuch <[EMAIL PROTECTED]>
wrote:
> On Dec 29, 11:54 am,Shriphani<[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I am looking for a pdf library that will give me a list of pages where
> > new chapters start. Can someone point me to such a module ?
> > Regards,
> >ShriphaniP.
>
> pyPdf may help you with that:http://pybrary.net/pyPdf/

I tried pyPdf for this and decided to get the pagelinks. The trouble
is that I don't know how to determine whether a particular page is the
first page of a chapter. Can someone tell me how to do this ?
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >