Re: import from future

2007-01-29 Thread Peter Otten
Marc 'BlackJack' Rintsch wrote:

> In <[EMAIL PROTECTED]>, Dan Bishop
> wrote:
> 
>> Now that nested_scopes and generators are no longer optional, the only
>> thing left is "from __future__ import division", which makes the "/"
>> operator on integers give the same result as for floats.
> 
> From 2.5 on we have `with_statement`::

...and absolute_import.

Peter


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


Re: Resizing widgets in text windows

2007-01-29 Thread Eric Brunel
On Fri, 26 Jan 2007 22:35:20 +0100, <[EMAIL PROTECTED]> wrote:

> Hi, I've been searching for a .resize()-like function to overload much
> like can be done for the delete window protocol as follows:
>
> toplevel.protocol("WM_DELETE_WINDOW", callback)
>
> I realize that the pack manager usually handles all of the resize
> stuff, but I've found an arrangement that the pack manager fails for.
> That is, if one embeds a canvas into a window created inside a text
> widget, then resize the text widget (via its container), the canvas and
> its container windows do not resize.

Supposing you call "embedding" inserting a widget in the text via the  
window_create method, why should they? Embedding a window in a Text is  
used to put some arbitrary widget in the middle of the text it contains.  
So the embedded widget has no reason to grow or shrink with the parent  
Text widget: it just moves with the text.

> So I need to resize the window
> that the canvas is embedded in. The most obvious way of doing this
> would be as above, but there does not seem to be an equivalent to the
> "WM_DELETE_WINDOW" protocol for resizing.

As James said, the  event is your friend. But I'm not sure I  
understand your use case...

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


Web File System

2007-01-29 Thread anthony . cutrone
Hi group,

I have a development with a file system in Python, accessible from a 
graphic web application.

I mustn't use an NTFS or EXT3 system, because those are not adapted 
for my use. Indeed, I would like my system to be able to recover 
files, and get precedent versions. I also want it to index words 
contained in files, to search with these.

Files and folders have to be in an SQL database, mounted in ext3-like 
system. File would be identified by a single ID, and links with names 
should be connected on these IDs.

Somebody have already worked (in Python) about this kind of things ? 
is there a publicly available framework or toolkit ?

thanks

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


SpecTix

2007-01-29 Thread ccardelli
Hi all.
I'd like to test the SpecTix package (GUI generation for TK). I have 
read somewhere that it can generate GUI code for python, but the 
download location (http://starship.python.net/crew/mike/Spectix/) is 
inactive.
Could someone provide a copy of the package or suggest an alternate 
download site?
Latest version seems to be 1.2a3-1.4.
Thank you.

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


Re: Web File System

2007-01-29 Thread Michele Simionato
On Jan 29, 9:31 am, [EMAIL PROTECTED] wrote:
> Hi group,
>
> I have a development with a file system in Python, accessible from a
> graphic web application.
>
> I mustn't use an NTFS or EXT3 system, because those are not adapted
> for my use. Indeed, I would like my system to be able to recover
> files, and get precedent versions. I also want it to index words
> contained in files, to search with these.
>
> Files and folders have to be in an SQL database, mounted in ext3-like
> system. File would be identified by a single ID, and links with names
> should be connected on these IDs.
>
> Somebody have already worked (in Python) about this kind of things ?
> is there a publicly available framework or toolkit ?
>
> thanks

I do not understand extractly what you are asking, but do you know 
about WebDAV?
I would give a look to Content Management Systems such as Zope for 
this kind of things.

  Michele Simionato

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


Re: Handling empty form fields in CGI

2007-01-29 Thread Christopher Mocock
Paul Boddie wrote:
> Try replacing this with...
> 
> form = cgi.FieldStorage(keep_blank_values=1)
> 
> Paul
> 

That worked a treat. Thanks very much to both who replied.

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Paul McGuire
On Jan 28, 10:58 pm, "NoName" <[EMAIL PROTECTED]> wrote:
> Perl:
> @char=("A".."Z","a".."z",0..9);
> do{print join("",@char[map{rand @char}(1..8)])}while(<>);
>
> !!generate passwords untill U press ctrl-z
>
> Python (from CookBook):
>
> from random import choice
> import string
> print ''.join([choice(string.letters+string.digits) for i in
> range(1,8)])
>
> !!generate password once :(
>
> who can write this smaller or without 'import'?

from random import choice
pwdchars = ''.join(chr(c) for c in range(ord('a'),ord('z')+1)+
range(ord('A'),ord('Z')+1)+
 range(ord('0'),ord('9')+1) )

while(True) : print ''.join(choice(pwdchars) for i in range(8))


(Note that you want to use range(8), not range(1,8), since range gives 
you the values [a,b) if two arguments are given, or [0,a) if only one 
is given, and it appears that you want 8-character passwords.)

But really, there's nothing wrong with using import, and reusing known 
good code from the string module is better than reimplementing it in 
new code as I have done (less code === fewer opportunities for bugs).  
rand is not a built-in as it apparently is in Perl, but random is part 
of the core library, so all Python installs will have it available - 
likewise for string.

-- Paul

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread James Stroud
NoName wrote:
> Perl:
> @char=("A".."Z","a".."z",0..9);
> do{print join("",@char[map{rand @char}(1..8)])}while(<>);
> 
> !!generate passwords untill U press ctrl-z
> 
> 
> 
> Python (from CookBook):
> 
> from random import choice
> import string
> print ''.join([choice(string.letters+string.digits) for i in 
> range(1,8)])
> 
> !!generate password once :(

Make a loop.

> who can write this smaller

I won't write it for you, but I'll tell you how:

Write a function for the whole loop and the password generator and from 
then on it will be a one-liner (as a function call).

 > or without 'import'?

Yes, make sure you do the import inside the function.

If you follow my advice, you will be able to get as many passwords as 
you want with one line (and no spaces, even!):

generate_passwords()

It also reads much clearer than the perl version, don't you think?

By the way, you can also make a script. Call it "genpass", then at the 
command prompt, it will be far less than one line:

 % genpass

Or, if you are using DOS/Windows:

 C:> genpass

A lot of systems don't have a standard command called "g", so then you 
can turn it into *ONE LETTER*!!! That beats the pants off perl!

 % g

Or, of course, for DOS:

 C:> g

Good luck!

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


Re: IP address

2007-01-29 Thread Scripter47
Beej skrev:
> On Jan 28, 2:26 am, Klaus Alexander Seistrup <[EMAIL PROTECTED]> wrote:
>> Scripter47 wrote:
>>> How do i get my ip address?
>>> in cmd.exe i just type "ipconfig" then it prints:
>>>   ...
>>>   IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10
>>>   ...
>>> how can i do that in python??#v+
>> python -c 'import re, urllib; print re.findall("Your IP: 
>> (.+?)", urllib.urlopen("http://myip.dk/";).read())[0]'
> 
> This is extremely unlikely to return 192.168.1.10. :-)
> 
> (It will give you the address of your firewall or whatever is your 
> gateway to the outside world...  which is a cool thing to know, but 
> I'm not sure it's what the op's after.)
> 
> -Beej
> 

Exactly i wnat my local ip. sorry if i din't tell that ;)

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


Re: Yank Bastards KILLED THEIR OWN PEOPLE to stage 911 DRAMA

2007-01-29 Thread Laurent Pointal
bryan rasmussen a écrit :
> See, if the python list mail server was written in Lisp Paul Graham
> would already have been able to write up a spam filter to ban this
> guy.
> 
> Seriously though,  shouldn't Thermate be banned by now.

I read this from comp.lang.python... and its very hard to ban people (or
better, ban out-of-subject posts) from non-moderated Usenet newsgroups.

A+

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


Re: Data structure and algorithms

2007-01-29 Thread Steve Holden
Terry Reedy wrote:
> "azrael" <[EMAIL PROTECTED]> wrote in message 
[...]
> |
> | but this was not dinamicly enough for me (or my prof.) so
> 
> dynamic?  I have no idea what you mean by 'not dynamic enough'.
> 
> Python is not C or C++.  It does not have pointers.  Trying to program in C 
> in Python does not work too well.
> 
Mostly because Python variables are precisely pointers to object values 
allocated from a heap.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


Re: PythonCard installation

2007-01-29 Thread Steve Holden
dudds wrote:
> Anyone had any joy with this using FC6?? When I try to run code editor
> I get the error "Traceback (most recent call last):
>   File
> "/usr/lib/python2.4/PythonCard-0.8.2/tools/codeEditor/codeEditor.py",
> line 13, in ?
> from PythonCard import about, configuration, dialog, log, menu,
> model, resource, util
> ImportError: No module named PythonCard"
> 
This isn't really a platform-specific issue - you just need to install 
PythonCard so that the interpreter can find it.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


interactive prompt in IDLE

2007-01-29 Thread Jan Kanis
Hello everyone,

I'm trying to change the interactive python prompt. According to the docs  
this is done by changing sys.ps1 and sys.ps2 . That works fine when  
running python interactively from a command line, but when running in IDLE  
the .ps1 and .ps2 don't seem to exist.

I suppose this has something to do with Idle and the python shell in it  
both running in different processes, with the prompts generated by the  
Idle process?

Does anyone know if and how to change the prompts in IDLE's interactive  
python?

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


Conversion of string to integer

2007-01-29 Thread jupiter
Hi guys,

I have a problem. I have a list which contains strings and numeric. 
What I want is to compare them in loop, ignore string and create 
another list of numeric values.

I tried int() and decimal() but without success.

eq of problem is

#hs=string.split(hs)
hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]

j=0
for o in range(len(hs)):
print hs[o],o
p=Decimal(hs[o])
if p > 200: j+=j
print "-"*5,j
print "*"*25

I could be the best way to solve this ..?


@nil

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


wxPython StatusBar Help

2007-01-29 Thread herve
Hi, everybody

I'm working with wxPython 2.8.1.1.

Does anybody know how to change the foreground colors in a wx.StatusBar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Paul Rubin
"Paul McGuire" <[EMAIL PROTECTED]> writes:
> from random import choice

Security note: if you're trying to generate real passwords this way,
you're better off using os.urandom instead of the random module to
generate the random numbers.  The random module's results are supposed
to be statistically uncorrelated (good for stuff like games and
simulations) but they don't try to resist guessing by malicious
attackers.  os.urandom results are supposed to be unguessable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pdf to text

2007-01-29 Thread tubby
Dieter Deyke wrote:
>> sout = os.popen('pdftotext "%s" - ' %f)

> Your program above should read:
> 
>sout = os.popen('pdftotext "%s" - ' % (f,))

What is the significance of doing it this way?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Conversion of string to integer

2007-01-29 Thread Wojciech Muła
jupiter wrote:
> I have a problem. I have a list which contains strings and numeric. 
> What I want is to compare them in loop, ignore string and create 
> another list of numeric values.
>
> I tried int() and decimal() but without success.
>
> eq of problem is
>
> #hs=string.split(hs)
> hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]

tmp = []
for s in hs:
try:
tmp.append( float(s) )
except ValueError:
# function float raises VE, if string 's' doesn't
# represent a number
pass

# tmp contains a list of floats
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread NoName
Hmmm..
In the Perl example password generates after user hit ENTER not 
continously like in Python you wrote... :)

i want see various ways to generate passwords even if they some 
indirect like using BASE64

thanks all


p.s. sorry for my eng ;)

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Szabolcs Nagy
> If you don't mind possibly getting a few nonalphanumeric characters:
>
> import os,binascii
> print binascii.b2a_base64(os.urandom(6))

what about

file('/dev/urandom').read(6).encode('base64')

(oneliner and without import sa op requested)

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Szabolcs Nagy
> If you don't mind possibly getting a few nonalphanumeric characters:
>
> import os,binascii
> print binascii.b2a_base64(os.urandom(6))

what about

file('/dev/urandom').read(6).encode('base64')

(oneliner and without import as op requested)

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


Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread thermate
http://a1135.g.akamai.net/f/1135/18227/1h/cchannel.download.akamai.com/
18227/podcast/PORTLAND-OR/KPOJ-AM/1-23-07%20POJ-cast.mp3?
CPROG=PCAST&MARKET=PORTLAND-
OR&NG_FORMAT=newstalk&SITE_ID=674&STATION_ID=KPOJ-
AM&PCAST_AUTHOR=AM620_KPOJ&PCAST_CAT=Talk_Radio&PCAST_TITLE=Thom_Hartma
nn_Podcast

Below is a post repeated with interesting information. But the main
purpose of this post is to find out how many sheeple still believe in
the 911 fairy tale of 19 hijackers that was to be USED BY THE EVIL
CRIMINALS TO "change the world forever" BUT IT WONT. Are we going to
PERMIT some evil criminals in the government positions to make an
Orwellian world of enslavement and doublespeak for us and our children
?


Journal of 911 studies:
http://www.journalof911studies.com/
=
$1 Million Challenge/REWARD Details regarding 9/11:
http://reopen911.org/Contest.htm
=
Background info:
http://st911.org/
=
REPUBLICANS are ANTICHRIST-FASCIST Bastards, Herbert Bush, Ronald
Reagan and NOW Mark Foley, VIDEO EVIDENCE
http://video.google.com/videoplay?
docid=359924937663867563&q=conspira...
http://www.voxfux.com/features/bush_child_sex_coverup/franklin.htm
There are two main suspects in the child ring were Craig Spence and
Lawrence E. King Jr. Below are some pictures of them. Both were
involved in the Republican party. King sang the National athem at two
republican national conventions during the 1980s. He served time in
jail for bank fraud and is now living somewhere on the east coast.
Spence was an important Republican lobbyist, who feared that, because
he knew something very dark, implicating the very most powerful man in
America, George H. W. Bush, that he would be killed by the CIA at his
murder would be made to look like a suicide. He was later found dead 
in
a hotel room - the CIA connected coroner declared the bizarre death
-suicide. Several of his partners went to jail for being involved in
the adult part of the homosexual sex ring. Democrats were also 
involved
in this as well, so don't expect them to expose the sex ring.

=
HOW 9/11 actually may have happened , WE HAVE BEEN MADE FOOLS OF THE
CENTURY by the media
From:
American Patriot Friends Network

http://www.apfn.org/apfn/WTC_STF.htm

The only thing to be afraid is cowardice itself. The news is spreading
like a jungle fire.
In your workplace, send email to everyone and anonymously about this
site and other top sites

Make a free email account:
www.gmail.com
=
Holocaust Victims Accuse
Product #: 10011

Documents and Testimony on Jewish war Criminals by Reb Moshe Shonfeld

This out of print book, published in 1977 describing the brutal 
Zionist
role which prevented the rescue of the holocaust victims,has been
reproduced with permission of the author.
http://www.jewsagainstzionism.com/bookstore/store.cfm?
catcode=1&catna...
www.nkusa.org

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Paul Rubin
"Szabolcs Nagy" <[EMAIL PROTECTED]> writes:
> file('/dev/urandom').read(6).encode('base64')
> (oneliner and without import sa op requested)

Nice, though Un*x dependent (os.urandom is supposed to be portable).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread sturlamolden


On Jan 29, 4:08 pm, Paul Rubin  wrote:
> "Szabolcs Nagy" <[EMAIL PROTECTED]> writes:
> > file('/dev/urandom').read(6).encode('base64')
> > (oneliner and without import sa op requested)Nice, though Un*x dependent 
> > (os.urandom is supposed to be portable).

Is os.urandom cryptographically strong on all platforms?

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Laszlo Nagy
NoName írta:
> Hmmm..
> In the Perl example password generates after user hit ENTER not 
> continously like in Python you wrote... :)
>
> i want see various ways to generate passwords even if they some 
> indirect like using BASE64
>   
I copied this from a recipe, I do not remember which one. I like it very 
much because it creates password that are easy to type in. You can type 
every odd letter with your left hand and every even letter with your 
right hand.

Best,

   Leslie

from random import Random

PASSWORD_LENGTH = 10

rng = Random()

def generatePassword(length=PASSWORD_LENGTH,alternate_hands=True):
righthand = '23456qwertasdfgzxcvbQWERTASDFGZXCVB'
lefthand = '789yuiophjknmYUIPHJKLNM'
allchars = righthand + lefthand
res = ""
for i in range(length):
if not alternate_hands:
res += rng.choice(allchars)
else:
if i%2:
res += rng.choice(lefthand)
else:
res += rng.choice(righthand)
return res


if __name__ == '__main__':
for i in range(10):
print generatePassword()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Szabolcs Nagy

> Is os.urandom cryptographically strong on all platforms?

http://docs.python.org/lib/os-miscfunc.html

"The returned data should be unpredictable enough for cryptographic 
applications, though its exact quality depends on the OS 
implementation."

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Stargaming
NoName schrieb:
> Perl:
> @char=("A".."Z","a".."z",0..9);
> do{print join("",@char[map{rand @char}(1..8)])}while(<>);
> 
> !!generate passwords untill U press ctrl-z
> 
> 
> 
> Python (from CookBook):
> 
> from random import choice
> import string
> print ''.join([choice(string.letters+string.digits) for i in 
> range(1,8)])
> 
> !!generate password once :(
> 
> who can write this smaller or without 'import'?
> 

If you really want a hack, here it is:

while 1:print 
''.join(__import__('random').choice(__import__('string').letters+'1234567890') 
for x in xrange(8)),;n=raw_input()

This is a one-liner (though mail transmission may split it up), no 
import statements. If someone can come up with an even smaller version, 
feel free to post. :)

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


Re: Off-Topic Posts

2007-01-29 Thread thermate
On Jan 27, 1:31 pm, Jim Klein <[EMAIL PROTECTED]> wrote:
> I'm not one of the conquered races, I'm Swiss. We are the bankers to
> the conquerers. :-)

Exactly, Honorable J Klein, (although my reference was a general one, 
you have entered the thread, so I will pick the swiss case) more like 
tributaries to the conquerers ... If you remember that the Japanese 
buy the US govt bonds because their whole country's policy is 
controlled and under the ceiling of the occupiers. The swiss insurance 
companies quietly paid Larry Silverstein $3billion insurance claim 
ONLY after a few months of premium, without raising a single objection 
about the event. Are you saying Dr Bob Bowman, an MIT or Caltech Phd, 
who has flied 100 combat missions, and was running for public office 
is a mad person?? But the point is accurate: Switzerland is not a 
banker but a tributary. You will soon see US twisting the arms of all 
its occupied and conquered races to share the financial loss from 
Bush's foolish policies. That exactly is the UNSTATED methodology.

Still, I would like to go and live in switzerland, if there is a way 
to become a swiss citizen ... like marc rich whom clinton gave 
immunity ... my record is a lot honest than that crook. where do you 
live in switzerland and can you get me a citizenship of that country 
of good people ... away from the FBI Bastards cowards who go around 
bugging people for no reason ... other than their racist and fascist 
outlook.

> It has been a long time since we got invaded by someone of your ilk. I
> comment you on your total lack of good taste.

Yeah ... taste what dick has to say, I repeat:

What did Dick Faced Cheney told Honorable Senator Patrick Leahy ? 
"Fuck
yourself".
So much for politeness and vulgarity at the top level.

Proof:
http://www.capitolhillblue.com/news2/2007/01/the_madness_of.html

> Please go prowl in someone else's news group. Most folks here are just
> not on your frequency.

911 optical illusions will be discussed here.
>
> [EMAIL PROTECTED] wrote:
> >Yeah, listen to wise counsel of klein. As a member of conquered races
> >and still under occupation, namely Jewish, French, German, Japanese,
> >Korean ... dont mess in the crimes of the anglo-saxon yanks. You should
> >remember the beating you got from the Anglo-Saxon Yanks and just keep
> >quiet ... As for the lunatics off their meds, its also true that 911
> >was a grand optical illusion and thus within the charter of this group
> >to study ... After all, one of its proponent is the former head of Star
> >Wars, Dr Bob Bowman from MIT and Caltech ... Do you have a degree from
> >those prestigious institutes or did you manage to get any of your kids
> >into one of them ??? As for vulgarity, its the mark of patriotism ...
> >the constitutional amendments guarantee it and Herbert Walker Bush was
> >a strongly suspected pedophile ... there is a video called conspiracy
> >of silence, watch it on video.google.com and download with before the
> >fascist bureau of incompetence bastards (running around like crazy rats
> >to confiscate pentagon videos on that day in destruction of evidence)
> >try to sabotage the google servers ... they are part of the crime and
> >complicit in it. If they were competent, we would see one consistent
> >theory coming out from that bureau to explain all significant events on
> >that day. Now dont forget the SHITTY job done by FEMA and NIST. There
> >are gaping holes in their work.
>
> >Hey Kinch, if you are jewish, did you forget that England was the first
> >country to expel the Jews.
>
> >If you forget your status as conquered races, then you are in delusion,
> >not anyone else.
>
> >The final balance of power provided against the anglos will be by
> >Slavs. Hurray to Vladimir Putin, and Mikhail Khodorkovsky in a Siberian
> >jail.
>
> >On Jan 26, 2:30 pm, Jim Klein <[EMAIL PROTECTED]> wrote:
> >> "alex" <[EMAIL PROTECTED]> wrote:
> >> >I have only just joined this group, but have noticed a significant rise
> >> >in off-topic posts that really detract from what is otherwise an
> >> >excellent place to learn and talk about optics.  While I'm sure people
> >> >who post these non-optic, non-scientific posts feel that they are
> >> >important they are not what the majority of the people come here to
> >> >read.  If the topics are that important to the poster then surely he or
> >> >she should take the time and trouble to find the best place to discuss
> >> >them.  A groups called "Sci-optic" is not one   I guess what I
> >> >am asking for is that off-topic posts are deleted  Is this
> >> >possible?
>
> >> >Thanks
> >> >ALexWe get off-topic posts on an infrequent basis. Usually some poor guy
> >> gets off his meds and we get some burst of non-optic garbage.
>
> >> Just delete them and kill file them. That is usually what most folks
> >> do.
>
> >> Remember, there has always been a lunatic standing on the corner
> >> yelling the wold is ending.
>
> >> It is but not for a few Bi

HTMLParser's start_tag method never called ?

2007-01-29 Thread ychaouche
Hi, python experts.


[EMAIL PROTECTED]:~/TEST$ python nettoyageHTML.py
[EMAIL PROTECTED]:~/TEST$


This is the nettoyageHTML.py python script


from HTMLParser import HTMLParser

class ParseurHTML(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)

def start_body(self,attrs):
print "this is my body"

p = ParseurHTML()
p.feed(open("/home/chaouche/TEST/AJAX/testXMLRPC.html","r").read())


this is the testXMLRPC.html html file :








if (typeof netscape != 'undefined' && typeof netscape.security != 
'undefined') {

netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRea
d');
}

var chiffre = 0;
handler = function (self){
if (self.xmlhttp.readyState == 4) {
reponse = self.xmlhttp.responseText;
//dump(reponse); permet d'acceder au dom si ce qu'on a recu est une 
forme de xml.
document.getElementById("txt").innerHTML=reponse;
}
}

function recupDonnees(){
chiffre+=1;
client = new ClientXMLRPC();
client.setUrl("http://10.75.49.100:8081/bonjour/sayHi?
chiffre="+chiffre);
client.executer();
client.handlerEvenement = handler;
}
recupDonnees();





NON




The script should output "this is my body", but nothing is printed. 
Anyone ?

Y.Chaouche

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


Re: HTMLParser's start_tag method never called ?

2007-01-29 Thread Diez B. Roggisch
ychaouche wrote:

> Hi, python experts.
> 
> 
> [EMAIL PROTECTED]:~/TEST$ python nettoyageHTML.py
> [EMAIL PROTECTED]:~/TEST$
> 
> 
> This is the nettoyageHTML.py python script
> 
> 
> from HTMLParser import HTMLParser
> 
> class ParseurHTML(HTMLParser):
> def __init__(self):
> HTMLParser.__init__(self)
> 
> def start_body(self,attrs):
> print "this is my body"
> 
> p = ParseurHTML()
> p.feed(open("/home/chaouche/TEST/AJAX/testXMLRPC.html","r").read())
> 
> 
> this is the testXMLRPC.html html file :
> 
> 
> 
>  src="ClientXMLRPC.js">
> 
> 
> 
> 
> if (typeof netscape != 'undefined' && typeof netscape.security !=
> 'undefined') {
> 
> netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRea
> d');
> }
> 
> var chiffre = 0;
> handler = function (self){
> if (self.xmlhttp.readyState == 4) {
> reponse = self.xmlhttp.responseText;
> //dump(reponse); permet d'acceder au dom si ce qu'on a recu est une
> forme de xml.
> document.getElementById("txt").innerHTML=reponse;
> }
> }
> 
> function recupDonnees(){
> chiffre+=1;
> client = new ClientXMLRPC();
> client.setUrl("http://10.75.49.100:8081/bonjour/sayHi?
> chiffre="+chiffre);
> client.executer();
> client.handlerEvenement = handler;
> }
> recupDonnees();
> 
> 
> 
> 
> 
> NON
> 
> 
> 
> 
> The script should output "this is my body", but nothing is printed.
> Anyone ?

You need a p.close() after the feed I guess.

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


Re: Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread Hampton Din

 stupid troll 


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


Re: Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread thermate
FBI spook bastard  that speaks french also

On Jan 29, 8:13 am, "Hampton Din" <[EMAIL PROTECTED]> wrote:
>  stupid troll


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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Szabolcs Nagy
> If you really want a hack, here it is:
>
> while 1:print
> ''.join(__import__('random').choice(__import__('string').letters+'1234567890')
> for x in xrange(8)),;n=raw_input()
>
> This is a one-liner (though mail transmission may split it up), no
> import statements. If someone can come up with an even smaller version,
> feel free to post. :)

while 
1:i=__import__;print''.join(i('random').choice(i('string').letters
+'1234567890')for x in range(8)),;raw_input()

same but shorter:
i = __import__;
xrange -> range (why use xrange? range is faster and simpler for small 
ranges)
n =(not needed)

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


Re: stop script w/o exiting interpreter

2007-01-29 Thread Garrick . Peterson
> I want, and the script will stop executing at that line and will
> return to the interactive interpreter, as I wish.

May I recommend wrapping your main program in a function definition? Such 
as:

main():
# Bulk of your code (use a macro to indent it faster)

if __name__ == "__main__":
main()

Then you should be able to throw in a "return" at any point and get a 
clean break, without affecting the flow of your program. This should make 
it easier to debug as well, offering a clean entry point from the python 
interactive session, and letting you return a specific value you wish to 
check.


Garrick M. Peterson
Quality Assurance Analyst
Zoot Enterprises, Inc.
[EMAIL PROTECTED]

Copyright © 2007 Zoot Enterprises, Inc. and its affiliates.  All rights 
reserved. This email, including any attachments, is confidential and may 
not be redistributed without permission. If you are not an intended 
recipient, you have received this message in error; please notify us 
immediately by replying to this message and deleting it from your 
computer. Thank you. -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Szabolcs Nagy

> while
> 1:i=__import__;print''.join(i('random').choice(i('string').letters
> +'1234567890')for x in range(8)),;raw_input()
>

while 
1:i=__import__;r='random';print''.join(i(r).choice(i('string').letters
+'1234567890')for x in`r`),;raw_input()

even shorter:
range -> `'random'`

:)

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


Possible security hole in SSL - was Random Passwords Generation

2007-01-29 Thread John Nagle
Paul Rubin wrote:
> "Szabolcs Nagy" <[EMAIL PROTECTED]> writes:
> 
>>file('/dev/urandom').read(6).encode('base64')
>>(oneliner and without import sa op requested)
> 
> 
> Nice, though Un*x dependent (os.urandom is supposed to be portable).

Uh oh.  I was looking at the Python "SSL" code recently, and
noted that OpenSSL initializes the keys with '/dev/urandom' if
available, and otherwise relies on the caller to seed it with
random data and to check that enough randomness has been input.

But the Python glue code for SSL doesn't seem to have the
machinery to seed SSL with randomness.  I suspect that on
platforms without '/dev/urandom', Python's SSL package may
be using the same keys every time.  This needs to be looked
at by a crypto expert.

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


Can I undecorate a function?

2007-01-29 Thread Matthew Wilson
The decorator as_string returns the decorated function's value as
string.  In some instances I want to access just the function f,
though, and catch the values before they've been decorated.

Is this possible?

def as_string(f):
def anon(*args, **kwargs):
y = f(*args, **kwargs)
return str(y)
return anon

@as_string
def f(x):
return x * x

Matt


-- 
A better way of running series of SAS programs:
http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I undecorate a function?

2007-01-29 Thread skip
Matt> In some instances I want to access just the function f, though,
Matt> and catch the values before they've been decorated.

def f(x):
return x * x

@as_string
def fs(x):
return f(x)

Call the one you want.

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


Re: Can I undecorate a function?

2007-01-29 Thread Diez B. Roggisch
Matthew Wilson wrote:

> The decorator as_string returns the decorated function's value as
> string.  In some instances I want to access just the function f,
> though, and catch the values before they've been decorated.
> 
> Is this possible?
> 
> def as_string(f):
> def anon(*args, **kwargs):
> y = f(*args, **kwargs)
> return str(y)
> return anon
> 
> @as_string
> def f(x):
> return x * x

Untested:


def as_string(f):
def anon(*args, **kwargs):
y = f(*args, **kwargs)
return str(y)
andon.the_function = f
return anon


@as_string
def f(x):
   return x * x

print f.the_function(10)


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


next berlin python-group meeting fr., 2.2.

2007-01-29 Thread Stephan Diehl
after a long (veeeyy) long time, I'm pleased to announce our next 
python meeting in berlin.
time: friday 2.2. 7pm
place:Cafe & Restaurant UNENDLICH
Boetzowstrasse 14
10407 Berlin (Prenzlauer Berg "Boetzowviertel")

This is a fun meeting without offical talks.
If you haven't done so already, subscribe to
http://starship.python.net/cgi-bin/mailman/listinfo/python-berlin
for last minute information. If you plan to come, please leave a short 
notice there, so we know how many people to expect.

Cheers

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


Re: next berlin python-group meeting fr., 2.2.

2007-01-29 Thread Stephan Diehl
Stephan Diehl wrote:

> http://starship.python.net/cgi-bin/mailman/listinfo/python-berlin

argghhh, wrong link. please try
http://starship.python.net/mailman/listinfo/python-berlin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I undecorate a function?

2007-01-29 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
> Matt> In some instances I want to access just the function f, though,
> Matt> and catch the values before they've been decorated.
> 
> def f(x):
> return x * x
> 
> @as_string
> def fs(x):
> return f(x)

or just
fs = as_string(f)

Kent

> 
> Call the one you want.
> 
> Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread Frank Arthur
Real funny? Holocaust Deniers Convention in Iran?

Sick, sick Islamists!

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> http://a1135.g.akamai.net/f/1135/18227/1h/cchannel.download.akamai.com/
> 18227/podcast/PORTLAND-OR/KPOJ-AM/1-23-07%20POJ-cast.mp3?


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


Re: Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread Frank Arthur
Islamist bastard <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> FBI spook bastard  that speaks french also
>
> On Jan 29, 8:13 am, "Hampton Din" <[EMAIL PROTECTED]> wrote:
>>  stupid troll
>
> 


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


Re: Python does not play well with others

2007-01-29 Thread Skip Montanaro

> Andy Dustman, the author of the package is quite responsive to requests
> raised in the mysql-python forums on SourceForge
> (http://sourceforge.net/forum/?group_id=22307).  If you have problems with
> MySQLdb, bring them up there.  I'm sure Andy will respond.

I apologize in advance for beating this dead horse...  This morning  a
possible bug was reported in MySQLdb.  Andy determined it was indeed a bug,
had a fix checked into the source repository in a couple hours and reported
that it would be in the next 1.2 beta release.

Skip


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


Re: Can I undecorate a function?

2007-01-29 Thread Steve Holden
Matthew Wilson wrote:
> The decorator as_string returns the decorated function's value as
> string.  In some instances I want to access just the function f,
> though, and catch the values before they've been decorated.
> 
> Is this possible?
> 
> def as_string(f):
> def anon(*args, **kwargs):
> y = f(*args, **kwargs)
> return str(y)
> return anon
> 
> @as_string
> def f(x):
> return x * x
> 
It's much simpler not to use the decorator syntax if you also want 
access to the original function.

Simply declare f as a function, then assign decorator(f) to some other name.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


Re: Data structure and algorithms

2007-01-29 Thread Beej
On Jan 28, 2:56 pm, "azrael" <[EMAIL PROTECTED]> wrote:
> class Node:
>   def __init__(self, cargo=None, next=None):
> self.cargo = cargo
> self.next  = next

This is OK for the node itself, but maybe you should try writing a 
LinkedList class that you use:

class LinkedList(object):
def __init__(self):
self.head = None

def append(self, node):
...

def remove(self, node):
...

>>> ll = LinkedList()
>>> ll.append(Node(3490))

(For extra fun, make it so you can iterate over the linked list and 
call it like this:for n in ll: print n   :-) )

> >>> list=[]
> >>> list.append(Node(1))
> >>> list.append(Node(2))
> >>> list[0].next=list[1]
> >>> list.append(Node(3))
> >>> list[1].next=list[2]

I'd classify this as "not pretty".  Sure, it's more "dynamic" in that 
you don't have a variable to reference every node, but it's way 
cleaner to make an encapsulating LinkedList class, right?

In in Python, references to objects are very much like pointers in C:

>>> foo = Node(3490)  # foo is a reference to a Node instance
>>> bar = foo   # bar points to the same Node instance as foo
>>> foo
<__main__.Node object at 0xb7b362ec>
>>> bar
<__main__.Node object at 0xb7b362ec>

See?  They point to the name Node object.

> I think that my concept is wrong by using a list to create a list.

I agree with you, if your goal is to implement your own list.  Using 
the Python functionality just makes things less clear.

> Is
> it possible to manage the insertation of new object like in C by
> allocating new memory space.

Absolutely.  The "next" pointer thing is the way to go, so you're on 
the right track with that.

When deleting nodes from the list, you don't explicitly delete them; 
you just need to remove all your references to them.  Nodes will be 
garbage collected when there are no more references to them anywhere.

> any sugestions how to make the implementation more like in C. I never
> managed the syntax of C so I stoped when structs crossed my way.
> Please help. I dont want to learn C.

Ah, it's a pity.  C is my favorite compiled procedural language.

-Beej

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


[Boost.Graph] graph.vertices property creates new objects

2007-01-29 Thread George Sakkis
I've just started toying with the python bindings of BGL and I'm 
puzzled from the following:

>>> from boost.graph import Graph
>>> g = Graph()
>>> v = g.add_vertex()
>>> g.vertices.next() == v
True
>>> g.vertices.next() is v
False

It seems that the vertices iterator creates new vertex objects every 
time instead of iterating over the existing ones. This essentially 
prevents, among other things, storing vertices as keys in a dictionary 
since the hashes of the stored and the new vertex differ although they 
compare equal. Is this really what's happening, and if so, why ?

George

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


Sourcing Python Developers

2007-01-29 Thread Kartic
Hello,

My company has quite a few opening involving python expertise. We are 
always looking for python resources (and find it difficult filling these 
positions, might I add). Is there any place to find developers' resumes 
(like finding jobs from http://python.org/community/jobs/)? If any one 
knows of a resume repository (other than Monster, Dice, 
Costs-an-arm-and-leg job site) please share.

In any case, we have immediate requirements for a Pythonista with C++, 
MySQL, XML, Debian expertise. Please email resume to: 
python-resumes(at)temporaryforwarding.com

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


List Behavior when inserting new items

2007-01-29 Thread Drew
I'm looking to add an element to list of items, however I'd like to 
add it at a specific index greater than the current size:

list = [1,2,3]
list.insert(10,4)

What I'd like to see is something like:

[1,2,3,,4]

However I see:

[1,2,3,4]

Is there any way to produce this kind of behavior easily?

Thanks,
Drew

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


Re: Sourcing Python Developers

2007-01-29 Thread Kartic
Current requirements in US only.

Kartic sayeth,  on 01/29/2007 01:56 PM:
> Hello,
> 
> My company has quite a few opening involving python expertise. We are 
> always looking for python resources (and find it difficult filling these 
> positions, might I add). Is there any place to find developers' resumes 
> (like finding jobs from http://python.org/community/jobs/)? If any one 
> knows of a resume repository (other than Monster, Dice, 
> Costs-an-arm-and-leg job site) please share.
> 
> In any case, we have immediate requirements for a Pythonista with C++, 
> MySQL, XML, Debian expertise. Please email resume to: 
> python-resumes(at)temporaryforwarding.com
> 
> Thank you,
> --Kartic
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Behavior when inserting new items

2007-01-29 Thread Diez B. Roggisch
Drew schrieb:
> I'm looking to add an element to list of items, however I'd like to 
> add it at a specific index greater than the current size:
> 
> list = [1,2,3]
> list.insert(10,4)
> 
> What I'd like to see is something like:
> 
> [1,2,3,,4]
> 
> However I see:
> 
> [1,2,3,4]
> 
> Is there any way to produce this kind of behavior easily?

Use a dictionary?

If you know how large the list eventually will be, and that each 
position is filled, you can also use range(n) to create a list.

What is your actual usecase?

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


Re: wxPython StatusBar Help

2007-01-29 Thread Frank Niessink

2007/1/29, herve <[EMAIL PROTECTED]>:



Does anybody know how to change the foreground colors in a wx.StatusBar




wx.StatusBar is a subclass of wx.Window so SetForegroundColour should
work...

Cheers, Frank

PS: In general, wxPython related questions are best asked on the
wxPython-users mailinglist (see http://www.wxpython.org/maillist.php).
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: List Behavior when inserting new items

2007-01-29 Thread Drew
> What is your actual usecase?
>
> diez

The issue is that I don't know how long the list will eventually be. 
Essentially I'm trying to use a 2D list to hold lines that I will 
eventually print to the screen. Blank elements in the list will be 
printed as spaces. I suppose every time I add an element, I could find 
the difference between the size of the list and the desired index and 
fill in the range between with " " values, however I just wanted to 
see if there was a more natural way in the language.

Thanks,
Drew

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


SQL connecting

2007-01-29 Thread Scripter47
Hey

It got a problem with python to connect to my SQL DBs, that's installed
on my apache server. how do i connect to sql? Gettting data? Insert into it?

it is a localserver with php if that means something

here is a *REALLY* dirty solution that a have used:
[CODE]
from urllib import *
# sql query
s = 'INSERT INTO `test` (`test`) VALUES ("1");'

# encode and insert into db
params = urlencode({'sql': sql})
urlopen("http://localhost/in/sql.php?%s"; % params)
[/CODE]

-- 
   _.____  __
  /   _/ ___|__|__/  |_  ___  /  |  \__  \
  \_  \_/ ___\_  __ \  \ \   __\/ __ \_  __ \/   |  |_  //
  /\  \___|  | \/  |  |_> >  | \  ___/|  | \/^   / //
/___  /\___  >__|  |__|   __/|__|  \___  >__|  \   | //
 \/ \/ |__| \/   |__|


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


Re: Bush, yank bastards kicked by india in their arse Re: *POLL* How many sheeple believe in the 911 fairy tale and willing to accept an Orwellian doublespeak and enslavement world ?

2007-01-29 Thread Vance P. Frickey
Hawk wrote:
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> you are such a dork.
>
> India has been a Russian satellite for years and years. 
> Who has been
> running their schools?  Not the British.

According to Oleg Kalugin, former head of the KGB's First 
Directorate (overseas espionage), his old employers owned 
someone in just about every important government agency in 
India, from the 1970s until they stopped being able to 
afford paying all those bribes.

Kalugin's book /The_First_Directorate/ is very interesting 
(even if he's a bit cagey in what he says and what he leaves 
unsaid).  Circumlocution didn't help Kalugin, though - he's 
on Putin's hit list anyway.  He can look forward to reading 
by his own light at bedtime if he's not careful from now on.
-- 
Vance P. Frickey
remove "safety" from listed Email address to send mail

"Either bring this back or be brought back upon it." - a 
Spartan (or Roman, depending on the source you believe) 
mother's words to her son on giving him his shield 


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


Re: Conversion of string to integer

2007-01-29 Thread Adam


On Jan 29, 1:55 pm, "jupiter" <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have a problem. I have a list which contains strings and numeric.
> What I want is to compare them in loop, ignore string and create
> another list of numeric values.


You can iterate over the list and use the type() function to work out 
what each entry and choose what to do with it.

type() works like so:
###Code###
>>> a = ["test", 1.25, "test2"]
>>> if type(a[2]) == str:
print "a string"


a string
>>>
###End Code###

Adam

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


Re: List Behavior when inserting new items

2007-01-29 Thread [EMAIL PROTECTED]
On Jan 29, 7:57 pm, "Drew" <[EMAIL PROTECTED]> wrote:
> I'm looking to add an element to list of items, however I'd like to
> add it at a specific index greater than the current size:
>
> list = [1,2,3]
> list.insert(10,4)
>
> What I'd like to see is something like:
>
> [1,2,3,,4]
>
> However I see:
>
> [1,2,3,4]
>
> Is there any way to produce this kind of behavior easily?
>
> Thanks,
> Drew

You could write your own class mimicing a list with your desired 
behaviour, something like:

py>class llist(object):
py>def __init__(self, arg = []):
py>self.__list = arg
py>def __setitem__(self, key, value):
py>length = len(self.__list)
py>if  length < key:
py>for i in range(length, key +1):
py>self.__list.append(None)
py>self.__list[key] = value
py>def __str__(self):
py>return str(self.__list)
py>
py>x = llist()
py>x[10] = 1
py>print x
[None, None, None, None, None, None, None, None, None, None, 1]

for other methods to add to the llist class see http://docs.python.org/
ref/sequence-types.html

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


Re: SQL connecting

2007-01-29 Thread John Nagle
Scripter47 wrote:
> Hey
> 
> It got a problem with python to connect to my SQL DBs, that's installed
> on my apache server. how do i connect to sql? Gettting data? Insert into 
> it?

You need a third-party open source package called "MySQLdb".

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


Re: Conversion of string to integer

2007-01-29 Thread [EMAIL PROTECTED]


On Jan 29, 2:55 pm, "jupiter" <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have a problem. I have a list which contains strings and numeric.
> What I want is to compare them in loop, ignore string and create
> another list of numeric values.
>
> I tried int() and decimal() but without success.
>
> eq of problem is
>
> #hs=string.split(hs)
> hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]
>
> j=0
> for o in range(len(hs)):
> print hs[o],o
> p=Decimal(hs[o])
> if p > 200: j+=j
> print "-"*5,j
> print "*"*25
>
> I could be the best way to solve this ..?
>
> @nil

function isinstance can help you to determine the type/class of an 
object:

py>hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]
py>
py>for i in hs:
py>if isinstance(i, str):
py>print str(i)
py>elif isinstance(i, float):
py>print float(i)
py>elif isinstance(i, int):
py>print int(i)
py>else:
py>print 'dunno type of this element: %s' % str(i)
popopopopop
254.25
pojdjdkjdhhjdccc
25452.25

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


Re: SQL connecting

2007-01-29 Thread Scripter47
John Nagle skrev:
> Scripter47 wrote:
>> Hey
>>
>> It got a problem with python to connect to my SQL DBs, that's installed
>> on my apache server. how do i connect to sql? Gettting data? Insert into 
>> it?
> 
> You need a third-party open source package called "MySQLdb".
> 
>   John Nagle
Yeah look great but im using python 2.5, and it only support 2.3-2.4 :(, 
but thanks :)

Any better solutions :)

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


Re: List Behavior when inserting new items

2007-01-29 Thread Paul McGuire
> py>def __init__(self, arg = []):
> py>self.__list = arg

Please don't perpetuate this bad habit!!!  "arg=[]" is evaluated at 
compile time, not runtime, and will give all default-inited llists the 
same underlying list.

The correct idiom is:

def __init__(self, arg = None):
if arg is not None:
self.__list = arg
else:
self.__list = []

-- Paul

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


Re: Python does not play well with others

2007-01-29 Thread Bruno Desthuilliers
John Nagle a écrit :

(snip)

>My main concern is with glue code to major packages.  The connections
> to OpenSSL, MySQL, and Apache (i.e. mod_python) all exist, but have major
> weaknesses.

Neither MySQLdb nor mod_python are part of the Python's standard lib AFAIK.

>  If you're doing web applications,

I do.

> those are standard pieces
> which need to work right. 

I avoid using MySQL - SQLite does a better job as a lighweight 
SQL-compliant no-server solution, and PostgreSQL is years ahead of MySQL 
when it comes to serious, rock-solid transactional RDBMS. But I had no 
problem with the MySQLdb package so far. I also tend to favor 
Apache-independant deployment solutions, so while I had some fun with 
mod_python, I failed to clearly understand how broken it is. And I did 
not have to worry about the ssl support in Python so far. FWIW, I had do 
some LDAP stuff with both PHP and Python, and I would certainly not 
advocate PHP's LDAP support.

> There's a tendency to treat those as abandonware
> and re-implement them as event-driven systems in Twisted.

While Twisted seems an interesting project, it's usually not the first 
mentioned when talking about web development with Python.

>  Yet the
> main packages aren't seriously broken.  It's just that the learning curve
> to make a small fix to any of them is substantial, so nobody new takes
> on the problem.

If you feel you need it, then it's up to you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Executing Javascript, then reading value

2007-01-29 Thread Melih Onvural
I need to execute some javascript and then read the value as part of a 
program that I am writing. I am currently doing something like this:

import htmllib, urllib, formatter

class myparser(htmllib.HTMLParser):
insave = 0
def start_div(self, attrs):
for i in attrs:
if i[0] == "id" and i[1] == "pr":
self.save_bgn()
self.insave = 1

def end_div(self):
if self.insave == 1:
print self.save_end()
self.insave = 0

parser = myparser(formatter.NullFormatter())

#def getPageRank(self, url):
try:
learn_url = "http://127.0.0.1/research/getPageRank.html?q=http://
www.yahoo.com&"
pr_url = urllib.urlopen(learn_url)
parser.feed(pr_url.read())
except IOError, e:
print e

but the result is the javascript function and not the calculated 
value. Is there anyway to get the javascript to execute first, and 
then return to me the value? thanks in advance,

Melih Onvural

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


Re: Sourcing Python Developers

2007-01-29 Thread Paul Rubin
Kartic <[EMAIL PROTECTED]> writes:
> In any case, we have immediate requirements for a Pythonista with C++,
> MySQL, XML, Debian expertise. Please email resume to:

Generally it's ok to post here to the newsgroup with Python jobs.  But
you should describe the specific openings you're trying to fill, and
their locations.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Compiling extension with Visual C++ Toolkit Compiler - MSVCR80.dll

2007-01-29 Thread alexandre_irrthum
Hi there,

I am trying to install a Python library with a C extension (the 
Polygon library) and I am having a bad time. My Python version is 
Python 2.4.3 - Enthought Edition 1.0.0 (#69, Aug  2 2006, 12:09:59) 
[MSC v.1310 32 bit (Intel)] on Windows XP Pro. I have dutifully 
followed the instructions here:

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

i.e.,

- Installed Microsoft Visual C++ Toolkit Compiler 2003
- Installed Microsoft Platform SDK for Windows Server 2003 R2
- Installed Microsoft .NET Framework SDK, version 1.1
- setup the path, include and lib environment variables with a .bat 
file, as described in the wiki document

The library seems to build correctly (producing Polygon.py and 
cPolygon.pyd), but when I import it I get the following message from 
python.exe: "This application has failed to start because MSVCR80.dll 
was not found". I thought that this might be due to Python trying to 
link against  the .dll from Microsoft Visual C++ Express 2005, also 
installed on my PC, instead of MSVCR71.dll. So I've removed MS Visual C
++ Express 2005, and any trace of it from my environment variables, 
but that doesn't seem to change anything.

Any help would be greatly appreciated.

Regards,

alex

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


Re: List Behavior when inserting new items

2007-01-29 Thread [EMAIL PROTECTED]


On Jan 29, 1:10 pm, "Drew" <[EMAIL PROTECTED]> wrote:
> > What is your actual usecase?
>
> > diezThe issue is that I don't know how long the list will eventually be.
> Essentially I'm trying to use a 2D list to hold lines that I will
> eventually print to the screen. Blank elements in the list will be
> printed as spaces. I suppose every time I add an element, I could find
> the difference between the size of the list and the desired index and
> fill in the range between with " " values, however I just wanted to
> see if there was a more natural way in the language.

I would use DBR's suggestion to use a dictionary and only store
actual values. In this example, I'm making a histogram that only
ends up having results for 4,7,8,9,10 but I want the graph to show
the zero occurrences as well, so I just create them on the fly
when printing.

print
print 'tc factor of 2 distribution (* scale = 8)'
print
tchistkeys = tchist.keys()
tchistkeys.sort()
prev_key = 0
for i in tchistkeys:
while prev_key0:
s = s + '.'
print s
prev_key += 1

##tc factor of 2 distribution (* scale = 8)
##
##  0 (  0)
##  1 (  0)
##  2 (  0)
##  3 (  0)
##  4 (  1) .
##  5 (  0)
##  6 (  0)
##  7 (112) **
##  8 (219) ***.
##  9 ( 58) ***.
## 10 (110) *.




>
> Thanks,
> Drew

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


Re: List Behavior when inserting new items

2007-01-29 Thread Bruno Desthuilliers
Drew a écrit :
> I'm looking to add an element to list of items, however I'd like to 
> add it at a specific index greater than the current size:
> 
> list = [1,2,3]

NB: better to avoid using builtins types and functions names as identifiers.

> list.insert(10,4)
> 
> What I'd like to see is something like:
> 
> [1,2,3,,4]

Hint : the Python representation of nothing is a singleton object named 
None.

> However I see:
> 
> [1,2,3,4]

Yeps. I thought it would have raised an IndexError. But I seldom use 
list.insert() to append to a list - there's list.append() (and/or 
list.extend()) for this.

> Is there any way to produce this kind of behavior easily?

Hints:
 >>> [None] * 5
[None, None, None, None, None]
 >>> [1, 2, 3, None] + [10]
[1, 2, 3, None, 10]

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


python 2.3 module ref

2007-01-29 Thread David Bear
Since redhat packages python2.3 with their distro (RHEL 4..) I was looking
for a module reference for that version. Looking at python.org I only see
current documentation.

any pointers to a 2.3 module ref?
-- 
David Bear
-- let me buy your intellectual property, I want to own your thoughts --
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Executing Javascript, then reading value

2007-01-29 Thread Jean-Paul Calderone
On 29 Jan 2007 12:44:07 -0800, Melih Onvural <[EMAIL PROTECTED]> wrote:
>I need to execute some javascript and then read the value as part of a
>program that I am writing. I am currently doing something like this:

Python doesn't include a JavaScript runtime.  You might look into the
stand-alone Spidermonkey runtime.  However, it lacks the DOM APIs, so
it may not be able to run the JavaScript you are interested in running.
There are a couple other JavaScript runtimes available, at least.  If
Spidermonkey is not suitable, you might look into one of them.

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


Re: python 2.3 module ref

2007-01-29 Thread Robert Kern
David Bear wrote:
> Since redhat packages python2.3 with their distro (RHEL 4..) I was looking
> for a module reference for that version. Looking at python.org I only see
> current documentation.
> 
> any pointers to a 2.3 module ref?

  http://docs.python.org/

Click on "Locate previous versions."

  http://www.python.org/doc/versions/

Click on "2.3.5" (or whichever microrelease your desire).

  http://www.python.org/doc/2.3.5/

-- 
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: Convert from unicode chars to HTML entities

2007-01-29 Thread Martin v. Löwis
Steven D'Aprano schrieb:
> A few issues:
> 
> (1) It doesn't seem to be reversible:
> 
 '© and many more...'.decode('latin-1')
> u'© and many more...'
> 
> What should I do instead?

For reverse processing, you need to parse it with an
SGML/XML parser.

> (2) Are XML entities guaranteed to be the same as HTML entities?

Please make a terminology difference between "entity", "entity
reference", and "character reference".

An (external parsed) entity is a named piece of text, such
as the copyright character. An entity reference is a reference
to such a thing, e.g. ©

A character reference is a reference to a character, not to
an entity. xmlcharrefreplace generates character references,
not entity references (let alone generating entities). The
character references in XML and HTML both reference by
Unicode ordinal, so it is "the same".

> (3) Is there a way to find out at runtime what encoders/decoders/error
> handlers are available, and what they do? 

Not through Python code. In C code, you can look at the
codec_error_registry field of the interpreter object.

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


Re: List Behavior when inserting new items

2007-01-29 Thread Drew

> > Is there any way to produce this kind of behavior easily?Hints:
>  >>> [None] * 5
> [None, None, None, None, None]
>  >>> [1, 2, 3, None] + [10]
> [1, 2, 3, None, 10]
>
> HTH

That is exactly what I was looking for. I'm actually working on some 
problems at http://codgolf.com. I find it helps me to learn a language 
and I'm coming from ruby where arrays have subtle differences from 
python's lists. Thanks for all the helpful responses.

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


Re: python 2.3 module ref

2007-01-29 Thread Martin v. Löwis
David Bear schrieb:
> Since redhat packages python2.3 with their distro (RHEL 4..) I was looking
> for a module reference for that version. Looking at python.org I only see
> current documentation.
> 
> any pointers to a 2.3 module ref?

http://www.python.org/doc/2.3/
http://www.python.org/doc/2.3/lib/lib.html

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


Re: Executing Javascript, then reading value

2007-01-29 Thread Melih Onvural
Thanks, let me check out this route, and then I'll post the results.

Melih Onvural

On Jan 29, 4:04 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On 29 Jan 2007 12:44:07 -0800, Melih Onvural <[EMAIL PROTECTED]> wrote:
>
> >I need to execute some javascript and then read the value as part of a
> >program that I am writing. I am currently doing something like this:Python 
> >doesn't include a JavaScript runtime.  You might look into the
> stand-alone Spidermonkey runtime.  However, it lacks the DOM APIs, so
> it may not be able to run the JavaScript you are interested in running.
> There are a couple other JavaScript runtimes available, at least.  If
> Spidermonkey is not suitable, you might look into one of them.
>
> Jean-Paul

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


Re: List Behavior when inserting new items

2007-01-29 Thread Bruno Desthuilliers
Drew a écrit :
>>What is your actual usecase?
>>
>>diez
> 
> 
> The issue is that I don't know how long the list will eventually be. 

How is this an issue ? Python's lists are not fixed-sized arrays.

> Essentially I'm trying to use a 2D list to hold lines that I will 
> eventually print to the screen.
 >
> Blank elements in the list will be 
> printed as spaces. I suppose every time I add an element, I could find 
> the difference between the size of the list and the desired index and 
> fill in the range between with " " values,

Yes. But note that [1,2,3,' ',' ',4]
is not the same thing as [1,2,3,,,4] (which is not valid Python FWIW).

> however I just wanted to 
> see if there was a more natural way in the language.

I'm not sure I get it. Do you mean you're trying to use a list of lists 
as a representation of a 2D matrix (IOW, a bitmap) ? Something like

bpm = [
   ['X',' ',' ',' ','X'],
   [' ','X',' ','X',' '],
   [' ',' ','X',' ',' '],
   [' ','X',' ','X',' '],
   ['X',' ',' ',' ','X'],
]

If so, using dicts can be somewhat simpler and less memory-consuming:

d = {1:1, 2:2, 3:3}
d[10] = 4
for i in range(1, max(d.keys())+1):
   print d.get(i, ' ')

That is, instead of storing useless spaces for "blank cells" and having 
to do math to compute how many of them you have to insert/delete, you 
just place stuff at desired indices, and 'fill in' spaces when printing 
out to screen.

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


Re: Sourcing Python Developers

2007-01-29 Thread Kartic
Paul Rubin sayeth,  on 01/29/2007 03:44 PM:
> Kartic <[EMAIL PROTECTED]> writes:
>> In any case, we have immediate requirements for a Pythonista with C++,
>> MySQL, XML, Debian expertise. Please email resume to:
> 
> Generally it's ok to post here to the newsgroup with Python jobs.  But
> you should describe the specific openings you're trying to fill, and
> their locations.  

Paul - Thanks for the clarification; will use the list _sparingly_ post 
jobs.

The skills I listed are the once I have (Py, MySQL, C++, XML, Debian). 
Location: Torrance CA.
Compensation: Commensurate with Experience.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling extension with Visual C++ Toolkit Compiler - MSVCR80.dll

2007-01-29 Thread Martin v. Löwis
[EMAIL PROTECTED] schrieb:
> The library seems to build correctly (producing Polygon.py and 
> cPolygon.pyd), but when I import it I get the following message from 
> python.exe: "This application has failed to start because MSVCR80.dll 
> was not found". I thought that this might be due to Python trying to 
> link against  the .dll from Microsoft Visual C++ Express 2005, also 
> installed on my PC, instead of MSVCR71.dll. So I've removed MS Visual C
> ++ Express 2005, and any trace of it from my environment variables, 
> but that doesn't seem to change anything.
> 
> Any help would be greatly appreciated.

Can you find out where msvcrt.lib comes from? If you manage to copy
the linker command line, I think link.exe has a way of telling you
where it picked up the file. If that won't work, and you find multiple
copies of msvcrt.lib on your disk, you can use dumpbin /all on
each of them to find out which one is right.

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


Re: strip question

2007-01-29 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> hi
> can someone explain strip() for these :
> [code]
> 
x='www.example.com'
x.strip('cmowz.')
> 
> 'example'
> [/code]
> 
> when i did this:
> [code]
> 
x = 'abcd,words.words'
x.strip(',.')
> 
> 'abcd,words.words'
> [/code]
> 
> it does not strip off "," and "." .Why is this so?

Probably because the Fine Manual(tm) says that str.strip() removes 
heading and trailing chars ?

"""
[EMAIL PROTECTED] ~ $ python
Python 2.4.1 (#1, Jul 23 2005, 00:37:37)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on 
linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> help(''.strip)
Help on built-in function strip:

strip(...)
 S.strip([chars]) -> string or unicode

 Return a copy of the string S with leading and trailing
 whitespace removed.
 If chars is given and not None, remove characters in chars instead.
 If chars is unicode, S will be converted to unicode before stripping
"""


You may want to try str.replace() instead:

"""
 >>> help(''.replace)
Help on built-in function replace:

replace(...)
 S.replace (old, new[, count]) -> string

 Return a copy of string S with all occurrences of substring
 old replaced by new.  If the optional argument count is
 given, only the first count occurrences are replaced.
 >>> 'abcd,words.words'.replace(',', '').replace('.', '')
'abcdwordswords'
"""

> thanks

HTH

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


We sell to everyone!!! Government, Wholesalers, Distributers, Entreprenuers.....www.martin-global.com

2007-01-29 Thread Martin Global
Martin Global is one of North America's leading importers of goods
 manufactured and produced throughout Asia. We are distinctively 
unique
 from other importers, as we have one of North America's largest 
networks
 linking our organization directly to thousands of manufacturers and 
suppliers in
 Asia and throughout the world.

 We at Martin Global are proud of our reputation for excellence: a
 reputation based on our commitment to the highest manufacturing and 
ethical
 standards.  At Martin Global, all of our business relationships with 
customers,
 suppliers, manufacturers and employees rest on a foundation of 
integrity and
 trust.


 Mission Statement

 Martin Global puts the needs of its clients first! We strive to 
establish
 long-term personal relationships built upon clients' trust in our 
ability
 to provide superior products at competitive prices. Whether you're a 
large
 corporation, government entity or a sole proprietor, we take these
 relationships very seriously and we believe that our success is 
measured
 by the success of our clients and their return business. Inquiries 
always welcomed.

 Your message will responded to within 8 hours.

 Regards,


 Donovan Martin
 Martin Global

www.martin-global.com

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


We sell to everyone!!! Government, Wholesalers, Distributers, Entreprenuers.....www.martin-global.com

2007-01-29 Thread Martin Global
Martin Global is one of North America's leading importers of goods
 manufactured and produced throughout Asia. We are distinctively 
unique
 from other importers, as we have one of North America's largest 
networks
 linking our organization directly to thousands of manufacturers and 
suppliers in
 Asia and throughout the world.

 We at Martin Global are proud of our reputation for excellence: a
 reputation based on our commitment to the highest manufacturing and 
ethical
 standards.  At Martin Global, all of our business relationships with 
customers,
 suppliers, manufacturers and employees rest on a foundation of 
integrity and
 trust.


 Mission Statement

 Martin Global puts the needs of its clients first! We strive to 
establish
 long-term personal relationships built upon clients' trust in our 
ability
 to provide superior products at competitive prices. Whether you're a 
large
 corporation, government entity or a sole proprietor, we take these
 relationships very seriously and we believe that our success is 
measured
 by the success of our clients and their return business. Inquiries 
always welcomed.

 Your message will responded to within 8 hours.

 Regards,


 Donovan Martin
 Martin Global

www.martin-global.com

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


Re: Compiling extension with Visual C++ Toolkit Compiler - MSVCR80.dll

2007-01-29 Thread Peter Wang
On Jan 29, 2:47 pm, [EMAIL PROTECTED] wrote:
> The library seems to build correctly (producing Polygon.py and
> cPolygon.pyd), but when I import it I get the following message from
> python.exe: "This application has failed to start because MSVCR80.dll
> was not found". I thought that this might be due to Python trying to
> link against  the .dll from Microsoft Visual C++ Express 2005, also
> installed on my PC, instead of MSVCR71.dll. So I've removed MS Visual C
> ++ Express 2005, and any trace of it from my environment variables,
> but that doesn't seem to change anything.

Alex,  I'm not familiar with the particular problem you're seeing, but 
did you try building the polygon library using the gcc that's included 
with the Enthought distribution?

python setup.py build_clib build_ext --inplace --compiler=mingw32


-Peter

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


Re: Data structure and algorithms

2007-01-29 Thread azrael
thanks guys. i see that there is no way then to go back to C to 
satisfy my prof and get a grade

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


Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread NoName
WOW! :shock:

in this case:

while 1:i=__import__;print 
i('binascii').b2a_base64(i('os').urandom(6)),;raw_input()


On 30 Янв., 04:06, "Szabolcs Nagy" <[EMAIL PROTECTED]> wrote:
> > while
> > 1:i=__import__;print''.join(i('random').choice(i('string').letters
> > +'1234567890')for x in range(8)),;raw_input()while
> 1:i=__import__;r='random';print''.join(i(r).choice(i('string').letters
> +'1234567890')for x in`r`),;raw_input()
>
> even shorter:
> range -> `'random'`
>
> :)

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

Re: The reliability of python threads

2007-01-29 Thread Carl J. Van Arsdall
Hendrik van Rooyen wrote:
> [snip]
>> could definitely do more of them.  The thing will be 
>> 
>
> When I read this - I thought - probably your stuff is working 
> perfectly - on your test cases - you could try to send it some
> random data and to see what happens - seeing as you have a test 
> server, throw the kitchen sink at it.
>
> Possibly "random" here means something that "looks like" data
> but that is malformed in some way. Kind of try to "trick" the 
> system to get it to break reliably.
>
> I'm sorry I can't be more specific - it sounds so weak, and you
> probably already have test cases that "must fail" but I don't 
> know how to put it any better...
>   
Well, sometimes a weak analogy is the best thing because it allows me to 
fill in the blanks "How can I throw a kitchen sink at it in a way I 
never have before"

And away my mind goes, so thank you.

-carl

-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


Re: Bush, yank bastards kicked by india in their arse Re: *POLL* How many sheeple believe in the 911 fairy tale and willing to accept an Orwellian doublespeak and enslavement world ?

2007-01-29 Thread thermate
On Jan 29, 11:15 am, "Vance P. Frickey" <[EMAIL PROTECTED]> wrote:

> Directorate (overseas espionage), his old employers owned
> someone in just about every important government agency in
> India, from the 1970s until they stopped being able to
> afford paying all those bribes.

But in this anglo-saxon heaven, monica lewinsky owns every president 
by his balls. Reagan and Herber Walker Bush have a serious pedophilia 
charges against
them. The jewcons control George Bush. In another article I will 
describe how
his mind is controlled. How he is fed the information and has no 
personal skill.
He is only good for exercising his ego and repeating what is taught to 
him. He
only signs documents. He cannot write his own speech. He cannot 
passionately
defend himself against tough opponents in public. In the presidential 
debates
he was scared to death. Certaily, kerry let him off very easily, and 
possibly
because kerry was under the threat of blackmail to not cross the line. 
If kerry
has attacked bush as a liar, or with valery plame case or Abu Gharib 
or using other strong points bush would have probably fainted from 
fear.

Almost every US senator is in the pocket of a certain lobby, which is 
too obvious to name  LAUGHING OUT LOUD

God save the Honorable Reverend Jimmy Carter for the book ..

Dont talk about India Impudently, ever .

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


Re: Overloading assignment operator

2007-01-29 Thread J. Clifford Dyer
Steven D'Aprano wrote:
> On Tue, 23 Jan 2007 18:07:55 -0800, Russ wrote:
> 
>> Achim Domma wrote:
>>> Hi,
>>>
>>> I want to use Python to script some formulas in my application. The user
>>> should be able to write something like
>>>
>>> A = B * C
>>>
>>> where A,B,C are instances of some wrapper classes. Overloading * is no
>>> problem but I cannot overload the assignment of A. I understand that
>>> this is due to the nature of Python, but is there a trick to work around
>>> this?
>>> All I'm interested in is a clean syntax to script my app. Any ideas are
>>> very welcome.
>>>
>>> regards,
>>> Achim
>> Why do you need to overload assignment anyway? If you overloaded "*"
>> properly, it should return
>> the result you want, which you then "assign" to A as usual. Maybe I'm
>> missing something.
> 
> One common reason for overriding assignment is so the left-hand-side of
> the assignment can choose the result type. E.g. if Cheddar, Swiss and
> Wensleydale are three custom classes, mutually compatible for
> multiplication:
> 
> B = Cheddar()  # B is type Cheddar
> C = Swiss()# C is type Swiss
> # without overloading assignment
> A = B * C  # A is (possibly) Cheddar since B.__mul__ is called first
> A = C * B  # A is (possibly) Swiss since C.__mul__ is called first
> # with (hypothetical) assignment overloading 
> A = B * C  # A is type Wensleydale since A.__assign__ is called
> 
> Except, of course, there is no assignment overloading in Python. There
> can't be, because A may not exist when the assignment is performed, and
> if it does exist it might be a complete different type.
> 
> Instead, you can do something like this:
>  
> A = Wensleydale(B) * Wensleydale(C)
> 
> or 
> 
> A = Wensleydale(B * C)
> 
> 
> 
> 

I think that's the first time I've actually seen someone use a Monty
Python theme for a python example, and I must say, I like it.  However,
"We are all out of Wensleydale."

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


Re: ctypes: Setting callback functions in C libraries

2007-01-29 Thread [EMAIL PROTECTED]
I realized my wrapping was broken, fixing that below...

On Jan 25, 12:47 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> 
wrote:
> I'm trying to wrap GNU readline withctypes(the Python readline
> library doesn't support the callback interface), but I can't figure out
> how to set values to a variable inside the library.  This is Python 2.5
> on Linux.  Here's what I have so far--if you comment out the memmove
> call (3 lines) it works as expected:
[SNIP]
> I need to assign ourfunc to RL_ATTEMPTED_COMPLETION_FUNCTION, but
> obviously simple assignment rebinds the name rather than assigning it
> to the C variable.
>
> Usingctypes.memmove to overwrite it(as I have here) will run the
> function but segfault when ourfunc goes to return (poking around with
> the debugger shows it's dying inctypes' callbacks.c at line 216, "keep
> = setfunc(mem, result, 0);" because setfunc is NULL).  I'm not entirely
> sure that's not because of some error in the prototyping or restype
> setting rather than as a result of memmove, but the memmove seems
> sketchy enough (only sets the function pointer itself presumably, not
> anything thatctypeswrappers need) that I'm looking for a better way
> to do it.
>
> As it is, returning rv directly or simply returning None causes the
> same segfault.
>
> Any idea?
>
> Thanks very much for your time!

# START
#!/usr/local/bin/python2.5
import ctypes

ctypes.cdll.LoadLibrary("libcurses.so")#, mode=ctypes.RTLD_GLOBAL)
ctypes.CDLL("libcurses.so", mode=ctypes.RTLD_GLOBAL)
ctypes.cdll.LoadLibrary("libreadline.so")
readline = ctypes.CDLL("libreadline.so")

RL_COMPLETION_FUNC_T = \
ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_char_p),
ctypes.c_char_p, ctypes.c_int, ctypes.c_int)
RL_LINE_BUFFER = ctypes.c_char_p.in_dll(readline, "rl_line_buffer")
RL_ATTEMPTED_COMPLETION_FUNCTION = \
RL_COMPLETION_FUNC_T.in_dll(readline,
"rl_attempted_completion_function")

def our_complete(text, start, end):
print "Test", text, start, end
rv = None
arrtype = ctypes.c_char_p*4
globals()["rv"] = arrtype("hello", "hatpin", "hammer", None)
globals()["crv"]=ctypes.cast(rv, ctypes.POINTER(ctypes.c_char_p))
return rv
ourfunc = RL_COMPLETION_FUNC_T(our_complete)

_readline = readline.readline
_readline.argtypes = [ctypes.c_char_p]
_readline.restype = ctypes.c_char_p

ctypes.memmove(ctypes.addressof(RL_ATTEMPTED_COMPLETION_FUNCTION),
   ctypes.addressof(ourfunc),
   4)
line = _readline("Input: ")
print "INPUT was: ", line
#END

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


Re: [Boost.Graph] graph.vertices property creates new objects

2007-01-29 Thread Szabolcs Nagy
> It seems that the vertices iterator creates new vertex objects every
> time instead of iterating over the existing ones. This essentially

i don't know much about bgl, but this is possible since vertices are 
most likely not stored as python objects inside boost

> prevents, among other things, storing vertices as keys in a dictionary
> since the hashes of the stored and the new vertex differ although they
> compare equal. Is this really what's happening, and if so, why ?

that sounds bad, fortunately __hash__ can be overriden so even if id() 
differs hash() can be the same for the same vertex.
if __hash__ is not handled then it's a bug in bgl imho.

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


[email protected]

2007-01-29 Thread Pappy
SHORT VERSION:
Python File B changes sys.stdout to a file so all 'prints' are written 
to the file.  Python file A launches python file B with os.popen("./B 
2>&^1 >dev/null &").  Python B's output disappears into never-never 
land.

LONG VERSION:
I am working on a site that can kick off large-scale simulations.  It 
will write the output to an html file and a link will be emailed to 
the user.  Also, the site will continue to display "Loading..." if the 
user wants to stick around.

The simulation is legacy, and it basically writes its output to stdout 
(via simple print statements).  In order to avoid changing all these 
prints, I simply change sys.stdout before calling the output 
functions.  That works fine.  The whole thing writes to an html file 
all spiffy-like.

On the cgi end, all I want my (python) cgi script to do is check for 
form errors, make sure the server isn't crushed, run the simulation 
and redirect to a loading page (in detail, I write a constantly 
updating page to the location of the final output file.  When the 
simulation is done, the constantly updating file will be magically 
replaced).  The root problem is that the popen mechanism described 
above is the only way I've found to truly 'Detach' my simulation 
process.  With anything else, Apache (in a *nix environment) sits and 
spins until my simulation is done.  Bah.

Any ideas?

_jason

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


deepcopy alternative?

2007-01-29 Thread none
I have a very complex data structure which is basically a class object 
containing (sometimes many) other class objects, function references, 
ints, floats, etc.  The man for the copy module states pretty clearly 
that it will not copy methods or functions.  I've looked around for a 
while (prob just using the wrong keywords) and haven't found a good 
solution.  As a workaround I've been using cPickle, loads(dumps(obj)) 
which is incredibly slow (~8 sec for a 1000 elem list).

I believe the only thing stopping me from doing a deepcopy is the 
function references, but I'm not sure.  If so is there any way to 
transform a string into a function reference(w/o eval or exec)?

Example
from copy import deepcopy
a = ClassObj([ClassObj([3.2, 'str', funcRef]), 4, ClassObj[funcRef])
b = deepcopy(a)
TypeError: function() takes at least 2 arguments (0 given)

All I want is a deepcopy of the list.  Any suggestions would be appreciated.

Jack Trades

PS: If the answer to this is in __getstate__() or __setstate__() is 
there some reference to how these should be implemented besides the 
library reference?
-- 
http://mail.python.org/mailman/listinfo/python-list


select windows

2007-01-29 Thread Siqing Du
Hi,

Is there is a way to write a program to select and switch between
windows? For instance, if I have three windows: Firefox, Thunderbird,
and emacs, can I run a program to bring up the desired windows, instead
of click on the  windows use mouse.

Thanks,

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


Re: python 2.3 module ref

2007-01-29 Thread Szabolcs Nagy

> any pointers to a 2.3 module ref?

also look at:
http://rgruet.free.fr/PQR2.3.html#OtherModules

when coding for different python versions i can reccommend this quick 
ref:
http://rgruet.free.fr/

(every language feature is colorcoded according to the version when it 
was included)

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


Re: Overloading assignment operator

2007-01-29 Thread Michael Spencer
J. Clifford Dyer wrote:
  > I think that's the first time I've actually seen someone use a Monty
> Python theme for a python example, and I must say, I like it.  However,
> "We are all out of Wensleydale."
> 
> Cheers,
> Cliff

Oh, then you clearly don't waste nearly enough time on this newsgroup ;-)

http://groups.google.com/group/comp.lang.python/search?group=comp.lang.python&q=spam+eggs

http://groups.google.com/group/comp.lang.python/search?q=shrubbery

http://groups.google.com/group/comp.lang.python/search?group=comp.lang.python&q=knights+ni

http://groups.google.com/group/comp.lang.python/search?group=comp.lang.python&q=larch

Idly yours,

Michael

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


Re: Conversion of string to integer

2007-01-29 Thread John Machin


On Jan 30, 6:48 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> 
wrote:
> On Jan 29, 2:55 pm, "jupiter" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi guys,
>
> > I have a problem. I have a list which contains strings and numeric.
> > What I want is to compare them in loop, ignore string and create
> > another list of numeric values.
>
> > I tried int() and decimal() but without success.
>
> > eq of problem is
>
> > #hs=string.split(hs)
> > hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]
>
> > j=0
> > for o in range(len(hs)):
> > print hs[o],o
> > p=Decimal(hs[o])
> > if p > 200: j+=j
> > print "-"*5,j
> > print "*"*25
>
> > I could be the best way to solve this ..?
>
> > @nilfunction isinstance can help you to determine the type/class of an
> object:
>
> py>hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"]
> py>
> py>for i in hs:
> py>if isinstance(i, str):
> py>print str(i)
> py>elif isinstance(i, float):
> py>print float(i)
> py>elif isinstance(i, int):
> py>print int(i)
> py>else:
> py>print 'dunno type of this element: %s' % str(i)
> popopopopop
> 254.25
> pojdjdkjdhhjdccc
> 25452.25

Call me crazy, but I can't understand what the above code is meant to 
demonstrate.

(1) All of the elements in "hs" are *known* to be of type str. The 
above code never reaches the first elif. The OP's problem appears to 
be to distinguish which elements can be *converted* to a numeric type.

(2) if isinstance(i, some_type) is true, then (usually) some_type(i) 
does exactly nothing that is useful

Awaiting enlightenment ...

John

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


Re: Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread thermate
Listen you mother fucker VULTURE, the past cold war was with soviet
block, NOW the whole world hates you ... bastard you need friends, but
now with your 911 in which YOU KILLED YOUR OWN CITIZENS, you are THE
MOST ODIOUS NATION ON EARTH.

YOU NEED FRIENDS, your biggest perceived rival CHINA is the most
popular nation on earth ... Venezuela's Chavez is most popular, and 
you
are the most odious anglo-saxon yank bastards ... Islamists hate you
also and neocons also hate you, only using you as trash paper as they
used Germany during WW1 and WW2, listen to Benjamin Friedman

On Jan 29, 10:15 am, "Frank Arthur" <[EMAIL PROTECTED]> wrote:
> Islamist bastard <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED]
>
> > FBI spook bastard  that speaks french also
>
> > On Jan 29, 8:13 am, "Hampton Din" <[EMAIL PROTECTED]> wrote:
> >>  stupid troll

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


Another link to the audio of radio interview by Dinesh D'Souza - HILLARIOUS

2007-01-29 Thread thermate
"http://a1135.g.akamai.net/f/1135/18227/1h/
cchannel.download.akamai.com/18227/podcast/PORTLAND-OR/KPOJ-AM/
1-23-07%20POJ-cast.mp3?CPROG=PCAST&MARKET=PORTLAND-
OR&NG_FORMAT=newstalk&SITE_ID=674&STATION_ID=KPOJ-
AM&PCAST_AUTHOR=AM620_KPOJ&PCAST_CAT=Talk_Radio&PCAST_TITLE=Thom_Hartma
nn_Podcast"

http://loadedorygun.blogspot.com/2007/01/disassembling-dsouza.html

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


Bush, clean up your shit and farts before you leave - Hillary Clinton

2007-01-29 Thread thermate
But Bush was merely an ego front for the neocons ... He spoke their 
speeches, signed their recommendations, and ordered their wars, go and 
listen to Benjamin Friedman's excellent video in his very passionate 
voice ...

http://video.google.com/videoplay?docid=3552214685532803163&q



http://www.nydailynews.com/front/story/492891p-415149c.html

Hil to W: Clean up your own mess
Leaving it to next Prez is irresponsible, she tells Iowa crowd

BY MICHAEL McAULIFF
DAILY NEWS WASHINGTON BUREAU

Hillary Clinton addresses crowd at town-hall style meeting yesterday 
in Davenport, Iowa. Her two-day swing through Iowa, where she hit hard 
on issues like Iraq war and health care, was first trip to state with 
earliest caucus since announcing presidential candidacy.
DAVENPORT, Iowa - President Bush should clean up the mess he made in 
Iraq and bring American troops home before he leaves the White House 
in 2009, Sen. Hillary Clinton said yesterday.

Clinton fired her rhetoric-raising broadside at Bush and the Iraq war 
on her first swing through Iowa as a presidential hopeful, painting 
herself as tough, warm and presidential all at the same time.

"The President has said this is going to be left to his successor," 
she said at a rally in Davenport. "I think it's the height of 
irresponsibility, and I really resent it.

"This was his decision to go to war; he went with an ill-conceived 
plan, an incompetently executed strategy, and we should expect him to 
extricate our country from this before he leaves office," the former 
First Lady said.

White House spokesman Rob Saliterman criticized Clinton (D-N.Y.) for 
"a partisan attack that sends the wrong message to our troops and the 
Iraqi people."

One questioner challenged Clinton to explain her vote in late 2002 to 
authorize the war. She said Congress was "misled" at the time by the 
President.

"He took the authority that I and others gave him, and he misused it," 
she said. "And I regret that deeply. And if we had known then what we 
know now, there never would have been a vote, and I never would have 
voted to give this President that authority."

Dawn Trettin, 33, and her son Ramon Briones, 18, who has joined the 
Army, said they liked what they heard from Clinton. Trettin, though, 
teared up when someone in the crowd told her son not to go to Iraq.

"I don't want to just pull out and leave it in chaos," she said, 
though she was waiting to make up her mind on whom to vote for next 
year.

Her son, who said he liked Clinton's depth, was ready to commit after 
hearing her pitch. "I liked her," he said. "I would vote for her."

Clinton is leading her Democratic rivals in national polls, but she is 
not the front-runner in Iowa. If Iowa's first-in-the-nation caucus was 
held now, she would lose to 2004 vice presidential nominee John 
Edwards. She also trails former Iowa Gov. Tom Vilsack and Illinois 
Sen. Barack Obama in state polls.

She completed a two-day swing through the state last night in a bid to 
close the gap and tried to erase the perception among many Iowans that 
she can't win, talking to them in small groups in living rooms and by 
the thousands in large halls.

The reception was strong, and Camp Clinton liked what it saw.

"We are thrilled with the weekend," said Clinton spokesman Howard 
Wolfson.

Clinton also focused on middle-class issues like making college more 
affordable and obtaining universal health care coverage.

She promised to try to at least get universal coverage for kids during 
her next two years in the Senate.

Today, she's picking up the war theme theme again in Texas, attending 
the dedication of Brooke Army Medical Center's $50 million Center for 
the Intrepid. The 60,000-square-foot physical rehabilitation center is 
for veterans injured in the war.

Originally published on January 28, 2007

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


Re: deepcopy alternative?

2007-01-29 Thread Szabolcs Nagy
> I believe the only thing stopping me from doing a deepcopy is the
> function references, but I'm not sure.  If so is there any way to
> transform a string into a function reference(w/o eval or exec)?

what's your python version?
for me deepcopy(lambda:1) does not work in py2.4 but it works in py2.5
(in py2.4 i tried to override __deepcopy__ but it had no effect)

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


Re: Excellent Interview with Dennis D'Souza, full of laughs

2007-01-29 Thread Michael L Torrie
On Mon, 2007-01-29 at 15:47 -0800, [EMAIL PROTECTED] wrote:
> 
I know this is a useless gesture, but my normal tolerance for such
behavior has reached an end.

Please stop spamming this list with off-topic profanities.  Your
ramblings have nothing to do with programming in Python (this is a
computer-related group by the way) and grow tiresome.  I generally
tolerate occasional off-topic posts because they can be intelligent,
witty, diverting, and sometimes informative and educational.  However
your posts are none of these things.  There are plenty of forums out
there for you to vent your frustrations and express your beliefs and
opinions.  Kindly take your musings elsewhere, particularly when you
have to resort to using profanity to make up for your lack of elegant
expression and inability to argue a point, or even present a point.

Should this become more of a problem, I would vote in favor of moving
this newsgroup to being moderated.  In fact, I'd be in favor of shutting
down the newsgroup entirely and using the members-only mailing list
exclusively, although I know a number of people here would oppose that.

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


  1   2   >