Re: Python for web...

2008-02-25 Thread Ivan Van Laningham
Hi All--
I didn't have any trouble setting up mod_python  Django.  However, I
am my own hosting provider.  That may make a difference. ;-)

I can install fastcgi if it's a big win.

Metta,
Ivan

On Mon, Feb 25, 2008 at 6:48 AM, Berco Beute [EMAIL PROTECTED] wrote:
  Use mod_python if you can.

  Although mod_python is fine, I had more success using fastcgi with
  Django (you can run Django as a fastcgi process). It was less
  troublesome to set up and the chances your hosting provider supports
  it are bigger.

  2B


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




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for web...

2008-02-24 Thread Ivan Van Laningham
Hi All--
Django is slick.  I just yesterday picked up the book and started
poking away.  Downloaded, Installed and running in about ten minutes
(I have several servers I can play with).  Today I have several
working pages.

Use mod_python if you can.

Django-mind-Beginner's-mind-ly y'rs,
Ivan

On Sun, Feb 24, 2008 at 12:03 PM, Tamer Higazi [EMAIL PROTECTED] wrote:
 http://www.djangobook.com/

  if you love to read that book online. Otherwise, if you don't have DSL,
  just mirror the site for offline usage with wget

  Tamer

  [EMAIL PROTECTED] wrote:
   Hi everyone,
  
   I have to develop a web based enterprise application for my final year
   project. Since i am interested in open source, i searched the net.
   Almost 90% of them were PHP and MySQL. Cant we use python for that ? I
   tried several sites, but there is not enough tutorial for beginners
   [mod_python, PSP etc]. I couldnt find any detailed book, not even a
   single book :( All the python books are covering only CGI part)
  
   Any suggestions? Any recommended book?
  
   Execuse my English.
  
   Thushanthan.
  --
  http://mail.python.org/mailman/listinfo/python-list




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Solve a Debate

2008-02-15 Thread Ivan Van Laningham
Hi All--
Lookup tables are always significantly faster than a bunch of ifs.

Metta,
Ivan

On Fri, Feb 15, 2008 at 10:10 AM, Tim Chase
[EMAIL PROTECTED] wrote:
  Ok the problem we had been asked a while back, to do a programming
   exercise (in college)
   That would tell you how many days there are in a month given a
   specific month.
  
   Ok I did my like this (just pseudo):
  
   If month = 1 or 3 or etc 
   noDays = 31
   Elseif month = 4 or 6 etc 
   noDays = 30
   Else
   noDays = 29
   (we didn't have to take into account a leap year)
  
   He declared an array and assigned the number of days in a month to its
   own element in an array. Now
   I realise that in this example it would not make a difference in terms
   of efficiency, but it is my belief that if
   there is more data that needed to be assigned(i.e. a couple megs of
   data) it would be simpler (and more efficient) to
   do a compare rather then assigning all that data to an array, since
   you are only going to be using 1 value and the rest
   of the data in the array is useless.
  
   What are everyone else's thoughts on this?

  Well, the standard library offers its opinion:

import calendar
calendar.mdays
   [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
month = 2
calendar.mdays[month]
   28

  If you want the actual number of days, taking leap-years into
  consideration

calendar.monthrange(2008,2)[1]
   29
calendar.monthrange(2007,2)[1]
   28

  So the answer is mu...let Python do the work for you :)

  -tkc






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




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why not a Python compiler?

2008-02-07 Thread Ivan Van Laningham
Gary Kurtz at SunCon 77 explained that it was a test to see if Obi-Wan
knew what he was doing; supposedly, Obi-Wan's expression indicated
that he knew Solo was feeding him shit.

I think Lucas didn't have a clue, myself; it's not credible that
citizens of a starfaring civilization who deliberately set out to hire
a starship wouldn't know the difference between time and distance.
Occam's razor says Lucas screwed up and doesn't want to admit it.

Metta,
Ivan

On Feb 7, 2008 1:05 PM, Grant Edwards [EMAIL PROTECTED] wrote:
 On 2008-02-06, Gary Duzan [EMAIL PROTECTED] wrote:
  In article [EMAIL PROTECTED],
  Grant Edwards  [EMAIL PROTECTED] wrote:
 On 2008-02-06, Reedick, Andrew [EMAIL PROTECTED] wrote:
 
  One demerit has been marked against your geek card for missing
  an obvious science pun.  Additionally, your membership to the
  Star Trek Lifestyle Adventure Club has been put on
  probationary status for the next twelve parsecs.
 
 Ouch. Two demerits for using the distance unit parsec in a
 context where a quantity of time was required.
 
 No demerits for Andrew; it is a Star Wars reference, which is
  quite on topic for this subthread.
 
  http://starwars.wikia.com/wiki/Kessel_Run

 Silly me.

 I wonder if George Lucas intended it as a joke or if he thought
 a parsec was a unit of time.

 --
 Grant Edwards   grante Yow! Clear the laundromat!!
   at   This whirl-o-matic just had
visi.coma nuclear meltdown!!

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




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Tkinter scrollbar callback

2008-01-30 Thread Ivan Van Laningham
HI All--
We've decided that this represents a bug in the tcl/tk library, and
there's no workaround.  I switched to + and - buttons, which are not
as nice aesthetically but work correctly on both Windows  Linux.

Thanks to everyone for their help.

Metta,
Ivan

On Jan 29, 2008 11:03 AM, Ivan Van Laningham [EMAIL PROTECTED] wrote:
 No Joy.

 Waits the 1 second, then clicks the button once per second until the
 limit's reached.

 Sigh.

 Metta,
 Ivan


 On Jan 29, 2008 10:20 AM, Russell E Owen [EMAIL PROTECTED] wrote:
  Nope:
  
  'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'),
  
  And even after I set it, it looks funny:
  
  'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', 
  '1000'),
  
  And when I try it with the new repeatdelay (1000), the only thing that
  has changed is that it waits 1000 milliseconds before exhibiting the
  same uncontrolled growth as before.
 
  You need to change repeatinterval, not repeatdelay.
 
  As to looking funny: that is the standard output format for
  configure(). I think can get a more reasonable value using
  cget(repeatdelay).
 
  -- Russell
 
 
  
  Metta,
  Ivan
  
  On Jan 25, 2008 5:49 PM, Russell E. Owen [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
 Ivan Van Laningham [EMAIL PROTECTED] wrote:
  
 Hi All--
 That helps.  Doing a get() on the scrollbar before a set(0.0,0.0)
 returns a 4-tuple:  (0.0, 0.0, 0.0, 0.0)  !  I did the set(0.0,0.0)
 and now the callback gets the correct number of arguments.

 However, I'm still getting the weird behaviour when clicking the
 arrowheads--and the heads are all I want.  They act like they've been
 set to a keybounce timeout of about a millisecond. ...  The arrow
 click increments the number of cells in a table row (effectively), and
 it shoots up from 5 to 26 columns almost instantly (that's the
 internal max I set).
  
Is the scroll bar's repeatinterval set to a reasonable value?
  
-- Russell
  
--
http://mail.python.org/mailman/listinfo/python-list
  
  
  
  
  --
  Ivan Van Laningham
  God N Locomotive Works
  http://www.pauahtun.org/
  http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
  Army Signal Corps:  Cu Chi, Class of '70
  Author:  Teach Yourself Python in 24 Hours
 
 



 --

 Ivan Van Laningham
 God N Locomotive Works
 http://www.pauahtun.org/
 http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
 Army Signal Corps:  Cu Chi, Class of '70
 Author:  Teach Yourself Python in 24 Hours




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Tkinter scrollbar callback

2008-01-29 Thread Ivan Van Laningham
Nope:

'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'),

And even after I set it, it looks funny:

'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '1000'),

And when I try it with the new repeatdelay (1000), the only thing that
has changed is that it waits 1000 milliseconds before exhibiting the
same uncontrolled growth as before.

Metta,
Ivan

On Jan 25, 2008 5:49 PM, Russell E. Owen [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
  Ivan Van Laningham [EMAIL PROTECTED] wrote:

  Hi All--
  That helps.  Doing a get() on the scrollbar before a set(0.0,0.0)
  returns a 4-tuple:  (0.0, 0.0, 0.0, 0.0)  !  I did the set(0.0,0.0)
  and now the callback gets the correct number of arguments.
 
  However, I'm still getting the weird behaviour when clicking the
  arrowheads--and the heads are all I want.  They act like they've been
  set to a keybounce timeout of about a millisecond. ...  The arrow
  click increments the number of cells in a table row (effectively), and
  it shoots up from 5 to 26 columns almost instantly (that's the
  internal max I set).

 Is the scroll bar's repeatinterval set to a reasonable value?

 -- Russell

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




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Tkinter scrollbar callback

2008-01-29 Thread Ivan Van Laningham
No Joy.

Waits the 1 second, then clicks the button once per second until the
limit's reached.

Sigh.

Metta,
Ivan

On Jan 29, 2008 10:20 AM, Russell E Owen [EMAIL PROTECTED] wrote:
 Nope:
 
 'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '300'),
 
 And even after I set it, it looks funny:
 
 'repeatdelay': ('repeatdelay', 'repeatDelay', 'RepeatDelay', '300', '1000'),
 
 And when I try it with the new repeatdelay (1000), the only thing that
 has changed is that it waits 1000 milliseconds before exhibiting the
 same uncontrolled growth as before.

 You need to change repeatinterval, not repeatdelay.

 As to looking funny: that is the standard output format for
 configure(). I think can get a more reasonable value using
 cget(repeatdelay).

 -- Russell


 
 Metta,
 Ivan
 
 On Jan 25, 2008 5:49 PM, Russell E. Owen [EMAIL PROTECTED] wrote:
   In article [EMAIL PROTECTED],
Ivan Van Laningham [EMAIL PROTECTED] wrote:
 
Hi All--
That helps.  Doing a get() on the scrollbar before a set(0.0,0.0)
returns a 4-tuple:  (0.0, 0.0, 0.0, 0.0)  !  I did the set(0.0,0.0)
and now the callback gets the correct number of arguments.
   
However, I'm still getting the weird behaviour when clicking the
arrowheads--and the heads are all I want.  They act like they've been
set to a keybounce timeout of about a millisecond. ...  The arrow
click increments the number of cells in a table row (effectively), and
it shoots up from 5 to 26 columns almost instantly (that's the
internal max I set).
 
   Is the scroll bar's repeatinterval set to a reasonable value?
 
   -- Russell
 
   --
   http://mail.python.org/mailman/listinfo/python-list
 
 
 
 
 --
 Ivan Van Laningham
 God N Locomotive Works
 http://www.pauahtun.org/
 http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
 Army Signal Corps:  Cu Chi, Class of '70
 Author:  Teach Yourself Python in 24 Hours





-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with Tkinter scrollbar callback

2008-01-24 Thread Ivan Van Laningham
Hi All--
I'm having two problems with the scrollbar callback on linux systems
(Fedora 7, Suse 10.1,2 and 3 all exhibit the issues).

Problem one:  on Windows, the callback is called with the arguments as
specified in the doc:  scroll, 1 or -1, units.  When I run the
identical code on linux, the callback is invoked with only one
argument, 1 or -1.  Here's a small program which demos the
problem:

begin
#!/usr/bin/env python

from Tkinter import *
import sys

def die(event):
sys.exit(0)
def sDoit(*args):
  for i in args:
print scrollbar:,i, type(i)
root=Tk()
f=Frame(root)
f.pack(expand=1,fill=BOTH)
button=Button(f,width=25)
button[text]=Quit
button.bind(Button,die)
button.pack()
xb=Scrollbar(f,orient=HORIZONTAL,command=sDoit)
xb.pack()
root.mainloop()
=end===

On Windows, it produces the correct output

scrollbar: scroll type 'str'
scrollbar: 1 type 'str'
scrollbar: units type 'str'

but on linux, it produces

scrollbar: 1 type 'str'

I can't believe that this is a bug that has not already been fixed, so
I must be doing something wrong.  But what?  I'm surely overlooking
something dead obvious. ...

Note that I don't want to use this as a scrollbar, all I need is the direction.

The second problem is more pernicious, in that I can work around the
first problem, and I don't really have a clue on the second.  On
Windows, clicking one of the arrow buttons produces one callback.  On
Linux, in the real application, if I click an arrow button once, the
callback continues to be called until I kill the app.  That doesn't
happen in the small program I've provided above, so I'm at a bit of a
loss where to start looking.  Any hints?

Metta,
Ivan
-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Tkinter scrollbar callback

2008-01-24 Thread Ivan Van Laningham
Hi All--
That helps.  Doing a get() on the scrollbar before a set(0.0,0.0)
returns a 4-tuple:  (0.0, 0.0, 0.0, 0.0)  !  I did the set(0.0,0.0)
and now the callback gets the correct number of arguments.

However, I'm still getting the weird behaviour when clicking the
arrowheads--and the heads are all I want.  They act like they've been
set to a keybounce timeout of about a millisecond. ...  The arrow
click increments the number of cells in a table row (effectively), and
it shoots up from 5 to 26 columns almost instantly (that's the
internal max I set).

Metta,
Ivan

On Jan 24, 2008 4:27 PM, Russell E. Owen [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],

  Ivan Van Laningham [EMAIL PROTECTED] wrote:

  Hi All--
  I'm having two problems with the scrollbar callback on linux systems
  (Fedora 7, Suse 10.1,2 and 3 all exhibit the issues).
 
  Problem one:  on Windows, the callback is called with the arguments as
  specified in the doc:  scroll, 1 or -1, units.  When I run the
  identical code on linux, the callback is invoked with only one
  argument, 1 or -1.  Here's a small program which demos the
  problem:
 
  begin
  #!/usr/bin/env python
 
  from Tkinter import *
  import sys
 
  def die(event):
  sys.exit(0)
  def sDoit(*args):
for i in args:
  print scrollbar:,i, type(i)
  root=Tk()
  f=Frame(root)
  f.pack(expand=1,fill=BOTH)
  button=Button(f,width=25)
  button[text]=Quit
  button.bind(Button,die)
  button.pack()
  xb=Scrollbar(f,orient=HORIZONTAL,command=sDoit)
  xb.pack()
  root.mainloop()
  =end===
 
  On Windows, it produces the correct output
 
  scrollbar: scroll type 'str'
  scrollbar: 1 type 'str'
  scrollbar: units type 'str'
 
  but on linux, it produces
 
  scrollbar: 1 type 'str'

 I see the same bad thing on our RedHat Enteprise unix system which has
 the default tcl/tk 8.4.6. However I found that if you send the scrollbar
 the set command first then it behaves normally. I think it just starts
 out in a funny state where it has no idea how to display itself.

 -- Russell

 (P.s. it works fine on my MacOS X 10.4.11 system with default tcl 8.4.7
 or with add-on 8.4.14).
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: World's largest Python caught!:)

2005-08-08 Thread Ivan Van Laningham
Hi All--

James Stroud wrote:
 
 http://www.afghania.com/News-article-sid-4792-mode-thread.html
 
 3rd hit in google with world's largest python. The first two hits were your
 email below to the newsgroups.
 

This hit says it's not the world's largest:

http://www.reptilia.org/NEWS.htm

And this one offers a better picture:

http://www.clubavalanche.com/forums/index.php?showtopic=2837;

Metta,
Ivan


 James
 
 On Sunday 07 August 2005 09:15 pm, Ashok Rajasingh wrote:
  Hi
 
 
 
  Can I please get some information on this python?  I saw a brief news
  clip last year  am very keen to know more.
 
 
 
  Thanks
 
  Ashok Rajasingh
 
  21 Cumberland street
 
  New Plymouth
 
  New Zealand
 
  +646 7575698 (home)
 
7599592 (work)
 
 
 
 
  ##
  Attention:
  The information contained in this message and or attachments is intended
  only for the person or entity to which it is addressed and may contain
  confidential and/or privileged material. Any review, retransmission,
  dissemination or other use of, or taking of any action in reliance upon,
  this information by persons or entities other than the intended recipient
  is prohibited. If you received this in error, please contact the sender and
  delete the material from any system and destroy any copies. Please note
  that the views or opinions expressed in this message may be those of the
  individual and not necessarily those of Tegel Foods Ltd.
 
  This email was scanned and cleared by NetIQ MailMarshal.
  ##
 
 --
 James Stroud
 UCLA-DOE Institute for Genomics and Proteomics
 Box 951570
 Los Angeles, CA 90095
 
 http://www.jamesstroud.com/
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [path-PEP] Path inherits from basestring again

2005-07-30 Thread Ivan Van Laningham
Hi All--

Tony Meyer wrote:
 
  (Those who are offended by sweeping generalisations should
  ignore this next bit)
 [...generalisation bit snipped...]
  This is not only bullshit, it's elitist bullshit.  Windows users are
  more clueless than users of posix systems.  Pfui.  Prove it
  or withdraw it.
 
 Sigh.  I guess you didn't read or understand the first sentence?
 

Yes, I read and understood it.  Saying Don't read this if you don't
want to be offended doesn't make an offensive statement inoffensive.

  This (readability without knowing the language/standard
  libraries) is a huge benefit of using Python.
 
  It's overrated.  It must be macho to say I learned Python without
  reading books.
 
 No it is not.  Have you used Python as pseudocode when teaching people how
 to program?  Many people have.  That's just one example.
 

I grant that Python is much easier to learn than other programming
languages; students can pick up the basics rapidly.  Once the basics are
mastered and mentoring is over, reliance on guess and intuition is not a
substitute for documentation, or for reading the code if documentation
is not available.

 People can subclass Path and add it if they really want it.  They can use
 Jason's original module.  My position is that the PEP without this use of
 __div__ is (a) better as a standard module, and (b) improves the chance of
 the PEP being accepted.
 

I disagree.  Using __div__ to mean path concatenation is no worse than
using __add__ to mean string concatenation, and it is both easy to
remember (once the manual is read) and easy to type.  Requiring users
who want / to mean what it has always meant in the path module is
neither easy nor intuitive.  On the face of it, Jason would seem to
agree, since he created / as a synonym for joinpath().  However, if the
intention here is to create something different from Jason's original
module, create something different and call it by another name than
path; don't attempt to guess what Jason really meant.  It is not
Pythonic to guess.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [path-PEP] Path inherits from basestring again

2005-07-29 Thread Ivan Van Laningham
Hi All--

Tony Meyer wrote:
 
 So far, there have been various statements that look like +0 for __div__,
 but no-one with a +1.  (And I've said this a couple of times now, which
 really is just trolling for a +1 from someone).
 
  It's not a question of saving characters, but readability which, as
  you've said, is a matter of opinion.
 

I like / as a shortcut to joinwith().  I like it a lot.  I like it so
much I'll give you a +2.

 (Those who are offended by sweeping generalisations should ignore this next
 bit)
 
 I think it's also worth considering that Windows users are more clueless
 than users of posix systems.  The readability of __div__ comes from
 familiarity with posix filesystems; for a Windows user, \ would be the
 natural character.  So we're making things more readable for users that are
 already more likely figure things out, and less readable for users that have
 trouble figuring things out.
 

This is not only bullshit, it's elitist bullshit.  Windows users are
more clueless than users of posix systems.  Pfui.  Prove it or withdraw
it.

 1.  ISTM that standard library modules should be as readable as possible,
 even for those that don't use them.  If I'm reading the source for module X
 and it uses a Path object, then it should be pretty straightforward to
 understand what is happening without also having to read the Path
 source/docs.  This (readability without knowing the language/standard
 libraries) is a huge benefit of using Python.
 

It's overrated.  It must be macho to say I learned Python without
reading books.  Next you'll tell me you never ask for directions when
you're lost.

 2.  If I did use the Path module, then I wouldn't use __div__, because it
 looks less readable to me.  I suppose I might find that I got annoyed typing
 joinpath, but I doubt it.  Also, because I have followed this PEP, I know
 that __div__ means joinwith, so if I read code that used path, I would
 understand it - it's too late for me to try reading code as a 'fresh' user
 and see if it confuses me or not.
 

Then that's your right, but don't try to take / away from people who use
it and like it.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [path-PEP] Path inherits from basestring again

2005-07-24 Thread Ivan Van Laningham
Hi All--

Reinhold Birkenfeld wrote:
 
 Reinhold Birkenfeld wrote:
  Hi,
 
  the arguments in the previous thread were convincing enough, so I made the
  Path class inherit from str/unicode again.
 

Thanks.

 * the following methods raise NotImplemented:
   capitalize, expandtabs, join, splitlines, title, zfill
 

If path inherits from str or unicode, why not leave these?  I can
certainly see uses for capitalize(), title() and zfill() when trying to
coerce Windows to let me use the case that I put there in the first
place;-)  What if I wanted to take a (legitimate) directory name
'parking\tlot' and change it to 'parkinglot'?

 Open issues:
 
 What about the is* string methods?

What about them?  What makes you think these wouldn't be useful? 
Imagine directory names made up of all numbers; wouldn't it be useful to
know which directories in a tree of, say, digital camera images,
comprise all numbers, all hex numbers, or alpha only?
 
 What about __contains__ and __getitem__?

I find it hard to imagine what would be returned when asking a path for
say, path[c:], other than the index. n=path[c:] = 0 ? 
 
 What about path * 4?

This one makes my brain hurt, I admit;-)


Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Image orientation and color information with PIL?

2005-07-18 Thread Ivan Van Laningham
Hi All--

[EMAIL PROTECTED] wrote:
 
 Does anyone know if it is possible to determine if an image is
 horizontal/vertical  and color or black  white using the python image
 library?  I have been searching this news group and the information was
 not all clear on this.
 

How are you going to determine the orientation of an image without
sophisticated image analysis?  I suspect Adobe Photoshop can do it, but
I don't know for sure.  You'd have to look for things like sky, or
clouds, overcast sky, people's faces, and so on and so forth.  It'd be
cool to have this available in Python, but unless the F-bot is busier
than I thought and working behind the scenes using his time machine,
it's not there now.

If you write it I'll use it;-)

Color vs BW ought to be easy, though, by analysing the color table, if
there is one, and/or image mode.  Check the PIL documentation.  If you
have only searched the newsgroup then you might have overlooked the
docs.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Earthquake Forecasting Program July 11, 2005

2005-07-18 Thread Ivan Van Laningham
Hi All--

Bob Officer wrote:
 
 On Mon, 11 Jul 2005 08:31:31 GMT, in sci.geo.earthquakes, edgrsprj
 [EMAIL PROTECTED] wrote:
 
 PROPOSED EARTHQUAKE FORECASTING
 COMPUTER PROGRAM DEVELOPMENT EFFORT
 
 sigh here we go again...
 
 EDG is not a computer programmer, nor is he a geologist...
 
 The best guess seems to be that he is he is crackpot, often going from group
 to group espousing some sort of knowledge and asking for people to forward
 his articles to government, schools and other professional bodies with a
 demand that public monies be giving to him to support his research.
 

Well, I guess this is in line with how I persist in seeing the Subject:
header.  _Every_ time I look at it, my brain sees Re: Earthquake
Fornicating Program.

Brings a whole new dimension to Did the earth move for you too,
honey?, doesn't it?

Metta,
the-devil-made-me-ly y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Codecs

2005-07-08 Thread Ivan Van Laningham
Hi All--
As far as I can tell, after looking only at the documentation (and not
searching peps etc.), you cannot query the codecs to give you a list of
registered codecs, or a list of possible codecs it could retrieve for
you if you knew enough to ask for them by name.

Why not?  It seems to me that if I want to try to read an unknown file
using an exhaustive list of possible encodings, the best place to keep
the most current list is the codec registry itself, not in the
documentation for the codec module.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-05 Thread Ivan Van Laningham
Hi All--

Tom Anderson wrote:
 
 I understand that the backslash is popular in some ivory-tower functional
 languages. Currently, a backslash can be used for explicit line joining,
 and is illegal elsewhere on a line outside a string literal, so i think
 it's available for this. It would be utterly unpythonic to use puntuation
 instead of a keyword, and it would make no sense to novices, but it would
 scare the crap out of C programmers, which has to be worth something.
 

Oh, I don't think so.  Don't forget that Perl was written by impatient C
programmers.  I think scaring C programmers, like giving engineers too
much information, is really hard to do.  Live by the sword, die by the
sword.

Metta,
int *(*(*foo)())()-ly y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-07-01 Thread Ivan Van Laningham
Hi All--

Max M wrote:
 
 Another good bet is BeautifulSoup, which is absolutely great for
 scraping content from webpages.
 
 http://crummy.com/software/BeautifulSoup/index.html
 

Not if you want to handle HTML in anything but ASCII.  BeautifulSoup
insists you change your site.py to change the default encoding if you
want to use non-ASCII.  It might work beautifully, but I won't use it,
at least not until it's fixed to understand encodings.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-01 Thread Ivan Van Laningham
Hi All--

Tom Anderson wrote:
 
 Comrades,
 
 I expect tons of disagreement in the feedback, all from ex-Lisp-or-Scheme
 folks. :-)
 
 I disagree strongly with Guido's proposals, and i am not an ex-Lisp,
 -Scheme or -any-other-functional-language programmer; my only other real
 language is Java. I wonder if i'm an outlier.
 
 So, if you're a pythonista who loves map and lambda, and disagrees with
 Guido, what's your background? Functional or not?
 

I'm a pythonista who doesn't love them.  In fact, even though I've done
more than my fair share of lambda Tkinter programming using lambdas,
I've never been happy with lambda.  And I've spent months inside of
Lisp/Emacs Lisp/Scheme, too (I have the world's second largest .emacs
file [my friend Andy Glew has the largest], even though I can't use it
on Windows;-).  I find list comprehensions easier to understand than
map, and small named functions or, better yet, class methods, *tons*
easier to read/understand than lambda--there are too many restrictions
you have to remember.

Personally, I find that Lisp  its derivatives put your head in a very
weird place.  Even weirder than PostScript/Forth/RPN, when you come
right down to it.

I won't miss them, but since I don't use them now, that doesn't mean a
whole lot.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for everything?

2005-06-30 Thread Ivan Van Laningham
Hi All--

Mike Meyer wrote:
 
 [EMAIL PROTECTED] writes:
 
 As other have noted, C was never really used for everything. Unix
 tools were designed to connect together from the very beginning, which
 is what makes shell scripting so powerful. This was true before there
 was a C. Likewise, some things you need more control over the machine
 than you get in C - those are still done in assembler. These days, C
 compilers let you embed assembler statements in your C, so some of
 these things are done in such variants.
 

It really was used for everything; C compilers have *always* let you
include assembler, with the asm keyword.  Unless you're talking about
the early days of DOS/Windows compilers, about which I know little, but
all *KR* compilers had asm.  If you wanted to write kernel code and
device driver code (including disk drivers) for large Unix systems, asm
was a requirement.  To put it in perspective, for Gould systems in the
80s, for the entire OS (BSD-derived Unix), there were under 100 lines of
assembler, all in a very few device drivers (multiple thousands of lines
of code, don't remember exactly how many).

And living with structs instead of classes was not nearly as much of a
pain in the butt as you make out; it was perfectly reasonable to include
methods within structs, by including a pointer to a function.  X10 and
X11 showed just how object-oriented you could get with C, using
callbacks with required signatures, and specifying how Widgets were to
be written--contracts before there were contracts.

It's true that OO languages are better, and languages like Python which
allow you to combine fairly low-level calls with an OO worldview make
life *vastly* easier, but C is still hugely flexible, highly adaptable,
and very powerful.  For about 10 or 15 years there, knowing C was pretty
much a guarantee of a good job.  That changed when C++ compilers became
common and good and not merely preprocessors that wrote really, really
ugly C.

Metta,
while(*s++=*p++);-ly y'rs,
Ivan;-)
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-28 Thread Ivan Van Laningham
Hi All--

Mike Meyer wrote:
 
 Since the user is the one bound with BD languages, they are clearly
 tops. Which makes Python a bottom.
 

Well, we certainly hope Python has a safe word.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Ivan Van Laningham
Hi All--

Aahz wrote:
 
 Perhaps.  But adding the time to learn those IDEs in addition to the time
 to learn Java is ridiculous.  I've been forced to use Java a bit to
 support credit cards for our web application; I've got a friend whose
 Java-vs-Python argument hinges on the use of Eclipse; I was unable to
 make use of Eclipse in the time I had available for the project.
 

Were there _good_ reasons not to do the credit card part of the web app
in Java instead of Python?  As in, there is no secure module, or you
didn't have time, or Python doesn't support crucial APIs?  I'm very
curious.

 f u cn rd ths, u cn gt a gd jb n nx prgrmmng.


l tk t.

Metta,
Ivan 
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which kid's beginners programming - Python or Forth?

2005-06-27 Thread Ivan Van Laningham
Hi All--

Roy Smith wrote:
   When you learn Forth, you will have learned Forth.
 About the best that can be said about that is that It'll give you a
 head-start if your next goal is to learn PostScript :-)
 

In which case, you should start with PostScript;-)  I learned it by
plugging a glass tty into the serial port on one of the very first
AppleWriters and typing away.  None of this fancy-shmancy ''
business;-)  But what a great reward, having graphics come out the
printer when you typed 'show'.

Seriously, PostScript is a lot more fun to learn than Forth, and more
directly useful.  Since the rewards are so immediate, a kid's attention
could be gained and kept pretty easily.

But I'd still recommend Python as a first programming language.  Keep to
the standard stuff--ignore list comprehensions and so on--until he or
she has the basic control flow down pat.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP ? os.listdir enhancement

2005-06-23 Thread Ivan Van Laningham
Hi All--

Thomas Guettler wrote:
 
 I like it. But as you noticed, too, join would be better than abs.
 
 Example:
 
 # mylistdir.py
 import os
 import sys
 
 def mylistdir(dir, join=False):
 for file in os.listdir(dir):
 yield os.path.join(dir, file)
 
 print list(mylistdir(sys.argv[1]))
 

Mmmm, how about:

# mylistdir.py
import os, os.path
import sys

def mylistdir(dir, join=False):
for file in os.listdir(dir):
if join:
yield join(dir, file)
else:
yield file

print list(mylistdir(sys.argv[1]))

or

print list(mylistdir(sys.argv[1],os.path.join))

That way I could def my own join and call it as

print list(mylistdir(sys.argv[1],myjoin))

(Note that in your version the join argument isn't used at all.)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Ivan Van Laningham
Hi All--

Tim Peters wrote:
 Fortran is so
 eager to allow optimizations that failure due to numeric differences
 in conformance tests rarely withstood challenge.

+1 QOTW

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: key - key pairs

2005-06-23 Thread Ivan Van Laningham
Hi All--

Terry Hancock wrote:
 
 On Thursday 23 June 2005 02:40 pm, Florian Lindner wrote:
  is there in python a kind of dictionary that supports key - key pairs?
  I need a dictionary in which I can access a certain element using two
  different keys, both unique.
 
  For example:
 
  I've a dictionary with strings and times. Sometimes I have the string and I
  want to have the time, other time I've the time and I want the string. It
  is important that one of the keys supports the min/max builtin function.
 
 Well, really, you're always using one or the other as the key and the other
 as the value.  Furthermore, it is not in the general case assured that you
 can do this --- the keys may not really be 1:1.
 
 If you are content to restrict yourself to the 1:1 case, you can construct
 an inverse dictionary from the first dictionary like this:
 
 time2string = dict([ (b,a) for a,b in string2time.items() ])
 
 Note that if string2time has duplicate values, this will arbitrarily pick
 one (in a consistent, but implementation dependent way) to use as
 the key in the inverse mapping.
 

Well, Florian said, using two different keys, both unique; if that is
true, then a single key maps to a single value  vice versa.  Easiest
way, it seems to me, would be to subclass dict and provide get/set that
always insert the value as a key.  So that dict[string]=time also
means dict[time]=string.  Only one dict required then.

Or am I missing something?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A World Beyond Capitalism 2005,

2005-06-23 Thread Ivan Van Laningham
Hi All--

Jenta wrote:
 
 Interesting.
 
 To anyone who didn't want to know about the conference, my apologies.
 
 To everyone who was supportive, thanks.  It is appreciated, because like
 many activists, many python activists have skills which are able to
 network people worldwide.
 

So, uh, what skills do python activists have?  Why are their skills
able to network people when the people who have the skills can't?  And
what defines a python activist anyway?  Blowing up Perl installations
worldwide?  That takes skill?  I thought they could handle that
themselves.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Ivan Van Laningham
Hi All--

Tim Peters wrote:
   Across platforms with a 754-conforming
 libm, the most portable way is via using atan2(!):
 
  pz = 0.0
  mz = -pz
  from math import atan2
  atan2(pz, pz)
 0.0
  atan2(mz, mz)
 -3.1415926535897931


Never fails.  Tim, you gave me the best laugh of the day.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functions with unlimeted variable arguments...

2005-06-18 Thread Ivan Van Laningham
Hi All--

Paul Rubin wrote:
 
 Xah Lee [EMAIL PROTECTED] writes:
  but are there other solutions?
 
   Xah
 
 Geez man, haven't you been around long enough to read the manual?
 
 def f(*a): return a


He's been around long enough to rewrite the manual.

Metta,
if-he-succeeds-we'll-all-have-to-take-up-perl-ly y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: maybe a bug in python: NOW Pythonic Gotchas

2005-06-05 Thread Ivan Van Laningham
Hi All--
This little gotcha ought to be number one on The Official List of
Pythonic Gotchas, which should be required reading for everyone.

What?  There isn't one?  Why not?

Send me your tired, your poor, your huddled gotchas yearning to breathe
free.  I'll whup 'em into shape and make a doc page.  The gods of
documentation (as opposed to the gods _in_ documentation) can transfer
it to the Official Documentation Homeland, or not, as they see fit.

Metta,
Ivan

Tiago Stürmer Daitx wrote:
 
 Just as everyone said, use ('a',) instead of ('a'). As Steve said
 there are lots of documentation about it. Check the Library Reference
 at http://www.python.org/doc/current/lib/typesseq.html#l2h-155 or to
 make things more clear you could read the tuples section in the
 tutorial at
 http://docs.python.org/tut/node7.html#SECTION00730
 
 my 2 cents
 
 Regards,
 Tiago S Daitx
 
 On 6/5/05, flyaflya [EMAIL PROTECTED] wrote:
 
   a = {1: (a)}
   a[1]
  'a'
  why not ('a')? when
   a = {1: (((a)))}
   a[1]
  'a'
  the result is 'a' too,not (((a))).but when use[a] or
  (a,b),the
  tuple is longer than 1, it's no problem.
 
  --
  [http://www.flyaflya.com/]
  --
  http://mail.python.org/mailman/listinfo/python-list
 
 ---
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: REQ: Small Perl to Python conversion needed

2005-06-02 Thread Ivan Van Laningham
Hi All--

John Machin wrote:
 
  how to duplicate the following bit of code using Python dictionaries.
 
 
 [expletives deleted]
 
+1 QOTW

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


PySol not working on WinXP, SP2

2005-06-01 Thread Ivan Van Laningham
Hi All--
I've been using PySol-4.40 for years, because that was the last Windows
installer version I could find.  My wife's been using it for almost the
same length of time.  That version's worked just fine on W98, W98SE, W2K
(server included), and WinXP SP1.

I upgraded to SP2 and pysol fails silently.  Running 'python pysol.pyw'
gives me this error: 

Traceback (most recent call last):

  File pysol.pyw, line 64, in ?

imp.load_compiled(__main__, sys.argv[0])

ImportError: Bad magic number in C:\Program
Files\PySol-4.40\data\pysol.pyc

I can't find any later version on google, although I turned up a thread
on this list regarding running pysol in a later version on W98.  I also
found http://avitous.net/software/pysol-windows/py23.shtml but the
version he has REQUIRES ActiveState python 2.2, even though he says he's
put together a version for 2.3--and of course, I'm running Python 2.4.

My wife's going to be force to upgrade to SP2 some of these days, and
she won't be happy if her solitaire doesn't work.  Does anyone have a
working version?  Anyone know what happened to Markus ... Oberhumer?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySol not working on WinXP, SP2

2005-06-01 Thread Ivan Van Laningham
Hi All--

Robert Kern wrote:
 
 Skip Montanaro wrote:
  Ivan I can't find any later version on google...
 
  It may not help you much, but I was able to get it working on MacOSX by
  grabbing the latest available source and tracking down the contents of the
  data directory via the Wayback Machine.  If you'd like to give it a try (I'm
  not sure how you'd get sound stuff working - I'm not a Windows guy), let me
  know.
 
 Source, data, and OS X binaries for 4.82 also available from here:
 
 http://homepage.mac.com/brian_l/FileSharing6.html
 

Very cool, but MacOSX doesn't help me much.

I'm sure I could get it working on Linux, but I'd like to be able to run
it on my main machine, instead of having to hop back over to the Win98
machine (an option my wife doesn't have). 

Sound server seems to be available as a .pyd file for the Win32
extensions, so I think that's not a problem.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PySol not working on WinXP, SP2

2005-06-01 Thread Ivan Van Laningham
Hi All--

James Carroll wrote:
 
 You might try finding the source to pysol, and you might notice that
 you have a bunch of *.py files and for each of those, a corresponding
 .pyc file.  If you delete all the pyc files, then they'll get
 re-created from the .py files, and you might be all set.
 

Nope.  The pyc files don't match the py files, and he imports the pyc
files directly.  That's what 'imp.load_compiled(__main__,
sys.argv[0])' means.  The windows version that Markus shipped never
included the .py files anyway, since he didn't need them.

Getting the source and trying to run it directly would work if there
were any doc help at all, but there's none.  What little there is is
aimed at Linux.  Makefiles need to be constructed,  there are templates
that get filled out automatically.  

I can get it working eventually, I suppose, but I was really hoping
someone else had done the work already, or at least had pointers to docs
on how to get it working.

Metta,
Ivan

 -Jim
 
 On 6/1/05, Ivan Van Laningham [EMAIL PROTECTED] wrote:
  Hi All--
  I've been using PySol-4.40 for years, because that was the last Windows
  installer version I could find.  My wife's been using it for almost the
  same length of time.  That version's worked just fine on W98, W98SE, W2K
  (server included), and WinXP SP1.
 
  I upgraded to SP2 and pysol fails silently.  Running 'python pysol.pyw'
  gives me this error:
 
  Traceback (most recent call last):
 
File pysol.pyw, line 64, in ?
 
  imp.load_compiled(__main__, sys.argv[0])
 
  ImportError: Bad magic number in C:\Program
  Files\PySol-4.40\data\pysol.pyc
 
  I can't find any later version on google, although I turned up a thread
  on this list regarding running pysol in a later version on W98.  I also
  found http://avitous.net/software/pysol-windows/py23.shtml but the
  version he has REQUIRES ActiveState python 2.2, even though he says he's
  put together a version for 2.3--and of course, I'm running Python 2.4.
 
  My wife's going to be force to upgrade to SP2 some of these days, and
  she won't be happy if her solitaire doesn't work.  Does anyone have a
  working version?  Anyone know what happened to Markus ... Oberhumer?
 
  Metta,
  Ivan
  --
  Ivan Van Laningham
  God N Locomotive Works
  http://www.andi-holmes.com/
  http://www.foretec.com/python/workshops/1998-11/proceedings.html
  Army Signal Corps:  Cu Chi, Class of '70
  Author:  Teach Yourself Python in 24 Hours
  --
  http://mail.python.org/mailman/listinfo/python-list
 
 

-- 
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with pointers

2005-05-31 Thread Ivan Van Laningham
Hi All--

Dave Brueck wrote:
 
 Michael wrote:
  sorry, I'm used to working in c++ :-p
 
  if i do
  a=2
  b=a
  b=0
  then a is still 2!?
 
  so when do = mean a reference to the same object
 
 Always.
 
  and when does it mean make a copy of the object??
 
 Never.
 

To which I would add (without attempting to preserve Dave's admirable
brevity):

a=[3,5,6]
b=a

b is a reference to a; both b and a are names bound to [3,5,6].

a=[3,5,6]
b=a[:]

a and b are now bound to different instances of [3,5,6]

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the problem with cgi

2005-05-29 Thread Ivan Van Laningham
Hi All--

EP wrote:
 
  Has anyone seen that problem with running a python cgi script in a
  server?
  It takes you to myspace.com/redmartian or something. Anyway, does
  anyone know when this problem will be fixed?
 
 Xah Lee is working on it.
 

Oh, that's reassuring.  Does he have his tinfoil hat on?

Metta,
Ivan

PS:  Sorry, I meant, Does he have his fucking tinfoil hat on?
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python forum

2005-05-19 Thread Ivan Van Laningham
Hi All--

Peter Hansen wrote:
 
 Ivan Van Laningham wrote:
  Robert Kern wrote:
 dict.org says _forums_. I used _fora_, but I'm silly.
 
  It also says appendixes and indexes are OK.  Yahoos.
 
 Should that be Yaha?
 

g  Nope.  I appreciate the sentiment, but Yahoo is neither Latin nor
Greek.  Instead, it was invented by Jonathan Swift for _Gulliver's
Travels_, published in 1726; since it is a made-up English word, it
follows the rules of English.

Metta,
Ivan 
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python forum

2005-05-18 Thread Ivan Van Laningham
Hi All--

Robert Kern wrote:
 
 Skip Montanaro wrote:
 
  (Is forums okay as a plural of forum or should I have used fora?)
 
 dict.org says _forums_. I used _fora_, but I'm silly.
 

It also says appendixes and indexes are OK.  Yahoos.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread Ivan Van Laningham
Hi All--

john67 wrote:
 
 LOL!  That is really funny, in a dark humor kind of way.  I don't want
 the project to fail either.  I am not convinced that we will succeed if
 we go the Java route.  However, I am just a grunt in the chain and not
 in a position to make the decision.  I hope I can have some influence
 on the decision though.  I will be pleased if I can get someone to at
 least seriously consider Python.
 
 I understand your sentiment about not encouraging something that might
 fail to be done in Python.  Hopefully it won't come to that.  Thanks
 for the info on Phaseit apps.


What you're going to run into are two major stumbling blocks.  One,
Python's got no credibility with management types unless the
credibility's already there.  Python?  Never heard of it.  Tell me
about it.  ...   Oh, it's interpreted, is it?  Interesting.  You can
see Python going down the sewer pipes, right on their faces.  Two,
security.  This python sounds pretty interesting.  Tell me about the
security.  How can we prevent people from stealing our source code,
which we just spent millions developing?  ...  Hmm, trust the developers
out there not to peek?  Oh, sure, let's use it.  (True, there are ways
around the second, but you're going to have to talk _very_ fast and have
ALL the answers before the management type gets to his/her office and
shuts the door in your face and on your idea.)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NaN support etc.

2005-05-18 Thread Ivan Van Laningham
Hi All--

Martin v. Löwis wrote:
 
 Andreas Beyer wrote:
  How do I find out if NaN, infinity and alike is supported on the current
  python platform?
 
 To rephrase Sebastian's (correct) answer: by
 
 1. studying the documentation of the CPU vendor
 2. studying the documentation of the compiler vendor, and performing
extensive tests on how the compiler deals with IEEE-754
 3. studying the documentation of the system's C library, reading
its source code (if available), and performing extensive tests
of the IEEE-754 support in the C libray
 4. studying Python's source code (you can spare yourself reading
documentation because there is none)
 
  Is there an 'official' handle for obtaining this information?
 
 No.
 
  Similar: How do I get the maximum/minimum double for current machine?
 
 By experimentation, and/or reading vendor documentation.
 

Something that might help a little is

http://www.pauahtun.org/TYPython/machar.zip

It's C source that you can compile on a unix system, and an .exe for
windows, to probe the limits of the IEEE-754 support on a system.  It's
not set up to show you NaN, but by studying the docs on your particular
system you could modify the code to print stuff like that out, I'd
think.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread Ivan Van Laningham
Hi All--

George Sakkis wrote:
 
 Ivan Van Laningham wrote:
 
 An idea that perhaps takes the best of both worlds is use java for the
 high level architecture and static type interfaces, and write the bulk
 of the implementation in jython. PSF has awarded a grant to make jython
 catch up with cpython, and that's good news for making the transition
 from java to python smoother to a large audience. Others may have more
 to say on the pros and cons of going with java/jython instead of
 cpython, but it seems a good compromise to me.
 

And another option that you'll find has a great deal of viability is
using Python in the build process.  Python's _wonderful_ to glue things
together, and its i18n capabilities are outstanding; I handled all the
internationalization and mock translation processes for a project near
the size you're describing in a dozen languages without working up a
sweat.  Python is easily called by Ant, it deals really well with
unicode  utf-8, can easily parse Java resource files and XML files, and
you can stick all this stuff together in a few hours to handle _really
big builds_.

It's been nearly a year since the project failed and the company riffed
60 people from our site besides me, and the java monkeys that are left
are still using my Python scripts, in the same state I left 'em.  They
can run them but they can't modify them.  And every time they have to
produce a new mock-translation build, they complain to their boss:  We
used to have someone here who LIKED to do this stuff!  And who could fix
it when it broke!  We laid him off WHY

;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Representing ambiguity in datetime?

2005-05-17 Thread Ivan Van Laningham
Hi All--

Ron Adam wrote:
 
 John Machin wrote:
 
  On Tue, 17 May 2005 17:38:30 -0500, Terry Hancock
  [EMAIL PROTECTED] wrote:
 
 
 What do you do when a date or time is
 incompletely specified? 

  The reason the ranges for the month and day specifiers begin
 with zero is that MySQL allows incomplete dates such as
 '2004-00-00' to be stored as of MySQL 3.23.
 
 So it seems using 0's for the missing day or month may be how to do it.
 

This is somewhat the approach I took in order to allow users to specify
an incomplete Mayan date in order to list possibilities.  But instead of
0 (which is a valid entry in most Mayan date components), I used None. 
The web version can be found at

http://www.pauahtun.org/Calendar/tools.html (the Search for Matching
Dates button)

The paper describing the incomplete Mayan date tool is at: 
http://www.pauahtun.org/python_vuh.html

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Documentation (should be better?)

2005-05-11 Thread Ivan Van Laningham
Hi All--
The Python docs are not ideal.  I can never remember, for instance,
where to find string methods (not methods in the string module, but
methods with ''), but I can remember a tortured path to get me there
(yes, I know, fix my brain; easier said than done).  The module index is
good, if what you're looking for is in a module.  The tutorial is good.

I can usually end up where I want to be by picking up my copy of _Python
in a Nutshell_.  95% of the time I can find what I want in there or from
there.  The other 5% is too new, in the _Python Cookbook_ or in a
third-party module/lib.  Or it's what I'm trying to write;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Documentation (should be better?)

2005-05-11 Thread Ivan Van Laningham
Hi All--
Yes.  There are multiple ways I can correct myself, some, I'm sure,
involving chains and whips.  But you're all missing the point: 
Christopher is right!  Python docs are not as good as PHP docs.  Why
not?  Why do I have to be told Hey, there are fifty ways to get what
you want! when I should be able to go to the main doc page and SEE the
right link to click.  Why isn't there a Methods in Standard Objects
page, for instance?  Why would I have to search?

And the search is sucky, anyway.  So there;-)  Christopher described the
right way.  I should be able to type string methods into the text box,
push submit, and IT SHOULD HAND ME THE PAGE.  Not Results 1 - 20 of
about 9,800 from www.python.org for string methods. (0.78 seconds) (and
no, I am not exaggerating).  And the first hit is from Python 2.1.3, NOT
the current doc.  Sorry.  No cigar.

There's Only One Way to Do It, except in the Docs, that is.  Good as
Google is, it is not good for a doc search.  We don't have a doc search,
we have a doc hurl.

BTW, my tortured method is quicker than Bruno's, because to use his
method I'd have to start the interactive interpreter.

Bruno Desthuilliers wrote:
 
 Ivan Van Laningham a écrit :
  Hi All--
  The Python docs are not ideal.  I can never remember, for instance,
  where to find string methods (not methods in the string module, but
  methods with ''),
 
   dir('')

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Documentation (should be better?)

2005-05-11 Thread Ivan Van Laningham
Hi All--

Steven Bethard wrote:
 
 Ivan Van Laningham wrote:
  I should be able to type string methods into the text box,
  push submit, and IT SHOULD HAND ME THE PAGE.  Not Results 1 - 20 of
  about 9,800 from www.python.org for string methods. (0.78 seconds)
 
 Regardless, assuming the right link is the first one, do I understand
 your complaint correctly as saying that you want Python to automatically
 pick the first link for you?  Do others agree with this complaint?  I
 imagine it wouldn't be that hard to add the equivalent of Google's I'm
 Feeling Lucky button beside the submit button if that would really help.
 

No.  If I type string methods into the search box (OK, I will type the
quotes), how many pages can there be?  If there are two or more, give me
the choice; if there is one, take me to it.  Why are there 9,801 pages
containing string, or method, or both, or neither?  What's wrong with
this picture?

 http://docs.python.org/lib/string-methods.html
 
 In fact, I tried just string and couldn't find anything but the
 current docs in the first 10 pages (and was too lazy to check anything
 else).
 
 Could you tell me how to reproduce your results (of getting Python 2.1.3)?
 

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

Type string methods into the box; push submit.  Result:

Results 1 - 20 of about 9,800 from www.python.org for string methods.
(0.14 seconds)

I did not go to docs.python.org, I went to www.python.org and clicked on
the doc link.  There is a difference, clearly, but I maintain there
should not be.  If I click on Documentation on the main page, am I
asking for All possible old and new and broken and repaired and
intermediate documentation pages?  No, I kind of thought I was asking
for the latest documentation.

I tried string methods at docs.python.org, and got Results 1 - 20 of
about 455 from docs.python.org for string methods. (0.11 seconds);
string methods retrieved Results 1 - 10 of about 30 from
docs.python.org for string methods. (0.13 seconds).  Why the
difference?


Metta,
i-have-not-yet-begun-to-rant-ly y'rs,
Ivan Sorry I am out of room for smiley faces
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Documentation (should be better?)

2005-05-11 Thread Ivan Van Laningham
Hi All--

Robert Kern wrote:
 
 Ivan Van Laningham wrote:
 
  http://www.python.org/doc/
 
 Searching on docs.python.org goes through just the stuff that's on
 docs.python.org, which is pretty much just documentation. Google's magic
 points to the current documentation.
 
 Searching on www.python.org trolls through the entire www.python.org
 site. The search box doesn't narrow its scope just because you happen to
 be in the Documentation section currently. It doesn't get the current
 documentation because Google's magic gets a bit confused.
 

I get that.  My question, cleverly concealed in a rant, was, Why does
clicking on the Documentation link at python.org NOT take me to
docs.python.org?  Why is there a difference?  If there must be a
difference, why isn't the difference labelled as such?  This is a
difference that makes a difference.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Documentation (should be better?)

2005-05-11 Thread Ivan Van Laningham
Hi All--

John Bokma wrote:
 
 Ivan Van Laningham wrote:
 
   Python docs are not as good as PHP docs.
 
 Oh my. I hope you are just making that up. PHP documentation is
 guesstimated on how PHP works on average. Add the online comments clutter
 and you probably are better off reading the source.
 

I didn't write that; I was riffing on Christopher's contention that
Python's docs ought to be awesome, which I think ought to be true.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Advice needed on __del__

2005-05-09 Thread Ivan Van Laningham
Hi All--

Fredrik Lundh wrote:

 Python is not C++.
 

I dunno if this makes QOTW, but I vote we put this in our list text that
goes out with each and every list message.

There will still be a lot of people who don't read it, but at least
we'll get to say, We told you so.

do-buddhists-get-to-say-that?-ly y'rs,
Ivan;-) 
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trouble saving unicode text to file

2005-05-07 Thread Ivan Van Laningham
Hi All--

John Machin wrote:
 
 
 The general rule in working with Unicode can be expressed something
 like work in Unicode all the time i.e. decode legacy text as early as
 possible; encode into legacy text (if absolutely required) as late as
 possible (corollary: if forced to communicate with another
 Unicode-aware system over an 8-bit wide channel, encode as utf-8, not
 cp666)
 

+1 QOTW

And true, too.

i-especially-like-the-cp666-part-ly y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Whats the best Python Book for me

2005-05-01 Thread Ivan Van Laningham
Hi All--

 On Sun, 01 May 2005 20:18:39 GMT, John Smith [EMAIL PROTECTED] wrote:
 I already know C/C++ programming and now wish to learn Python to do
 scripting for some games that are coming out. What book would you recommend.
 
 I am thinking Teach Your Self Python in 24 Hours is probably the best place
 to start...
 

If you can program in C  C++, I wouldn't recommend starting with my
book.  It's geared to people who know very, very little programming
(Python Mind, Beginner's Mind).  I think that most of what you have to
do is unlearn things you already know how to do.  I started in Python
from where you are, with the addition of a passel of Postscript
programming and enough Lisp to make me dangerous, and learned by setting
myself a real, useful task that hadn't been done before.  I dug through
the manuals and through Lutz' _Programming Python_ and I asked dumb
questions on this list.

If I were starting now, in your place, I'd get a copy of the _Python
Cookbook_ (2e) and keep that handy.  It's a good place to learn idioms,
and that's what you're most in need of right now.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Ivan Van Laningham
Hi All--

Jason Tishler wrote:
 
 Ivan,
 
 On Tue, Apr 26, 2005 at 07:02:48PM -0600, Ivan Van Laningham wrote:
  Use win32api to find drives:
 
  cut here
  #!/usr/bin/python
  # -*- coding: utf-8 -*-
 
  import os
  import os.path
  import win32api
  [snip]
 
 AFAICT, the win32api module has not been ported to Cygwin Python.
 

I'm not running Cygwin, but Uwin.  I installed regular 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.
 ^Z  


with the win32api that matched.  I have no trouble running it.  Is there
some reason to prefer a Python compiled by the Cygwin tools?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: how to find the drive in python/cygwin?

2005-04-30 Thread Ivan Van Laningham
Hi All--

Jason Tishler wrote:
 
 Ivan,
 
 It depends on your needs.  If you are looking for a more Unix-like
 Python, then the Cygwin version would probably be better.  If
 Windows-like, then the native Windows version would probably be better.
 
 The OP seem to be interested in a Cygwin Python solution -- not a
 Windows one.  So, I was just clarifying that the win32api module is not
 supported under Cygwin Python.
 

Could you clarify?  I always thought that the only thing really
different were the default path assumptions--/ instead of \, and so
on--rather than anything substantive.  I try to use os.path.sep() and
os.path.join(), etc.

What else could bite me?  ;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python documentation moronicities (continued)

2005-04-26 Thread Ivan Van Laningham
Hi All--

Richie Hindle wrote:
 
 Xah is right - I have a copy here of his message of 18th April, saying i
 have rewrote the Python's re module documentation..
 

Which announcement alone I take as evidence sufficient unto itself.  I
shall not be reading the rewrote documentation.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: how to find the drive in python/cygwin?

2005-04-26 Thread Ivan Van Laningham
Hi All--
Use win32api to find drives:

cut here
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import os.path
import win32api
import sys


def findAllDrives():
Drives=[]
print Searching for drives...
drives=win32api.GetLogicalDriveStrings().split(:)
for i in drives:
dr=i[-1].lower()
if dr.isalpha():
dr+=:\\
inf=None
try:
inf=win32api.GetVolumeInformation(dr)
except:
pass # Removable drive, not ready
 # You'll still get the drive letter, but inf will be None
Drives.append([dr,inf])
return Drives

if __name__==__main__:
drives=findAllDrives()
for i in drives:
print i[0],i[1]

cut here

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple tuples for one for statement

2005-04-25 Thread Ivan Van Laningham
Hi All--

R. C. James Harlow wrote:
 
 or just:
 
 for a,b,c in (tup1, tup2, tup3):
 print a
 print b
 print c
 

And this works in Python version???

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple tuples for one for statement

2005-04-25 Thread Ivan Van Laningham
Hi All--

R. C. James Harlow wrote:
 
 On Monday 25 April 2005 14:34, Ivan Van Laningham wrote:
  Hi All--
 
  R. C. James Harlow wrote:
   or just:
  
   for a,b,c in (tup1, tup2, tup3):
   print a
   print b
   print c
 
  And this works in Python version???
 
 Ah, reading the replies to the original post, this works but doesn't give the
 result that the original poster wanted.
 

Define works:

a=(1,2,3,4,9,43,256,8,2021)
b=(1,0,3,4,7,999,256,8,2023)
c=(1,7,8,4,9,43,,8,2028)

for x,y,z in (a,b,c):
print x,y,z


12 [/c/CDListings][8] python fneeg.py
Traceback (most recent call last):
  File fneeg.py, line 8, in ?
for x,y,z in a,b,c:
ValueError: too many values to unpack



PyVersion:

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.


Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple tuples for one for statement

2005-04-25 Thread Ivan Van Laningham
Hi All--

Peter Hansen wrote:
 
  Define works:
 
   a = (1,2,3)
   b = ('a','b','c')
   c = (None, 'foo', 3.14)
   tup1 = (1,2,3)
   tup2 = ('a','b','c')
   tup3 = (None, 'foo', 3.14)
   for a,b,c in (tup1,tup2,tup3):
 ...   print a
 ...   print b
 ...   print c
 ...
 1
 2
 3
 a
 b
 c
 None
 foo
 3.14
  
 
 It's a valid interpretation of the OP's
 ambiguously stated requirements, though probably
 not the right one.
 

I can see that now.  I had three hours sleep last night and my brain
hurts, so I don't get it.  I seek enlightenment.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple tuples for one for statement

2005-04-25 Thread Ivan Van Laningham


Peter Hansen wrote:
 
 Ivan Van Laningham wrote:
  I can see that now.  I had three hours sleep last night and my brain
  hurts, so I don't get it.  I seek enlightenment.
 
 So do I: did you mean you don't even get what
 my code is doing...?

Yes.  I barely remember my own name right now.

 
 (My sample works only because I created tuples that
 had exactly three items each, of course.  It's the
 same as your previous code which didn't work, except
 for the number of elements in each tuple.  I wrote
 it just to show that R.C.James's idea was a reasonable,
 if probably mistaken, interpretation of the OP's request.)
 

I worked out that the a,b,c must match the length of the tuples.  The
fog past that point is too dense.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rudeness on this list [Re: rudeness was: Python licence again]

2005-04-24 Thread Ivan Van Laningham
Hi All--

James Stroud wrote:
 
 On Sunday 24 April 2005 06:59 am, so sayeth François Pinard:
  As seen from here, the Python mailing list quality has been degrading
  significantly for the last half-year or so.
 
 That's funny. That's exactly as long as I've been on this list. I wonder if
 the correlation is causal?


Nope.  I've been MIA 4 years, and the only difference I can see between
now and four years ago is that Tim, Guido, Barry  a couple of others
aren't here or don't participate very much.  It was a pretty nice list
then, it's a pretty nice list now, so I'm afraid I must disagree with
François.

Oh, and Gordon.  Don't see Gordon around.  Where's he?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trying to read from dying disk

2005-04-23 Thread Ivan Van Laningham
Hi All--

[EMAIL PROTECTED] wrote:
 
 I'm currently attempting something with
 
   http://www.python.org/doc/current/lib/node368.html
 
 but it seems the read operation is ignoring these signals just as it is
 ignoring my signals from the kill command -- perhaps unsurprisingly.
 
 Perhaps there is no hope.
 


Basically, if you are waiting for a hardware interrupt that never comes,
you are doomed.  You can escape by rebooting; in dire cases the only way
out is to power down.  One of the prime sources of zombie processes on
unix systems is users trying to interrupt (with ^C) a process that is
waiting for a hardware interrupt.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-21 Thread Ivan Van Laningham
Hi All--

Fredrik Lundh wrote:
 
 Maxim Kasimov wrote:
 
  how do use this here:
 
 are you still claiming you're not a troll?
 
 *plonk*
 

Oh, I don't think he's a troll, but his license to use Python should be
revoked.  I think RPG would be a good language for him, don't you?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Name/ID of removable Media: how?

2005-04-19 Thread Ivan Van Laningham
Hi All--

Heiko Selber wrote:
 
 I am trying to find out (using Python under windows) the name of a CD that
 is currently in the drive specified by a path name.
 
 And while I am at it, I'd also like to know whether the specified drive
 contains a CD at all, and whether the drive is actually a CD drive.
 
 AFAIK, Python doesn't provide a way to do it, and a search in the web
 yielded only soutions for Linux.
 
 Can anyone show me a solution that works with windoze?
 

This works.  The only thing you have to do is stuff a floppy into the
drive  find out what the fstype is (that's inf[-1] in the code below)
so you can key on it.  Try the docs for Mark Hammond's Win32, and
there's always his _Python Programming on Win32_.

import os
import os.path
import win32api

def findCDs():
cdDrives=[]
print Searching for cd drives...
drives=win32api.GetLogicalDriveStrings().split(:)
for i in drives:
dr=i[-1].lower()
if dr.isalpha():
dr+=:\\
inf=None
try:
inf=win32api.GetVolumeInformation(dr)
except:
pass # Removable drive, not ready
if inf!=None:
if inf[-1].lower().endswith(cdfs):
cdDrives.append([dr,inf])
elif inf[-1].lower().endswith(udf):
cdDrives.append([dr,inf])
return cdDrives

inf[0] contains the volume label if there is one and if there's a CD
loaded:

 win32api.GetVolumeInformation(c:\\)
('God_C', -798323922, 255, 459007, 'NTFS')


Note that you must use the full drive spec, letter:\\ or
GetVolumeInformation() doesn't always work.

There are probably better ways to do these things, but they do work;
I've been using them constantly the last few days.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Name/ID of removable Media: how?

2005-04-19 Thread Ivan Van Laningham
Hi All--
Tim's wmi stuff looked interesting, so I tried it out, and now I have a
question.


-
#!/usr/bin/python

import wmi
import win32api


c=wmi.WMI()
for i in c.Win32_CDROMDrive():
v=i.VolumeSerialNumber
print WMI serial,v,long(v,0x10)

vn,sn,ln,flg,fstype=win32api.GetVolumeInformation(d:\\)
print win32api serial,sn,long(sn)


The output from the above script (drive d contains cd) is:

WMI serial D0ADBEE7 3501047527

win32api serial -793919769 -793919769


What's the difference between the two serial numbers?  WMI is returning
a long converted to a hex repr string, while win32api is returning an
int (type(sn) is type 'int'),  converting to hex bears no resemblance
to what WMI shows.  What am I missing?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Name/ID of removable Media: how?

2005-04-19 Thread Ivan Van Laningham
Hi All--

Tim Golden wrote:
 
 Try this: hex (-793919769)
 
 You might need to check back on recent discussions here re
 negative / positive numbers and hexadecimal.
 
 (Short version: we used to treat hex numbers with the top bit
 set as negative decimal numbers; now only negative hex numbers
 are negative decimals)
 


Of course I tried that.  Did you?


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.
 hex (-793919769)
'-0x2f524119'



Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Variables variable

2005-04-19 Thread Ivan Van Laningham
Hi All--

Cameron Laird wrote:
 .
 I have a few comments on this:  Python can do essentially what
 PHP does.  One means is the getattr() Reinhold cites.
 
 HOWEVER, it's generally always a mistake to do so.  Dictionaries
 are simply better.  AND THAT'S TRUE IN PHP, too.  I'm frankly
 disappointed in PHP leaders that they continue to promote this
 variable-variable idiom.  As much as anything is certain in
 the realm of stylistic expression, dictionaries are a superior
 mechanism.


I don't know if this dictionary insight is Cameron's, but my experience
with Python has been that when I'm developing something from scratch,
I'll start with a big pile of cruft.  I think I'll need this.  Oh, and
that, too.  And what about this!  Oooh, cool!  Then I start carving
away the excess.  It usually takes two or three iterations at carving to
realize that whatever it is needs a dictionary.  I have never seen a
case where a dictionary didn't improve the design.  +1QOTW.

Well.  Storing a Mayan number/date as a dictionary turned out to be a
Spectacularly Bad Idea(tm);-), so I guess that's one case.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Slight discrepancy with filecmp.cmp

2005-04-18 Thread Ivan Van Laningham
Hi All--

John Machin wrote:
 
 On Sun, 17 Apr 2005 22:06:04 -0600, Ivan Van Laningham
 [EMAIL PROTECTED] wrote:
 [snip]
  So I wrote a set of
 programs to both index the disk versions with the cd versions, and to
 compare, using filecmp.cmp(), the cd and disk version.  Works fine.
 Turned up several dozen files that had been inadvertantly rotated or
 saved with the wrong quality, various fat-fingered mistakes like that.
 
 However, it didn't flag the files that I know have bitrot.  I seem to
 remember that diff uses a checksum algorithm on binary files, not a
 byte-by-byte comparison.  Am I wrong?
 
 According to the docs:
 
 
 cmp( f1, f2[, shallow[, use_statcache]])
 
 Compare the files named f1 and f2, returning True if they seem equal,
 False otherwise.
 Unless shallow is given and is false, files with identical os.stat()
 signatures are taken to be equal
 
 
 and what is an os.stat() signature, you ask? So did I.
 
 According to the code itself:
 
 def _sig(st):
 return (stat.S_IFMT(st.st_mode),
 st.st_size,
 st.st_mtime)
 
 Looks like it assumes two files are the same if they are of the same
 type, same size, and same time-last-modified. Normally I guess that's
 good enough, but maybe the phantom bit-toggler is bypassing the file
 system somehow. What OS are you running?
 

WinXP, SP2

 You might like to do two things: (1) run your comparison again with
 shallow=False (2) submit a patch to the docs.
 

You know, I read that doc, tried it, and it made absolutely no
difference.  Then I read your message, read the docs again, and finally
realized I had flipped the sense of shallow in my head.  Sheesh.  So
then I tried it with shallow=False, not True, and it runs about ten
times slower, but it works.  Beautifully.

Now I have to go back and redo the first five thousand, but it's worth
it.  Thanks.  Shows how much you need another set of eyeballs to debug
your brain;-)

 (-:
 You have of course attempted to eliminate other variables by checking
 that the bit-rot effect is apparent using different display software,
 a different computer, an observer who's not on the same medication as
 you, ... haven't you?
 :-)
 

;-)  Absolutely.  Several different viewers and several different OSs. 
And my wife never sees anything the way I do;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Slight discrepancy with filecmp.cmp

2005-04-17 Thread Ivan Van Laningham
Hi All--
I noticed recently that a few of the jpgs from my digital cameras have
developed bitrot.  Not a real problem, because the cameras are CD
Mavicas, and I can simply copy the original from the cd.  Except for the
fact that I've got nearly 25,000 images to check.  So I wrote a set of
programs to both index the disk versions with the cd versions, and to
compare, using filecmp.cmp(), the cd and disk version.  Works fine. 
Turned up several dozen files that had been inadvertantly rotated or
saved with the wrong quality, various fat-fingered mistakes like that.

However, it didn't flag the files that I know have bitrot.  I seem to
remember that diff uses a checksum algorithm on binary files, not a
byte-by-byte comparison.  Am I wrong?  If I am, what then is the source
of the problem in my jpg images where it looks like a bit or two has
been shifted or added; suddenly, there's a line going through the
picture above which it's normal, and below it either the color has
changed (usually to pinkish) or the remaining raster lines are all
shifted either right or left?

Any ideas?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A little request about spam

2005-04-14 Thread Ivan Van Laningham
Hi All--

The listowner could turn on the [PYTHON] headers.  I'm not using
spambayes yet, although I'm leaning toward it, but that step alone could
save me some work when trying to decide based on subject line alone
whether or not an email is spam.  As it stands now, it's too easy to
decide incorrectly that Subject: Inelegant is a spamdunk.

Metta,
Ivan

mark hellewell wrote:
 
 On 4/14/05, James [EMAIL PROTECTED] wrote:
  Yes - it's been like that for the last month or so now and it's quite
  annoying, especially seeing as before it was working at near enough
  100% accuracy.
 
 And I don't suppose there's much we can do about it?
 
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A little request about spam

2005-04-14 Thread Ivan Van Laningham
Hi All--

Roman Neuhauser wrote:
 
 # [EMAIL PROTECTED] / 2005-04-14 08:22:48 -0600:
  The listowner could turn on the [PYTHON] headers.
 
 I hope they don't.
 

What's your reasoning?

  I'm not using spambayes yet, although I'm leaning toward it, but that
  step alone could save me some work when trying to decide based on
  subject line alone whether or not an email is spam.  As it stands now,
  it's too easy to decide incorrectly that Subject: Inelegant is a
  spamdunk.
 
 Don't base your decisions (only) on subject then. Oh, and spam sent
 through the list would have the [PYTHON] space eater too, so what
 would it buy you?
 

Of course I wouldn't base decisions _only_ on whether or not [PYTHON]
appears in the subject.  But I ordinarily do base decisions on the whole
subject line, and I think that's perfectly reasonable.  There's nothing
else to go on without opening the message, and for HTML-based mail
there's no surer way to let spammers know they've found a live email
addres than to open it.  You know that.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting a perl module to a python module would it be worthit?

2005-04-14 Thread Ivan Van Laningham
Hi All--

bruno modulix wrote:
 
 Mothra wrote:
  Hi All,
 
  I am the current author of the Astro-Sunrise perl module
  http://search.cpan.org/~rkhill/Astro-Sunrise-0.91/Sunrise.pm
  and was wondering if it would be worth while to convert it to python.
 
 Only you and your module's users may tell...
 

I'd use it.

  First off, I have never programmed in python. I would like to use
  this project to learn python.
 
 Well, this might be an answer to your first question !-)
 

If you can get your mind off the @#)*[EMAIL PROTECTED]-ing Perl syntax, 
you'll be
fine;-)

  Another question is, if I do this where can I put the results?
  As far as I know python has no CPAN.
 http://www.python.org/pypi/
 

They're working on the Python version of CPAN, but it's taking a long
time.  I think they started in 1998 or so?  Haven't kept up, so I have
no idea what's taking so long.  I'm sure someone more knowledgeable than
me will come along and set us straight.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Utah Python Users Group

2005-04-13 Thread Ivan Van Laningham
Hi All--

Matthew Thorley wrote:
 
 lugal wrote:
  Is anyone aware if there's a Utah-based Python User Group? If not, does
  any else from Utah have any interest in forming a Utah-based Python
  User Group?
 
 I'm in Utah, I don't know of any groups but I might be interested.

 
Ditto.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Ivan Van Laningham
Hi All--

Dick Moores wrote:
 
 Dan wrote at 18:02 4/13/2005:
 On Wed, 13 Apr 2005 03:27:06 -0700, Dick Moores [EMAIL PROTECTED]
 wrote:
 
   I'm just trying to help an artist acquaintance who needs (I just
  learned) the first 3003 digits of pi to the base 12.
 
 Now you've got me curious.  Why would an artist want the first 3003
 digits of pi to the base 12?
 
 He says,
 Do you know how I can get base12 pi?
 Because the chromatic scale is base12.
 c c# d d# e f f# g g# a a# b
 

Oooh.  Wanta hear it.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] Python documentation moronicities (continued)

2005-04-12 Thread Ivan Van Laningham
Hi All--

Richie Hindle wrote:
 
 [Xah]
  motherfucking ... fucking ... fucking ... fucking ... fuck ... fucking
  fucking ... fucking ... mother fucking ... fucking ... piece of shit ...
  motherfucking ... fucking ... fucking ... big asshole ... masturbation ...
  Fucking morons ... fucking stupid ... fuckhead coders ... fuckheads ...
  you fucking asses.
 
  paypal me a hundred dollars and i'll rewrite the whole re doc in a few
  hours.
 
 Can we paypal you a hundred dollars to leave us alone?  I'll pledge $10.
 Are there another nine people here who'll do the same?
 
 

Why don't we pay him $100 to re-write the PERL docs?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: curious problem with large numbers

2005-04-08 Thread Ivan Van Laningham
Hi All--
Windows XP, uwin running on Athlon XP 3000+:

0 [/c/users/ivanlan][1] 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.
 1e1
1.#INF


Metta,
Ivan

Michael Spencer wrote:
 
  A further Windows data point from Cygwin:
 
  Python 2.4 (#1, Dec  4 2004, 20:10:33)
  [GCC 3.3.3 (cygwin special)] on cygwin
  Type help, copyright, credits or license for more information.
1e1
  Inf
   
 
  regards
   Steve
 I guess the behavior is also hardware-dependent.  FWIW, I tested on an Athlon 
 XP
 box.
 
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interpreter problem

2005-04-08 Thread Ivan Van Laningham
Hi All--

Steve Holden wrote:
 
  It's odd that deleting the line and reentering it on the Linux box did
  not correct the problem.  Perhaps vim recognized the format as having
  cr-lf and inserted it even though I was editing on Linux.
 
  Anyhow, it would have been a long time before I got this one.  Thanks.
 
 A pleasure - just passing on payback for the huge amounts of help I've
 had here myself. See also my post in reply to rbt's latest for remarks
 on other possible fixes using vim.
 

Vim is pretty smart.  If you edit something in DOS mode, it'll preserve
it.  If you edit it in UNIX mode, it'll preserve that too.  Thus, if you
copy a dos file to a unix and edit with vim on both systems, it'll stay
dos unless you change it; this is a Good Thing(tm).  You run into
problems with mixed line endings, or when it makes a difference to the
program/OS (the shebang trick).

In vim, if you run

:se fileformat?

it'll tell you exactly what file format you're using.  The choices are
(surprise) unix and dos.

To change the file format of a file explicitly, simply issue the command

:set fileformat=dos

or 

:set fileformat=unix

When you write the file, it'll be saved exactly the way you specify.

Note that you get the ^M at the ends of lines when a file you've been
editing in one mode shifts to another and you have to reload the file. 
Reading [open(foofile,rb)]  re-writing [open(foofile,wb)] a file
will do this if you are not excruciatingly careful.

If you don't have dos2unix on your win system, but do have cat, you can
use cat -d.

#!/bin/sh
cat -d $1  snot
mv snot $1

(Prone to error, of course.)

insert-std-disclaimers-about-vim-vs-classic-vi-behaviours-here-ly
y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shebang in cross platform scripts

2005-04-06 Thread Ivan Van Laningham
Hi All--

Simon Brunning wrote:
 
 On Apr 6, 2005 2:37 PM, rbt [EMAIL PROTECTED] wrote:
 
  Does the line below have any negative impact on Windows machines? I
  develop and test mostly on Unix, but my scripts are often used on Win
  systems too.
 
  #!/usr/bin/env python
 
 Nope. On Windows it's just a comment.
 

It works fine using cygwin, uwin, mks and pdksh, all available for
Windows.  Google is your friend.

Symbolic links also work under uwin (don't know for sure about the
others).  That means you can install a link in /usr/bin to whereever
python lives, and expect #!/usr/bin/python to work just fine.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IronPython 0.7 released!

2005-04-05 Thread Ivan Van Laningham
Hi All--

Tim Peters wrote:
 
 not-mentioning-that-i-don't-feel-particularly-embraced-yet-ly y'rs  - tim
 

Don't worry, Tim.  You will.

it-only-takes-a-little-groupthink-exercise-ly y'rs,
Ivan

Meta:  1984-in-what-base-was-that?-ly y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best editor?

2005-04-05 Thread Ivan Van Laningham
Hi All--

Aahz wrote:
 
 Use vim.  80% of the power of emacs at 20% of the learning curve.
 

I think Aahz has it dead on.  Umpty-mumble years ago I spent six weeks
learning emacs lisp and customizing emacs until it did EXACTLY what I
wanted.  It was a great user interface, logical, consistent,
orthagonal.  It had only one thing wrong with it; it depended on
hardware keyboard features that PC keyboards don't have.

It would have taken me six weeks to retrain myself to the standard emacs
interface, so I used vi.  When vim became available, I switched to
that.  There's a good book available for vim:

http://www.amazon.com/exec/obidos/ASIN/0735710015/qid=1112743931/sr=2-1/ref=pd_bbs_b_2_1/102-7196910-2449750

It's excellent; even the index is useful, which is more than I can say
for 80% of the O'Reilly books out there, much as I love 'em.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-05 Thread Ivan Van Laningham
Hi All--

Aahz wrote:
  Given the tension of the various
 requirements, I think that Python has broken only one way as little as
 possible, with the full intention of getting closer to its ideal when the
 time comes to break backward compatibility.
 

I wrote my mayalib package under 1.3.0.  It still runs perfectly well. 
I will only have to rewrite parts of it when the string module goes
away.  Everything else works, and will continue to work for the
forseeable future.

That's actually less change than happened with C over the same time
period.  But there, the language didn't change, just the environment
around it--includes, libs, where things lived, etc.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pseudocode in the wikipedia

2005-04-02 Thread Ivan Van Laningham
Hi All--

Cameron Laird wrote:
 
 Welcome back, Ivan.  Your follow-ups make one wonder about the
 span of related topics clp has been missing in your absence.


Thanks for the welcome.  Absence was more a consequence of working for
idiots for four years (at 60-80 hours/week) than anything else.  Now
that I'm not working I've got time to catch up on what's new in Python. 
Nice to see a few familiar faces, too.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string goes away

2005-04-01 Thread Ivan Van Laningham
Hi All--

Michael Chermside wrote:
 
 The REAL lesson here is that you shouldn't follow any optimization
 rules without actually testing them. If you don't have time to test,
 then just don't optimize... write whatever is most readable. If you
 NEED more speed, then profiling and testing will show you what to
 fix. (Using a better algorithm is a different story... do that
 whenever you need it.)


Tim Peters sayeth, Premature Optimization is the Root of All Evil. 
And he is not kidding.

Ever try to persuade a boatload of Java programmers that?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pseudocode in the wikipedia

2005-04-01 Thread Ivan Van Laningham
Hi All--

Jeremy Bowers wrote:

 Your ass is your identity function.
 
 Python 2.3.5 (#1, Mar  3 2005, 17:32:12)
 [GCC 3.4.3  (Gentoo Linux 3.4.3, ssp-3.4.3-0, pie-8.7.6.6)] on linux2
 Type help, copyright, credits or license for more information.
  25
 25
  (_ | _)
 25
 
 
 There's clearly some interesting biometrics research to be done here,
 although there is a well-known ass-capturing attack based on readily
 commercially available machines from Xerox that might make it hard to make
 an ass-based identity system resistant to attacks.

http://www.jacquelinestallone.com/rumps.html

Metta,
Ivan

PS:  I don't think this is an 0401 page; it's been there a while.
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string goes away

2005-03-31 Thread Ivan Van Laningham
Hi All--

Andreas Beyer wrote:
 
 I loved to use
   string.join(list_of_str, sep)
 instead of
   sep.join(list_of_str)
 
 I think the former is much more telling what is happening than the
 latter. However, I will get used to it.
 

I disagree, but maybe you could think of it as a mutant list
comprehension?-)

 But what about this:
   upper_list = map(string.upper, list_of_str)
 
 What am I supposed to do instead?
 


 u
['a', 'b', 'c']
 [i.upper() for i in u]
['A', 'B', 'C']


Works pretty well for me.  Better'n map() any day.

 I am sure there has been lots of discussion on whether or not to remove
 the string module. Maybe you can just direct me to the right place.
 

I think we both missed it.  I been off the list for four years.  They
wouldn'ta listened to me anyhow.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Stylistic question about inheritance

2005-03-31 Thread Ivan Van Laningham
Hi All--

Michele Simionato wrote:
 
 recently I realized that they look better on the paper
 than in practice. A non-needed class just adds cognitive
 burden to the maintainer.

Agreed.  Too many classes make me think I'm back trying to figure out
what the )([EMAIL PROTECTED] those guys were thinking making 200 twelve-line ASP
classes.  Ya think there's a hard-wired limit past which your brain
melts?

 Paraphrasing Occam,  I would say don't multiply base classes without
 necessity ;)
 

+1 QOTW

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN]: Last Chance 2005 IORCC Entries

2005-03-30 Thread Ivan Van Laningham
Hi All--

[EMAIL PROTECTED] wrote:
 
 FOR IMMEDIATE RELEASE: Wed Mar 30 11:58:39 CST 2005
 LOCATION:  http://iorcc.dyndns.org/2005/press/033005.html
 ANNOUNCEMENT:  2005 IORCC Deadline Approaches
Entry Deadline March 31st, 2005
Less than 36 Hours Left, Great Prizes and Fun!
 
 Dear Rubyists, Perlists, Shellists, Cists and Hackers,
 

I still don't understand why we are receiving this.  Apparently,
Pythonistas are either not eligible or we are lumped under 'Hackers.' 
If the former, I can certainly understand; it is possible, but
fiendishly difficult, to write obfuscated code in Python, and thus, any
Pythonista submitting *any* obfuscated code would win almost by
default.  The others wouldn't even bother to enter, in that case.

If the latter, that shows what they think of us, and why should we enter
a contest where we are dissed by being shoehorned into someone else's
categories?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using something other than ';' to separate statements

2005-03-30 Thread Ivan Van Laningham
Hi All--

Michael Hoffman wrote:
 
 Jaime Wyant wrote:
 
  # This won't work
  if a  5: print a  5;else print Doh
 
 This will:
 
 [Doh, a  5][a  5]
 
 I highly discourage using it though--it's somewhat obtuse.


Bad Michael.  Bad, bad Michael.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Max files in unix folder from PIL process

2005-03-29 Thread Ivan Van Laningham
Hi All--

Rowdy wrote:
 
 FreeDB (CD database) stores one file per CD in one directory per
 category.  The misc category/directory on my FreeBSD 5.3 system
 currently contains around 481,571 small files.  The rock
 directory/category contains 449,208 files.
 
 As some have said, ls is *very* slow on these directories, but otherwise
 there don't seem to be any problems.
  

I assume you're all using Linux.  The GNU version of ls does two things
that slow it down.  The System V and BSD versions were pretty much
identical, in that they processed the argv array in whatever order the
shell passed it in.  The GNU version re-orders the argv array and stuffs
all the arguments into a queue.  No big deal if you're just doing ls,
but for ls multiple directory names it can slow it down for large
argv[n] and/or recursive/deep ls.

The other thing it does different from SysV/BSD ls is that it provides
for default options in an environment variable.  If those env settings
specify to always use color, that will slow directory processing _way_
down, identically to the -F option.  That's because the color and -F
options _require_ a stat() on each and every file in the directory. 
Standard ls with no options (or old SysV/BSD ls that came with no
options) works nearly as fast as os.listdir() in Python, because it
doesn't require a stat().

The only thing faster, from a shell user's viewpoint, is 'echo *'.  That
may not be much help;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Ivan Van Laningham
Hi All--

Larry Bates wrote:
 
 Secondly,  Python nudges me into writing better
 (easier to maintain and clearer to understand) code by
 influencing me towards splitting my code into smaller
 functions/classes.  If I find myself with more than 3-4
 levels of indentation, I probably need to move some of the
 lower level code into a function or a class anyway (I
 actually ran into this this very morning). Some might
 interpret this as a negative, I don't.  I find that a lot
 of programmers put WAY too much code into single individual
 modules (main programs, functions) for their own good.

Agreed.  Any method where you have to scroll to figure out what matches
what is _too big_.  This principle holds true for any language.  Keeping
to that aesthetic forces you to modularize your code and often generates
far more flexible functions/methods than you would have any right to
expect otherwise.

As far as grouping by indentation goes, it's why I fell in love with
Python in the first place.  Braces and so on are just extraneous cruft
as far as I'm concerned.  It's the difference between Vietnamese verbs
and Latin verbs;-)

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C type buffer copy

2005-03-22 Thread Ivan Van Laningham
Hi All--

def testCode(data):
   buf=data[:]
   # and I hope you're going to do something with buf,
   # because otherwise this function's a bit of a waste;-)

[EMAIL PROTECTED] wrote:
 
 Hello,
 
 How does Python deal with C type memory buffers. Does Python return
 everything as an object irrespective of the data type?
 
 Here's what i am trying to achieve?
 
 testCode(unsigned char buf, unsigned long len)
 {
 unsigned long data=0x0;
 while (len--)
 {
 *buf++ = (unsigned char)data++
 }
 
 }
 
 What's the best way to deal with this in python?
 

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python scope is too complicated

2005-03-20 Thread Ivan Van Laningham
Hi All--

Dan Bishop wrote:
 
  In Python, there are only two scopes.  The global and the local.
  The global scope is a dictionary while the local, in the case of a
  function is extremely fast.  There are no other scopes.
 
 This isn't true anymore, now that generator comprehensions have been
 added to the language.
 
  x = 17
  sum(x for x in xrange(101))
 5050
  x
 17
 

The equivalent in list comprehensions which currently allows the x to
leak out into its containing scope is going away soon.  Will that be
another scope?  Or are generator and list comprehensions only one scope?

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Ivan Van Laningham
Hi All--

Raymond Hettinger wrote:
 
 [Michele Simionato]
  +1 for inc instead of count.
 
 Any takers for tally()?
 

Sure.  Given the reasons for avoiding add(), tally()'s a much better
choice than count().

What about d.tally(key,0) then?  Deleting the key as was suggested by
Michael Spencer seems non-intuitive to me.

  Just my 2 Eurocents,
 
 I raise you by a ruble and a pound ;-)
 

hardly-anything-is-worth-less-than-vietnamese-dong-ly y'rs,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Ivan Van Laningham
Hi All--

Raymond Hettinger wrote:
 
 Separating the two cases is essential.  Also, the wording should contain 
 strong
 cues that remind you of addition and of building a list.
 
 For the first, how about addup():
 
 d = {}
 for word in text.split():
  d.addup(word)
 

I still prefer tally(), despite perceived political connotations. 
They're only connotations, after all, and tally() comprises both
positive and negative incrementing, whereas add() and addup() will tease
users into thinking they are only for incrementing.

What about adding another method, setincrement()?

d={}
d.setincrement(-1)
for word in text.split():
d.tally(word,1)
if word.lower() in [a,an,the]:
d.tally(word)

Not that there's any real utility in that.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.andi-holmes.com/
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pre-PEP: Dictionary accumulator methods

2005-03-18 Thread Ivan Van Laningham
Hi All--
Maybe I'm not getting it, but I'd think a better name for count would be
add.  As in

d.add(key)
d.add(key,-1)
d.add(key,399)
etc.

Raymond Hettinger wrote:
 
 I would like to get everyone's thoughts on two new dictionary methods:
 
 def count(self, value, qty=1):
 try:
 self[key] += qty
 except KeyError:
 self[key] = qty
 

There is no existing add() method for dictionaries.  Given the name
change, I'd like to see it.

Metta,
Ivan
--
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.andi-holmes.com/
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list