How to find the present working directory using python.

2007-05-04 Thread pradeep nair
how to find out the present working directory using python.

os.system('pwd') works good. But i need some specific one in
python rather than embedding shell command into python.

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


default config has no md5 module?

2007-05-04 Thread Leo Jay
i want to compile a python by myself, but after configure and make, it
seems that md5 is not built by default.

what should i do to compile md5 as an module?

-- 
Best Regards,
Leo Jay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to find the present working directory using python.

2007-05-04 Thread SamG
On May 4, 12:03 pm, pradeep nair <[EMAIL PROTECTED]> wrote:
> how to find out the present working directory using python.
>
> os.system('pwd') works good. But i need some specific one in
> python rather than embedding shell command into python.


os.path.getcwd()

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


base64 and unicode

2007-05-04 Thread EuGeNe Van den Bulke
Hi,

I am trying to convert the file hebrew.b64 attached into hebrew.lang 
(text file usable by Inline Search  
for localization purposes.

 >>> import base64
 >>> base64.decode(file("hebrew.b64","r"),file("hebrew.lang","w"))

It runs but the result is not correct: some of the lines in hebrew.lang 
are correct but not all of them (hebrew.expected.lang is the correct 
file). I guess it is a unicode problem but can't seem to find out how to 
fix it.

 hebrew.b64 = file to convert 

//4jACAARQBuAGcAbABpAHMAaAAgAHYAIAAxAC4ANAANAAoAMQA6AOIF0QXoBdkF6gUNAAoA
DQAKADEAMAAxADoA0QXZBdgF1QXZBSAA3AXQBSAA4AXeBeYF0AUNAAoAMQAwADIAOgDUBdIF
2QXiBSAA3AXhBdUF4wUgANQF0wXjBSwAIADeBd4F6QXZBdoFIADeBegF0AXpBSAA1AXTBeMF
DQAKADEAMAAzADoA0gXoBeEF1AUgANcF0wXpBdQFIADpBdwFIABJAG4AbABpAG4AZQAgAFMA
ZQBhAHIAYwBoACAA4AXeBeYF0AXUBS4AIADcBdcF5QUgAOIF3AUgACIA2wXfBSIAIADbBdMF
2QUgANwF4gXRBdUF6AUgANwF0wXjBSAA1AXUBdUF6AXTBdQFLgANAAoAMQAwADQAOgDZBekF
IADcBdoFIADQBeoFIADUBdIF6AXhBdQFIADUBdAF1wXoBdUF4AXUBSAA6QXcBSAASQBuAGwA
aQBuAGUAIABTAGUAYQByAGMAaAAuAA0ACgAxADAANQA6AN4F5gXQBSAAOgANAAoAMQAwADYA
OgDUBeoF0AXdBSAA6AXZBekF2QXVBeoFDQAKADEAMQAxADoA3gXmBdAFIADQBeoFIADUBdEF
0AUNAAoAMQAxADIAOgDeBeYF0AUgANAF6gUgANQF5wXVBdMF3QUNAAoAMQAxADMAOgDUBdMF
0gXpBSAA1AXbBdwFDQAKAA0ACgAjACAATQBlAG4AdQANAAoAMwAyADcANgA4ADoA0AXVBdMF
1QXqBQ0ACgAzADIANwA2ADkAOgDRBdMF1QXnBSAA0AXdBSAA5wXZBdkF3QUgAOIF0wXbBdUF
3wUNAAoAMwAyADcANwAwADoA1AXqBdAF3QUgANAF2QXpBdkF6gUuAC4ALgANAAoADQAKACMA
IABPAHAAdABpAG8AbgAgAGQAaQBhAGwAbwBnAA0ACgAxADAANwA6ANQF6gXQBd0FIADQBdkF
6QXZBeoFIADQBeoFIABJAG4AbABpAG4AZQAgAFMAZQBhAHIAYwBoAA0ACgAxADAAOAA6AOkF
5AXUBQ0ACgAxADAAOQA6ANEF1wXoBSAA0AXqBSAA1AXpBeQF1AUgANQF3gXVBeIF0wXkBeoF
IADiBdwF2QXaBSAAOgANAAoAMQAxADAAOgDpBdkF4AXVBdkF2QXdBSAA0QXpBeQF1AUgANkF
1QXkBdkF4gXVBSAA0QXUBeQF4gXcBdQFIADUBdEF0AXUBSAA6QXcBSAASQBuAHQAZQByAG4A
ZQB0ACAARQB4AHAAbABvAHIAZQByAA0ACgA=

 hebrew.expected.lang = expected output 
# English v 1.4
1:עברית

101:ביטוי לא נמצא
102:הגיע לסוף הדף, ממשיך מראש הדף
103:גרסה חדשה של Inline Search נמצאה. לחץ על "כן" כדי לעבור לדף ההורדה.
104:יש לך את הגרסה האחרונה של Inline Search.
105:מצא :
106:התאם רישיות
111:מצא את הבא
112:מצא את הקודם
113:הדגש הכל

# Menu
32768:אודות
32769:בדוק אם קיים עדכון
32770:התאם אישית...

# Option dialog
107:התאם אישית את Inline Search
108:שפה
109:בחר את השפה המועדפת עליך :
110:שינויים בשפה יופיעו בהפעלה הבאה של Internet Explorer

Could someone enlighten me on how to go from hebrew.b64 to 
hebrew.expected.lang?

Thanks a lot,

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to find the present working directory using python.

2007-05-04 Thread pradeep nair
On May 4, 12:05 pm, SamG <[EMAIL PROTECTED]> wrote:
> On May 4, 12:03 pm, pradeep nair <[EMAIL PROTECTED]> wrote:
>
> > how to find out the present working directory using python.
>
> > os.system('pwd') works good. But i need some specific one in
> > python rather than embedding shell command into python.
>
> os.path.getcwd()



Thank u...

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


Re: Replacement for HTMLGen?

2007-05-04 Thread Gerrit Muller
 >
 > That said, can someone recommend a good replacement for
 > HTMLGen?
<...snip...>
 >  Granted, I know HTML doesn't change (much) but it's at least
 > nice to know something you're going to be using is maintained.
<...snip...>

Joshua,

I am happily using HTMLgen. I do think that maintenance has not been 
required, since HTML didn't change. It is pure Python, so it doesn't 
require any recompilation for Python updates.

If you need HTMLgen send me an e-mail and I will send you a zipfile.

kind regards, Gerrit Muller

-- 
Gaudi systems architecting:
http://www.gaudisite.nl/

> 
> That said, can someone recommend a good replacement for HTMLGen?  I've found
> good words about it (http://www.linuxjournal.com/article/2986), but every
> reference to it I find points to a non-existant page
> (http://starship.python.net/lib.html is 404,
> http://www.python2.net/lib.html is not responding,
> http://starship.python.net/crew/friedrich/HTMLgen/html/main.html is 404)
> Found http://www.python.org/ftp/python/contrib-09-Dec-1999/Network/, but
> that seems a bit old.
> 
> I found http://dustman.net/andy/python/HyperText, but it's not listed in
> Cheeseshop, and its latest release is over seven years ago.  Granted, I
> know HTML doesn't change (much) but it's at least nice to know something
> you're going to be using is maintained.
> 
> Any suggestions or pointers?
> 
> j
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urllib.quote fails on Unicode URL

2007-05-04 Thread Peter Otten
John Nagle wrote:

> The code in urllib.quote fails on Unicode input, when
> called by robotparser.
> 
> That bit of code needs some attention.
> - It still assumes ASCII goes up to 255, which hasn't been true in
> Python
>   for a while now.
> - The initialization may not be thread-safe; a table is being
> initialized
>   on first use.  The code is too clever and uncommented.
> 
> "robotparser" was trying to check if a URL,
>
"http://www.highbeam.com/DynamicContent/%E2%80%9D/mysaved/privacyPref.asp%22";
> could be accessed, and there are some wierd characters in there.  Unicode
> URLs are legal, so this is a real bug.
> 
> Logged in as Bug #1712522.

There has been a related discussion:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b331dc3625dbfc41/ce6e6a3c0635e340

IIRC the outcome was that while UTF-8 is recommended
urllib.quote()/unquote() should not guess the encoding.

What changes that would imply for robotparser I don't know...

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


Re: 32 OS on 64-bit machine

2007-05-04 Thread Hendrik van Rooyen
 "SamG" <[EMAIL PROTECTED]> wrote:

> If anyone has a x86_64 machine and is running a 32bit OS on top of
> that could you tell me what output would you get for the following
> program
> 
> #==
> import platform
> print platform.processor()
> print platform.architecture()
> #==
> 

not copy pasted - the new machine is not on the network yet
the answers look like:
i686
and
('32bit','')

Suse 10 gave me a warning during installation last night...
the machine is an HP Compaq Celeron D

- Hendrik

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


Re: base64 and unicode

2007-05-04 Thread Duncan Booth
EuGeNe Van den Bulke <[EMAIL PROTECTED]> wrote:

> >>> import base64
> >>> base64.decode(file("hebrew.b64","r"),file("hebrew.lang","w"))
> 
> It runs but the result is not correct: some of the lines in hebrew.lang 
> are correct but not all of them (hebrew.expected.lang is the correct 
> file). I guess it is a unicode problem but can't seem to find out how to 
> fix it.

My guess would be that your problem is that you wrote the file in text 
mode, so (assuming you are on windows) all newline characters in the output 
are converted to carriage return/linefeed pairs. However, the decoded text 
looks as though it is utf16 encoded so it should be written as binary. i.e.  
the output mode should be "wb".

Simpler than using the base64 module you can just use the base64 codec. 
This will decode a string to a byte sequence and you can then decode that 
to get the unicode string:

with file("hebrew.b64","r") as f:
   text = f.read().decode('base64').decode('utf16')

You can then write the text to a file through any desired codec or process 
it first.

BTW, you may just have shortened your example too much, but depending on 
python to close files for you is risky behaviour. If you get an exception 
thrown before the file goes out of scope it may not get closed when you 
expect and that can lead to some fairly hard to track problems. It is much 
better to either call the close method explicitly or to use Python 2.5's 
'with' statement.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing an array of variant in vb to a python COM object = win32com bug ?

2007-05-04 Thread vml
On 4 mai, 06:56, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Thu, 03 May 2007 09:41:57 -0300,vml<[EMAIL PROTECTED]> escribió:
>
> > On 3 mai, 14:20, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> >> En Thu, 03 May 2007 04:54:43 -0300,vml<[EMAIL PROTECTED]>
> >> escribió:
>
> >> > I have a python com object which contains a method to inverse an array
> >> > in vb 6 the definition of the class is :
>
> > I just tried to replace the *val by SqVal(self,val) and call the
> > method in vb but it crashes down :
>
> > "when refilling safe array the sequence must have the same number of
> > dimension as the existing array"
>
> That can't happen with your Python code below, so it must be on the
> caller. Maybe you wrote something like: xx=something.SqVal(yy) and xx,yy
> are declared of different sizes.
>

It is true that I call the python routine like that in vb :


 toto = obj.SqVal(ty)

If I am understanding well I need to pass an array of 2x2 and I should
retireve an array of variant of 2x2 

I tried to do that :
vb6 :

Dim obj As Object
Dim toto(1, 1, 2) As Variant

Set obj = CreateObject("Python.Fop")
Dim ty(1, 1, 2) As Variant

ty(0, 0, 0) = 1
ty(0, 1, 0) = 2
ty(0, 0, 1) = 3
ty(0, 0, 2) = 7
ty(0, 1, 1) = 4
ty(0, 1, 2) = 45

ty(1, 0, 0) = 1
ty(1, 1, 0) = 2
ty(1, 0, 1) = 3
ty(1, 0, 2) = 7
ty(1, 1, 1) = 4
ty(1, 1, 2) = 45



toto = obj.SqVal(ty)



but it is saying that the compiler can not assign the array toto at
the line toto=obj.SqVal() hum strange .



any ideas ?


Thank you for your help !






> >  def SqVal(self,val):
> > ## ...
> > return val
>
> > By the way Do you have any idea to debug the com server script ? ( I
> > would like to know if a can access the value in the function while
> > calling it from vb 6)
>
> Write a log file as suggested, or use OutputDebugString with the DebugView
> program fromwww.sysinternals.com
>
> --
> Gabriel Genellina


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


Re: tkinter listboxes

2007-05-04 Thread Eric Brunel
On Fri, 04 May 2007 05:26:56 +0200, <[EMAIL PROTECTED]> wrote:

> I will give a simplified example of the problem at hand --
>
> I have a case in which I have two listboxes - listbox1 and listbox2,
> if I click on an item in listbox1 the item gets highlighted as
> expected. Now if I click on an item in listbox2 the selected item in
> listbox1 loses its highlight. My question is how do I keep the
> listbox1 item from losing its highlight if I select an item in
> listbox2 or to that matter any other widget.

By default, the 'highlighting' is considered as a selection. Since you  
can't have two items selected at the same time, the second cancels the  
first. To avoid this behaviour, make each list keep its selection to  
itself by using the 'exportselection=0' option when you create the Listbox  
instance. This should work as you expect.

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


invoke user's standard mail client

2007-05-04 Thread [EMAIL PROTECTED]
Hello,

the simplest way to launch the user's standard mail client from a
Python program is by creating a mailto: URL and launching the
webbrowser:

def mailto_url(to=None,subject=None,body=None,cc=None):
"""
encodes the content as a mailto link as described on
http://www.faqs.org/rfcs/rfc2368.html
Examples partly taken from
http://selfhtml.teamone.de/html/verweise/email.htm
"""
url = "mailto:"; + urllib.quote(to.strip(),"@,")
sep = "?"
if cc:
url+= sep + "cc=" + urllib.quote(cc,"@,")
sep = "&"
if subject:
url+= sep + "subject=" + urllib.quote(subject,"")
sep = "&"
if body:
# Also note that line breaks in the body of a message MUST be
# encoded with "%0D%0A". (RFC 2368)
body="\r\n".join(body.splitlines())
url+= sep + "body=" + urllib.quote(body,"")
sep = "&"
return url

import webbrowser
url = mailto_url(...)
webbrowser.open(url,new=1)

(Excerpt from 
http://svn.berlios.de/wsvn/lino/trunk/src/lino/tools/mail.py?op=file&rev=0&sc=0)

But this method is limited: you cannot specify a file to be attached
to the mail. And I guess that there would be problems if the body text
is too complex.

Does somebody know about a better method?
It should be possible at least on Windows, since Acrobat Reader is
able to do it.

Thanks in advance for any hints!
Luc Saffre

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


Need Help

2007-05-04 Thread Komar Wijaya
Hello,

I'm a new guy in Linux. My name is Komar from Indonesia.
I am doing a project about GNU radio and i need to install wxPython.
I'm using fedora core 5 and suse 10.0 as my operating systems and using python 
2.4.

In Suse 10.0, I have search the internet and I found file 
'python-wxGTK-2..1.0-4.i586.rpm' and when I start to install the file there are 
so many errors like this:

error: Failed depedencies:
libwx_baseu-2.6.so is needed ..
libwx_baseu_net-2.6.so is needed
libwx_baseu_xml-2.6.so is needed
libwx_gtk2u_adv-2.6.so is needed
libwx_gtk2u_animate-2.6.so is needed
libwx_gtk2u_core-2.6.so is needed
libwx_gtk2u_gizmos-2.6.so is needed
libwx_gtk2u_gl-2.6.so is needed
libwx_gtk2u_html-2.6.so is needed
libwx_gtk2u_stc-2.6.so is needed
libwx_gtk2u_xrc-2.6.so is needed

Am I downloading wrong file? What is the solution?

In fedora core 5, I am downloading the file from wxPython.org and I downloaded 
file for fedora core 4. There are:

- wxPython-common-gtk2-unicode-2.8.3.0-fc4_py2.4.i386.rpm
- wxPython2.8-gtk2-unicode-2.8.3.0-fc4_py2.4.i386.rpm
- wxPython2.8-devel-unicode-2.8.3.0-fc4_py2.4.i386.rpm

The installation of wxPython-common-gtk2-unicode-2.8.3.0-fc4_py2.4.i386.rpm is 
succesfull but the installation of 
wxPython2.8-gtk2-unicode-2.8.3.0-fc4_py2.4.i386.rpm is failed and the error 
message appear like this:

' libgstgconf-0.8.so. is needed by wxPython2.8-gtk2-unicode-2.8.3.0
  libgstinterfaces-0.8.so is needed by wxPython2.8-gtk2-unicode-2.8.3.0
  libgstreamer-0.8.so is needed by wxPython2.8-gtk2-unicode-2.8.3.0
'

I don't understand about the error. Maybe you can help e solve the problem.

Thank you.

 Send instant messages to your online friends http://uk.messenger.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Getting some element from sets.Set

2007-05-04 Thread [EMAIL PROTECTED]
On May 4, 11:34 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > It is not possible to index set objects. That is OK.
> > But, what if I want to find some element from the Set.
>
> > from sets import Set
> > s = Set( range(12 )
>
> > if I do pop, that particular element gets removed.
> > I do not want to remove the element, but get some element
> >  from the Set.
>
> > s.some_element() # Is not available
>
> > Is there a way to do this. I am doing it like this:
>
> > for x in s: break
>
> > Now x is /some_element/ from s.
>
> A set is probably not the appropriate container then. What is your use case?
>
> Peter

Peter, I need to do a lot of union and intersection operations on
these elements. So, set is a must for me in this case.

In the particular case, I have to read an attribute from any one of
the elements, which one doesn't matter because this attribute value is
same across all elements in the set.

-
Suresh

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


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread mike3
On May 3, 12:14 am, malibu <[EMAIL PROTECTED]> wrote:
> On May 2, 9:46 pm, Eric Gisse <[EMAIL PROTECTED]> wrote:
>
> > On May 2, 7:10 pm, Midex <[EMAIL PROTECTED]> wrote:
>
> > [...]
>
> > I guess the explanation that people were looking at the building and
> > watching its' structure deform is too rational.
>
> Also, that was a Larry Silverstein impostor who
> said they were going to 'pull it'.
> And the only reason he took out huge amounts
> of extra insurance on the buildings two months
> before this happened was because of global
> warming, because we all know a little bit of heat
> will bring down steel buildings.
>
> John

Pull = pull out the firefighters. Also, did you know
that when they used "pull" to refer to pulling WTC6
it was because they were going to _pull it over_
not blow it up?

http://www.debunking911.com/pull.htm

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


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread mike3
On May 2, 9:10 pm, Midex <[EMAIL PROTECTED]> wrote:
> 100% EVIDENCE  - SEE THE TRUTH FINALLY - ON THE GROUND VIDEO 
> WITNESSEShttp://www.youtube.com/watch?v=YNN6apj5B2U
>
> In order to appreciate just what Truthers are talking about when they
> cry Treason over WTC7, you would want to see this History Channel
> documentary on what they claim happened to 
> WTC7:http://www.youtube.com/watch?v=TVSxeJH_RCY
>
> Ben Chertoff can't get his story 
> straighthttp://www.youtube.com/watch?v=9YND7XocMocj
>
> LIES LIES LIES LIES LIES
>
> 9/11 Truth Focoist Revolution. "When peaceful revolution is made
> impossible, violent revolution is inevitable" - Martin Luther King.
> How long shall they kill our prophets? Look up Focoism. Write about
> it. Spread the method. It will be how this revolution will take shape.

Maybe they were just speaking in the heat of the moment... or does
this mean that the FIREFIGHTERS were in on the conspiracy too?
Did you know that a conspiracy becomes more and more difficult
to do the bigger it gets? Do you also know that every structural
engineer, every scientist, all of NIST, everyone would have to be
"in" on this conspiracy?

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


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread mike3
On May 3, 9:53 am, malibu <[EMAIL PROTECTED]> wrote:
> On May 3, 12:18 am, Eric Gisse <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On May 2, 10:14 pm, malibu <[EMAIL PROTECTED]> wrote:
>
> > > On May 2, 9:46 pm, Eric Gisse <[EMAIL PROTECTED]> wrote:
>
> > > > On May 2, 7:10 pm, Midex <[EMAIL PROTECTED]> wrote:
>
> > > > [...]
>
> > > > I guess the explanation that people were looking at the building and
> > > > watching its' structure deform is too rational.
>
> > > Also, that was a Larry Silverstein impostor who
> > > said they were going to 'pull it'.
>
> > ...maybe if you read the context, it would make a little more rational
> > sense. Fucking nutter.
>
> > > And the only reason he took out huge amounts
> > > of extra insurance on the buildings two months
> > > before this happened was because of global
> > > warming, because we all know a little bit of heat
> > > will bring down steel buildings.
>
> > A little heat and major structural damage.
>
> > > John
>
> Gee, I'll bet all those explosions in the
> subfloors of WTC1 + WTC2 did some
> structural damage also!
>
> Come to think of it.
>
> When the firefighters got there, all the glass
> on the street floors was blown out.
>
> Shock wave from the plane hitting
> 80 floors up?
>
> Janitors and such coming up from the basement levels
> bleeding and dazed.
>
> Jet fuel trickling down the elevator shafts being ignited
> by someone's roach? And exploding?
> Severing the three-foot thick steel columns?
> All  5 dozen of them?
> (That's mighty fine primo, pardner!)
>
> Your brain got structural damage?
> Dropped on your head as a kid?
>
> Don't put that fire iron too close
> to the flames, honey. It'll melt
> and deform!
>

Never mind that the irons in the WTC
were IN the fire, amongst the coals
no less!

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


Re: My Python annoyances

2007-05-04 Thread Nick Craig-Wood
Thorsten Kampe <[EMAIL PROTECTED]> wrote:
>  He was using /Windows/ Python in Cygwin *chuckle*... Windows Python 
>  says Ctrl-Z because it doesn't know that it's been run from bash where 
>  Ctrl-Z is for job control.
> 
>  And the lesson we learn from that: if you're using Windows Python use 
>  a Windows shell. If you're using a Cygwin shell use Cygwin Python - 
>  unless you know what you're doing (which he wasn't).

I've noticed in the past that using cygwin python under a cygwin shell
is broken in some subtle ways when building extensions.  Using the
windows python build in a windows command windows always works though
(with mingw as the compiler).

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread mike3
On May 3, 7:22 pm, The Great Attractor
<[EMAIL PROTECTED]> wrote:
> On 3 May 2007 08:53:39 -0700, malibu <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> >On May 3, 12:18 am, Eric Gisse <[EMAIL PROTECTED]> wrote:
> >> On May 2, 10:14 pm, malibu <[EMAIL PROTECTED]> wrote:
>
> >> > On May 2, 9:46 pm, Eric Gisse <[EMAIL PROTECTED]> wrote:
>
> >> > > On May 2, 7:10 pm, Midex <[EMAIL PROTECTED]> wrote:
>
> >> > > [...]
>
> >> > > I guess the explanation that people were looking at the building and
> >> > > watching its' structure deform is too rational.
>
> >> > Also, that was a Larry Silverstein impostor who
> >> > said they were going to 'pull it'.
>
> >> ...maybe if you read the context, it would make a little more rational
> >> sense. Fucking nutter.
>
> >> > And the only reason he took out huge amounts
> >> > of extra insurance on the buildings two months
> >> > before this happened was because of global
> >> > warming, because we all know a little bit of heat
> >> > will bring down steel buildings.
>
> >> A little heat and major structural damage.
>
> >> > John
>
> >Gee, I'll bet all those explosions in the
> >subfloors of WTC1 + WTC2 did some
> >structural damage also!
>
>   You're an idiot.
>

You did not refute the claim. How do you
know this claim is wrong?

>
>
> >Come to think of it.
>
>  Slugs do not think.
>

You did not refute the claim.

>
>
> >When the firefighters got there, all the glass
> >on the street floors was blown out.
>
>   You're an idiot.
>

You did not refute the claim.

> >Shock wave from the plane hitting
> >80 floors up?
>
>   You're a goddamned retard, boy.  ARe you an islamic extremist by
> chance?
>

You did not refute the claim.

>
>
> >Janitors and such coming up from the basement levels
> >bleeding and dazed.
>
>   You're full of shit.
>

You did not refute the claim.


>
>
> >Jet fuel trickling down the elevator shafts being ignited
> >by someone's roach? And exploding?
>
>   You're an ifiot.
>

You did not refute the claim.

> >Severing the three-foot thick steel columns?
> >All  5 dozen of them?
> >(That's mighty fine primo, pardner!)
>
>   The buildings collapsed WAY WAY UP on the floors where the planes
> hit, and fell from there down, taking floors out as the large top
> section of the building fell.
>

First good argument so far...

>   You could be a bit more retarded, just not in this life.
>
> >Your brain got structural damage?
>
>   No, but your never was right from the moment your retarded felon
> criminal mother shat you out of her ass and forgot to flush.
>

You did not refute the claim.

> >Dropped on your head as a kid?
>
>  Got any more adolescent baby bullshit, little boy?
>

You did not refute the claim.

> >Don't put that fire iron too close
> >to the flames, honey. It'll melt
> >and deform!
>
>   You're an idiot.  There was a tanker crash in Oakland a couple days
> back (Sunday) that melted sections of the bridge it was on.

Second good argument so far.

Two good arguments and eight non-arguments,
but those two good arguments happen to clinch the thing
anyway...

>
>   Got Clue?  You and Rosie are retarded.

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



Re: invoke user's standard mail client

2007-05-04 Thread Tim Golden
[EMAIL PROTECTED] wrote:
> the simplest way to launch the user's standard mail client from a
> Python program is by creating a mailto: URL and launching the
> webbrowser:

[... snip code ...]

> But this method is limited: you cannot specify a file to be attached
> to the mail. And I guess that there would be problems if the body text
> is too complex.

> Does somebody know about a better method?
> It should be possible at least on Windows, since Acrobat Reader is
> able to do it.

I'm going to stick my neck out and say: I doubt
if there's one recognised, approved method. That
would require every email client to have a way
of accepting a command which said "Open up a new
email and put this, this, and this into that field,
that space, and that attachment." The only thing
I can think of which comes close is the mailto:
protocol you refer to, but according to its RFC

   http://www.faqs.org/rfcs/rfc2368.html

the only fields allowed are headers and the special
case of "body" which, as you point out, is hardly
intended for embedded attachments.

I would imagine that Acrobat must special case
known email clients and probably won't work for
some obscure client. Thunderbird, for example,
seems (haven't tried it) to allow for an attachment:

   http://www.mozilla.org/docs/command-line-args.html

Doubtless Outlook has some equivalent mechanism. After
that, you're down to looking at docs for Eudora, Pine,
etc.

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


Re: Getting some element from sets.Set

2007-05-04 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> On May 4, 11:34 am, Peter Otten <[EMAIL PROTECTED]> wrote:

>> A set is probably not the appropriate container then. What is your use
>> case?

> Peter, I need to do a lot of union and intersection operations on
> these elements. So, set is a must for me in this case.
> 
> In the particular case, I have to read an attribute from any one of
> the elements, which one doesn't matter because this attribute value is
> same across all elements in the set.

Convinced -- I lacked the imagination for this scenario :-)

Peter

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


Lisp for the C21

2007-05-04 Thread Mark Tarver
QUOTE
Python has readable syntax, a huge library, and bindings for what
seems like every major in linux. Perl has CPAN. It seems with those
languages if you want to do something all you have to do is import
functionality from a library someone had written and use that.

In lisp you'd have to "roll your own".

Why should I keep on learning lisp when there are python and perl?
UNQUOTE

I can see where this guy is coming from (though I can't find the
original post any more (?)).

See my remarks on the Lisp for the Twenty First Century

http://www.lambdassociates.org/lC21.htm

for our take on this one.

Mark


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


Re: My Python annoyances

2007-05-04 Thread Ross Ridge
Thorsten Kampe  <[EMAIL PROTECTED]> wrote:
>He was using /Windows/ Python in Cygwin *chuckle*... Windows Python 
>says Ctrl-Z because it doesn't know that it's been run from bash where 
>Ctrl-Z is for job control.

No, if you run Windows Python from Cygwin bash CTRL-Z works as the
EOF character:

~$ /cygdrive/e/util/python24/python
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit
'Use Ctrl-Z plus Return to exit.'
>>> ^Z

~$ jobs
~$ python
Python 2.5 (r25:51908, Mar 13 2007, 08:13:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>>
[1]+  Stopped python
~$ 

Apparently though the Cygwin version of Python now prints the correct
message for quit.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why stay with lisp when there are python and perl?

2007-05-04 Thread Tim Bradshaw
On May 4, 3:06 am, Jon Harrop <[EMAIL PROTECTED]> wrote:
>
> Lisp compilers are much more advanced, for one thing.

Though I hesitate to respond in this thread (and I didn't actually
read the rest of the article) there's actually a valid point here.

The last programming job I did involved doing some search stuff in
Python.  I think Python had been chosen for almost (but actually not)
good reasons - people really wanted to use Lisp but it would have been
too hard (politically and technically), and the same people had recent
first-hand experience of some of the worse horrors of J2EE programming
so were negative about Java.  Finally Python actually had the required
stuff (the ability to mmap files was critical to the proposed
technique for doing the search).  (The reasons were actually not good
because Java could have done it as well, and if we'd had the courage
we could have done a POJO-style Java thing which would have been fine
and set a good example to other people, which as it was we failed
dismally to do.  On the other hand they'd not have hired me - despite
the fact that even by then I didn't care about language choice with a
few exceptions (C++), I didn't look enough like a Java person (and
still don't of course).)

Anyway the experience of writing in Python was kind of interesting.
It had the usual single-implementation issues common to such things
which meant we depended on the right version (and I think a later
version than the one shipped with the OS since they'd decided to
change semantics in some quite major way at some point).  But apart
from that writing programs that performed well (for us - we actually
had performance issues since we wanted to look at a lot of data)
turned out to be a matter of making sure that all the performance-
critical bits were done in libraries (in C) with Python merely a kind
of elaborate glue to get in the way.  It was a bit like writing code
for an array processor or a DSP or something, except without any good
hardware reason for it.  So one of the things I learned was "use a
language with a decent compiler"[*] I think.

--tim

[*] No glib comments about Java not having a decent compiler: actually
typical implementations do now (or did in 2004/5 and I bet they are
better now).

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


Re: Why stay with lisp when there are python and perl?

2007-05-04 Thread Tim Bradshaw
On May 4, 10:13 am, Tim Bradshaw <[EMAIL PROTECTED]> wrote:

> Anyway the experience of writing in Python was kind of interesting.
> [...] So one of the things I learned was "use a
> language with a decent compiler"[*] I think.

Bugger, I did not realise until too late that this was going to
comp.lang.python as well.  I should therefore add a caveat: Use a
language with a high-performance (this is what I meant by "decent")
compiler if that kind of performance matters to you.  It did to us,
but there are very many cases where it does not. In other words,
despite appearances I'm not particularly trying to slag off Python.

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


Re: DiffLib Question

2007-05-04 Thread whitewave
> Usually, Differ receives two sequences of lines, being each line a  
> sequence of characters (strings). It uses a SequenceMatcher to compare  
> lines; the linejunk argument is used to ignore certain lines. For each  
> pair of similar lines, it uses another SequenceMatcher to compare  
> characters inside lines; the charjunk is used to ignore characters.
> As you are feeding Differ with a single string (not a list of text lines),  
> the "lines" it sees are just characters. To ignore whitespace and  
> newlines, in this case one should use the linejunk argument:
>
> def ignore_ws_nl(c):
>return c in " \t\n\r"
>
> a =difflib.Differ(linejunk=ignore_ws_nl).compare(d1,d2)
> dif = list(a)
> print ''.join(dif)
>
>I  n a  d  d  i  t  i  o  n  , t  h  e c  o  n  s  i  d  e  
> r  e
> d p  r  o  b  l  e  m d  o  e  s n  o  t h  a  v  e  
> a m
>   e  a  n  i  n  g  f  u  l t  r  a  d  i  t  i  o  n  a  l t  y  
> p  e
>o  f-  +
>a  d  j  o  i  n  t-
> +p  r  o  b  l  e  m e  v  e  n f  o  r t  h  e s  i  
> m  p
> l  e f  o  r  m  s o  f t  h  e d  i  f  f  e  r  e  n  t  
> i  a
>   l e  q  u  a  t  i  o  n a  n  d t  h  e n  o  n  l  o  
> c  a  l
>   c  o  n  d  i  t  i  o  n  s  . D  u  e-  +
>t  o t  h  e  s  e f  a  c  t  s  , s  o  m  e s  e  r  
> i  o
> u  s d  i  f  f  i  c  u  l  t  i  e  s a  r  i  s  e i  n  
> t  h
>   e a  p  p  l  i  c  a  t  i  o  n o  f t  h  e c  l  a  
> s  s  i
>c  a  l m  e  t  h  o  d  s t  o s  u  c  h a-  +
>p  r  o  b  l  e  m  .+
>

Thanks! It works fine but I was wondering why the result isn't
consistent. I am comparing two huge documents with several paragraphs
in it. Some parts in the paragraph returns the diff perfectly but
others aren't. I am confused.

Thanks.
Jen

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


Re: base64 and unicode

2007-05-04 Thread EuGeNe Van den Bulke
Duncan Booth wrote:
> However, the decoded text looks as though it is utf16 encoded so it should be 
> written as binary. i.e.  
> the output mode should be "wb".

Thanks for the "wb" tip that works (see bellow). I guess it is 
experience based but how could you tell that it was utf16 encoded?

> Simpler than using the base64 module you can just use the base64 codec. 
> This will decode a string to a byte sequence and you can then decode that 
> to get the unicode string:
> 
> with file("hebrew.b64","r") as f:
>text = f.read().decode('base64').decode('utf16')
> 
> You can then write the text to a file through any desired codec or process 
> it first.

 >>> with file("hebrew.lang","wb") as f:
 >>> ... file.write(text.encode('utf16'))

Done ... superb!

> BTW, you may just have shortened your example too much, but depending on 
> python to close files for you is risky behaviour. If you get an exception 
> thrown before the file goes out of scope it may not get closed when you 
> expect and that can lead to some fairly hard to track problems. It is much 
> better to either call the close method explicitly or to use Python 2.5's 
> 'with' statement.

Yes I had shortened my example but thanks for the 'with' statement tip 
... I never think about using it and I should ;)

Thanks,

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
mike3 wrote:
> On May 2, 9:10 pm, Midex <[EMAIL PROTECTED]> wrote:
>> 100% EVIDENCE  - SEE THE TRUTH FINALLY - ON THE GROUND VIDEO 
>> WITNESSEShttp://www.youtube.com/watch?v=YNN6apj5B2U
>>
>> In order to appreciate just what Truthers are talking about when they
>> cry Treason over WTC7, you would want to see this History Channel
>> documentary on what they claim happened to 
>> WTC7:http://www.youtube.com/watch?v=TVSxeJH_RCY
>>
>> Ben Chertoff can't get his story 
>> straighthttp://www.youtube.com/watch?v=9YND7XocMocj
>>
>> LIES LIES LIES LIES LIES
>>
>> 9/11 Truth Focoist Revolution. "When peaceful revolution is made
>> impossible, violent revolution is inevitable" - Martin Luther King.
>> How long shall they kill our prophets? Look up Focoism. Write about
>> it. Spread the method. It will be how this revolution will take shape.
> 
> Maybe they were just speaking in the heat of the moment... or does
> this mean that the FIREFIGHTERS were in on the conspiracy too?
> Did you know that a conspiracy becomes more and more difficult
> to do the bigger it gets? Do you also know that every structural
> engineer, every scientist, all of NIST, everyone would have to be
> "in" on this conspiracy?
> 

Not entirely.

"A nobleman from the Baltic states, Freytag von Loringhoven was viewed 
with suspicion by the Nazis 'who loathed education, real culture and 
tradition'. Unlike Hitler's secretary, Traudl Junge, whose memoirs were 
published before her death two years ago, he claims he never fell under 
the Führer's spell and insists the distinction between the professional 
Wehrmacht and politicised Waffen-SS was real. 'After the war I had the 
unpleasant feeling of having served as a combustible, as heating wood, 
for the adventures of a charlatan,' he says. 'I had served a criminal 
regime while remaining loyal to my military convictions.'

It was only as a prisoner of war that he realised the Nazis had murdered 
Jews 'on an industrial scale', he says. ' We didn't even know the names 
of the concentration camps.'"

http://www.guardian.co.uk/germany/article/0,2763,1446410,00.html

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


Re: OT somewhat: Do you telecommute? What do you wish the boss understood about it?

2007-05-04 Thread Anton Vredegoor
estherschindler wrote:

> * If you telecommute, full- or part-time, what *one* thing do you wish
> the CIO or IT Management would understand that they don't currently
> "get"?

I'm not currently telecommuting but last year I had a telecommuting job 
for half a year. What I would want to say to all future employers 
considering to hire telecommuting personnel is : Don't let the 
telecommuter pay the extra costs that are caused by telecommuting. And I 
don't mean only the financial aspects, I also mean the immaterial costs.

For example if one is working at home it can be hard for an employer to 
check whether the work is still progressing and if there are no 
immediate results there can be some suspicion that the employee is just 
sitting at home watching television or is out shopping, because hey, 
there's no way to check that anyway and people tend to become lazy if no 
one is watching them? So the employer can become tempted to find ways to 
check upon his employee by other means. Why not let him write a daily 
report of his activities even if you never read it? Why not ask for an 
open MSN chat window at all times so that one can check how fast the 
employee is responding? Is he at his desk *right now*?

These are all things that are not usually asked of the people sitting in 
the main office and create an extra burden for the employee. In fact the 
employee gets burdened with the costs of the employers insecurities. If 
one doesn't trust the employee then don't hire him or don't let him 
telecommute in the first place!

Then there are other aspects. For example sometimes I had to use an 
expensive mobile Internet connection when I was on the road or when the 
Internet connection at home didn't work. It was some account that lets 
one use some amount of megabytes for free but after that was used up 
there were high costs for each further megabyte. It was certainly the 
wrong kind of subscription but sometimes it's hard to determine whether 
one buys an expensive flat rate subscription with the risk of all this 
money never being used because one is using the home Internet connection 
all the time. On the other hand things can really get expensive if one 
has the cheap fixed megabytes type of account and the home Internet 
connection fails for an extended period or if one has to be on location 
often.

So sometimes the wrong business decision was made. But if someone at the 
workplace has a HD crash or some other costly error happens this is 
normally not something the employee has to pay for. If one is informed 
about the costs and one doesn't read the emails but just says "fix that 
server malfunction *now*, don't mind the connection costs" one should 
not be scolding the employee for the large bills that appear one month 
later.

Then there are things like travel costs and hotel costs, say we want the 
employee to be present at the office for a few days each month, the 
employee can pay for it in advance and the employer will reimburse him 
later on. Normally employees get a fixed paycheck each month and there 
are few extra costs involved and things can get arranged quickly.

However the extra costs for the telecommuter are highly variable and so 
there can be a situation where one has payed in advance out of ones own 
pocket and one has to ask more than once to receive the money back. If 
one has to ask too often this can be highly demoralizing, because this 
is time and money spent on the company without earning anything.

The employer maybe starts to think: "Hey this guy is living in an 
expensive hotel and eating in restaurants while other people go there to 
have a vacation, so why should I have to pay for that?" Well for the 
employee it's a completely different story, hotel rooms aren't fun if 
one arrives late at night and leaves early in the morning and cities 
remain tantalizing mysteries if one never has the time to do some 
sightseeing.

There is also the idea that working at home is some luxurious privilege 
that the employee should be thankful for. I can tell you that even the 
nicest home can become a prison if one has to be there all the time. In 
fact any escape can be a relief so one is thankful to spend some time in 
a hotel room ... But that doesn't mean it's vacation! No way. It's just 
that other people get out of their homes normally at the beginning of 
the day, a telecommuter *has* to go out for a walk or go bicycling for 
half an hour or so during lunch break just to keep fit. A normal 
employee can integrate that into his routine of coming to work and 
having lunch at a nearby restaurant.

So all in all my conclusion is, if one wants the employee to be happy 
and loyal, don't destroy his good intentions by letting him pay for all 
kinds of luxuries that he didn't ask for and that aren't even much fun 
anyway. Even though such things might seem the most desirable working 
environments for those having to work in a crowded office where they 
have to go to each day, sitting al

Antigen Notification: Antigen found a message matching a filter

2007-05-04 Thread Antigen_VITORIA
Microsoft Antigen for Exchange found a message matching a filter. The message 
is currently Detected.
Message: "Python_list Digest_ Vol 44_ Issue 70"
Filter name: "KEYWORD= spam: Did you know"
Sent from: "[EMAIL PROTECTED]"
Folder: "SMTP Messages\Inbound And Outbound"
Location: "ITURAN/First Administrative Group/VITORIA"


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


Non blocking sockets with select.poll() ?

2007-05-04 Thread Maxim Veksler
Hi,

I'm trying to write a non blocking socket port listener based on
poll() because select is limited to 1024 fd.

Here is the code, it never gets to "I did not block" until I do a
telnet connection to port 1.

"""
#!/usr/bin/env python
import socket
import select

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(0)
s.bind(('0.0.0.0', 1))
s.listen(5)

__poll = select.poll()
__poll.register(s)
__poll.poll()

print "I did not block"
"""

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why stay with lisp when there are python and perl?

2007-05-04 Thread Pascal Costanza
Jon Harrop wrote:

> It is worth noting that eager, statically-typed languages like OCaml and F#
> are many times faster than the other languages at this task. This is
> precisely the forte of OCaml and F#, manipulating trees and graphs.

Here is a page that sums up some important observations about 
benchmarks: http://www.ccs.neu.edu/home/will/Twobit/bmcrock.temp.html

Especially:

- "With modern superscalar architectures, 5-level memory hierarchies, 
and wide data paths, changing the alignment of instructions and data can 
easily change the performance of a program by 20% or more, and Hans 
Boehm has witnessed a spectacular 100% variation in user CPU time while 
holding the executable file constant. Since much of this alignment is 
determined by the linker, loader, and garbage collector, most individual 
compiler optimizations are in the noise. To evaluate a compiler 
properly, one must often look at the code that it generates, not the 
timings."

- "The execution time of a program is often dominated by the time spent 
in very small pieces of code. If an optimizing compiler happens to do a 
particularly good job of optimizing these hot spots, then the program 
will run quickly. If a compiler happens to do an unusually poor job of 
optimizing one or more of these hot spots, then the program will run 
slowly."

- "If the hot spots occur within library routines, then a compiler may 
not affect the performance of the program very much. Its performance may 
be determined by those library routines."

- "The performance of a benchmark, even if it is derived from a real 
program, may not help to predict the performance of similar programs 
that have different hot spots."



Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check if a string is empty in python?

2007-05-04 Thread Jaswant
This is  a simple way to do it i think


s=hello

>>> if(len(s)==0):
... print "Empty"
... else:
... print s
...
hello

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


is there a module to work with pickled objects storage in database?

2007-05-04 Thread krishnakant Mane
hello all,
I am trying a very complex kind of a task in a project.
I have a knowledge management system where I need to store a lot of
objects (pickled).  I have to store mostly lists and dictionaries into
a rdbms.
mostly I will be using mysql.  I want to know if there is any module
that can help me store a pickled object inside a blob field instead of
a file.  I know that pickle.dump() can store an object into a file but
I can't find a way to transfer pickled objects into a database.
I so far tried to read a dumpped file for pickled object and directly
right the contents of the file to the blob field in my database.
but that does not seam to give the right result.
I first dump the object into the file through pickle.dump and then
open the file in read mode.
then I read the contents of the file and then store what ever comes
out into the blob field.
I know this is not right and there should be ways of storing a pickled
object other than file.
Please guide me on this issue.
regards.
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list


High resolution sleep (Linux)

2007-05-04 Thread John

The table below shows the execution time for this code snippet as
measured by the unix command `time':

for i in range(1000):
time.sleep(inter)

inter   execution time  ideal
0 0.02 s0 s
1e-44.29 s0.1 s
1e-34.02 s1 s
2e-34.02 s2 s
5e-38.02 s5 s

Hence it seems like the 4 s is just overhead and that the time.sleep
method treats values below approximately 0.001 as 0.

Is there a standard way (or slick trick) to get higher resolution? If
it is system dependent it's acceptable but not very nice :)

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


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
default wrote:
> On 2 May 2007 20:10:20 -0700, Midex <[EMAIL PROTECTED]> wrote:
> 
>> LIES LIES LIES LIES LIES
> 
> Trying to understand the World Trade Center events is like waking up
> to act fifteen of a long Greek Tragedy. It needs a complex fabric of
> description to give a full picture. In explaining this crisis, we will
> be showing how the situation rests on layers of historical
> developments, layers of crises and solutions.
> 
> shamelessly taken from:
> http://www.againstsleepandnightmare.com/ASAN/ASAN7/ASAN7.html
> 
> The World After September 11th, 2001
> 
> The Old Mole
> 
> By the time you read this, a crisis different from September 11th may
> well be foremost in people's minds. Read on. For us today, all the
> crises merge to one and we can see the form of Enron's Collapse or the
> Iraq War within September 11th and vice-versa. Now, beyond the death
> and destruction, the horror of an event like September 11th is the
> horror of losing control of your world. This feeling is an extension
> of the ordinary experience of being a resident of modern capitalist
> society. Here, work, commuting, shopping, and television are
> transmitted to you in ways that are beyond any individual or
> collective control. 
> 
> Damn good read. 

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


Re: is there a module to work with pickled objects storage in database?

2007-05-04 Thread Paul Boddie
On 4 Mai, 12:18, "krishnakant Mane" <[EMAIL PROTECTED]> wrote:
>
> I first dump the object into the file through pickle.dump and then
> open the file in read mode.
> then I read the contents of the file and then store what ever comes
> out into the blob field.
> I know this is not right and there should be ways of storing a pickled
> object other than file.

Try pickle.dumps to produce a string containing the pickled object.
Obviously, you then need to supply the string to the database using
the normal DB-API mechanisms. That said, although I haven't done much
work with BLOBs in the DB-API, it would surprise me if it were not
possible with some database modules to pass a file-like object as a
parameter to the cursor's execute method, although I don't recall
there being any classes whose objects act like files and produce
pickled objects on demand.

Paul

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


Newbie and Page Re-Loading

2007-05-04 Thread mosscliffe
I am very new to this python world, but I do like the look of the
language / syntax, though I have had some problems with indenting
using a text editor.

I have managed to get my ISP to execute .py files on their server.

I have created a .py file and it does in fact do the various little
tasks I have asked it to do.

Now i need to get a bit more serious.

I wish to have a web page with a search form at the top and on
processing the form re-load my current page, but with the various
search results.

Do I just add my script name to the Action part of the Form and how
can I pass variables, other than form variables to each execution of
the script.  If I have to use hidden form variables, how would I alter
them for each page.

I suppose I am looking for some sort of session management, but I have
not been able to track one down as yet.  I am running on an ISP, with
no knowledge of python, so asking about getting packages loaded will
not be an option.

I have 'Python in a Nutshell', but it is a bit sparse on everyday web
page examples.

Any help with regard to simple examples or tutorials would be most
useful.

Thanks

Richard

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


ftplib acting weird

2007-05-04 Thread Merrigan
Hi All,

I have written a little script to upload some files to an ftp folder.
The problem is as follows :

I wrote the script on my windows laptop, and I want to run it from
mylinux server. Everything worked fine so I uploaded it to my linux
machine. Every time I tun the script I get the following error:

***

[EMAIL PROTECTED] ftpsync]# python ftpsync.py
!!
The Connection to the Server Could not be established.
Please Check all neccesary settings and run the script again.
Thank you
!!
Traceback (most recent call last):
  File "ftpsync.py", line 194, in ?
ftplisting()
  File "ftpsync.py", line 83, in ftplisting
ftpconn.cwd(remotedir) #This changes to the remote directory
  File "/usr/lib64/python2.4/ftplib.py", line 494, in cwd
return self.voidcmd(cmd)
  File "/usr/lib64/python2.4/ftplib.py", line 245, in voidcmd
self.putcmd(cmd)
  File "/usr/lib64/python2.4/ftplib.py", line 175, in putcmd
self.putline(line)
  File "/usr/lib64/python2.4/ftplib.py", line 170, in putline
self.sock.sendall(line)
AttributeError: 'NoneType' object has no attribute 'sendall'
[EMAIL PROTECTED] ftpsync]#

***

When I copy the same piece of scripting and run it from the python
command shell, it works...

what am I doing wrong? I have double checked everything about a
million times, but to no avail.

Blessings!

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


Re: Active Directory: how to delete a user from a group?

2007-05-04 Thread Dirk Hagemann
On 2 Mai, 17:48, Tim Golden <[EMAIL PROTECTED]> wrote:
> Tim Golden wrote:
> >Dirk Hagemannwrote:
> >> Hi!
>
> >> Does anyone has experience with manipulating MS Active Directory
> >> objects? I'd like to delete some users from a group, but so far I
> >> couldn't find anything about this.
> >> There is some good stuff about retrieving data out of the AD (thanks
> >> to Tim Golden!), but how can I manipulate or change AD objects like
> >> users, computers and groups with Python? Is there somewhere a
> >> documentation or some code?
>
> > I freely admit I don't do too much changing of AD objects,
> > but my module should at least support the methods for doing
> > things. Some examples in Active Directory Cookbook:
>
> >http://techtasks.com/code/viewbook/2
>
> Sorry, you wanted to remove a user *from a group*. Misread.
>
> Translated fromhttp://techtasks.com/code/viewbookcode/1626
>
> 
> import active_directory
> group = active_directory.find_group ("name-of-group")
> # or group = active_directory.AD_object ("group-moniker")
>
> user = active_directory.find_user ("name-of-user")
> # or user = active_directory.AD_object ("user-moniker")
>
> group.Remove (user.path ())
>
> 
>
> Obviously, for something this simple using an extra module
> is overkill. You might as well:
>
> 
> import win32com.client
>
> group = win32com.client.GetObject ("group-moniker")
> group.Remove ("user-moniker")
>
> 
>
> NB I haven't tried these, I've just translated them
> from the Cookbook site!
>
> TJG

Hi Tim!

The first code does exactly what I want - thanks a lot again for your
help.

Dirk

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


Re: How to check if a string is empty in python?

2007-05-04 Thread Tim Williams
On 4 May 2007 03:02:37 -0700, Jaswant <[EMAIL PROTECTED]> wrote:
> This is  a simple way to do it i think
>
>
> s=hello
>
> >>> if(len(s)==0):
>  print "Empty"
>  else:
>  print s
> 
> hello

Not as simple as   " If not s: "

and nowhere near as simple as  "  print s or 'Empty'  "   :) :)


>>> s = ''
>>> print s or 'Empty'
Empty
>>> s = 'hello'
>>> print s or 'Empty'
hello
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are functions atomic?

2007-05-04 Thread Dustan
On May 4, 1:36 am, Michael <[EMAIL PROTECTED]> wrote:
> On May 2, 6:08 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
>
> > On Tue, 2007-05-01 at 22:21 -0700, Michael wrote:
> > > Is there a reason for using the closure here?  Using function defaults
> > > seems to give better performance:[...]
>
> > It does? Not as far as I can measure it to any significant degree on my
> > computer.
>
> I agree the performance gains are minimal.  Using function defaults
> rather than closures, however, seemed much cleaner an more explicit to
> me.  For example, I have been bitten by the following before:
>
> >>> def f(x):
>
> ... def g():
> ... x = x + 1
> ... return x
> ... return g>>> g = f(3)
> >>> g()
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "", line 3, in g
> UnboundLocalError: local variable 'x' referenced before assignment
>
> If you use default arguments, this works as expected:>>> def f(x):
>
> ... def g(x=x):
> ... x = x + 1
> ... return x
> ... return g
> >>> g = f(3)
> >>> g()
>
> 4

>>> g()

4

>>> g()

4

>>> g() # what is going on here

4

> The fact that there also seems to be a performance gain (granted, it
> is extremely slight here) led me to ask if there was any advantage to
> using closures.  It seems not.
>
> > An overriding theme in this thread is that you are greatly concerned
> > with the speed of your solution rather than the structure and
> > readability of your code.
>
> Yes, it probably does seem that way, because I am burying this code
> deeply and do not want to revisit it when profiling later, but my
> overriding concern is reliability and ease of use.  Using function
> attributes seemed the best way to achieve both goals until I found out
> that the pythonic way of copying functions failed.  Here was how I
> wanted my code to work:
>
> @define_options(first_option='abs_tol')
> def step(f,x,J,abs_tol=1e-12,rel_tol=1e-8,**kwargs):
>"""Take a step to minimize f(x) using the jacobian J.
>Return (new_x,converged) where converged is true if the tolerance
>has been met.
>"""
>
>return (x + dx, converged)
>
> @define_options(first_option='min_h')
> def jacobian(f,x,min_h=1e-6,max_h=0.1):
>"""Compute jacobian using a step min_h < h < max_h."""
>
>return J
>
> class Minimizer(object):
> """Object to minimize a function."""
> def __init__(self,step,jacobian,**kwargs):
> self.options = step.options + jacobian.options
> self.step = step
> self.jacobian = jacobian
>
> def minimize(self,f,x0,**kwargs):
> """Minimize the function f(x) starting at x0."""
> step = self.step
> jacobian = self.jacobian
>
> step.set_options(**kwargs)
> jacobian.set_options(**kwargs)
>
> converged = False
> while not converged:
> J = jacobian(f,x)
> (x,converged) = step(f,x,J)
>
> return x
>
> @property
> def options(self):
> """List of supported options."""
> return self.options
>
> The idea is that one can define different functions for computing the
> jacobian, step etc. that take various parameters, and then make a
> custom minimizer class that can provide the user with information
> about the supported options etc.
>
> The question is how to define the decorator define_options?
>
> 1) I thought the cleanest solution was to add a method f.set_options()
> which would set f.func_defaults, and a list f.options for
> documentation purposes.  The docstring remains unmodified without any
> special "wrapping", step and jacobian are still "functions" and
> performance is optimal.
>
> 2) One could return an instance f of a class with f.__call__,
> f.options and f.set_options defined.  This would probably be the most
> appropriate OO solution, but it makes the decorator much more messy,
> or requires the user to define classes rather than simply define the
> functions as above.  In addition, this is at least a factor of 2.5
> timese slower on my machine than option 1) because of the class
> instance overhead.  (This is my only real performance concern because
> this is quite a large factor.  Otherwise I would just use this
> method.)
>
> 3) I could pass generators to Minimize and construct the functions
> dynamically.  This would have the same performance, but would require
> the user to define generators, or require the decorator to return a
> generator when the user appears to be defining a function.  This just
> seems much less elegant.
>
> ...
> @define_options_generator(first_option='min_h')
> def jacobian_gen(f,x,min_h=1e-6,max_h=0.1):
>"""Compute jacobian using a step min_h < h < max_h."""
>
>return J
>
> class Minimizer(object):
> """Object to minimize a function."""
> def __init__(self,step_gen,jacobian_gen,**kwargs):
> self.options = step_gen.options + jacobian_gen.options
> self.step_gen = step_gen
> self.jacobian_gen

Re: Non blocking sockets with select.poll() ?

2007-05-04 Thread Jean-Paul Calderone
On Fri, 4 May 2007 13:04:41 +0300, Maxim Veksler <[EMAIL PROTECTED]> wrote:
>Hi,
>
>I'm trying to write a non blocking socket port listener based on
>poll() because select is limited to 1024 fd.
>
>Here is the code, it never gets to "I did not block" until I do a
>telnet connection to port 1.
>

What were you expecting?

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


Re: 4 quadrant atan

2007-05-04 Thread Roel Schroeven
Charles Sanders schreef:
> Roel Schroeven wrote:
>> I might be wrong of course, but can't you just use atan2? Only problem 
>> is that it returns negative angles for quadrants 3 and 4, but that is 
>> easily solved. In Python:
>>
>> from math import atan2, pi, fmod
>> def vectorAngle(x, y):
>> return fmod(atan2(y, x) + 2*pi, 2*pi)
>>
>> No conditionals in sight.
>>
> 
>   Yes, but there will be some conditionals for special
> cases in the implementation of atan2().

That's true, but the user of the atan2() doesn't need to concern himself 
with it; that's what I meant with 'in sight'.

> 
>   I am pretty sure that in Python (and Perl) atan2() is
> the C atan2() from the C math library, also often used by
> Fortran.

I'm pretty sure too: the Python 2.4 documentation says "The math module 
consists mostly of thin wrappers around the platform C math library 
functions."

>   This is normally written in assembler for the individual
> architecture by the hardware vendor or compiler writer, is usually
> heavily optimized, carefully handles all the corner cases, and
> often carries extra precision to ensure accuracy.

Yep, and that's why I prefer using that instead of trying to roll my 
own. And because it leverages the speed of the FPU on platforms where it 
is implemented in hardware.

I believe the FPU's of the i386 family have it in their instruction set. 
I even believe there are no instructions for asin, atan and acos; they 
are all calculated using FPATAN which calculates atan2.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: Calling Exe from Python

2007-05-04 Thread Rex Turnbull
muhamad.abbas :
> Hello Folks,
> 
> This is what i am required to do.
> Call an executable from my python script, and when the executable is
> finished running, i should continue with my python script.
> 
> I have tried "os.exec()" but it calls the executable and never returns
> to the calling python script.
> I tried "os.fork" it will start an independent process,
> since logic of my program depends on the results of executable.
> 
> I am unable to figure, how to do it.
> Hope you folks would help me.
> 
> ~JinBaba
> 
I use
import os
os.spawnl(os.P_WAIT, pathToExe, pathToExe, parm1, parm2, parm3,  )

Remember that pathToExe must also be the first parameter.
There are many other flavors of os.spawn, check documentation!

Good luck,
Rex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Non blocking sockets with select.poll() ?

2007-05-04 Thread Maxim Veksler
On 5/4/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Fri, 4 May 2007 13:04:41 +0300, Maxim Veksler <[EMAIL PROTECTED]> wrote:
> >Hi,
> >
> >I'm trying to write a non blocking socket port listener based on
> >poll() because select is limited to 1024 fd.
> >
> >Here is the code, it never gets to "I did not block" until I do a
> >telnet connection to port 1.
> >
>
> What were you expecting?
>

I'll try to explain.
I'm doing a little experiment: Capturing the whole tcp 1-65535 range
of the machine, allowing me to connect to the my service on the
machine on every port. I know that it's probably the most dumb thing
to do with TCP/IP communication please don't forget it's an
experiment.

My first attempt was made with select.select please see here
http://article.gmane.org/gmane.comp.python.general/516155/ and the
next attempt for slice-by 1024 which also didn't work, here:
http://article.gmane.org/gmane.comp.python.general/517036/

Now, after I realized I won't be able to implement this using
select.select I turned to select.poll(). My problem now it that I'm
able to register more then 1024 socket fd but now I can't replicate
the behaviour select gave me. When I used select for <1024 sockets, I
was able to telnet to each of the 1024 ports and select.select would
return the proper object to do accept() on it, shortly speaking: no
exception was thrown, you can see the working code in the second link
above. The situation I have now with the code attached below is that
if I try querying one of the registered ports I get the following :

TERM1:
"""
./listener_sockets_range_poll.py
.
.
Asking 10182
Asking 10183
Asking 10184
Asking 10185
Asking 10186
Found 10186
Traceback (most recent call last):
  File "./listener_sockets_range_poll.py", line 35, in 
conn, addr = nb_active_socket.accept()
  File "/usr/lib/python2.5/socket.py", line 167, in accept
sock, addr = self._sock.accept()
socket.error: (11, 'Resource temporarily unavailable')
"""

TERM2:
"""
telnet localhost 10100
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
"""

and the code running is this:
"""
#!/usr/bin/env python
import socket
import select

class PollingSocket(socket.socket):
__poll = select.poll()

def __init__(self, port_number):
self.tcp_port_number = port_number

socket.socket.__init__(self, socket.AF_INET, socket.SOCK_STREAM)
self.setblocking(0)
self.bind(('0.0.0.0', self.tcp_port_number))
self.listen(5)
self.__poll.register(self)

def poll(self, timeout = 0):
return self.__poll.poll(timeout)

def debugPollingSocket(port_num):
print "BIND TO PORT: ", port_num
return PollingSocket(port_num)

all_sockets = map(debugPollingSocket, xrange(1, 19169))

print "We have this in stock:"
for nb_active_socket in all_sockets:
print nb_active_socket.tcp_port_number

while 1:
for nb_active_socket in all_sockets:
print "Asking", nb_active_socket.tcp_port_number
if nb_active_socket.poll(1):
print "Found", nb_active_socket.tcp_port_number
conn, addr = nb_active_socket.accept()
while 1:
data = conn.recv(1024)
if not data: break
conn.send(data)
conn.close()
"""

> Jean-Paul

Thank you,
Maxim.

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?
-- 
http://mail.python.org/mailman/listinfo/python-list


PHP or Python Developer needed

2007-05-04 Thread Marie
I represent Chris TALARICO & Associates, Inc., an award winning personnel 
placement service.  Our client seeks a PHP or Python developer for a 2-6 month 
assignment in Reading, PA.  Please contact me if you would be interested in 
learning more about this opportunity or if you know of someone who would be 
interested.  Thank you.

Sincerely,



Marie Fretz
Vice President
Chris TALARICO & Associates, Inc.
Historic Centre Park District
401 Oley Street
Reading, PA  19601
(610) 478-1151 Fax (610) 478-1162 (T, F)
(610) 689-0827 Fax (610) 689-0828 (M, W, TH)
Toll Free 1-877-CTA-0115

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

Re: Non blocking sockets with select.poll() ?

2007-05-04 Thread Maxim Veksler
On 5/4/07, Maxim Veksler <[EMAIL PROTECTED]> wrote:
> On 5/4/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> > On Fri, 4 May 2007 13:04:41 +0300, Maxim Veksler <[EMAIL PROTECTED]> wrote:
> > >Hi,
> > >
> > >I'm trying to write a non blocking socket port listener based on
> > >poll() because select is limited to 1024 fd.
> > >
> > >Here is the code, it never gets to "I did not block" until I do a
> > >telnet connection to port 1.
> > >
> >
> > What were you expecting?
> >
>
> I'll try to explain.
> I'm doing a little experiment: Capturing the whole tcp 1-65535 range
> of the machine, allowing me to connect to the my service on the
> machine on every port. I know that it's probably the most dumb thing
> to do with TCP/IP communication please don't forget it's an
> experiment.

[snip]

I think I got it working now :)

"""
#!/usr/bin/env python
import socket
import select

class PollingSocket(socket.socket):


def __init__(self, port_number):
self.__poll = select.poll()
self.tcp_port_number = port_number

socket.socket.__init__(self, socket.AF_INET, socket.SOCK_STREAM)
self.setblocking(0)
self.bind(('0.0.0.0', self.tcp_port_number))
self.listen(5)
self.__poll.register(self)

def poll(self, timeout = 0):
return self.__poll.poll(timeout)

def debugPollingSocket(port_num):
print "BIND TO PORT: ", port_num
return PollingSocket(port_num)

all_sockets = map(debugPollingSocket, xrange(1, 19169))

print "We have this in stock:"
for nb_active_socket in all_sockets:
print nb_active_socket.tcp_port_number

while 1:
for nb_active_socket in all_sockets:
print "Asking", nb_active_socket.tcp_port_number
if nb_active_socket.poll(0):
print "Found", nb_active_socket.tcp_port_number
conn, addr = nb_active_socket.accept()
while 1:
data = conn.recv(1024)
if not data: break
conn.send(data)
conn.close()
"""

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Where are the strings in gc.get_objects?

2007-05-04 Thread Edward K Ream
Hello all.  I'm tracking down memory leaks in my app.  To do this I wrote a 
script to show the numbers of each different type of object.  But it doesn't 
show strings!  Here is the script:

import gc,types

def printDict(d):
keys = d.keys() ; keys.sort()
print '-' * 30
for key in keys:
n = d.get(key)
print '%+6d %s' % (n,key)

d = {} ; d2 = {}
for obj in gc.get_objects():
t = type(obj)
r = repr(t)
n = d.get(r,0)
d[r] = n + 1
if t == types.InstanceType:
t = obj.__class__
r = repr(t)
n = d2.get(r,0)
d2[r] = n + 1

printDict(d)
printDict(d2)

And here is example output.  The first part of the listing shows the 'raw' 
type of each object, the second part of the listing shows 
type(obj.__class__) for instance types.

--
 +1925 
+1 
   +47 
 +2858 
 +2877 
+1 
+1 
+3 
+1 
+1 
+1 
+1 
  +536 
   +27 
+1 
+1 
  +538 
+11942 
   +14 
 +8493 
+3 
   +70 
 +1997 
 +3704 
 +4441 
   +72 
  +226 
  +181 
+1 
+29740 
+1 
   +53 
  +105 
  +362 
--
+1 
+1 
   +30 
+1 
+5 
+9 
+1 
   +51 
   +15 
   +11 
+3 
   +61 
+7 
+3 
   +19 
+5 
+1 
+9 
+6 
 +1545 
+2 
+1 
+2 
+3 
+2 
+1 
+3 
+2 
+2 
+1 
+1 
+3 
+3 
+1 
+1 
+2 
+3 
+3 
+1 
+1 
+1 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+3 
+1 
+3 
+3 
+5 
+2 
+2 
+2 
+2 
+2 
+6 
+2 
+2 
+3 
+3 
+3 
+3 
+2 
+2 
+3 
+1 
+1 
   +12 
   +20 
+1 
+1 
+1 
+1 
+1 
+1 
+1 
+1 
+1 
+1 
+3 
+3 
+1 
+1 
+1 
+1 
+1 
+5 
+1 
+2 
   +10 
+2 

I get similar results on both Python 2.4 and Python 2.5.  I'm running on XP.

Can anyone explain were the strings are?  I expect at least twice the number 
of strings as there are leoNodes.vnode objects.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: anyone has experience on cross-compile python 2.5.1?

2007-05-04 Thread Leo Jay
On 4/30/07, Leo Jay <[EMAIL PROTECTED]> wrote:
> i have a development board based on s3c2410 arm cpu. and i want to
> port python on it.
> after googling some threads, i successfully cross compiled python.
> but i still encountered a weird issue that when i ran
> /lib/python2.5/test/testall.py,
> the process stuck at test_asynchat.py, i located the stuck point here:
>
>def test_numeric_terminator(self):
># Try reading a fixed number of bytes
>s = echo_server()
>s.start() # <- stuck here  !!!
>time.sleep(1) # Give server time to initialize
>c = echo_client(6L)
>c.push("hello ")
>c.push("world\n")
>asyncore.loop()
>s.join()
>
>
> but the weirdest thing is, if i run python test_asynchat.py directly,
> everything is ok.
> anybody could help me?
>
> thanks in advance.
>
> ps, my linux box is an ubuntu 6.10.
>

hello, anybody could help me? thanks.


-- 
Best Regards,
Leo Jay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: hp 11.11 64 bit python 2.5 build gets error "import site failed"

2007-05-04 Thread bhochstetler
On May 4, 1:17 am, Leo Kislov <[EMAIL PROTECTED]> wrote:
> On May 3, 2:54 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
>
>
>
> > >>> "import site failed"
> > >>> OverflowError: signed integer is greater than the maximum.
> > >> - what is the value of ival?
> > > ival: 4294967295
>
> > I see. This is 0x, which would be -1 if it were of type
> > int. So perhaps some value got cast incorrectly at some point,
> > breaking subsequent computations
>
> > >> - where does that number come from?
>
> > > It is coming from the call to PyInt_AsLong. In that function there is
> > > a call to:
> > > PyInt_AS_LONG((PyIntObject*)op)
> > > which returns the value of ival.
>
> > That was not my question, really. I wanted to know where the object
> > whose AsLong value was taken came from. And before you say "it's
> > in the arg parameter" of convertsimple() - sure it is. However, how
> > did it get there? It's in an argument tuple - and where came
> > that from?
>
> Looking at the call stack OP posted, -1 is coming as forth parameter
> of
> __import__, I *guess* at the first import in site.py or at implicit
> "import site". I think it'd be helpful if OP also tried if it works:
> python -S -c -v "print -1, type(-1), id(0), id(-1)"
>
>   -- Leo

Here is the output, along with my printf statements that show the call
stack:

builtin___import__
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
vgetargskeywords: positional arg: 3
convertitem
builtin___import__
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
vgetargskeywords: positional arg: 3
convertitem
BRAD 20
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
builtin___import__
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
vgetargskeywords: positional arg: 3
convertitem
builtin___import__
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
vgetargskeywords: positional arg: 3
convertitem
convertitem
convertitem
convertitem
convertitem
builtin___import__
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
vgetargskeywords: positional arg: 3
convertitem
vgetargskeywords: positional arg: 4
convertitem
ival: 4294967295
builtin___import__
PyArg_ParseTupleAndKeywords
vgetargskeywords: positional arg: 0
convertitem
vgetargskeywords: positional arg: 1
convertitem
vgetargskeywords: positional arg: 2
convertitem
vgetargskeywords: positional arg: 3
convertitem
vgetargskeywords: positional arg: 4
convertitem
ival: 4294967295
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'v' is not defined

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


Re: Why stay with lisp when there are python and perl?

2007-05-04 Thread David Formosa (aka ? the Platypus)
Nameless wrote:
> Why should I keep on learning lisp when there are python and perl?

The more programing languages you know the better programer you will
be.  Lisp can teach you a number of key things that are required to
be a good programmer in any of the P* lanuages.

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


Re: Why are functions atomic?

2007-05-04 Thread Chris Mellon
On 3 May 2007 23:36:11 -0700, Michael <[EMAIL PROTECTED]> wrote:
> On May 2, 6:08 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
> > On Tue, 2007-05-01 at 22:21 -0700, Michael wrote:
> > > Is there a reason for using the closure here?  Using function defaults
> > > seems to give better performance:[...]
> >
> > It does? Not as far as I can measure it to any significant degree on my
> > computer.
>
> I agree the performance gains are minimal.  Using function defaults
> rather than closures, however, seemed much cleaner an more explicit to
> me.  For example, I have been bitten by the following before:
>
> >>> def f(x):
> ... def g():
> ... x = x + 1
> ... return x
> ... return g
> >>> g = f(3)
> >>> g()
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "", line 3, in g
> UnboundLocalError: local variable 'x' referenced before assignment
>
> If you use default arguments, this works as expected:
> >>> def f(x):
> ... def g(x=x):
> ... x = x + 1
> ... return x
> ... return g
> >>> g = f(3)
> >>> g()
> 4
>

You aren't getting "bit" by any problem with closures - this is a
syntax problem.
Assigning to x within the scope of g() makes x a local variable. x =
x+1 doesn't work, then, because "x+1" can't be evaluated.

If you just used "return x+1" or if you named the local variable in g
something other than "x", the closure approach would also work as
expected.
-- 
http://mail.python.org/mailman/listinfo/python-list


using pyparsing to extract METEO DATAS

2007-05-04 Thread napolpie
DISCUSSION IN

USER nappie writes:
Hello, I'm Peter and I'm new in python codying and I'm using parsying
to extract data from one meteo Arpege file. This file is long file and
it's composed by word and number arguments like this: GRILLE EURAT5
Coin Nord-Ouest : 46.50/ 0.50 Coin Sud-E
Hello,
I'm Peter and I'm new in python codying and I'm using parsying to
extract data from one meteo Arpege file.
This file is long file and it's composed by word and number arguments
like this:

[[code]]

GRILLE EURAT5 Coin Nord-Ouest : 46.50/ 0.50 Coin Sud-Est : 44.50/ 2.50
MODELE PA PARAMETRE P
NIVEAU MER 0 ECHEANCE 0.0 DATE 2002030400 NB_POINTS 25
1020.91 1020.87 1020.91 1021.05 1021.13
1020.07 1020.27 1020.49 1020.91 1021.15
1019.37 1019.65 1019.79 1020.53 1020.77
1018.73 1018.89 1019.19 1019.83 1020.81
1018.05 1018.19 1018.75 1019.55 1020.27
NIVEAU MER 0 ECHEANCE 3.0 DATE 2002030400 NB_POINTS 25
1019.80 1019.78 1019.92 1020.18 1020.34
1018.94 1019.24 1019.54 1020.08 1020.32
1018.24 1018.64 1018.94 1019.84 1019.98
1017.48 1017.88 1018.28 1018.98 1019.98
1016.62 1017.08 1017.66 1018.26 1018.34
NIVEAU MER 0 ECHEANCE 6.0 DATE 2002030400 NB_POINTS 25
1019.37 1019.39 1019.57  
... .
...
...
...
... .
NIVEAU MER 0 ECHEANCE 48.0 DATE 2002030400 NB_POINTS 25
1017.84 1017.46 1017.14 1016.86 1016.58
1017.28 1016.90 1016.46 1016.48 1016.34
1016.50 1016.06 1015.62 1015.90 1015.72
1015.94 1015.30 1014.78 1014.68 1014.86
1015.86 1015.10 1014.36 1014.00 1013.90

.
MODELE PA PARAMETRE T
NIVEAU HAUTEUR 2 ECHEANCE 0.0 DATE 2002030400 NB_POINTS 25
1.34 1.51 1.40 0.56 -0.36
1.73 1.43 0.89 -0.16 -0.99
2.06 1.39 1.14 -0.53 -0.99
2.12 2.22 2.15 0.76 -1.16
1.67 1.45 1.40 1.26 0.28
NIVEAU HAUTEUR 2 ECHEANCE 3.0 DATE 2002030400 NB_POINTS 25
0.94 1.16 1.03 0.44 -0.41
0.95 0.61 0.22 .

[[code]]

I'am at the begginning of computation and for the moment I write this
code to extract only number data in form of a string:

[[code format="python"]]

from pyparsing import *
dec
Combine (Optional( "-" ) + delimitedList( Word( nums ), ".", combine
True ))
datas = ZeroOrMore( dec )
f=file("arqal-Arpege.00", "r")
g=file("out3", "w")
for line in f:
try:
result = datas.parseString (line)
add = result
add1 = ";".join(add)
print >> g,"(",add1,")"
except ParseException, pe:
print pe

[[code]]

This is the output result in file g=file("out3", "w")

( )
( )
( )
( 1020.91;1020.87;1020.91;1021.05;1021.13 )
( 1020.07;1020.27;1020.49;1020.91;1021.15 )
( 1019.37;1019.65;1019.79;1020.53;1020.77 )
( 1018.73;1018.89;1019.19;1019.83;1020.81 )
( 1018.05;1018.19;1018.75;1019.55;1020.27 )
( )
( 1019.80;1019.78;1019.92;1020.18;1020.34 )
( 1018.94;1019.24;1019.54;1020.08;1020.32 )
( 1018.24;1018.64;1018.94;1019.84;1019.98 )
( 1017.48;1017.88;1018.28;1018.98;1019.98 )
( 1016.62;1017.08;1017.66;1018.26;1018.34 )
( )
( 1019.37;1019.39;1019.57;1019.9;..;



.;1016.87)
( )
( 1017.84;1017.46;1017.14;1016.86;1016.58 )
( 1017.28;1016.90;1016.46;1016.48;1016.34 )
( 1016.50;1016.06;1015.62;1015.90;1015.72 )
( 1015.94;1015.30;1014.78;1014.68;1014.86 )
( 1015.86;1015.10;1014.36;1014.00;1013.90 )

[[code]]

So I don't have any word but the problem is that Now I have to put in
order this numerical datas in a type of NESTED matrix emulated by
python like a nested dictionary :

[[code]]

{ 'P ' : { MER 0 : [ (1020.91;1020.87;;1020.27 ) ;
(.) ; ( 1019.80;1019.78;;1018.26;1018.34 ) ]; ..;
SOL 0 : [ ( ...);.;( ) ] } ; 'T' : { SOL 0 :
[(.;..) ; (ECHEANCE 3.0) ; (ECHEANCE 6.0) ;
(...;) ]; HAUTEUR 2 : [(...;..;..) ] } }
=
=>> { 'Parameter X' : { Level X : [ (predict step 3 hours from +0
to +48 hours ) ;]} }

  o the bigger shell is fixed by
Dictionary PARAMETER in the example is P= 'Pressure' but thre are many
of this Temperature
T , Wind
U and V ecc... the second nested
shell is setted by another Dictionary NIVEAU MER 0 in the example is
MER 0
sea level or SOL 0, but can be
HAUTER 2,10 (HEIGHT 2,10 METERS)ecc. (soil level , 1;0 meter from
soil) ecc (from French language) and after every Level is associated
with a LIST OF TUPLE: [();();()] to rappresented every
step hours of prediction or expiration hours in French language:
ECHEANCE XX.X
predicted hour +3.0 +6.0 until 48H
is setted of a list of tuple [(ECHEANCE 3.0);(ECHEANCE 6.0); (ECHEANCE
XX.0);.;(ECHEANCE 48.0)] like so:
[1019.37;1019.39;;1020.27 );(.);
(1019.80;1019.78;;1018.26;1018.34 )] where every list is at
the end the is the datas grill: (5 x 5 points)= 25 datas

1020.91 1020.87 1020.91 1021.05 1021.13
1020.07 1020.27 1020.49 1020.91 1021.15
1019.37 1019.65 1019.79 1020.53 1020.

RE: Strange terminal behavior after quitting Tkinter application

2007-05-04 Thread Hamilton, William
> -Original Message-
> From: Chris
> Subject: Re: Strange terminal behavior after quitting Tkinter
application
> Clicking 'Quit' or on the window's 'x' causes the application to quit
> without messing up the terminal. With root.mainloop() commented out,
> though, no combination of root.quit(), root.destroy(), and sys.exit()
> stops the terminal from getting messed up.
> 
> So, I should call mainloop() for my application...except that I want
> to use the commandline, too, and calling mainloop() freezes the
> commandline. I wonder if there is another way to use the commandline
> and have a GUI? I couldn't find any clear information about that.
 

Can you run it in the background?  IIRC, if you put an ampersand ('&')
at the end of the command line, it will run as a background process and
leave your command line available for other tasks.  (The marker may be
something other than &, it's been a long, long time since I've used *nix
in a gui environment.)


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


Re: How to find the present working directory using python.

2007-05-04 Thread Isaac Rodriguez

> how to find out the present working directory using python.
>

Try this:

import os
os.getcwd()

It returns the current working directory.

Thanks,

- Isaac.

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


Plot with scipy

2007-05-04 Thread redcic
Hi all,

I've just downloaded scipy v 0.5.2 and I would like to be able to draw
plots. I've tried:
import scipy.gplt
import scipy.plt
import scipy.xplt

and none of them work. Are these modules still included in scipy ? If
not, where can I find them ?

Thanks for your answers,

Cédric

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


Re: Non blocking sockets with select.poll() ?

2007-05-04 Thread Jean-Paul Calderone
On Fri, 4 May 2007 15:05:46 +0300, Maxim Veksler <[EMAIL PROTECTED]> wrote:
>On 5/4/07, Maxim Veksler <[EMAIL PROTECTED]> wrote:
>>On 5/4/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>> > On Fri, 4 May 2007 13:04:41 +0300, Maxim Veksler <[EMAIL PROTECTED]> 
>>wrote:
>> > >Hi,
>> > >
>> > >I'm trying to write a non blocking socket port listener based on
>> > >poll() because select is limited to 1024 fd.
>> > >
>> > >Here is the code, it never gets to "I did not block" until I do a
>> > >telnet connection to port 1.
>> > >
>> >
>> > What were you expecting?
>> >
>>
>>I'll try to explain.
>>I'm doing a little experiment: Capturing the whole tcp 1-65535 range
>>of the machine, allowing me to connect to the my service on the
>>machine on every port. I know that it's probably the most dumb thing
>>to do with TCP/IP communication please don't forget it's an
>>experiment.
>
>[snip]
>
>I think I got it working now :)
>
>"""
>#!/usr/bin/env python
>import socket
>import select
>
>class PollingSocket(socket.socket):
>
>
>def __init__(self, port_number):
>self.__poll = select.poll()
>self.tcp_port_number = port_number
>
>socket.socket.__init__(self, socket.AF_INET, socket.SOCK_STREAM)
>self.setblocking(0)
>self.bind(('0.0.0.0', self.tcp_port_number))
>self.listen(5)
>self.__poll.register(self)
>
>def poll(self, timeout = 0):
>return self.__poll.poll(timeout)
>
>def debugPollingSocket(port_num):
>print "BIND TO PORT: ", port_num
>return PollingSocket(port_num)
>
>all_sockets = map(debugPollingSocket, xrange(1, 19169))
>
>print "We have this in stock:"
>for nb_active_socket in all_sockets:
>print nb_active_socket.tcp_port_number
>
>while 1:
>for nb_active_socket in all_sockets:
>print "Asking", nb_active_socket.tcp_port_number
>if nb_active_socket.poll(0):
>print "Found", nb_active_socket.tcp_port_number
>conn, addr = nb_active_socket.accept()
>while 1:
>data = conn.recv(1024)
>if not data: break
>conn.send(data)
>conn.close()
>"""
>

This will only handle one connection at a time, of course.  The polling
it does is also somewhat inefficient.  Perhaps that's fine for your use
case.  If not, though, I'd suggest this version (untested):

  from twisted.internet import pollreactor
  pollreactor.install()

  from twisted.internet import reactor
  from twisted.protocols.wire import Echo
  from twisted.internet.protocol import ServerFactory

  f = ServerFactory()
  f.protocol = Echo
  for i in range(1, 19169):
  reactor.listenTCP(i, f)
  reactor.run()

This will handle traffic from an arbitrary number of clients at the same
time and do so more efficiently than the loop in your version.  You can
also try epollreactor instead of pollreactor, if the version of Linux you
are using supports epoll, for even better performance.

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


Re: default config has no md5 module?

2007-05-04 Thread Sebastian Bassi
On 5/4/07, Leo Jay <[EMAIL PROTECTED]> wrote:
> i want to compile a python by myself, but after configure and make, it
> seems that md5 is not built by default.
>
> what should i do to compile md5 as an module?

md5 module was deprecated, now it functions are in hashlib.
(see http://docs.python.org/lib/module-hashlib.html).
So you may not need to compile md5 module at all.


-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Real Time Battle and Python

2007-05-04 Thread hg
Matimus wrote:

> On May 3, 5:20 am, hg <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I have started to work on a python-based robot, and am interested in your
>> feedback:
>>
>> http://realtimebattle.sourceforge.net/www.snakecard.com/rtb
>>
>> hg
> 
> This is not necessarily a response to your effort, but just a note
> (rant) about realtimebattle. It reminds me more of homework in 300 and
> 400 level college engineering classes than a game. Based upon my
> previous effort and realizations, I found realtimebattle coding to be,
> from a programming perspective, an exercise in protocol implementation
> first. Once the protocol work is done you need to implement control
> algorithms for movement and enemy tracking. Think PID algorithms
> (Proportional, Integral and Differential). Only when the protocol and
> control portions are done can you focus on strategy and play the game.
> You should also note, however, that the first two tasks are quite
> daunting. And the second is difficult to get right. I found the whole
> process to be very tiring and not very rewarding.  I don't mean to
> discourage you, I just think it would be more fun to write my own game
> than to 'play' that one.
> 
>  A better game, from a programming perspective, would be
> "discretetimebattle". Where each player controls their robot with
> second order parameters (velocity not force), the world has no third
> order effects (friction) and the time is discrete. Discrete time
> meaneing that the protocol  updates every player at regular intervals
> with the same information and, in terms of the simulation, each update
> represents a set time delta.
> 
> I would be interested to know if anybody else has played, or tried to
> play, realtimebattle and has similar sentiments.
> 
> I do wish you luck though. If you get a robot working you are a far
> more dedicated and patient individual than me.
> 
> -Matt


I do try to separate the "engine" from the "driver". Yes the engine is a
pain to code and the documentation quite skimpy (have to got through C
headers to understand the command set) ... still I'll try to finish it.

hg


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


Re: How do I get type methods?

2007-05-04 Thread yavannadil
On 4 май, 09:08, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Fri, 04 May 2007 01:34:20 -0300, <[EMAIL PROTECTED]> escribio:
> > I'm not against 'dir(MyClass)'; the question is, what should I 'dir()'
> > to get methods of 'pyuno' type instance?
> Usually instances don't have its own methods, they get them from the
> class. So you actually need dir(MyClass).
> Note that dir() might not show all available methods.

Let me retype my question: what I 'dir()' in case of 'pyuno' type
instance?
Or in case of 'dict' type instance? Or in case of any other new python
type?

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

Re: base64 and unicode

2007-05-04 Thread Duncan Booth
EuGeNe Van den Bulke <[EMAIL PROTECTED]> wrote:

> Duncan Booth wrote:
>> However, the decoded text looks as though it is utf16 encoded so it
>> should be written as binary. i.e.  the output mode should be "wb".
> 
> Thanks for the "wb" tip that works (see bellow). I guess it is 
> experience based but how could you tell that it was utf16 encoded?

I pasted the encoded form into idle and decoded it base 64. It ends with \r
\x00\n\x00 and the nulls instantly suggest a 16 bit encoding. Scrolling to 
the beginning and it starts \xff\xfe which is the BOM for little-endian 
utf16.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Paul Boddie wrote:
> I'm sorry to hear about that. If by "macho" you mean people who insist
> that things are good enough as they are, and that newcomers should
> themselves adapt to whatever they may discover, instead of things
> being improved so that they are more intuitive and reliable for
> newcomers and experienced developers alike, then I'd certainly be
> interested in undermining that culture.

That was the sort of response I got on freenode #python, which I realize 
I should not take as representative of the whole community.  Thank you 
for the thoughtful response.

>> I tried to write portable Python code.  The zlib CRC function returned
>> different results on architectures between 32 bit and 64 bit
>> architectures.  I filed a bug report.  It was closed, without a comment
>> from the person who closed it.  I get the unspoken message: bug reports
>> are not welcome.
> 
> Can you provide the bug identifier? Bug reports are generally welcome,
> and despite complaints about patch reviews, I've found people
> reviewing things I've submitted.

It is problem report #1678102.  I understand the problem: that a 32 bit 
number looks different in a 32 bit signed int than in a 64 bit signed 
int.  However, the workaround of dropping a bit seems to defeat the 
purpose of using a CRC.

> Yes, Ctrl-Z exits Python in the standard Windows edition. Since Cygwin
> provides a POSIX-like environment, Ctrl-D should be used instead. If
> the documentation is wrong, a bug report or patch should be filed
> against the software.

This morning I could not reproduce the problem.  When the user types 
"quit" at the Python prompt, the Cygwin port instructs the user to press 
Control-D, which works.  Even if you SSH in to Cygwin, and run the win32 
port, it instructs the user to press Control-Z plus Return, which works.
Maybe it was fixed after I had the problem.

>> Between 2.4 and 2.5, tempfile returns a different type of object.  My
>> code cannot have a single test, it has check for type(obj) == file or
>> obj.__class__ == tempfile._TemporaryFileWrapper.
> 
> Try using isinstance or relying on "deeper" knowledge of how the
> object will be used.

Thank you for the hint.  I just want my function to validate that one of 
its arguments is a file-like object.  It isn't necessarily going to be a 
temporary file, but it might be.

 >>> import temporaryfile
 >>> t = tempfile.TemporaryFile()
 >>> isinstance(t, file)
False

> My opinions, already expressed, include the observation that the core
> development community is more interested in extending the language
> than in strengthening the standard library (and its documentation). It
> should be noted that the proposed standard library reorganisation,
> which is a very conservative affair, has actually been postponed until
> after the release of Python 3.0a1 according to a message I read
> recently. And yet, if you read people's lists about what they "hate"
> about Python (amongst actual users of Python), guess which thing
> almost always comes up?

I guess you cannot blame folks for working on what they find interesting.

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


RE: unittest dependencies

2007-05-04 Thread Urban, Gabor
Hullo!

I have several questions about this problem. Do you have more test scripts 
using the unittest framework?

My blind idea would be the following: run test b first, and go forward when no 
errors are found. To do this you could change the TestRunner component. The 
official documentation is good enough.

Good luck,

Gabor Urban
NMC - ART

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of urielka
Sent: 2007. május 2. 23:10
To: [email protected]
Subject: unittest dependencies

i am using unittest to test a project,and one thing i really want is a
way to say that test a depends on test b,so it need to run before it
and be successful in order to run this test.

i just wanted to know if anyone have done it before(i searched for it
but didn`t find something useful),i think it can be done easily using
a decorator that will run the test which is depend on and mark it as
successful,the only problem will be detecting circular test
dependencies,but that can be fixed by keeping all the functions that
the decorator have seen.

what do you guys think? did someone did it before?

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


Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread default
On Fri, 04 May 2007 03:26:17 -0700, James Stroud
<[EMAIL PROTECTED]> wrote:

>default wrote:
>> On 2 May 2007 20:10:20 -0700, Midex <[EMAIL PROTECTED]> wrote:
>> 
>>> LIES LIES LIES LIES LIES
>> 
>> Trying to understand the World Trade Center events is like waking up
>> to act fifteen of a long Greek Tragedy. It needs a complex fabric of
>> description to give a full picture. In explaining this crisis, we will
>> be showing how the situation rests on layers of historical
>> developments, layers of crises and solutions.
>> 
>> shamelessly taken from:
>> http://www.againstsleepandnightmare.com/ASAN/ASAN7/ASAN7.html
>> 
>> The World After September 11th, 2001
>> 
>> The Old Mole
>> 
>> By the time you read this, a crisis different from September 11th may
>> well be foremost in people's minds. Read on. For us today, all the
>> crises merge to one and we can see the form of Enron's Collapse or the
>> Iraq War within September 11th and vice-versa. Now, beyond the death
>> and destruction, the horror of an event like September 11th is the
>> horror of losing control of your world. This feeling is an extension
>> of the ordinary experience of being a resident of modern capitalist
>> society. Here, work, commuting, shopping, and television are
>> transmitted to you in ways that are beyond any individual or
>> collective control. 
>> 
>> Damn good read. 
>
>Marxist trash.

We've been conditioned to think in those terms and the web site is
communist.  The philosophy of communism isn't so bad, it is the people
and application that are the problem.

Capitalism works right out of the box then begins to fray and
deteriorate - again due to people and application.  Either system
creates an elite class and poor class with little or no middle ground.
Each system is, ultimately, a failure.

I'm not advocating either system, both are flawed as long as people
can gain and hold power.  Somewhere in there is a solution to the
problems - I wouldn't presume to know the right course.

Our politicians presume to know the right course - but they have no
idea what is happening in the real world just their own political
world.

We have a mix of socialism and capitalism in the US no matter what the
government/media hype says it is.  Free market capitalism?  hardly.
-- 

== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for HTMLGen?

2007-05-04 Thread Walter Dörwald
Joshua J. Kugler wrote:
> I realize that in today's MVC-everything world, the mere mention of
> generating HTML in the script is near heresy, but for now, it's what I ened
> to do. :)
> 
> That said, can someone recommend a good replacement for HTMLGen?  I've found
> good words about it (http://www.linuxjournal.com/article/2986), but every
> reference to it I find points to a non-existant page
> (http://starship.python.net/lib.html is 404,
> http://www.python2.net/lib.html is not responding,
> http://starship.python.net/crew/friedrich/HTMLgen/html/main.html is 404)
> Found http://www.python.org/ftp/python/contrib-09-Dec-1999/Network/, but
> that seems a bit old.
> 
> I found http://dustman.net/andy/python/HyperText, but it's not listed in
> Cheeseshop, and its latest release is over seven years ago.  Granted, I
> know HTML doesn't change (much) but it's at least nice to know something
> you're going to be using is maintained.
> 
> Any suggestions or pointers?

You might try XIST:
http://www.livinglogic.de/Python/xist/

Hope that helps!

Servus,
   Walter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Python annoyances

2007-05-04 Thread Chris Mellon
On 5/4/07, Ben Collver <[EMAIL PROTECTED]> wrote:
> Paul Boddie wrote:
> > I'm sorry to hear about that. If by "macho" you mean people who insist
> > that things are good enough as they are, and that newcomers should
> > themselves adapt to whatever they may discover, instead of things
> > being improved so that they are more intuitive and reliable for
> > newcomers and experienced developers alike, then I'd certainly be
> > interested in undermining that culture.
>
> That was the sort of response I got on freenode #python, which I realize
> I should not take as representative of the whole community.  Thank you
> for the thoughtful response.
>

#python is one of the most accepting communities around. If the bug
reports here and the way you've presented them in this thread (vs the
way that they appear to an outside observer) are any indication,
though, I'm not surprised that you might have left in a huff.

Bear in mind that #python has no special status with regards to python
development and is primarily a community of *users*. If you go in with
some sort of thing you consider a problem, you are likely to be shown
a solution. Debate over whether it should be fixed in the core is
likely to be met with "patches accepted".

> >> I tried to write portable Python code.  The zlib CRC function returned
> >> different results on architectures between 32 bit and 64 bit
> >> architectures.  I filed a bug report.  It was closed, without a comment
> >> from the person who closed it.  I get the unspoken message: bug reports
> >> are not welcome.
> >
> > Can you provide the bug identifier? Bug reports are generally welcome,
> > and despite complaints about patch reviews, I've found people
> > reviewing things I've submitted.
>
> It is problem report #1678102.  I understand the problem: that a 32 bit
> number looks different in a 32 bit signed int than in a 64 bit signed
> int.  However, the workaround of dropping a bit seems to defeat the
> purpose of using a CRC.
>

That's a valid point. Maybe you should have responded on the tracker
with that viewpoint. Your characterization of what happened in your
original post borders on dishonest - how can you possibly view what
happened there as "bug reports not welcomed"?

> > Yes, Ctrl-Z exits Python in the standard Windows edition. Since Cygwin
> > provides a POSIX-like environment, Ctrl-D should be used instead. If
> > the documentation is wrong, a bug report or patch should be filed
> > against the software.
>
> This morning I could not reproduce the problem.  When the user types
> "quit" at the Python prompt, the Cygwin port instructs the user to press
> Control-D, which works.  Even if you SSH in to Cygwin, and run the win32
> port, it instructs the user to press Control-Z plus Return, which works.
> Maybe it was fixed after I had the problem.
>

Huh.

> >> Between 2.4 and 2.5, tempfile returns a different type of object.  My
> >> code cannot have a single test, it has check for type(obj) == file or
> >> obj.__class__ == tempfile._TemporaryFileWrapper.
> >
> > Try using isinstance or relying on "deeper" knowledge of how the
> > object will be used.
>
> Thank you for the hint.  I just want my function to validate that one of
> its arguments is a file-like object.  It isn't necessarily going to be a
> temporary file, but it might be.
>
>  >>> import temporaryfile
>  >>> t = tempfile.TemporaryFile()
>  >>> isinstance(t, file)
> False
>

Code like this is working directly against Python philosophy. You
probably got told this on #python, too. There's hardly any
circumstance where you should need to validate the exact class of an
object, and as long as they have the same interface theres no harm
whatsoever in tempfile changing it's return value between Python
versions.

> > My opinions, already expressed, include the observation that the core
> > development community is more interested in extending the language
> > than in strengthening the standard library (and its documentation). It
> > should be noted that the proposed standard library reorganisation,
> > which is a very conservative affair, has actually been postponed until
> > after the release of Python 3.0a1 according to a message I read
> > recently. And yet, if you read people's lists about what they "hate"
> > about Python (amongst actual users of Python), guess which thing
> > almost always comes up?
>
> I guess you cannot blame folks for working on what they find interesting.
>
> Ben
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Terry Reedy wrote:
> Three days after you posted, 'gagenellina' explained that he thought your 
> complaint was invalid.
> "py> -531560245 & 0x
> 3763407051L
> 
> It's the same number (actually, the same bit pattern). ..."
> 
> A few weeks later, noticing that you had not challenged his explanation, I 
> closed after changing the Resolution box to Invalid.  THAT WAS MY COMMENT.
> 
> A month later, I notice that you still have not directly challenged G's 
> claim of invalidity.  Instead, you ignored it and simply repeated your 
> claim here.  WHO IS IGNORING WHO?
> ...
> Real bug reports are quite welcome, as any honest person could determine by 
> looking thru the tracker.

Hi Terry,

I understand and agree that the number was the same bit pattern.  I 
don't remember being asked to challenge this.  I must have missed the 
status change notification.

I do wonder whether the diagnosis is accurate: is the sparc64 port 
actually using an unsigned int where the i386 port is using a signed int?

Either way, I don't see how it reflects on the validity of the report. 
I reported that the resulting numbers were different.  To me that seems 
a trap for the unwary.

All I saw was a comment on what might cause my problem, and then I saw 
that the problem report was closed.  Now I am told that I didn't even 
file a real bug report.  I don't know whether to take that as "this is a 
trivial problem not worth reporting" or "this is a poorly filed bug report".

I am an honest person, honestly!

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


Re: Organizing code - import question

2007-05-04 Thread Carlos Hanson
On 5/3/07, Brian Blais <[EMAIL PROTECTED]> wrote:
> Carlos Hanson wrote:
> > It looks like you need __init__.py in MyPackage.  Then you can import
> > starting with MyPackage.  For example, you might use one of the
> > following:
> >
> >   import MyPackage
> >   from MyPackage.Common import *
> >   etc
> >
>
> that means that MyPackage must be in the sys path too?  It doesn't seem like a
> contained-module sees the container in any way.
>

That is exactly right.  Without being in the sys path, Python does not
know where to look to resolve the import statements.


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


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Thorsten Kampe wrote:
> He was using /Windows/ Python in Cygwin *chuckle*... Windows Python 
> says Ctrl-Z because it doesn't know that it's been run from bash where 
> Ctrl-Z is for job control.
> 
> And the lesson we learn from that: if you're using Windows Python use 
> a Windows shell. If you're using a Cygwin shell use Cygwin Python - 
> unless you know what you're doing (which he wasn't).

The reason I tried to do this: Cygwin python lacks _winreg, but I wanted 
to SSH into Cygwin to run this script.

I suppose the folks who know what they are doing probably stick to 
wscript and WMI for this sort of stuff.

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


Re: tkinter listboxes

2007-05-04 Thread rahulnag22
On May 4, 1:55 am, "Eric Brunel" <[EMAIL PROTECTED]> wrote:
> On Fri, 04 May 2007 05:26:56 +0200, <[EMAIL PROTECTED]> wrote:
> > I will give a simplified example of the problem at hand --
>
> > I have a case in which I have two listboxes - listbox1 and listbox2,
> > if I click on an item in listbox1 the item gets highlighted as
> > expected. Now if I click on an item in listbox2 the selected item in
> > listbox1 loses its highlight. My question is how do I keep the
> > listbox1 item from losing its highlight if I select an item in
> > listbox2 or to that matter any other widget.
>
> By default, the 'highlighting' is considered as a selection. Since you
> can't have two items selected at the same time, the second cancels the
> first. To avoid this behaviour, make each list keep its selection to
> itself by using the 'exportselection=0' option when you create the Listbox
> instance. This should work as you expect.
>
> HTH
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in
> 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"


Eric that works. Thank You. James thank you for the detailed
explanation it will be useful for me.
Regards
Rahul

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


Re: BUSTED!!! 100% VIDEO EVIDENCE that WTC7 was controlled demolition!! NEW FOOTAGE!!! Ask yourself WHY havn't I seen this footage before?

2007-05-04 Thread MooseFET
On May 3, 4:08 pm, quasi <[EMAIL PROTECTED]> wrote:
> On Fri, 04 May 2007 09:37:37 +1200, Gib Bogle
>
> <[EMAIL PROTECTED]> wrote:
> >Ah, so the firefighters were in on the conspiracy!
>
> No, but the firefighters are very much aware that there is more to
> 9/11 than has been officially revealed.
>
> This is even more true at Pentagon. The firefighters there brought
> dogs trained to search for survivors and/or remains and found nothing.

Thats because nobody works at the Pentagon.  Like the CIA headquarters
it is actually a show run by Disney corp on a special contract.  It is
just to keep the voters from asking where all that money really goes.


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


Re: Plot with scipy

2007-05-04 Thread Lou Pecora
In article <[EMAIL PROTECTED]>,
 redcic <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I've just downloaded scipy v 0.5.2 and I would like to be able to draw
> plots. I've tried:
> import scipy.gplt
> import scipy.plt
> import scipy.xplt
> 
> and none of them work. Are these modules still included in scipy ? If
> not, where can I find them ?
> 
> Thanks for your answers,
> 
> Cédric
> 

You really want matplotlib and PyLab the library built on top of it.  
Search on the python.org site for examples.  Google will turn up a lot. 
Matplotlib w/ PyLab is a nice, easy plotting package.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Plot with scipy

2007-05-04 Thread redcic
I've already got this package. I just wanted to try something new.

However, since you talk about it, I've got a question regarding this
package. The execution of the code stops after the line:
pylab.show()
which is off course the last line of my code. My problem is that I
have to close the figure window in order to launch my program another
time. I'd like to be able to launch my program many times with
different parameters without having to close the figure windows before
each launch.
Just so you know, I'm using TkAgg backend.

Any hint ?

Thanks,

Cédric

On 4 mai, 15:49, Lou Pecora <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
>
>
>
>  redcic <[EMAIL PROTECTED]> wrote:
> > Hi all,
>
> > I've just downloaded scipy v 0.5.2 and I would like to be able to draw
> > plots. I've tried:
> > import scipy.gplt
> > import scipy.plt
> > import scipy.xplt
>
> > and none of them work. Are these modules still included in scipy ? If
> > not, where can I find them ?
>
> > Thanks for your answers,
>
> > Cédric
>
> You really want matplotlib and PyLab the library built on top of it.
> Search on the python.org site for examples.  Google will turn up a lot.
> Matplotlib w/ PyLab is a nice, easy plotting package.


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


Re: Decorating class member functions

2007-05-04 Thread Andy Terrel
 Thanks Peter and 7stud.  That is the solution that really works for
me.

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


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Chris Mellon wrote:
> #python is one of the most accepting communities around. If the bug
> reports here and the way you've presented them in this thread (vs the
> way that they appear to an outside observer) are any indication,
> though, I'm not surprised that you might have left in a huff.
> 
> Bear in mind that #python has no special status with regards to python
> development and is primarily a community of *users*. If you go in with
> some sort of thing you consider a problem, you are likely to be shown
> a solution. Debate over whether it should be fixed in the core is
> likely to be met with "patches accepted".

I generally use IRC for idle chat and mulling over problems, and I 
realize it would be the wrong place to ask for a change.  At the time I 
was talking about XML in the Python library.  I was informed that I was 
unwise to read 3rd party documentation for the Python library.  I get 
"Don't complain about documentation we didn't write" instead of "Yeah 
it's broken, use pyxml instead."

>> It is problem report #1678102.  I understand the problem: that a 32 bit
>> number looks different in a 32 bit signed int than in a 64 bit signed
>> int.  However, the workaround of dropping a bit seems to defeat the
>> purpose of using a CRC.
>>
> 
> That's a valid point. Maybe you should have responded on the tracker
> with that viewpoint. Your characterization of what happened in your
> original post borders on dishonest - how can you possibly view what
> happened there as "bug reports not welcomed"?

I made a mistake when I first read the response: it does not drop any bits.

In the bug report itself, I saw a diagnosis of my problem's cause, and 
then I saw the bug report closed as invalid.  I did not know why the bug 
was flagged invalid and closed, because I received no comment from the 
person who closed it.  I assumed that I should not have filed the bug 
report.

Feedback in this newsgroup names my bug report as a "hobby horse", a 
"wart", and "not a real bug report".  I apologize for this noise over 
such a small issue.  It is clear now that real bug reports are welcome.

> Code like this is working directly against Python philosophy. You
> probably got told this on #python, too. There's hardly any
> circumstance where you should need to validate the exact class of an
> object, and as long as they have the same interface theres no harm
> whatsoever in tempfile changing it's return value between Python
> versions.

I am unqualified to comment on the Python philosophy, but I would like 
for my function to do some basic error checking on its arguments.  I 
will read up on the Python philosophy.

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


How safe is a set of floats?

2007-05-04 Thread Thomas Nelson
I want to generate all the fractions between 1 and limit (with
limit>1) in an orderly fashion, without duplicates.

def all_ratios(limit):
s = set()
hi = 1.0
lo = 1.0
while True:
if hi/lo not in s:
s.add(hi/lo)
yield (hi,lo)
hi += 1
if hi/lo > limit:
lo += 1
hi = lo

I use a set to keep from giving duplicates; but is this safe?  In C
they always tell you not to trust floating point equality comparisons,
since they may not work as you expect.  My code seems fine for the
limited amount I've tested, but I'm curious: is there a gaurantee
about sets of floats?  Or a warning?

Thanks,

Tom

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


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Ben Collver wrote:
> Chris Mellon wrote:
>> Code like this is working directly against Python philosophy. You
>> probably got told this on #python, too. There's hardly any
>> circumstance where you should need to validate the exact class of an
>> object, and as long as they have the same interface theres no harm
>> whatsoever in tempfile changing it's return value between Python
>> versions.
> 
> I am unqualified to comment on the Python philosophy, but I would like 
> for my function to do some basic error checking on its arguments.

By "basic error checking" I mean "verify that the file argument actually 
is a file-like object".  By same interface, do you mean that I should 
check for the methods that I depend on?  That sounds easy enough.

Thanks for the hint,

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


Re: My Python annoyances

2007-05-04 Thread Chris Mellon
On 5/4/07, Ben Collver <[EMAIL PROTECTED]> wrote:
> Ben Collver wrote:
> > Chris Mellon wrote:
> >> Code like this is working directly against Python philosophy. You
> >> probably got told this on #python, too. There's hardly any
> >> circumstance where you should need to validate the exact class of an
> >> object, and as long as they have the same interface theres no harm
> >> whatsoever in tempfile changing it's return value between Python
> >> versions.
> >
> > I am unqualified to comment on the Python philosophy, but I would like
> > for my function to do some basic error checking on its arguments.
>
> By "basic error checking" I mean "verify that the file argument actually
> is a file-like object".  By same interface, do you mean that I should
> check for the methods that I depend on?  That sounds easy enough.
>

You should "check" for the methods by calling them. If the object
doesn't support the method in question, you will get a runtime
exception. Premature inspection of an object is rarely useful and
often outright harmful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Python annoyances

2007-05-04 Thread Ant
On May 4, 3:17 pm, Ben Collver <[EMAIL PROTECTED]> wrote:
> Chris Mellon wrote:
...
> > Code like this is working directly against Python philosophy. You
> > probably got told this on #python, too. There's hardly any
> > circumstance where you should need to validate the exact class of an
> > object, and as long as they have the same interface theres no harm
> > whatsoever in tempfile changing it's return value between Python
> > versions.
>
> I am unqualified to comment on the Python philosophy, but I would like
> for my function to do some basic error checking on its arguments.  I
> will read up on the Python philosophy.

The basic point here is that the code will do it's own error checking.
If you pass in a string to your function, and it tries to call
write("xxx") on it, then you will get an exception thrown:

AttributeError: 'str' object has no attribute 'write

If your goal is to provide feedback to a potential user that they are
using the wrong arguments, then you can use something like the
following (the "Easier to ask for forgiveness than for permission"
idiom):

>>> arg = "A String not a File"
>>> try:
...   arg.write("")
... except AttributeError:
...   print "You need to pass in a file like object!"
...
You need to pass in a file like object!


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


Re: How do I get type methods?

2007-05-04 Thread Thomas Nelson
On May 4, 7:59 am, [EMAIL PROTECTED] wrote:
> On 4 ÍÁÊ, 09:08, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > En Fri, 04 May 2007 01:34:20 -0300, <[EMAIL PROTECTED]> escribio:
> > > I'm not against 'dir(MyClass)'; the question is, what should I 'dir()'
> > > to get methods of 'pyuno' type instance?
> > Usually instances don't have its own methods, they get them from the
> > class. So you actually need dir(MyClass).
> > Note that dir() might not show all available methods.
>
> Let me retype my question: what I 'dir()' in case of 'pyuno' type
> instance?
> Or in case of 'dict' type instance? Or in case of any other new python
> type?

>>> class Foo:
... def f(self,x):
... print x+1
... def g(self,x):
... print x-1
...
>>> dir(Foo)
['__doc__', '__module__', 'f', 'g']

Is this not what you want?  These are the only methods in the Foo
class.

Tom

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


Re: Tcl-tk 8.5?

2007-05-04 Thread Kevin Walzer
James Stroud wrote:
> Méta-MCI wrote:
>> Any plan to integrate Tcl 8.5 in standard Python?
>>
> 
> Better would be to outegrate it and instead use another gui kit as the 
> standard.
> 

This statement puzzles me, as you are something of a Tkinter expert (you 
have helped me with some Tk issues). What is so bad about Tkinter? What 
should replace it in the core library?

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


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Chris Mellon wrote:
> You should "check" for the methods by calling them. If the object
> doesn't support the method in question, you will get a runtime
> exception. Premature inspection of an object is rarely useful and
> often outright harmful.

That makes sense, thank you for the response.

What about the case where I have an array of objects that represent some 
particular binary file format.  If the object is a file, then I want to 
copy its contents.  If the object is a string, then I want to write the 
string.  And so forth.

Should I assume that an object is file-like if it has a read method, and 
that I can call the read method without unexpected side effects?

Ben


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


Re: My Python annoyances

2007-05-04 Thread Alex Martelli
Chris Mellon <[EMAIL PROTECTED]> wrote:

> > > I am unqualified to comment on the Python philosophy, but I would like
> > > for my function to do some basic error checking on its arguments.
> >
> > By "basic error checking" I mean "verify that the file argument actually
> > is a file-like object".  By same interface, do you mean that I should
> > check for the methods that I depend on?  That sounds easy enough.
> 
> You should "check" for the methods by calling them. If the object
> doesn't support the method in question, you will get a runtime
> exception. Premature inspection of an object is rarely useful and
> often outright harmful.

However, hoisting method extraction out of the loop is often useful,
because it may speed up operations, and when you do that you might as
well use a try/except AttributeError to provide better diagnostics if
something is missing.  E.g., suppose you have a need to slurp away one
char at a time from a file until you get a 'Z':

def readToZ(f):
while True:
c = f.read(1)
if c == 'Z': return
elif not c: raise ValueError, "No Z in file f"

this may also raise IOError if the read fails, AttributeError if f does
not have a read method, TypeError (or who knows what) if f.read is not
callable, or does not let you call it with one int argument, etc, etc.

A slightly faster approach:

def readToZ(f):
read = f.read
while True:
c = read(1)
if c == 'Z': return
elif not c: raise ValueError, "No Z in file f"

this has exactly the same exception-behavior as the previous version.
It's hardly an error to tweak that behavior slightly:

def readToZ(f):
try: read = f.read
except AttributeError: raise TypeError, "%s has no read" % type(f)
while True:
c = read(1)
if c == 'Z': return
elif not c: raise ValueError, "No Z in file f"

going to horrid amounts of trouble to check that the call to read(1)
won't produce weird failures would be unwarranted, but making one case
of AttributeError into a TypeError in this way is quite OK, for example.


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


Re: How safe is a set of floats?

2007-05-04 Thread Alex Martelli
Thomas Nelson <[EMAIL PROTECTED]> wrote:

> I want to generate all the fractions between 1 and limit (with
> limit>1) in an orderly fashion, without duplicates.
> 
> def all_ratios(limit):
> s = set()
> hi = 1.0
> lo = 1.0
> while True:
> if hi/lo not in s:
> s.add(hi/lo)
> yield (hi,lo)
> hi += 1
> if hi/lo > limit:
> lo += 1
> hi = lo
> 
> I use a set to keep from giving duplicates; but is this safe?  In C
> they always tell you not to trust floating point equality comparisons,
> since they may not work as you expect.  My code seems fine for the
> limited amount I've tested, but I'm curious: is there a gaurantee
> about sets of floats?  Or a warning?

sets of floats work exactly like sets of anything else and thus in
particular they DO intrinsically rely on == comparisons, i.e., exact
equality checks (just like dicts whose keys are floats, etc).

In your code, some "fractions" that actually differ from others you're
previously seen will in fact be skipped because they don't differ _by
enough_ -- i.e. they do compare == to within the limited precision of
floating-point computations.  But if you do want to be yielding floats,
and never want to yield the (num, denom) tuples for two items that *as
float* compare ==, there's nothing you can do about that issue.

My main suggestion to you actually would be to compute hi/lo ONCE per
iteration rather than 3 times -- I detest repetition in principle and
here it may be costing you a few nanoseconds' speed:-)

[[If you don't truly care about whether the fractions you yield do
compare as == "as floats", you might e.g. use gmpy.mpq rather than
division to perform your checks]]


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


Re: My Python annoyances

2007-05-04 Thread Alex Martelli
Ben Collver <[EMAIL PROTECTED]> wrote:

> Chris Mellon wrote:
> > You should "check" for the methods by calling them. If the object
> > doesn't support the method in question, you will get a runtime
> > exception. Premature inspection of an object is rarely useful and
> > often outright harmful.
> 
> That makes sense, thank you for the response.
> 
> What about the case where I have an array of objects that represent some
> particular binary file format.  If the object is a file, then I want to
> copy its contents.  If the object is a string, then I want to write the
> string.  And so forth.

"Type-switching" in this way is a rather dubious practice in any
language (it can't respect the "open-closed" principle).  Can't you have
those objects wrapped in suitable wrappers with a "copyorwrite" method
that knows what to do?  For example, StringIO.StringIO is a standard
library wrapper type that makes a string look like a file.

It's a reasonable request you can make to whatever code is putting stuff
in that container: make the container "weakly homogeneous" by having it
stuffed only with "suitably file-like" objects.  Dealing with totally
and weirdly heterogeneous containers is not a sensible task, because
there will be infinite types that COULD be in the container and about
which your code just can't be expected to guess right what to do.


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


Re: Strange terminal behavior after quitting Tkinter application

2007-05-04 Thread Chris
On May 4, 8:52 pm, "Hamilton, William " <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: Chris
> > Subject: Re: Strange terminal behavior after quittingTkinter
> application
> > Clicking 'Quit' or on the window's 'x' causes the application to quit
> > without messing up the terminal. With root.mainloop() commented out,
> > though, no combination of root.quit(), root.destroy(), and sys.exit()
> > stops the terminal from getting messed up.
>
> > So, I should call mainloop() for my application...except that I want
> > to use the commandline, too, and calling mainloop() freezes the
> > commandline. I wonder if there is another way to use the commandline
> > and have a GUI? I couldn't find any clear information about that.
>
> Can you run it in the background?  IIRC, if you put an ampersand ('&')
> at the end of the command line, it will run as a background process and
> leave your command line available for other tasks.  (The marker may be
> something other than &, it's been a long, long time since I've used *nix
> in a gui environment.)

Ah, sorry, I wasn't being precise. I meant the python commandline
python interpreter.

So from a terminal I type (for example):
python -i application.py

This launches the interpreter in my terminal. Then I can start the GUI
(by typing "Application()", for example). If I use mainloop(), I can't
interact with the interpreter from the terminal until I quit the GUI.
Without mainloop(), I can continue to enter python commands.

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


Re: My Python annoyances

2007-05-04 Thread Ben Collver
Alex Martelli wrote:
> "Type-switching" in this way is a rather dubious practice in any
> language (it can't respect the "open-closed" principle).  Can't you have
> those objects wrapped in suitable wrappers with a "copyorwrite" method
> that knows what to do?  For example, StringIO.StringIO is a standard
> library wrapper type that makes a string look like a file.

That is very reasonable.  Thanks again,

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


Re: How do I get type methods?

2007-05-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Thomas Nelson
wrote:

> On May 4, 7:59 am, [EMAIL PROTECTED] wrote:
>> Let me retype my question: what I 'dir()' in case of 'pyuno' type
>> instance?
>> Or in case of 'dict' type instance? Or in case of any other new python
>> type?
> 
 class Foo:
> ... def f(self,x):
> ... print x+1
> ... def g(self,x):
> ... print x-1
> ...
 dir(Foo)
> ['__doc__', '__module__', 'f', 'g']
> 
> Is this not what you want?  These are the only methods in the Foo
> class.

The OPs problem is, there is no access to the class or type because
there is no name.  You can get just instances from a factory function. 

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


Re: Why stay with lisp when there are python and perl?

2007-05-04 Thread Rayiner Hashem
> It is worth noting that eager, statically-typed languages like OCaml and F#
> are many times faster than the other languages at this task. This is
> precisely the forte of OCaml and F#, manipulating trees and graphs.

To be fair, it is also worth noting that both the OCaml and F#
implementations have code generators that are much more advanced than
the usual suspects in the Lisp world (save maybe for Allegro, with
which I have no experience). The OCaml code generator is reknowned for
producing good code. And of course, F# has the benefit of the CLR code
generator, which is state of the art.

I don't know why the ML-family language implementations tend to have
better code generators, but they do. SML/NJ's register allocator is an
iterated-coalescing implementation written by Appel himself.
Meanwhile, SBCL's allocator is a simple heuristic implementation,
which wouldn't have been state of the art even 25 years ago. MLton
does a full suite of SSA-based optimizations. SBCL's doesn't even do
peephole optimization. And of course the CLR does *everything* (with
Microsoft's $$$, there is no excuse for it not to).

PS) I don't mean to pick on SBCL here. I'm just using it as an example
because it's state of the art as far as free Lisp compilers go.

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


Re: Lisp for the C21

2007-05-04 Thread Paul Rubin
Mark Tarver <[EMAIL PROTECTED]> writes:
> See my remarks on the Lisp for the Twenty First Century
> http://www.lambdassociates.org/lC21.htm

Anyone who didn't love lisp in the 20th century has no heart.
Anyone who still loves it in the 21st, has no head.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How safe is a set of floats?

2007-05-04 Thread Paul McGuire
On May 4, 9:50 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Thomas Nelson <[EMAIL PROTECTED]> wrote:
> > I want to generate all the fractions between 1 and limit (with
> > limit>1) in an orderly fashion, without duplicates.
>
> > def all_ratios(limit):
> > s = set()
> > hi = 1.0
> > lo = 1.0
> > while True:
> > if hi/lo not in s:
> > s.add(hi/lo)
> > yield (hi,lo)
> > hi += 1
> > if hi/lo > limit:
> > lo += 1
> > hi = lo
>
> > I use a set to keep from giving duplicates; but is this safe?  In C
> > they always tell you not to trust floating point equality comparisons,
> > since they may not work as you expect.  My code seems fine for the
> > limited amount I've tested, but I'm curious: is there a gaurantee
> > about sets of floats?  Or a warning?
>
> sets of floats work exactly like sets of anything else and thus in
> particular they DO intrinsically rely on == comparisons, i.e., exact
> equality checks (just like dicts whose keys are floats, etc).
>
> In your code, some "fractions" that actually differ from others you're
> previously seen will in fact be skipped because they don't differ _by
> enough_ -- i.e. they do compare == to within the limited precision of
> floating-point computations.  But if you do want to be yielding floats,
> and never want to yield the (num, denom) tuples for two items that *as
> float* compare ==, there's nothing you can do about that issue.
>
> My main suggestion to you actually would be to compute hi/lo ONCE per
> iteration rather than 3 times -- I detest repetition in principle and
> here it may be costing you a few nanoseconds' speed:-)
>
> [[If you don't truly care about whether the fractions you yield do
> compare as == "as floats", you might e.g. use gmpy.mpq rather than
> division to perform your checks]]
>
> Alex- Hide quoted text -
>
> - Show quoted text -

Does set membership test for equality ("==") or identity ("is")?  I
just did some simple class tests, and it looks like sets test for
identity.  So if I were to create a Rational class in which
Rational(1,2) and Rational(2,4) both evaluate to 0.5, such that
Rational(1,2) == Rational(2,4) evaluates to True, a set of such
Rationals would still hold both instances.

-- Paul


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


Re: curses mystical error output

2007-05-04 Thread Skip Montanaro
> You might be trying to write to a section that is currently off
> screen.

Bingo.  I *thought* I was okay, but I wasn't refreshing until the
end of the display loop, so I never saw all the addstr() calls that
had succeeded but which had yet to be painted.  Adding a refresh()
call in the loop exposed my ignorance.

Thx Ian,

Skip




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


Re: How safe is a set of floats?

2007-05-04 Thread Arnaud Delobelle
On May 4, 3:21 pm, Thomas Nelson <[EMAIL PROTECTED]> wrote:
> I want to generate all the fractions between 1 and limit (with
> limit>1) in an orderly fashion, without duplicates.
>
> def all_ratios(limit):
> s = set()
> hi = 1.0
> lo = 1.0
> while True:
> if hi/lo not in s:
> s.add(hi/lo)
> yield (hi,lo)
> hi += 1
> if hi/lo > limit:
> lo += 1
> hi = lo
>
> I use a set to keep from giving duplicates; but is this safe?  In C
> they always tell you not to trust floating point equality comparisons,
> since they may not work as you expect.  My code seems fine for the
> limited amount I've tested, but I'm curious: is there a gaurantee
> about sets of floats?  Or a warning?

There won't be either, but you actually don't need to store the
previous fractions.  All you need to verify is that the denominator
and numerator are relatively prime (i.e. their gcd is 1).  That could
be implemented as:


from itertools import count

def gcd(x, y):
while x:
x, y = y % x, x
return y

def all_ratios(limit):
for d in count(1):
for n in xrange(d, int(limit*d) + 1):
if gcd(d, n) == 1:
yield n, d


HTH

--
Arnaud

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


ANN: ActivePython 2.5.1.1 is now available

2007-05-04 Thread Trent Mick
I'm happy to announce that ActivePython 2.5.1.1 is now available for
download from:
 http://www.activestate.com/products/activepython/

This is a patch release that updates ActivePython to core Python 2.5.1.
This release also fixes a couple problems with running pydoc from the
command line on Windows. See the release notes for full details:
http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/relnotes.html


What is ActivePython?
-

ActivePython is ActiveState's binary distribution of Python. Builds for
Windows, Mac OS X, Linux, HP-UX and AIX are made freely available.

ActivePython includes the Python core and the many core extensions: zlib
and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite
(sqlite3) database libraries, OpenSSL bindings for HTTPS support, the
Tix GUI widgets for Tkinter, ElementTree for XML processing, ctypes (on
supported platforms) for low-level library access, and others. The
Windows distribution ships with PyWin32 -- a suite of Windows tools
developed by Mark Hammond, including bindings to the Win32 API and
Windows COM. See this page for full details:
http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/whatsincluded.html

As well, ActivePython ships with a wealth of documentation for both new
and experienced Python programmers. In addition to the core Python docs,
ActivePython includes the "What's New in Python" series, "Dive into
Python", the Python FAQs & HOWTOs, and the Python Enhancement Proposals
(PEPs).

An online version of the docs can be found here:
 http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/welcome.html

We would welcome any and all feedback to:
 [EMAIL PROTECTED]

Please file bugs against ActivePython at:
 http://bugs.activestate.com/query.cgi?set_product=ActivePython


On what platforms does ActivePython run?


ActivePython includes installers for the following platforms:

- Windows/x86
- Mac OS X
- Linux/x86
- Solaris/SPARC
- Solaris/x86
- Windows/x64 ("x64" is also known as "AMD64")
- Linux/x86_64 ("x86_64" is also known as "AMD64")
- HP-UX/PA-RISC
- AIX/PowerPC


Extra Bits
--

ActivePython releases also include the following:

- ActivePython25.chm: An MS compiled help collection of the full
   ActivePython documentation set. Linux users of applications such as
   xCHM might find this useful. This package is installed by default on
   Windows.

Extra bits are available from:
 http://downloads.activestate.com/ActivePython/etc/


Thanks, and enjoy!

Trent, Python Tech Lead

--
Trent Mick
trentm at activestate.com


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


Re: Why are functions atomic?

2007-05-04 Thread John Nagle
Michael wrote:
> On May 2, 6:08 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
> 
>>On Tue, 2007-05-01 at 22:21 -0700, Michael wrote:

> I agree the performance gains are minimal.  Using function defaults
> rather than closures, however, seemed much cleaner an more explicit to
> me.  For example, I have been bitten by the following before:
>
def f(x):
> 
> ... def g():
> ... x = x + 1

 Too cute.  Don't nest functions in Python; the scoping model
isn't really designed for it.

>>An overriding theme in this thread is that you are greatly concerned
>>with the speed of your solution rather than the structure and
>>readability of your code.
...
> 
> @define_options(first_option='abs_tol')
> def step(f,x,J,abs_tol=1e-12,rel_tol=1e-8,**kwargs):
>"""Take a step to minimize f(x) using the jacobian J.
>Return (new_x,converged) where converged is true if the tolerance
>has been met.
>"""

Python probably isn't the right language for N-dimensional optimization
if performance is a major concern. That's a very compute-intensive operation. 
I've done it in C++, with heavy use of inlines, and had to work hard to
get the performance up.  (I was one of the first to do physics engines for
games and animation, which is a rather compute-intensive problem.)

If you're doing number-crunching in Python, it's essential to use
NumPy or some other C library for matrix operations, or it's going to
take way too long.

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


Re: Microsoft's Dynamic Languages Runtime (DLR)

2007-05-04 Thread Kaz Kylheku
On May 2, 5:19 pm, sturlamolden <[EMAIL PROTECTED]> wrote:
> On May 3, 2:15 am, Kaz Kylheku <[EMAIL PROTECTED]> wrote:
>
> > Kindly refrain from creating any more off-topic, cross-posted threads.
> > Thanks.
>
> The only off-topic posting in this thread is your own (and now this
> one).

You are making a very clumsy entrance into these newsgroups. So far
you have started two cross-posted threads. The first is only topical
in comp.lang.python (how to emulate macros in Python). This one is
topical in neither one, since it is about Microsoft DLR.

It's quite possible that some Lisp and Python programmers have a
strong interest in Microsoft DLR. Those people who have such an
interest (regardless of whether they are Lisp and Python user also)
and who like to read Usenet will almost certainly find a Microsoft DLR
newsgroup for reading about and discussing Microsoft DLR. Do you not
agree?

Also note that there is very rarely, if ever, any good reason for
starting a thread which is crossposted among comp.lang.* newsgroups,
even if the subject contains elements that are topical in all of them
(yours does not).

> Begone.

You are childishly beckoning Usenet etiquette to be gone so that you
may do whatever you wish. But I trust that you will not, out of spite
for being rebuked, turn a few small mistakes into a persistent style.

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


Re: How safe is a set of floats?

2007-05-04 Thread Peter Otten
Paul McGuire wrote:

> Does set membership test for equality ("==") or identity ("is")?  

As Alex said, equality:

>>> a = 0.0
>>> b = -0.0
>>> a is b
False
>>> a == b
True
>>> set([a, b])
set([0.0])

Peter

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


Re: is there a module to work with pickled objects storage in database?

2007-05-04 Thread Bruno Desthuilliers
krishnakant Mane a écrit :
> hello all,
> I am trying a very complex kind of a task in a project.
> I have a knowledge management system where I need to store a lot of
> objects (pickled).  I have to store mostly lists and dictionaries into
> a rdbms.

Which totally defeats the purpose of a rdbms.

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


Re: New York City Python Users Group Meeting - Tuesday May 8th

2007-05-04 Thread ddimuc




Does that mean if I am not "in the NYC area", I am not welcomed?  Not
even if I frequently visit NYC (Manhattan)?  If I were born and raised
in NYC (not necessarily Manhattan), would I be granted the opportunity
to attend?  Hmm...

DPD.

John Clark wrote:

  
  
  
  
  Greetings!
  The next New York City Python Users Group meeting
is this Tuesday, May 8th, 6:30pm at at the
Millennium Partners office at 666 Fifth Avenue (53rd St. and 5th Ave.)
on the 8th Floor. We welcome all those in the NYC area who are
interested in Python to attend. However, we need a list of first and
last names to give to building security to make sure you can gain
access to the building. RSVP to [EMAIL PROTECTED] to add your name to the
list. 
  More information can be found on the yahoo group
page:
  http://tech.groups.yahoo.com/group/nycpython/
  Hope to see you there!
  -John
  
  
  

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.6.2/779 - Release Date: 4/28/2007 3:32 PM
  



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

  1   2   >