[ANN] Release 0.37 of Task Coach

2005-05-15 Thread Frank Niessink
Hi all,

I'm pleased to announce release 0.37 of Task Coach. New in this release:

Bugs fixed:
- Icons in tree view on Windows 2000 (1194654). I hope I fixed this, but 
since I have no access to Windows 2000 it's a bit difficult to test.

Features added:
- Columns in the task list view can be turned on/off by right-clicking
   on the column headers.
- Tasks can be sorted either by due date or alphabetically (1177984).
- More options when editing an effort record.
- Used a new DatePickerCtrl (1191909).


What is Task Coach?

Task Coach is a simple task manager that allows for hierarchical
tasks, i.e. tasks in tasks. Task Coach is open source (GPL) and is
developed using Python and wxPython. You can download Task Coach from:

http://taskcoach.niessink.com
https://sourceforge.net/projects/taskcoach/

A binary installer is available for Windows XP, in addition to the
source distribution.

Note that Task Coach is alpha software, meaning that it is wise to back
up your task file regularly, and especially when upgrading to a new release.

Cheers, Frank

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Release of version 0.3a1 of xlrd (Excel read) package

2005-05-15 Thread sjmachin

The first publicly-released version of the xlrd (Excel read) package is now 
available for 
download from:
* http://www.lexicon.net/sjmachin/xlrd.htm
* PyPI (Windows installer only; unresolved problem with uploading 
source-distribution 
zip file)
 
Purpose: Provide a library for developers to extract data from Microsoft Excel 
(tm) 
spreadsheet files. It is not an end-user tool.
 
Platform: Any. You don’t need to be on Windows. If you are, you can avoid 
hassles with 
approaches like COM, ODBC, save-as-CSV, etc
 
Python requirements: Works with Python 2.2 or later. There are no dependencies 
on 
modules or packages outside the standard Python distribution.
 
Versions of Excel supported: 2004, 2002, XP, 2000, 97, 95, 5.0, 4.0, 3.0.
 
Features:
* Strong support for handling dates, and documentation of Excel date problems 
and how 
to avoid them. 
* Unicode aware; correctly handles compressed Unicode in modern files; 
decodes 
legacy charsets in older files (if Python has the codec). 
* Extracts all data (including Booleans and error-values) 
 
Exclusions: xlrd will not attempt to decode password-protected (encrypted) 
files. 
Otherwise, it will safely and reliably ignore any of these if present:
* Anything to do with the on-screen presentation of the data (fonts, panes, 
column 
widths, row heights, ...) 
* Charts, Macros, Pictures, any other embedded object. WARNING: currently this 
includes embedded worksheets. 
* Visual Basic (VBA) modules 
* Formulas (results of formula calculations are extracted, of course) 
* Comments and hyperlinks 
 
WANTED: *ALPHA* testers with:
* bigendian platforms, and/or
* Excel 95 (or earlier) files created in non-Latin1 locales
 
Feedback: mailto: [EMAIL PROTECTED] preferably with [xlrd] in the message 
subject.
 

--- End of forwarded message ---
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


X2Y 1.1.7 Document Processor Released!

2005-05-15 Thread Chris Withers
X2Y is a flexible, configurable and extendable server-based document 
processing framework written in python.

It has the following feaures:

- Cross platform

- Fully documented

- Run as either a cron job, scheduled task or by hand

- Fully configurable logging and notification

- Fully configurable processing chains, including multiple seperate
   processing chains on a single server

- Scriptable conversion plugins, inputs and outputs

- Processors can be written in ANY language

- Input from local file system, http get or imap folder supplied as
   standard

- Output to local file system, http post or mail message supplied as
   standard

- Supplied processors for EasyPDF and OpenOffice for document conversion

Potential applications include server-side document conversion, virus 
scanning.

We are particularly interested in hearing from anyone who develops new 
inputs, outputs and processors!

For more information, please see: 
http://www.simplistix.co.uk/software/applications/x2y

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Optimise Europython competition

2005-05-15 Thread Jacob Hallen
A classic dilemma for conferences is that if you have many tracks,
you may find that all of a sudden, a room is swamped, and there is
a queue of people wanting to get in. Another problem is that you
risk scheduling talks against each other that have a very large
set of interested people in common.

At Europython we are this year going to try a new way of scheduling,
in order to reduce these problems. Before the schedule is made, we
will give all attendees the opportunity to register what talks they
are most interested in. We then want to make a schedule that is
optimised based on these data.

Since I am no expert in optimising algorithms of this type, and since
the time I have available for these things is limited, I'm turning to
the readers of c.l.p and python-logic for help.

I'm offering the following bounty for a working solution (in Python):

- Free attendance at this years Europython, as a guest of honour
- A Europython T-shirt in a limited special edition
- Fame and gratitude from conference attendees who get better scheduling

The winner of the bounty is the person who scores most points, according
to the criteria below. If we get more than one solution that does good
optimisation, we will award more than one bounty.

Here are the parameters:

1. There are 10 tracks with between 1 and 30 talks in each track.
   You may not schedule two talks in the same track against each other,
   unless there is more talks than available calendar time.

2. A track should be continuous. Each track that is continuous gives you
   10 points.

3. We expect about 300 attendees. About half of them are expected to
   register their interests. Interests may range from a single talk
   to more than half of all the talks. You get one point for each
   talk an attendee can attend out of the ones the attendee has registered
   interest in.

4. Talks are of varying lengths. Lengths can be 30, 45, 60 and 90 minutes.
   The large majority of talks are 30 minutes. Only a very few are 45
   minutes.

5. Rooms come in different sizes
   Room A has 180 seats
   Room B has 140 seats
   Room C has 140 seats
   Room D has 70 seats
   Room E has 70 seats

   Room A-D should be scheduled throughout the conference while room E
   is extra expansion space, only to be used when absolutely necessary.

   For every person scheduled above (Room capacity * (Number of responding
   attendees / Total number of attendees)) you get one point taken off 
   your score.

6. There are a total of 10 90-minute time blocks.

   Day 1: 09:00
   Day 1: 11:00
   Day 1: 14:00
   Day 1: 16:00

   Day 2: 09:00
   Day 2: 11:00
   Day 2: 14:00
   Day 2: 16:00

   Day 3: 09:00
   Day 3: 11:00

   A track should not change room in the middle of a time block. Doing
   so reduces your score by 50 points.

7. Input data
   You get your input data in the form of a list of tuples; one tuple
   per talk.

   Each tuple looks like this:
   
   (talk id, talk length, track id, [list of interested attendees])
   
   Talk length is an integer, all other items are strings.

8. Output data
   You should supply your output data in the form of a list of tuples; one
   tuple per talk.

   Each tuple should look like this:
   
   (talk id, room, day, starting time)

   Talk id should be the same as in the input. Room should be a one letter
   string with a value in the range A-E. Day should be a one letter string
   in the range 1-3. Starting time should be a string on the form HH:MM,
   in the 24 hour clock.

Solutions should be sent by email to europython@python.org no later than
1 June 2005. Currently we haven't started gathering real data, but there should 
be some available for real world testing before 1 June.

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


BayPIGgies: May 19, 7:30pm (FIRST meeting at Google)

2005-05-15 Thread Aahz
NOTE: we are no longer meeting at Stanford; the May meeting is at
Google in Mountain View.


The next meeting of BayPIGgies will be Thurs, May 19 at 7:30pm.

NOTE: to celebrate our first meeting at Google, Google will be providing
a buffet dinner starting at 6:45pm.

Alex Martelli will be repeating his OSCON/PyCon presentations about OOP
and design patterns -- with improvements!

BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://www.baypiggies.net/


Advance notice: The June 9 meeting agenda has been set.  Drew Perttula
will be talking about his Python-based lighting system controller.

Advance notice: The July 14 meeting agenda has not been set.  Please send
e-mail to [EMAIL PROTECTED] if you want to suggest an agenda (or
volunteer to give a presentation).
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

And if that makes me an elitist...I couldn't be happier.  --JMS
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: pygame on win32, image.fromstring()

2005-05-15 Thread tlviewer
tlviewer wrote:

 Next I'm going to load all 53 card resources into a list (array) of
 strings, then write it out, pickled. That should smooth out loading the
game when I use 4-6 decks (Blackjack-21).

# -*- coding: cp1252 -*-

keywords: resource bitmap pickle
description: pickle resources from cards.dll 
requires: 
Pygame from www.pygame.org, 
PIL from www.pythonware.com/products/pil/ 

WinXP out:
63  ioerror
64  ioerror
66  resource skipped
saving pickled list
closing
debugging Surface(71x96x8 SW) rect(0, 0, 71, 96)



# imports
import win32api as wi 
import string as st 
import pygame as gm 
import Image as im 
import StringIO
import win32con as wc 

import os, sys
import pickle as pkl

# OS independent path -- win32 only
sysroot = os.environ.get('SYSTEMROOT') 

# get module handle for cards DLL
hnd = wi.LoadLibrary(sysroot + '/system32/cards.dll')


Loadresource returns the card image without a header! I dumped these
header strings from ResourceHacker. There are only 2 kinds: one for the
pictures, and one for Ace+numbers.

# this header works for 71x96x1BPP image
pic_header = [ chr(0x42), chr(0x4D), chr(0xDE), chr(0x0D), chr(0x00), \
chr(0x00), chr(0x00), chr(0x00), chr(0x00), chr(0x00), chr(0x4A), \
chr(0x00), chr(0x00), chr(0x00)]
num_header = [ chr(0x42), chr(0x4D), chr(0xA0), chr(0x04), chr(0x00), \
chr(0x00), chr(0x00), chr(0x00), chr(0x00), chr(0x00), chr(0x20), \
chr(0x00), chr(0x00), chr(0x00)] 


fname = 'pkl_deck.dat'
fname = os.curdir + '/' + fname 
debugr=1 

#init main array to hold the cards as strings 
arr_cards=[]

def cards(fname):
#sheader = ''.join([ chr(header[x]) for x in range(len(header))]) 
if debugr!=0:
str = wi.LoadResource( hnd, 2, 1, 1033)   
str = st.join(num_header,'') + str
fp = open( os.curdir + '/aceclub.bmp', wb)
fp.write( str)
fp.close ()

for i in range(1,68):
#default header (num)
#print fetch , i
header = num_header
if i % 13  10:
header = pic_header
try:
str = wi.LoadResource( hnd, wc.RT_BITMAP, i, 1033)
except:
print %d % i,  resource skipped
continue
str = st.join(header,'') + str
try:
obj = im.open(StringIO.StringIO(str)) 
arr_cards.insert(i,obj.tostring())
except IOError:
print %d % i,  ioerror
pass

wi.FreeLibrary(hnd)
#
# pickle out the list
print saving pickled list
fp = open(os.curdir + '/pkl_deck.dat', wb)
try:
pkl.dump( arr_cards, fp, 1) #binary size Win2k:312kB WinXP:445kB
except:
print errored, but still closing file
fp.close()
else:
print closing
fp.close()
#fp = open(e:/batch/msdn/Bitmap_11.bmp, rb) 

## main ##

# retrieve the deck from our pickled list, or repickle the list to file

if not os.path.exists(fname):
cards(fname)
else:
fp = open(os.curdir + '/pkl_deck.dat','rb')
val=fp.read()
print pickled list len=,len(val)
fp.close 
arr_cards=pkl.loads(val)
 
if debugr!=0:  
img = gm.image.fromstring(arr_cards[11],(71,96),P)   
print debugging,img, img.get_rect() 
   


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


Re: A new to Python question

2005-05-15 Thread Fredrik Lundh
Bernd Nawothnig wrote:

  You're thinking you're passing the arguments as reference

 That is the way Fortran handles them:

which is one of the things you really love when you link against
underdocumented Fortran programs from C.  (is that parameter
a scalar or an array? crash! oh, an array. how many values does
it expect? crash! oh, a few more, I suppose).

/F



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


Re: converting a set into a sorted list

2005-05-15 Thread MackS
Thank you for the pointer. I'll upgrade to 2.4.

Best,

Mack

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


In search of prothon source

2005-05-15 Thread Alex
Since the DNS servers hosting prothon.org have stopped responding, the 
sole source of the source of prothon online that I can find has become 
inaccessable.  I was wondering if anyone subscribed has a copy of the 
source for the last C version of prothon, and would be kind enough to 
post a copy online.

Thanks,

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


Transparenz ist das Mindeste

2005-05-15 Thread vballsweetheart22
Lese selbst:
http://www.npd.de/npd_info/deutschland/2005/d0405-39.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modifying a built-in function for logging purposes

2005-05-15 Thread Bengt Richter
On Sat, 14 May 2005 19:19:08 -0700, Robert Kern [EMAIL PROTECTED] wrote:

[EMAIL PROTECTED] wrote:
 Hi Greg,
 thank for your replay, but I didn't succeed in any way. You must
 consider however that I'm not a Python expert...
 IMHO, it must be a script that change part of the interpreter, and
 substitute a new module (py) in the place of the standard one (py or
 pyc). The standard module must be saved in order to be able to undo the
 changes and go back to the normal behaviour.
 The problem is that I don't know if the built-in functions like open
 (or file) are written in Python or in C and, besides that, if they can
 be modified.

Short answer: if you don't know stuff like this, then you probably 
shouldn't mess around with the builtins in production code.

Depending on your operating system, there are probably programs that let 
you list all of the files that have been opened on your system. For 
example, on OS X, lsof(1) does the trick.

 Other solutions which modify the source to be logged, are not
 solutions, because it is far simpler to introduce here and there print
 statements... 

Playing with this a little:

 logopen.py ---
import sys, time

class OpenLogger(object):
def __init__(self, logfile=sys.stdout):
self.logfile = logfile
self.old_open = __builtins__.open
def open(self, path, *mode):
openargs = ', '.join(map(repr, mode and [path, mode[0]] or [path]))
tt = time.time()
thdr = '%s.%02d' % (time.strftime('%Y-%m-%d %H:%M:%S', 
time.localtime(tt)), int(tt*100)%100) 
print  self.logfile, '%s: open(%s) called from %r in %s line %s' % 
((thdr, openargs) + 
[(f.f_code.co_name, f.f_code.co_filename, f.f_lineno) for f in 
[sys._getframe(1)]][0])
return self.old_open(path, *mode)
def on(self):
__builtins__.open = self.open
def off(self):
__builtins__.open = self.old_open

def main(*logfile):
logger = OpenLogger(*logfile)
try:
logger.on()
script_to_monitor = sys.argv[1]
sys.argv[0:] = sys.argv[1:]
xdict = dict(__builtins__=__builtins__, __name__='__main__')
execfile(script_to_monitor, xdict)
finally:
logger.off()

if __name__ == '__main__':
if not sys.argv[2:]: raise SystemExit, 
Usage: [python] logopen.py [-log logfile] script_to_monitor 
[script_to_monitor args]
logfile = sys.argv[1] == '-log' and sys.argv.pop(1) and 
[open(sys.argv.pop(1), 'a')] or []
main(*logfile)
-

A script whose opens we can monitor, that opens a file from module and function 
scope:
 pnlines.py ---
import sys
print ' %r' % sys.argv[1]
for i, line in enumerate(open(sys.argv[1], 'r')):
print '%4s: %s' %(i+1, line.rstrip())

def foo(nlines=1):
for i, line in enumerate(open(sys.argv[1])):# test default 'r'
print '%4s: %s' %(i+1, line.rstrip())
if i+1 = nlines: break
print ' 3 lines of %r' % sys.argv[1]
foo(3)
-

Result (tested only as as far as you see here):

[ 0:23] C:\pywk\clpdel logopen.txt
Could Not Find C:\pywk\clp\logopen.txt

[ 0:23] C:\pywk\clppy24 logopen.py

Usage: [python] logopen.py [-log logfile] script_to_monitor 
[script_to_monitor args]

Ok, so we pass pnlines.py as the file for it itself to print:

[ 0:23] C:\pywk\clppy24 logopen.py -log logopen.txt pnlines.py pnlines.py
 'pnlines.py'
   1: import sys
   2: print ' %r' % sys.argv[1]
   3: for i, line in enumerate(open(sys.argv[1], 'r')):
   4: print '%4s: %s' %(i+1, line.rstrip())
   5:
   6: def foo(nlines=1):
   7: for i, line in enumerate(open(sys.argv[1])):# test default 'r'
   8: print '%4s: %s' %(i+1, line.rstrip())
   9: if i+1 = nlines: break
  10: print ' 3 lines of %r' % sys.argv[1]
  11: foo(3)
  12:
 3 lines of 'pnlines.py'
   1: import sys
   2: print ' %r' % sys.argv[1]
   3: for i, line in enumerate(open(sys.argv[1], 'r')):

[ 0:24] C:\pywk\clptype logopen.txt
2005-05-15 00:24:06.55: open('pnlines.py', 'r') called from '?' in pnlines.py 
line 3
2005-05-15 00:24:06.55: open('pnlines.py') called from 'foo' in pnlines.py 
line 7

Maybe the OP can build on this and contribute back something more useful and 
tested ;-)

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


Re: Question about extending the interperter

2005-05-15 Thread Eli
I've tried that and it worked. I've used Python to generate wrapper and
it seems ok- I'm yet testing it, so far so good.

thanks,
Elie

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


Re: converting a set into a sorted list

2005-05-15 Thread Bengt Richter
On Sat, 14 May 2005 19:20:24 -0700, Robert Kern [EMAIL PROTECTED] wrote:

MackS wrote:
 Dear all,
 
 I've got several large sets in my program. After performing several
 operations on these I wish to present one set to the user [as a list]
 sorted according to a certain criterion. Is there any direct way to do
 so? Or must I
 
 list = []
 
 for item in set1:
list.append(item)
 
 list.sort()
 
 Can I somehow avoid doing this in two stages? Can I somehow avoid first
 creating a long list only to immediately sort it afterwards?

In Python 2.4,

In [1]:sorted?
Type:   builtin_function_or_method
Base Class: type 'builtin_function_or_method'
String Form:built-in function sorted
Namespace:  Python builtin
Docstring:
 sorted(iterable, cmp=None, key=None, reverse=False) -- new sorted list

That's plenty of information, but IMO key=None doesn't hint strongly enough
about what you can do with it, so I'd advise reading about all the parameters 
;-)

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


Re: Question about extending the interperter

2005-05-15 Thread Eli
Thanks for your answer, I've tried the way Fredrik suggested which
pointed out to a solution.

cheers

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


pydoc for global variables

2005-05-15 Thread alexk
Hi,
Is it possible to pydoc global variables also ?
It just stucks them into the DATA section.

Thanks, Alex

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


Re: A new to Python question

2005-05-15 Thread Bengt Richter
On Sun, 15 May 2005 08:00:47 +0200, Fredrik Lundh [EMAIL PROTECTED] wrote:

M.E.Farmer wrote:

 I said exactly what I meant, the parentheses around the values creates
 a tuple that you have no reference to!

repeating it doesn't make you right; no extra tuple is created, and the
parens are part of the syntax:

If the target is a target list enclosed in parentheses or in square
brackets: The object must be a sequence with the same number
of items as there are targets in the target list, and its items are
assigned, from left to right, to the corresponding targets.

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

(originally, you had to use [] to unpack lists, and () or no parens only
worked for tuples.  the ability to use an arbitrary sequence was added
in 1.5)

Note that (x) without a comma doesn't unpack like [x] however:

  (x)= 123,
  x
 (123,)
  [x]= 123,
  x
 123
  (x,)= 123,
  x
 123
  x,= 123,
  x
 123

Also, BTW,

  123,
 (123,)
  [123,]
 [123]

I.e., that last result is not [(123,)]

There's actually a bunch of context-sensitive things about commas that
you just have to get used to, in lists, tuples, function call arg lists,
subscripts (__getitem__ args), unpacking assignment targets, etc.

on the other hand, the function you're calling in this example *does*
create a tuple that you have no reference to after the assignment.
Yeah, but it would create that tuple whether there was an assignment
of the returned result or not. Collecting unconnected facts in one
breath remind me too much of political speeches ;-)
that doesn't matter, of course, since the tuple is removed by the
garbage collector immediately after it has been unpacked.
I'm too tired to figure a humorous segue ;-)

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


Re: Modifying a built-in function for logging purposes

2005-05-15 Thread Bengt Richter
On Sun, 15 May 2005 07:52:42 +0200, Fredrik Lundh [EMAIL PROTECTED] wrote:

[EMAIL PROTECTED] wrote:

 I wonder if it is possible to change (temporarily) a built-in function
 for logging purposes.
 Let me explain:
 I want to log all the 'open' operations, recording the file to be
 opened, the mode (r/w/a...) and (possibly) the module which made the
 call.

import sys
import __builtin__ # note: no plural s

old_open = __builtin__.open

def myopen(*args):
code = sys._getframe(1).f_code
print OPEN, args, FROM, code.co_name, IN, code.co_filename
return old_open(*args)

__builtin__.open = myopen

this only handles file opens that goes via the open function, of course.
to handle all opens, including internal operations (e.g. imports), you're
probably better off using an external tool (e.g. strace, filemon, or some-
thing similar).

I should have mentioned that for my version of the same thing.

I wonder what the chances are for a hook to catch all opens.
My feeling is that file system access should be virtualized
to look like a unix directory tree, with all manner of duck-typed
file-system-like things mountable in the tree, and built-in open
would refer to the open of a particular virtually mounted file system
that might be configured to default as now. Anyway, lots of stuff
would become possible... e.g., msys, the MinGW-related shell provides
some of this capability, virtualizing windows partitions as /c/* /d/* 
and so forth, as well as having virtual mounts of various subdir trees.
Good night...

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


Re: Modifying a built-in function for logging purposes

2005-05-15 Thread qwweeeit
Hi Robert,
 Short answer: if you don't know stuff like this, then you probably
 shouldn't mess around with the builtins in production code.
I begin to be fed up of beeing treated as a child who is only able to
make damages...
But this time you are right...
So let's change point of view: instead of trying to modify built-in
functions, it is better to write a small wrapper of the application you
want to log.
For example:
# app_wrapper.py
...insert here the excellent routine of Fredrik Lundh (thank you
Fredrik for your contribution!)
import app#name of the application to be logged.
In the test I carried on the answer was:
OPEN ('pippo2',) FROM ? IN /home/qwweeeit/app.py
OPEN ('pippo3', 'w') FROM ? IN /home/qwweeeit/app.py
OPEN ('pippolong', 'w') FROM ? IN /home/qwweeeit/app.py
I have not tested yet if multi-module applications answer in terms of
modules.
I must thank also Bengt Richter, also if his suggestion is far too
complicate for me...
Concerning his second replay and the virtualization of file system
access (or the usage of an external tool as suggested by Fredrik), I
leave the matter to the experts.
Bye.

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


Re: Jesus said, I am the way, the truth and the life: no one can come to the Father(God)(in Heaven), but by me. (John 14:6) This means that if you die without trusting in Jesus Christ as your Lord and Saviour you will die in your sins and be forever sepa

2005-05-15 Thread LouisB
hum a few bars and I'll try to pick it up

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 http://www.gotquestions.org/sinners-prayer.html  I saw this site on a
 search directory. Great Resource!
 


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


Re: Range function

2005-05-15 Thread Xah Lee
Here's the Perl code.

--

#! perl

# http://xahlee.org/tree/tree.html
# Xah Lee, 2005-05

#_ Range _ _ _ _

=pod

BRange

Range($iMax) generates the list [1, 2, ... , $iMax].

Range($iMin, $iMax) generates the list [$iMin, ... , $iMax].

Range($iMin, $iMax, $iStep) uses increment $iStep, with the last
element in the result being less or equal to $iMax. $iStep cannot be 0.
If $iStep is negative, then the role of $iMin and $iMax are reversed.

If Range fails, 0 is returned.

Example:

 Range(5); # returns [1,2,3,4,5]

 Range(5,10); # returns [5,6,7,8,9,10]

 Range( 5, 7, 0.3); # returns [5, 5.3, 5.6, 5.9, 6.2, 6.5, 6.8]

 Range( 5, -4, -2); # returns [5,3,1,-1,-3]

=cut

sub Range ($;$$) {
if (scalar @_ == 1) {return _rangeFullArgsWithErrorCheck(1,$_[0],1);};
if (scalar @_ == 2) {return
_rangeFullArgsWithErrorCheck($_[0],$_[1],1);};
if (scalar @_ == 3) {return
_rangeFullArgsWithErrorCheck($_[0],$_[1],$_[2]);};
};

sub _rangeFullArgsWithErrorCheck ($$$) {
my ($a1, $b1, $dx) = @_;

if ($dx == 0) {print Range: increment cannot be zero.; return 0}
elsif ($a1 == $b1) {return [$a1];}
elsif ( ((($b1 - $a1)  0)  ($dx  0)) || ((($b1 - $a1)  0)  ($dx
 0)) ) {print Range: bad arguments. You have [$a1,$b1,$dx]; return
0;}
elsif ((($a1  $b1)  ($b1  ($a1 + $dx))) || (($a1  $b1)  ($b1 
($a1 + $dx {return [$a1];}
else { return _rangeWithGoodArgs ($a1,$b1,$dx);};
};

sub _rangeWithGoodArgs ($$$) {
my ($a1, $b1, $dx) = @_;
my @result;

if ($a1  $b1) {for (my $i = $a1; $i = $b1; $i += $dx) { push
(@result, $i);}; }
else {for (my $i = $a1; $i = $b1; $i += $dx) { push (@result, $i);};
};
return [EMAIL PROTECTED];
};

#end Range

##
# test

use Data::Dumper;
print Dumper(Range(5,7,0.3));

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


Re: Range function

2005-05-15 Thread Xah Lee
Here's the Python solution.

--
# -*- coding: utf-8 -*-
# Python

# http://xahlee.org/tree/tree.html
# Xah Lee, 2005-05

# implementation note: When iStep is a decimal, rounding error
# accumulates. For example, the last item returned from
# Range(0,18,0.3) is 17.7 not 18. A remedy is to turn iStep into a
# fraction and do exact arithmetics, and possibly convert the result
# back to decimal. A lesser workaround is to split the interval as to
# do multiple smaller range and join them together.

def Range(iMin, iMax=None, iStep=None):
  if (iMax==None and iStep==None):
return Range(1,iMin)
  if iStep==None:
return Range(iMin,iMax,1)
  if iMin = iMax and iStep  0:
if (isinstance(iStep,int) or isinstance(iStep,long)):
  return range( iMix, iMax, iStep)
else:
  result=[];temp=iStep
  while iMin = iMax:
result.append(iMin)
iMin += iStep
  return result

# test
print Range(0, 18, 0.3)

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


Paranoider Deutschenmoerder kommt in Psychiatrie

2005-05-15 Thread MSN-nivgalo
Lese selbst:
http://brandenburg.rz.fhtw-berlin.de/poetschke.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Desrtuctor WOES, was Advice on __del__

2005-05-15 Thread Fredrik Lundh
phil wrote:

 SO: without significant rewrite of each class such as triangle
 and line, how can I ensure those canvas lines get deleted?
 You don't really need to understand Canvas, just trust me
 I have to delete those objects and they are not properties of the
 class which go away with garbage collection.

well, I think you're asking the wrong person: I wouldn't use a Canvas
in the first place.  instead, I'd update the screen based on the current
contents of the data structure:

http://effbot.org/zone/wck-3.htm

(see the A Simple Canvas Widget example, and the Using the
ui_doublebuffer flag modifications)

/F



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


mod_python and logging

2005-05-15 Thread Daniel Lichtenberger
Hi,

I'm looking for a logging module to be used in a mod_python-powered
website. Python 2.3's logging package seems like a good fit, however
I'm not sure if it's completely safe to use it under high load. The
library documentation states that it's thread-safe, but what about
several forked apache processes running different (sub-)interpreters,
logging to the same file? 

Other suggestions for logging (I really don't need most of logging.*'s
facilities) are also welcome.

Thanks,
Daniel

-- 
For mail replies please use my address from 
http://perplex.schmumpf.de/
http://www.gametective.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Multi-Kulturell = Multi-Kriminell

2005-05-15 Thread tobias . hofmann
Lese selbst:
http://www.npd.de/npd_info/meldungen/2005/m0105-19.html
-- 
http://mail.python.org/mailman/listinfo/python-list


To circumvent the bug cp1252

2005-05-15 Thread Do Re Mi chel La Si Do
Hi !


*** for information ***


There is a bug in Python 2.4, worsened with the 2.4.1, for scripts, if they 
are:
  - large
  - with larges lines
  - prefixed (coded) with   # -*- coding: cp1252 -*-
  - on windows (XP  S2003)
  - perhaps, also, other conditions...

This bug announces, wrongly, of the non-existent errors of syntax, blocks 
the generation of the programmable interface of the servers-COM, with Pywin, 
etc.

But I found a means of circumventing the problem:  it is enough to encoder 
scripts in utf-8, and to prefix them with   # -*- coding: utf-8 -*-
(with that, all the problems disappear)

And, I can, finally, use version 2.4.1-   Yeah !



@-salutations

Michel Claveau







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


Re: Modifying a built-in function for logging purposes

2005-05-15 Thread Steven D'Aprano
On Sat, 14 May 2005 15:14:01 -0700, qwweeeit wrote:

 Hi Greg,
 thank for your replay, but I didn't succeed in any way. You must
 consider however that I'm not a Python expert...

Can you post what you did and what results you got? Because Greg's trick
worked for me. See below.

 IMHO, it must be a script that change part of the interpreter, and
 substitute a new module (py) in the place of the standard one (py or
 pyc). The standard module must be saved in order to be able to undo the
 changes and go back to the normal behaviour. The problem is that I don't
 know if the built-in functions like open (or file) are written in Python
 or in C and, besides that, if they can be modified. 

Why do you think it matters if they are written in Python or C or any
other language for that matter? Almost everything in Python is a
first-class object. That means you can rebind functions, methods, classes,
and any other object.

You can't rebind statements like print. But open is just an object:

py open
type 'file'
py print open(Something.txt, r).read()
some text in a file
py
py save_open = open
 save_open
type 'file'
py
py def open(pathname, mode):
... print The pathname is:  + pathname
... print The mode is:  + mode
... return save_open(pathname, mode)
...
py contents = open(Something.txt, r).read()
The pathname is: Something.txt
The mode is: r
py contents
'some text in a file'


 Other solutions
 which modify the source to be logged, are not solutions, because it is
 far simpler to introduce here and there print statements... Bye.

Introducing print statements is good for quick-and-dirty debugging. For
more serious work, you should investigate the debug module.


-- 
Steven



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


Schily ueber Deutschland

2005-05-15 Thread mal
Lese selbst:
http://www.heise.de/newsticker/meldung/59427
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is the best way to determine system OS?

2005-05-15 Thread googleboy
I did somethign that really seems far brighter...  approaching it from
a slightly different angle I just search through each line for the
right field title,  and then take that field's value from teh last line
of output.

Doesn't matter what OS, doesn't matter what format now.  It can cope
with it all.

:-)

Thanks for the advice!  I learned a bunch.

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


Re: Jesus said, I am the way, the truth and the life: no one can come to the Father(God)(in Heaven), but by me. (John 14:6) This means that if you die without trusting in Jesus Christ as your Lord and Saviour you will die in your sins and be forever sepa

2005-05-15 Thread Mike brown
In article [EMAIL PROTECTED], Bubba [EMAIL PROTECTED] wrote:

 I'm so glad you've decided what everyone believes
 



Some of us don't.





Believe that is.





In anything in particular.




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


string.lstrip stripping too much?

2005-05-15 Thread joram gemma
Hello,

on windows python 2.4.1 I have the following problem

 s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona'
 print s
D:\music\D\Daniel Lanois\For the beauty of Wynona
 t = 'D:\\music\\D\\'
 print t
D:\music\D\
 s.lstrip(t)
'aniel Lanois\\For the beauty of Wynona'
 

why does lstrip strip the D of Daniel Lanois also?

thanks in advance
joram


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


Re: Range function

2005-05-15 Thread Peter Hansen
Xah Lee wrote:
 Here's the Python solution.
 # implementation note: When iStep is a decimal, rounding error
 # accumulates. For example, the last item returned from
 # Range(0,18,0.3) is 17.7 not 18. A remedy is to turn iStep into a
 # fraction and do exact arithmetics, and possibly convert the result
 # back to decimal. A lesser workaround is to split the interval as to
 # do multiple smaller range and join them together.

Good lord no!  The correct way is to use an integer count and simply 
multiply it each time by the step, and add that to the range.  No 
accumulation of errors then.  Where did you learn to program?
(Rhetorical question of course, as you haven't, yet.)

 def Range(iMin, iMax=None, iStep=None):
   if (iMax==None and iStep==None):
 return Range(1,iMin)
   if iStep==None:
 return Range(iMin,iMax,1)
   if iMin = iMax and iStep  0:
 if (isinstance(iStep,int) or isinstance(iStep,long)):
   return range( iMix, iMax, iStep)
 else:
   result=[];temp=iStep
   while iMin = iMax:
 result.append(iMin)
 iMin += iStep
   return result

That's some of the worst Python code I've seen recently.  Please, no one 
take this as representative of how decent Python programmers write code.

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


RE: Turkish Tabloid Enrages Germany with Nazi Comparisons

2005-05-15 Thread EBU.Database. IB.Interclient
Thank you for e-mailing [EMAIL PROTECTED] This is an auto
generated message, please do not respond to this mail.
 
Most questions regarding InterClient can be resolved by first visiting
http://support.borland.com/. From this site you can create a free
presales or installation case, find out how to contact Borland developer
support if you have a question about using InterClient, or get
information on posting to Borland's newsgroups - a free dynamic
information source staffed by a set of dedicated volunteers.
 
Other sources of information you may find of use are:
 
http://qualitycentral.borland.com/ - is a Web Services based community
collaboration system for problem reports and feature suggestions.
 
http://codecentral.borland.com/ - is a repository of member submitted
source code, projects, components, models, patterns, and more.
 
http://bdn.borland.com/ - The Borland Developer Network
-- 
http://mail.python.org/mailman/listinfo/python-list


X2Y 1.1.7 Document Processor Released!

2005-05-15 Thread Chris Withers
X2Y is a flexible, configurable and extendable server-based document 
processing framework written in python.

It has the following feaures:

- Cross platform

- Fully documented

- Run as either a cron job, scheduled task or by hand

- Fully configurable logging and notification

- Fully configurable processing chains, including multiple seperate
   processing chains on a single server

- Scriptable conversion plugins, inputs and outputs

- Processors can be written in ANY language

- Input from local file system, http get or imap folder supplied as
   standard

- Output to local file system, http post or mail message supplied as
   standard

- Supplied processors for EasyPDF and OpenOffice for document conversion

Potential applications include server-side document conversion, virus 
scanning.

We are particularly interested in hearing from anyone who develops new 
inputs, outputs and processors!

For more information, please see: 
http://www.simplistix.co.uk/software/applications/x2y

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Precision?

2005-05-15 Thread Steven Bethard
tiissa wrote:
 Steffen Glückselig wrote:
 
 1.0 + 3.0 + 4.6
 8.5996

 Ehm, how could I get the intuitively 'correct' result of - say - 8.6?
 ;-)
 
 You may find annex B of the python tutorial an interesting read:
 http://docs.python.org/tut/node16.html

Yes, the simplest way to get what you are expecting is probably:

py print 1.0 + 3.0 + 4.6
8.6

The print statement calls str() instead of repr().  In many (most?) 
cases, this will print out what you expect it to.  But you should be 
aware of floating-point representation issues, and you should definitely 
read the reference above.  If you really do need precise decimal 
representation, you can use the 2.4 decimal.Decimal objects:

py d.Decimal(1.0) + d.Decimal(3.0) + d.Decimal(4.6)
Decimal(8.6)

But if you just want a handy calculator, I'd go with print.

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


Re: incorrect(?) shlex behaviour

2005-05-15 Thread bill
Its gets worse:
 from shlex import StringIO
 from shlex import shlex
 t = shlex(StringIO(21))
 while True:
...  b = t.read_token()
...  if not b: break
...  print b
...
2

1--- where's the '' !?
 import shlex
 print shlex.split(21)
['21']

It strikes me that split should be behaving exactly the same way as
read_token, but that may be a misunderstanding on my part of what split
is doing.

However, it is totally bizarre that read_token discards the '' symbol
in the string!  I don't know much about lexical analysis, but it
strikes me that discarding characters is a bad thing.

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


Re: Exception question

2005-05-15 Thread Ron Adam
Steven Bethard wrote:
 Ron Adam wrote:
 
Do exceptions that take place get stored in a stack or list someplace?
 
 [snip]
 
I know I can catch the error and store it myself with,

except Exception, exc:

or possibly,

errlist = []
errlist.append(sys.exc_info())

But what I want to know is does the interpreter do that in any way?  And 
if so, can I access it?
 
 
 No, but there's been some recent talk about having it do so:
 
 http://mail.python.org/pipermail/python-dev/2005-May/053672.html
 
 If that happens though, it's not likely to show up before Python 3.0. 
 Too backwards incompatible to do now.  It also seems that the exact 
 semantics haven't yet been agreed upon.
 
 STeVe

Thanks Steve,

I had actually skimmed over those, but wasn't thinking of this at the 
time. I reread them.  And it clears up a few things.

I had read somewhere that exception objects were global, but that wasn't 
correct, after testing it, they appear to be part of the local frame. 
So once a function exits, any exceptions objects that happened inside 
the function are no longer retrievable.

And checking exception ID's to see if any new exceptions occurred 
doesn't work either, as the numbers get reused too frequently in a short 
period.

Conclusion: Exceptions need to be logged or handled as they occur.

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


Re: Faster GUI text control

2005-05-15 Thread none
Fredrik Lundh wrote:
 none @bag.python.org wrote:
 
 
no, it would mean writing some python code.  if all you need is a scrolling
text list, you can simply use the code on this page:

http://effbot.org/zone/wck-4.htm

(see A scrollable list view, with scrollbar support and, optionally,
the virtual data modifications under Displaying Huge Data Sets)

the resulting widget will update at constant speed, independent of the
data size.

/F

Thanks for the suggestion.  I looked at that, but I need to be able to
selectively change colors on parts of the text and I didn't think I
could do that with a list box.  Am I misunderstanding that?
 
 
 yes.  the list view isn't a listbox, it's a new widget.
 
 with the list view, you control the drawing yourself, and can draw things
 in whatever way you want.  (the section Non-Standard Rendering talks
 about this; reading http://effbot.org/zone/wck-3.htm also helps).
 
 /F
 
 
 
Thanks for the clarification.  I'm going to go back and read the 
Writing widgets articles in detail.
-- 
http://mail.python.org/mailman/listinfo/python-list


Error when calling the metaclass bases function() argument 1 must be code, not str

2005-05-15 Thread sector119
I use python 2.4.1 and PIL 1.1.5 and when I execute my program I got
error:

./code.py
Traceback (most recent call last):
  File ./code.py, line 7, in ?
class DrawPlus(ImageDraw.Draw):
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str


Why I got this error? It work good on python 2.3 + PIL 1.1.4



#!/usr/bin/env python
# -*- coding: iso8859-1 -*-

import random
import Image, ImageFont, ImageDraw

class DrawPlus(ImageDraw.Draw):
def __init__(self, im, mode=None):
ImageDraw.Draw.__init__(self, im, mode=None)

def text(self, xy, text, fill=None, font=None, angle=None,
anchor=None):
ink, fill = self._getink(fill)
if font is None:
font = self.getfont()
if ink is None:
ink = fill
if ink is not None:
bitmap = font.getmask(text)
if angle is not None:
bitmap = bitmap.rotate(angle, Image.BILINEAR)
self.draw.draw_bitmap(xy, bitmap, ink)

class ImageRandomCode:
def __init__(self, filename, size=None):
# plain text code
self.code = ''
# code image file name
self.filename = filename
# fonts
import glob
dir = 'fonts/*.ttf'
self.fonts = glob.glob(dir)
# chars tuple
#self.chars = chars or
('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')
self.chars = ('0','1','2','3','4','5','6','7','8','9')
# image width
self.img_width = 100
# image height
self.img_height = 30
# image size = (image width, image height)
self.img_size = size or (self.img_width, self.img_height)
# image background color (r,g,b)
self.img_background_color = (255, 255, 255)
# image font color (r,g,b)
self.img_font_color = (0, 0, 0)
# code length
self.length = 5
# minimum font size
self.font_size_min = 13 # 12
# maximum font size
self.font_size_max = 18
# maximum noise lines to draw
self.lines_noise_max = 3
# maximum noise pixels to draw
self.pixels_noise_percent = 3 # 5
# maximum char angle
self.angle_max = 15 # 20

img = Image.new('RGB', self.img_size, self.img_background_color)
self.draw = DrawPlus(img)

self.draw_chars()
self.draw_noise()

del self.draw
img.save(self.filename)

def draw_noise(self):
self.draw_noise_pixels()
self.draw_noise_lines()

def get_code(self):
return self.code

def get_filename(self):
return self.filename

def draw_chars(self, chars=None, length=None):
chars = chars or self.chars
length = length or self.length
for i in range(length):
font_size = random.randint(self.font_size_min, self.font_size_max)
font_name = random.choice(self.fonts)
font = ImageFont.truetype(font_name, font_size)
angle = random.randint(-self.angle_max, +self.angle_max)
text = random.choice(chars)
size = self.draw.textsize(text, font=font)
x = i*(self.img_width-2-2)/length
y = random.randint(2, self.img_height-size[1]-2)
self.draw.text((x,y), text, font=font, angle=angle,
fill=self.img_font_color)
self.code += text

def draw_noise_pixels(self, percent=None):
percent = percent or self.pixels_noise_percent
N = int(self.img_width*self.img_height*percent/100)
for i in range(N):
x = random.randint(0, self.img_width)
y = random.randint(0, self.img_height)
self.draw.point((x,y), fill=self.img_font_color)
for i in range(N):
x = random.randint(0, self.img_width)
y = random.randint(0, self.img_height)
self.draw.point((x,y), fill=self.img_background_color)

def draw_noise_lines(self, max=None):
max = max or self.lines_noise_max
N = random.randint(0, max)
for i in range(N):
x1 = random.randint(0, self.img_width)
y1 = random.randint(0, self.img_height)
x2 = random.randint(0, self.img_width)
y2 = random.randint(0, self.img_height)
self.draw.line((x1,y1,x2,y2), fill=(0,0,0))

code = ImageRandomCode('test.png')

print code.get_code()

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


Re: Mandrake 10.1 and Python 2.3.4

2005-05-15 Thread qwweeeit
Hi Joal,
I can only tell you that in my Linux Mandrake 10.1 (Community Edition),
all is ok:
Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type help, copyright, credits or license for more information.
 import site
 dir (site)
['_Helper', '_Printer', '__builtin__', '__builtins__', '__doc__',
'__file__', '__name__', '_dirs_in_sys_path', '_init_pathinfo', '_test',
'addpackage', 'addsitedir', 'encoding', 'here', 'makepath', 'os',
'prefixes', 'sitedirs', 'sys']

This can't exclude that the error is in Mandrake's site (if you have
the Official Edition),  but I can't help you further because I am not
an expert.
Bye.

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


Re: Unique Elements in a List

2005-05-15 Thread Facundo Batista
On 5/9/05, James Stroud [EMAIL PROTECTED] wrote:

  Is there an easy way to grab the Unique elements from a list?

 from sets import Set as set
 data = [0.1,0.5,0.6,0.4,0.1,0.5,0.6,0.9]
 for x in set(data):
... print x
...
0.5
0.9
0.6
0.4
0.1


.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anybody know the status of PyCon recordings?

2005-05-15 Thread Facundo Batista
On 9 May 2005 11:02:27 -0700, Sébastien Boisgérault
[EMAIL PROTECTED] wrote:

 http://www.pycon.org/talks/

¿?:


Site Error

An error was encountered while publishing this resource.

Debugging Notice
Zope has encountered a problem publishing your object.

The object at http://www.pycon.org/talks/index_html has an empty or
missing docstring. Objects must have a docstring to be published.


.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python and logging

2005-05-15 Thread qwweeeit
Hi Daniel,
look at the thread I started (Modifying a built-in function for
logging purposes).
http://groups.google.it/group/comp.lang.python/messages/56e905ff27462d91,8f431d9da6140849,95368b6d5db3237d,f1aa51de9139a751,79d9ad3b78f1b875,a7a68e017f064eca,1c203ffc19cdeaac,3e31db7958bffbf1,0889cc903a62266f?hl=itthread_id=bd3b300a4d880820mode=threadnoheader=1_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2Fbd3b300a4d880820%2F1c203ffc19cdeaac%3Fhl%3Dit%26#doc_56e905ff27462d91
There you can find another approach to logging (limited, but specific)
and you can appreciate the point of view of various experts (I am not
one of them!).
Bye.

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


Re: incorrect(?) shlex behaviour

2005-05-15 Thread M.E.Farmer
bill wrote:
 Its gets worse:
  from shlex import StringIO
  from shlex import shlex
  t = shlex(StringIO(21))
  while True:
 ...  b = t.read_token()
 ...  if not b: break
 ...  print b
 ...
 2
 
 1--- where's the '' !?
  import shlex
  print shlex.split(21)
 ['21']

 It strikes me that split should be behaving exactly the same way as
 read_token, but that may be a misunderstanding on my part of what
split
 is doing.

 However, it is totally bizarre that read_token discards the ''
symbol
 in the string!  I don't know much about lexical analysis, but it
 strikes me that discarding characters is a bad thing.
From the docs:
split(s[, comments])
Split the string s using shell-like syntax. If comments is False
(the default), the parsing of comments in the given string will be
disabled (setting the commenters member of the shlex instance to the
empty string). This function operates in POSIX mode. New in version
2.3.

Maybe looking at string methods split might help.
 $(which sh).split()
['($(which', 'sh)']

From the docs:
read_token()
Read a raw token. Ignore the pushback stack, and do not interpret
source requests. (This is not ordinarily a useful entry point, and is
documented here only for the sake of completeness.)

# Just like in my first post
 from StringIO import StringIO
 from shlex import shlex
 t = shlex(StringIO(21))
 t.get_token()
'2'
 t.get_token()
''
 t.get_token()
''
 t.get_token()
'1'
 t.get_token()
''
# Your way
 t = shlex(StringIO(21))
 t.read_token()
'2'
 t.read_token()
''
 t.read_token()
'1'
 t.read_token()
''


Hth,
M.E.Farmer

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


Re: Range function

2005-05-15 Thread Xah Lee
the previous posted solutions are badly botched.

Here's a better solution. Any further correction will appear on the
website instead. (http://xahlee.org/tree/tree.html)

Similar change needs to be made for the Perl code... Java code will
come tomorror.

By the way, the code from me are not expected to be exemplary. These
are exercises for all, also as a intro to functional programing to
industry programers. Also, later on there will be non-trivial problems.

# -*- coding: utf-8 -*-
# Python

# http://xahlee.org/tree/tree.html
# Xah Lee, 2005-05

import math;

def Range(iMin, iMax=None, iStep=None):
  if (iMax==None and iStep==None):
return Range(1,iMin)
  if iStep==None:
return Range(iMin,iMax,1)
  if iMin = iMax and iStep  0:
if (isinstance(iStep,int) or isinstance(iStep,long)):
  return range( iMin, iMax+1, iStep)
else:
  result=[]
  for i in range(int(math.floor((iMax-iMin)/iStep))+1):
result.append( iMin+i*iStep)
  return result
  if iMin = iMax and iStep  0:
if (isinstance(iStep,int) or isinstance(iStep,long)):
  return range( iMin, iMax-1, iStep)
else:
  result=[]
  for i in range(int(math.floor((iMin-iMax)/-iStep))+1):
result.append( iMin+i*iStep)
  return result
  # raise error about bad argument. To be added later.

# test
print Range(5,-4,-2)

# Thanks to Peter Hansen for a correction.

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

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

Calling C/C++ not contained inside a .dll

2005-05-15 Thread delrocco
Hello,

I really appreciate anyone who has time to read this and help, Thanks
up front.
I'm very new to python, having picked it up for the first time a week
ago, but I feel I'm very close to getting this working.

Here's what I'm trying to do:
 - call python scripts from game code
 - have those called scripts call functions that are back in game code

The first part looks easy enough to do if I use, ppembed or something.
The second part has been driving me nuts, because I thought I had a
solution and now I just feel defeated.

I've gotten SWIG working and built a .dll extension with functions in
it to be loaded from python and communicate with my game.  I've
successfully imported it into a python interpreter and called
functions in it.

The problem is I haven't figured out how to make those calls call
functions in my game application.  If I load the same .dll from my
game and pass in a structure full of function pointers, the
communication from the game to the .dll works... but then the module I
am using in the python interpreter is not the same one, as if its a
copy.

My question is..
How do I get python scripts to call functions in my game code without
having to build a .dll that has the entire meat of my game inside of
it?  Ultimately I want to be able to load scripts from my game and
have those scripts call functions in my game code.

Example:
- game calls script's onDamage function
- script sets various variables, and then calls swapModel function in
game

Thanks,
Joe

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


Re: A new to Python question

2005-05-15 Thread M.E.Farmer

No. You claimed
quote
This will only create a tuple in memory
/quote
That is not what I said please do not edit my words and call it a
quote!

But we just learned that this is not the case.
Yes it seems I was proven wrong and have learned much from the
discussion ;)
That is why I am here to learn from others and help if I can (
sometimes I am just plain wrong and I get the help )

Reduced to this argument I have no objection.
Glad to hear it.

Lisp is far from being ugly ;-)
Your words not mine.I never said it was ugly.
Lisp is beautiful but Python isn't Lisp, and the () *are* getting
overloaded.

M.E.Farmer

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


Re: A new to Python question

2005-05-15 Thread M.E.Farmer
Fredrik and Bengt:
Thank you for the time.
I will study the docs and play with the shell till this is firm.
M.E.Farmer

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


Re: A new to Python question

2005-05-15 Thread M.E.Farmer
It looks like the docs could use some examples of the various
assignments it refers to.
I think something like Bengt posted would be a nice addition if it
included assignments with slices and dicts too.
Just a thought.
M.E.Farmer

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


Re: Is isinstance always considered harmful?

2005-05-15 Thread Terry Reedy

Jordan Rastrick [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I've read arguments, here and elsewhere, to the effect that in Python
 isinstance should be avoided like the plague, except in a few very
 specific and narrow circumstances.

Putting it like this is rather extreme.

 Roughly speaking, due in part to
 Python's dynamic nature its better to concern yourself only with the
 interface an object provides, and not whether it happens to inherit
 from a given base class.

To my mind, your example of using isinstance to select a better (such as 
speedier) subalgorithm for a special case is not just fine, but good 
programming.  (Selecting a subalgorithm that works more robustly is also a 
good reason for special casing.)  It is an internal matter whose externally 
visible effect is to improve performance.

Using isinstance to unnecessarily narrow the domain is quite different.  It 
has the externally visible effect of degrading performance (to a nullity) 
for arguments that the user might reasonably want to work.

Terry J. Reedy



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


Re: string.lstrip stripping too much?

2005-05-15 Thread Bengt Richter
On Sun, 15 May 2005 15:24:25 +0200, joram gemma [EMAIL PROTECTED] wrote:

Hello,

on windows python 2.4.1 I have the following problem

 s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona'
 print s
D:\music\D\Daniel Lanois\For the beauty of Wynona
 t = 'D:\\music\\D\\'
 print t
D:\music\D\
 s.lstrip(t)
'aniel Lanois\\For the beauty of Wynona'
 

why does lstrip strip the D of Daniel Lanois also?

Because the lstrip argument is a set of characters in the form of
a string, not a single substring to replace from the left. Note:
(repeating your example to start with)

  s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona'
  print s
 D:\music\D\Daniel Lanois\For the beauty of Wynona
  t = 'D:\\music\\D\\'
  print t
 D:\music\D\
  s.lstrip(t)
 'aniel Lanois\\For the beauty of Wynona'

Now we make an equivalent lstrip argument from your t argument
  t2 = ''.join(sorted(set(t)))
  print t2
 :D\cimsu

Note that there is only one of each character in t2 (e.g. 'D' and '\\')
And the result is the same for t and t2:

  s.lstrip(t)
 'aniel Lanois\\For the beauty of Wynona'
  s.lstrip(t2)
 'aniel Lanois\\For the beauty of Wynona'

If you want to replace an exact prefix, a regex could be a simple way
to get the startswith check and replace in one whack.

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


Re: Mandrake 10.1 and Python 2.3.4

2005-05-15 Thread Terry Reedy

Joal Heagney [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 'import site' failed; traceback:
 Traceback (most recent call last):
   File /usr/lib/python2.3/site.py, line 169, in ?
 sys.lib,
 AttributeError: 'module' object has no attribute 'lib'

Right: the sys module usually has no .lib attribute that I know of

 import sys; sys.lib
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'lib'

 Is this a Mandrake or a Python mistake?

It is a site.py code mistake, but who wrote your copy of site.py?

 And does anyone know how to fix it?

Correct or remove the offending line (169)

Terry J. Reedy



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


Re: string.lstrip stripping too much?

2005-05-15 Thread Terry Reedy
 why does lstrip strip the D of Daniel Lanois also?

Because it does just what the Lib Ref doc on str.lstrip says that it does.
help(str.lstrip) # should also explain

Terry J. Reedy



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


Re: Precision?

2005-05-15 Thread Ron Adam
tiissa wrote:
 Steffen Glückselig wrote:
 
1.0 + 3.0 + 4.6

8.5996

Ehm, how could I get the intuitively 'correct' result of - say - 8.6?
;-)
 
 
 You may find annex B of the python tutorial an interesting read:
 http://docs.python.org/tut/node16.html

In addition to what you find in the above link, the round function can 
be used.

p = 1   #digits of precision after decimal
a, b, c = 1.0, 3.05, 4.6
print round(a+b+c,p)

- 8.6

You also have the option to use the print statements '%' operator to 
format the output.


a, b, c = 1.0, 3.05, 4.6
print %.1f%(a+b+c)

- 8.6


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


Re: Is isinstance always considered harmful?

2005-05-15 Thread Leif K-Brooks
Jordan Rastrick wrote:
 Say you're writing, in Python, the extend() method for a Linked List
 version of python's builtin list. Its really important to know what
 kind of iterable youre being passed in - because if its another
 Linked list, and you know it, you can connect the two in 0(1) time;
 whereas any other arbitrary iterable is going to take 0(n), as you're
 just going to have to append the items one by one. Is this a case
 where use of isinstance, to see exactly what kind of Iterable you
 have, can be justified?

 def extend(self, elems):
if isinstance(elems, LinkedList):
   # Point last to first
else:
   for elem in elems: self.append(elem)

Regardless of the various issues surrounding isinstance(), you have a
difference in functionality. Since you're just storing a reference in
the case of another LinkedList instead of copying it, mutating the
LinkedList will be different from mutating another iterable type which
has been passed to extend:

 linkedlist1 = LinkedList()
 list1 = [1, 2, 3]
 linkedlist2 = LinkedList([4, 5, 6])
 linkedlist1.extend(list1)
 linkedlist1.extend(linkedlist2)
 linkedlist1
LinkedList([1, 2, 3, 4, 5, 6])
 list1.append(4)
 linkedlist1 # Notice how there's still only one 4
LinkedList([1, 2, 3, 4, 5, 6])
 linkedlist2.append(7)
 linkedlist1 # Notice how there's now a 7
LinkedList([1, 2, 3, 4, 5, 6, 7])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie : checking semantics

2005-05-15 Thread beliavsky
[EMAIL PROTECTED] wrote:

snip

 2. Trust me (and other Python programmers most likely would agree)
this
 type of error happens much more seldom then newbies (especially
coming
 from strongly typed languages) imagine while adjusting to the
language.

 3. Python advantages overpower drawbacks 10 to 1.

 4. Most likely you never used Fortran :)

The Newbie is outnumbered on this issue in comp.lang.python, but he is
not alone :). In Fortran 77 and earlier versions, many run-time errors
resulted from

(1) misspelling a variable name, since variable declarations were not
required and IMPLICIT NONE (forcing declarations) was standardized only
in Fortran 90.

(2) passing variables of the wrong type (real instead of double
precision, scalar instead of array, etc.) to a procedure -- this could
not be checked at compile-time if the procedure and caller were
compiled separately and then linked. Fortran 90 added MODULEs, partly
to fix this.

I programmed in Fortran 77 for years before using Fortran 90 and find
that in the latter version I am more productive, since a program that
compiled was much more likely to be correct. I think many Fortranners
concur.

ANSI C 89 provides for more static type checking than the original KR
C, and I think most C programmers appreciate this.

Looking at how other programming languages evolved, based on hard-won
experience, Python looks like a move in the opposite direction -- less
compile-time checking.

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


wxPython and a Control Property Editor

2005-05-15 Thread [EMAIL PROTECTED]
Hi,

I'm building a modest GUI editor for myself using wxPython, and I need
some help.
I want to create a nice 'Control Property Editing Window', just like
VisualBasic, Delphi, Visual C++, etc.

After searching for a while, I found an interesting extension for wx
that does exactly this (and very nicely too), but its written in c++
and unavailable in python. I'm not interested in modifying the source
to be compatible with python, so unfortunately that extension is no
longer an option.

I tried searching the demo's of wxPython for something useful, and I
figured the Grid control could be somewhat useful (wx.Grid using a
custom Table, with non-string data).
The problems with the Grid are -
   - no option to collapse rows (tree-like)
   - can't define different data type (choice, number, ...) for each
row

After also looking at other GUI editor scripts out there, like
wxWidgets, I turn to this group for some help.

Any help would be greatly appreciated.
Thanks.

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


[no subject]

2005-05-15 Thread gerald hereford
 
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Quick Reference from module doc strings.

2005-05-15 Thread Ron Adam

I think this deserves a little more of a description than I gave it 
initially.

The routine in the previous message does a little more than just print 
out __doc__ strings. It outputs a formatted alphabetical list of objects 
in a module with each objects, name, class or type, and then tries to 
determine if the doc string is part of the class or was inherited from a 
parent class.  If the object is a storage type, then it will print the 
objects contents/values giving you what they are at import time.  If the 
string or list, tuple, or dict is large, it will print just the 
beginning with '..' at the end to let you know there is more.

So what you get is a printable alphabetical quick reference guide with 
the first level class's, functions, exceptions, and attributes with the 
initial values after importing.  (You can also do this with a single 
class and get it's methods and attributes.)

Here is the first part of __builtins__ (Python 2.3) as an example.  If 
anyone has any suggestions or corrections, Please let me know.

Cheers,
_Ron Adam



__builtins__
Class:type 'module'

Built-in functions, exceptions, and other objects.

Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices.


__builtins__.__debug__
Class:type 'bool'

__builtins__.__debug__=True


__builtins__.__doc__
Class:type 'str'

__builtins__.__doc__=Built-in functions, exceptions, and other objects.

Noteworthy: None is the `nil' object; Ellipsis represents `...' in 
slices.


__builtins__.__import__
Module:__builtin__
Class:type 'builtin_function_or_method'

__import__(name, globals, locals, fromlist) - module

Import a module.  The globals are only used to determine the context;
they are not modified.  The locals are currently unused.  The fromlist
should be a list of names to emulate ``from name import ...'', or an
empty list to emulate ``import name''.
When importing a module from a package, note that __import__('A.B', ...)
returns package A when fromlist is empty, but its submodule B when
fromlist is not empty.


__builtins__.__name__
Class:type 'str'

__builtins__.__name__=__builtin__


__builtins__.abs
Module:__builtin__
Class:type 'builtin_function_or_method'

abs(number) - number

Return the absolute value of the argument.


__builtins__.apply
Module:__builtin__
Class:type 'builtin_function_or_method'

apply(object[, args[, kwargs]]) - value

Call a callable object with positional arguments taken from the tuple args,
and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__() method.

Deprecated since release 2.3. Instead, use the extended call syntax:
 function(*args, **keywords).


__builtins__.ArithmeticError
Module:exceptions
Type:type 'classobj'

Base class for arithmetic errors.


__builtins__.AssertionError
Module:exceptions
Type:type 'classobj'

Assertion failed.


__builtins__.AttributeError
Module:exceptions
Type:type 'classobj'

Attribute not found.


__builtins__.basestring
Module:__builtin__
Class:type 'type'

Type basestring cannot be instantiated; it is the base for str and unicode.


__builtins__.bool
Module:__builtin__
Class:type 'type'

bool(x) - bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.


__builtins__.buffer
Module:__builtin__
Class:type 'type'

buffer(object [, offset[, size]])

Create a new buffer object which references the given object.
The buffer will reference a slice of the target object from the
start of the object (or at the specified offset). The slice will
extend to the end of the target object (or with the specified size).


Continued.




And here is the program again.



def getobjs(object, dlist=[], lvl=0, maxlevel=1):
  Retreive a list of sub objects from an object. 
 if object not in dlist:
 dlist.append(object)
 if lvlmaxlevel:
 dobj = dir(eval(object))
 for item in dobj:
 try:
 dlist = getobjs(object+'.'+item, dlist, lvl+1)
 except:
 pass
 return dlist

def printdoc(objectlist):
  Return a sorted printable quick reference
 guide from a list of objects. 
 outtext = []
 objectlist.sort(lambda x, y: cmp(x.lower(), y.lower()))
 for obj in objectlist:
 

Sober-Q

2005-05-15 Thread Kay Schluehr

Paul Rubin wrote:
 Bernd Nawothnig [EMAIL PROTECTED] writes:
  On 2005-05-15, [EMAIL PROTECTED] [allegedly] wrote: ...

 I don't think that post was really from MAL.  It seems to be a
sporgery
 attack on the newsgroup.  Sigh.

The spam mails stem from a Sober variant, which sends Nazi propaganda
around. 

Kay

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


Re: Mandrake 10.1 and Python 2.3.4

2005-05-15 Thread Steve Horsley
[EMAIL PROTECTED] wrote:
 Hi Joal,
 I can only tell you that in my Linux Mandrake 10.1 (Community Edition),
 all is ok:
 Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
 [GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
 Type help, copyright, credits or license for more information.
 
import site
dir (site)
 
 ['_Helper', '_Printer', '__builtin__', '__builtins__', '__doc__',
 '__file__', '__name__', '_dirs_in_sys_path', '_init_pathinfo', '_test',
 'addpackage', 'addsitedir', 'encoding', 'here', 'makepath', 'os',
 'prefixes', 'sitedirs', 'sys']
 
 This can't exclude that the error is in Mandrake's site (if you have
 the Official Edition),  but I can't help you further because I am not
 an expert.
 Bye.
 

Likewise, 10.1 official (powerpack) is OK:

[EMAIL PROTECTED] steve]$ cat /proc/version
Linux version 2.6.8.1-12mdk ([EMAIL PROTECTED]) (gcc 
version 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)) #1 Fri Oct 1 
12:53:41 CEST 2004
[EMAIL PROTECTED] steve]$ python
Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type help, copyright, credits or license for more 
information.
  import sys
  dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__name__', 
'__stderr__', '__stdin__', '__stdout__', '_getframe', 
'api_version', 'arch', 'argv', 'builtin_module_names', 
'byteorder', 'call_tracing', 'callstats', 'copyright', 
'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 
'exec_prefix', 'executable', 'exit', 'getcheckinterval', 
'getdefaultencoding', 'getdlopenflags', 'getfilesystemencoding', 
'getrecursionlimit', 'getrefcount', 'hexversion', 
'last_traceback', 'last_type', 'last_value', 'lib', 'maxint', 
'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 
'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 
'setcheckinterval', 'setdlopenflags', 'setprofile', 
'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 
'version', 'version_info', 'warnoptions']
 


Perhaps you should uninstall and reinstall python, in case a file 
is corrupt.

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


Re: Precision?

2005-05-15 Thread Jeff Epler
If you want to do decimal arithmetic, use the decimal module which is
new in Python 2.4.

Python 2.4 (#1, Jan 22 2005, 20:45:18) 
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type help, copyright, credits or license for more information.
 from decimal import Decimal as D
 D(1.0) + D(3.0) + D(4.6)
Decimal(8.6)
 

when you write '4.6', you get a binary floating-point number which is
not equal to the decimal number 4.6.
 4.6
4.5996
 4.6 == D(4.6)
False

Jeff


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

Re: Precision?

2005-05-15 Thread Peter Dembinski
Steffen Glckselig [EMAIL PROTECTED] writes:

 Hello,

 I've just wanted to check Python's abilities as a calculator and this
 is what came out:

 1.0 + 3.0 + 4.6
 8.5996

 Ehm, how could I get the intuitively 'correct' result of - say - 8.6?
 ;-)

This is as correct as your computer's FPU can made it :)

-- 
http://www.peter.dembinski.prv.pl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string.lstrip stripping too much?

2005-05-15 Thread Fredrik Lundh
joram gemma wrote:

 on windows python 2.4.1 I have the following problem

  s = 'D:\\music\\D\\Daniel Lanois\\For the beauty of Wynona'
  print s
 D:\music\D\Daniel Lanois\For the beauty of Wynona
  t = 'D:\\music\\D\\'
  print t
 D:\music\D\
  s.lstrip(t)
 'aniel Lanois\\For the beauty of Wynona'
 

 why does lstrip strip the D of Daniel Lanois also?

because you told it to do that?

 help(str.lstrip)
Help on method_descriptor:

lstrip(...)
S.lstrip([chars]) - string or unicode

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

(chars is a set of characters, not a prefix.  the string D:\\music\\D\\
contains a D, obviously.  to strip off a prefix, use s[len(prefix):])

/F



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


RE: Is isinstance always considered harmful?

2005-05-15 Thread Robert Brewer
Jordan Rastrick wrote:
 Subject: Is isinstance always considered harmful?
 
 Say you're writing,
 in Python, the extend() method for a Linked List version of python's
 builtin list. Its really important to know what kind of iterable youre
 being passed in - because if its another Linked list, and you know it,
 you can connect the two in 0(1) time; whereas any other arbitrary
 iterable is going to take 0(n), as you're just going to have to append
 the items one by one. Is this a case where use of isinstance, to see
 exactly what kind of Iterable you have, can be justified?

I'd say so, definitely.

 There are other solutions I can think of - perhaps the least 
 hideous is factoring out the 0(1), point last to first code
 in a separated method, __linkedExtend() or something, and then
 do something similar to the above by using an exception,
 like this:
 
 def extend(self, elems):
try:
   self.__linkedExtend(elems)
catch NotALinkedListError:
   for elem in elems: self.append(elem)
 
 I dont know, I don't really like this (although it is more BAFP than
 the first version, so maybe that makes it more Pythonic?).

You've decided to special-case a binary operation based on the type of
*both* objects. Whether you use isinstance or __linkedExtend, you're
still providing a single-dispatch mechanism, which gets uglier in
proportion to the number of types involved. Meh. I'd go with isinstance
for now. Your use case is exactly why it's in the language, IMO.

If the number of types you're special-casing becomes unwieldy, you might
be interested in multiple-dispatch approaches (cf
http://gnosis.cx/publish/programming/charming_python_b12.html) and
generic functions (cf
http://dirtsimple.org/2004/11/generic-functions-have-landed.html).


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]

 To me,
 instanceof seems like the infimum of all possible evils in this case.
 
 It'd be nice if I'd seen the source code for Python's builtin list to
 see if any of these kind of considerations are taken into 
 account there
 (ultra fast array copying in C when extend is called on another list,
 perhaps)? Luckily, one of the great gifts of Python is I can indeed
 look at the source for the entire langauge at any time I want. So I'm
 going to go read it (my first time, how exciting!), and in the
 meantime, I'll let replies start accumulating froma  whole lot of
 people who are a lot smarter and more experience in Python than myself
 :)
 
 Several-weeks-in-and-still-liking-Python-better-than-any-other
 -previously-learned-language-ly
 yours,
 Jordan Rastrick
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Importing and namespace visibility

2005-05-15 Thread jean-marc
As an application programmer, I'm not well versed in the material
aspects of computing (memory, cpu, bus and all). My understanding of
imports in Python is such: the __main__ program is the center piece
which holds the programs reference: globals, functions, classes,
modules etc. The objects of this file (functions and classes) are
directly accessible; 'import suchModule' s objects are attainable
through the *qualified name* (module.function); the 'from suchModule
import *' the objects are directly attainable.

A recent msg from F. Lundh
http://groups.google.ca/group/comp.lang.python/browse_frm/thread/f9bf9734fa19eee9/8a51ab24748251d8?q=rnum=12hl=en#8a51ab24748251d8
suggested being careful with recursive importing...

BUT, of all this I thought that if you import module1, then module2
(into __main__), objects from module1 would be available to objects of
module2 which came (into memory space) after module1 was loaded. This
does not seem to be the case, and module2 requires an 'import module1'
statement in its own file to see this last module's objects.  This is
not the recursive situation that was a pitfall Fredrik was evoking.
What am I missing here???

The reason I'm asking is to setup team development, using Tkinter,
where different people will be programming diverse sections to be
'packed' into the main interface...

Thanks for any help in understanding what is happening in this
situation,

JMD

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


Re: Quick Reference from module doc strings.

2005-05-15 Thread John Machin
Ron Adam wrote:
 Does anyone have suggestions on how to improve this further?

Not functionally (from me, yet). However if you can bear a stylistic
comment, do read on :-)

  elif (isinstance(object,str)
  or isinstance(object,int)
  or isinstance(object,bool)
  or isinstance(object,tuple)
  or isinstance(object,list)
  or isinstance(object,dict)):

Since Python version 2.2, the 2nd arg of isinstance may be a tuple. You
could define this up front, with a meaningful name:

TYPES_WHICH_whatever = (str, int, bool, etc etc)

Cheers,
John

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


Re: Mandrake 10.1 and Python 2.3.4

2005-05-15 Thread John Ridley
Joal Heagney wrote:

 Hi everyone. I've been getting this error message in python, and it's

 really driving me up the wall.
 
 
 [EMAIL PROTECTED] joal]$ python
 'import site' failed; use -v for traceback
 Python 2.3.4 (#1, Apr 18 2005, 19:03:06)
 [GCC 3.4.1] on linux2
 Type help, copyright, credits or license for more
information.
  
 
 Here's the relevant line when i run python in verbose mode:
 
 
 'import site' failed; traceback:
 Traceback (most recent call last):
File /usr/lib/python2.3/site.py, line 169, in ?
  sys.lib,
 AttributeError: 'module' object has no attribute 'lib'
 
 Is this a Mandrake or a Python mistake?
 And does anyone know how to fix it?
 
 I think this is the reason why I'm getting errors when it comes to 
 importing other python packages.

I have both python 2.3.4 and 2.4.1 installed on Mandrake 10.1 - and
only 2.4.1 gives the error.

So - have you tried to install python 2.4 recently?

Also, are you using a pythonrc.py startup file which is trying to
import the sys module? Have a look to see if a PYTHONSTARTUP
environment variable has been set to the path of such a file.

HTH

John Ridley



___ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Property,how to use it?

2005-05-15 Thread Delaney, Timothy C (Timothy)
[EMAIL PROTECTED] wrote:

 What is the property mean in the python? Who can explain it
 for me? I don't know how to use it.

http://www.catb.org/~esr/faqs/smart-questions.html

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


Resizing VListBox on parent (wxPython)

2005-05-15 Thread Ivan Voras
I hava a hierarhical sizer layout in which there's a panel in the upper 
part of a window with some buttons, and another panel with wxVListBox 
that's meant to occupy all the remaining space in the window. Both 
panels are put inside a vertical BoxSizer, and the VListBox in its panel 
is also in BoxSizer.

The hierarchy is like this:

- window, vertical BoxSizer
   - panel, horizontal BoxSizer
 - some buttons
   - panel, vertical BoxSizer
 - a single VListBox

(the VListBox is alone in its panel for future compatibility - I plan 
to add more controls to the panel)

I want the lower panel and the VListBox to automatically resize and fill 
all the remaining space in the window. I can get this to work in the 
horizontal direction by default, but not in vertical. When I set the 
vertical size of VListBox to -1, it only displays one line; I can set it 
to a fixed vertical size, but I really need it to adapt its size to that 
of the window (something like Center layout option in Java BorderLayout).

(The items in VListBox are generated at program runtime, and are not 
available during window controls creation stage)

Can somebody explain why is this happening and how to do what I want? I 
have almost no experience in wxWindows.
-- 
http://mail.python.org/mailman/listinfo/python-list


thread title's getting shorter...

2005-05-15 Thread Johnny Gentile
.

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


python-dev Summary for 2005-04-16 through 2005-04-30

2005-05-15 Thread Tony Meyer
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2005-04-16_2005-04-30.html]



==
Summary Announcements
==

---
Exploding heads
---

After a gentle introduction for our first summary, python-dev really let
loose last fortnight; not only with the massive PEP 340 discussion, but
also more spin-offs than a `popular`_ `TV`_ `series`_, and a few
stand-alone threads.

Nearly a week into May, and the PEP 340 talk shows no sign of abating;
this is unfortunate, since Steve's head may explode if he has to write
anything more about anonymous blocks.  Just as well there are three of us!

This summary has ended up rather late (we're starting summarising May,
already).  I have to admit that this is all my (Tony's) fault - we got
a draft done nicely on time, and then a week of really good thesis
writing distracted me and I neglected to send this out.  My apologies,
and I promise to try harder in future!

.. _popular: http://imdb.com/title/tt0060028/
.. _TV: http://imdb.com/title/tt0098844/
.. _series: http://imdb.com/title/tt0247082/

[TAM]

---
PEP 340
---

A request for anonymous blocks by Shannon -jj Behrens launched a
massive discussion about a variety of related ideas. This discussion
is split into different sections for the sake of readability, but
as the sections are extracted from basically the same discussion,
it may be easiest to read them in the following order:

1. `Localized Namespaces`_

2. `The Control Flow Management Problem`_

3. `Block Decorators`_

4. `PEP 310 Updates Requested`_

5. `Sharing Namespaces`_

6. `PEP 340 Proposed`_

[SJB]


=
Summaries
=


Localized Namespaces


Initially, the anonymous blocks discussion focused on introducing
statement-local namespaces as a replacement for lambda expressions.
This would have allowed localizing function definitions to a single
namespace, e.g.::

foo = property(get_foo) where:
 def get_foo(self):
 ...

where get_foo is only accessible within the ``foo = ...`` assignment
statement. However, this proposal seemed mainly to be motivated by a
desire to avoid namespace pollution, an issue which Guido felt was not
really that much of a problem.


Contributing threads:

- `anonymous blocks
http://mail.python.org/pipermail/python-dev/2005-April/052717.html`__

[SJB]


---
The Control Flow Management Problem
---

Guido suggested that if new syntax were to be introduced for anonymous
blocks, it should address the more important problem of being able to
extract common patterns of control flow. A very typical example of such
a problem, and thus one of the recurring examples in the thread, is
that of a typical acquire/release pattern, e.g.::

lock.acquire()
try:
   CODE
finally:
   lock.release()

Guido was hoping that syntactic sugar and an appropriate definition of
locking() could allow such code to be written as::

locking(lock):
   CODE

where locking() would factor out the acquire(), try/finally and
release().  For such code to work properly, ``CODE`` would have to
execute in the enclosing namespace, so it could not easily be converted
into a def-statement.

Some of the suggested solutions to this problem:

- `Block Decorators`_

- `PEP 310 Updates Requested`_

- `Sharing Namespaces`_

- `PEP 340 Proposed`_


Contributing threads:

- `anonymous blocks
http://mail.python.org/pipermail/python-dev/2005-April/052717.html`__

[SJB]



Block Decorators


One of the first solutions to `The Control Flow Management Problem`_ was
block decorators.  Block decorators were functions that accepted a
block object (also referred to in the thread as a thunk), defined a
particular control flow, and inserted calls to the block object at the
appropriate points in the control flow. Block objects would have been
much like function objects, in that they encapsulated a sequence of
statements, except that they would have had no local namespace; names
would have been looked up in their enclosing function.

Block decorators would have wrapped sequences of statements in much the
same way as function decorators wrap functions today. Block decorators
would have allowed locking() to be written as::

def locking(lock):
def block_deco(block):
lock.acquire()
try:
block()
finally:
lock.release()
return block_deco

and invoked as::

@locking(lock):
CODE

The implementation of block objects would have been somewhat
complicated if a block object was a first class object and could be
passed to other functions.  This would have required all variables used
in a block object to be cells (which provide slower access than
normal name lookup). Additionally, first class block objects, as a type
of 

MacOS X drag drop?

2005-05-15 Thread Han-Wen Nienhuys

Hi there,

this might not be the right group to ask, but I'm looking for some
hints on making a drag  droppable application on MacOS X.  I
succeeded in producing a bundle that calls a python script. 
When I drop a file onto the application, the python script is called
with the following arguments,

  ['/Users/hanwen/src/maclily/BUILD/lilypond.app/Contents/MacOS/lilypond',
   '-psn_0_3145729']

how can I find the path to the dropped file from -psn_0_3145729 ? Or
is this signaled to the script through a different channel?


Thanks!

-- 
 Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: An example in point 2

2005-05-15 Thread Lee Cullens
    From:       [EMAIL PROTECTED]    Subject:     RE:  An example in point 2    Date:     May 15, 2005 8:35:01 PM EDT    To:       [EMAIL PROTECTED]I guess Python is just a cover for this list.  Since the holly rollers can post whatever they want, now the survivalists are chiming in also.  Yet Python content with some harmless vernacular gets kicked.   No point in feeding the idiots that post this garbage so maybe we (as in interested in Python) should start sending it all to you.From: [EMAIL PROTECTED]Date: May 15, 2005 7:33:38 PM EDTTo: python-list@python.orgSubject: The world is really unstable these days..We've got a lot to deal with these days. Terrorism, Recession, blah, blah, blahAn example in point.  You let the holly rollers clutter up the list, but this little test message gets blocked.  Very inconsiderate and inconsistent of you.  If you can block this then you can block all the holly roller garbage.      From:       [EMAIL PROTECTED]    Subject:     Re: Jesus said, "..."    Date:     May 15, 2005 1:52:43 PM EDT    To:       python-list@python.orgThe annoying thing about this junk mail is if one receives just a digest (otherwise the junk mail filter cans it).  Funny how one perfectly innocent word can hold up a post for review, but this sort of thing gets through every timeLee C-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Quick Reference from module doc strings.

2005-05-15 Thread Ron Adam
John Machin wrote:
 Ron Adam wrote:
 
Does anyone have suggestions on how to improve this further?
 
 
 Not functionally (from me, yet). However if you can bear a stylistic
 comment, do read on :-)
 
 
 elif (isinstance(object,str)
 or isinstance(object,int)
 or isinstance(object,bool)
 or isinstance(object,tuple)
 or isinstance(object,list)
 or isinstance(object,dict)):
 
 
 Since Python version 2.2, the 2nd arg of isinstance may be a tuple. You
 could define this up front, with a meaningful name:
 
 TYPES_WHICH_whatever = (str, int, bool, etc etc)
 
 Cheers,
 John

Actually I'm begging for comments, it's the beginning of a project not 
the end.  So thanks!  ;-)

I changed it to:

if type(object)==str:

elif type(object) in (str,int,bool,tuple,list,dict):


Thanks, I don't need the isinstance(), type works here just as well.

What would it take to make it useful?  I'm thinking of putting it to use 
in a database where you can get quickly get info by subject and 
keywords, not just by module.  I'm also thinking of using it to generate 
web pages.

As far as the actual content of doc strings for each item, we can submit 
requests for improvements where it's needed.

Cheers,
_Ron

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


Re: The world is really unstable these days......

2005-05-15 Thread Lucas Raab
snip

 Don't change eventually while you're climbing through a light 
 pumpkin.  If the open clouds can play wrongly, the lean elbow may 
 call more bedrooms.  He can help believably, unless Wail teases 
 farmers throughout Wednesday's enigma.  She wants to join good 
 tyrants about Allan's sign.  Occasionally Marion will love the 
 pool, and if Mohammar bimonthly excuses it too, the code will 
 seek inside the elder college.  
 
 Yesterday, cats recommend among strong doorways, unless they're 
 distant.  Don't try to attack the floors fully, order them amazingly.  
 
 Hardly any tags will be strange smart boats.  Let's creep around the 
 polite rooms, but don't sow the handsome figs.  
 
 
 

Y'know, I really do love these random word spam messages. They're quite 
entertaining to read.

-- 
--
Lucas Raab
lvraab@earthlink.net
dotpyFE@gmail.com
AIM:Phoenix11890
MSN:dotpyfe @ gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: deleting the terminal prompt?

2005-05-15 Thread MackS
Thanks, Dennis, that solved it.

Cheers

Mack

Dennis Lee Bieber wrote:
 On 15 May 2005 16:32:57 -0700, MackS [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:


  while cmd != :
 
  sys.stdout.write(prompt: )
  cmd = raw_input()
 
  # at this point it studies the contents of cmd and decides what
to
  do next.
 
  However, if the user simply presses Tab followed by a backspace
s/he
  effectively makes the prompt disappear. Is there a way to prevent
this
  from happening?
 
   What behavior does...

 while cmd != :
   cmd = raw_input(prompt: )

 ... give you?

 --
   == 
 [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG 
[EMAIL PROTECTED] |   Bestiaria Support Staff   
   == 
 Home Page: http://www.dm.net/~wulfraed/
  Overflow Page: http://wlfraed.home.netcom.com/

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


PIGIP Meeting -- Python Interest Group In Princeton

2005-05-15 Thread [EMAIL PROTECTED]
PIGIP, the Python Interest Group In Princeton, NJ, USA will have
a meeting Monday night at 7 (May 15)  in the Lawrenceville, NJ library.


No formal topic is set tonight, but we will be reviewing some bits of
the standard library that are highlighted in the Python Tutorial.

Anyone with an interest in the Python language are encouraged to
attend, and no RSVP is required and there is no charge is required or
expected for attendence.

You can read more about PIGIP at http://www.pigip.org.

-- Jon R. Fox 
-- [EMAIL PROTECTED]

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


Re: MacOS X drag drop?

2005-05-15 Thread Simon Percivall
Take a look at Platypus at http://sveinbjorn.sytes.net/platypus. It
will make it easier for you.

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


Re: thread title's getting shorter...

2005-05-15 Thread \Rolland\ rolland1

Johnny Gentile [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 .
? 


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


Re: Property,how to use it?

2005-05-15 Thread Peter Hansen
Delaney, Timothy C (Timothy) wrote:
 [EMAIL PROTECTED] wrote:
 
What is the property mean in the python? Who can explain it
for me? I don't know how to use it.
 
 http://www.catb.org/~esr/faqs/smart-questions.html

Or he can just learn to use Google:

http://www.google.com/search?q=python+properties

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


German spam event [was: Re: Schily ueber Deutschland]

2005-05-15 Thread François Pinard
[Paul Rubin]

 I don't think that post was really from MAL.  It seems to be a
 sporgery attack on the newsgroup.  Sigh.

For the last two days, I receive quite an amount of robotic rejects,
after my name was used as the forged From: for an apparently massive
spam invoice written in German.  At the same time, I noticed an increase
of German-written spam filtering through a few lists I'm subscribed to,
and the Python list among others.

Such forged From appears all the time as far as I am concerned, and had
for years now.  But something significant happened this weekend.

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: The world is really unstable these days......

2005-05-15 Thread Delaney, Timothy C (Timothy)
Peter Hansen wrote:

 Lucas Raab wrote:
 snip
 [...]
 Y'know, I really do love these random word spam messages. They're
 quite entertaining to read.
 
 Although, when posting in reply to them it apparently helps those who
 read this through the mailing list, and who have Bayesian filtering of
 spam happening, if you would snip the entire content.
 
 Otherwise it can confuse the spam blockers since they have your name
 generally associated with useful messages (I presume ;-) )  instead of
 with spam.  You're messin' with their statistics, man!  ;-)

Absolutely. Another example of where these things can mess with
Spambayes is people replying to XL and correcting his horrendous
troll-posts. It makes it really hard for Spambayes to determine that
*anything* coming from XL is spam.

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


Re: Is isinstance always considered harmful?

2005-05-15 Thread Bengt Richter
On Sun, 15 May 2005 14:31:21 -0400, Terry Reedy [EMAIL PROTECTED] wrote:


Jordan Rastrick [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I've read arguments, here and elsewhere, to the effect that in Python
 isinstance should be avoided like the plague, except in a few very
 specific and narrow circumstances.

Putting it like this is rather extreme.

 Roughly speaking, due in part to
 Python's dynamic nature its better to concern yourself only with the
 interface an object provides, and not whether it happens to inherit
 from a given base class.

To my mind, your example of using isinstance to select a better (such as 
speedier) subalgorithm for a special case is not just fine, but good 
programming.  (Selecting a subalgorithm that works more robustly is also a 
good reason for special casing.)  It is an internal matter whose externally 
visible effect is to improve performance.
I agree, but I am also a little uncomfortable about such performance tuning,
unless the assumptions it depends on are prominently documented or even
validated with an assert or explicit warning. Otherwise the next version
of the interpreter or a library module could change the optimal decision,
and a bad optimization decision could be locked in for the new version.

Maybe there should be another testable condition like __debug__ except for
testing (e.g. __testing__ ;-) which could be used to introduce temporary
alternative code (such as alternate optimization decisions) so that system
tests could be used to validate locking in one decision or another for a
new system version being tested.

For trivial personally maintained code, a one-line version check with a
reminder exception to re-visit the optimization or whatever decision
(and revise the version check for next time) could cheaply prevent hidden
lock-in of bad optimization etc.


Using isinstance to unnecessarily narrow the domain is quite different.  It 
has the externally visible effect of degrading performance (to a nullity) 
for arguments that the user might reasonably want to work.
Agreed, but the key thing there is to define unnecessarily ;-)

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


Re: problem uploading ZIP file tp PyPI

2005-05-15 Thread richard
John Machin wrote:
 Sorry in advance if this is not the correct forum ...

Quite. The support link for PyPI is in the sidebar of the site.


 I'm trying to upload what appears to be a perfectly OK zip file as a
 source file type to PyPI, and am getting this response:
 
 Error...
 There's been a problem with your request
 exceptions.ValueError: invalid distribution file

The *only* valid (perfectly OK) source file to upload is a Source
Distribution as generated by the sdist setup.py command.


 I have managed to upload a Windows installer, and downloaded it again
 [but the download count is still stuck on zero].

The download counts are updated daily (IIRC).


Richard

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


Re: [Docutils-develop] Re: Have you tried eric3 ?

2005-05-15 Thread Steve Holden
Nicola Larosa wrote:
I've recently discovered Eric3, a development environment dedicated to 
python, 
and I'm really impressed ! Up to now I'd been using kdevelop for my projects 
involving python but I always felt unsatisfied with it.
...
Let me know your thoughts about this nice app !

Web page: http://www.die-offenbachs.de/detlev/eric3.html
Screenshots: http://www.die-offenbachs.de/detlev/eric3-screenshots.html
 
 
 I've been using Eric3 for quite a while now. I tried it years ago, but it
 did only supported .py files in the project, and that was not enough.
 
 Then I used Leo, not your run-of-the-mill IDE, but a very capable outliner
 meant for literate programming, implemented with Python and Tkinter. It too
 had a few idiosyncrasies, so I tried Eric3 again, that in the meanwhile had
 gotten support for .ptl files. It was enough for me, so I switched.
 
 Eric3 is a more traditional, quite featureful IDE, and its Python
 implementation is very clean. I was able to fix a couple minor problems,
 and the patches were accepted into the source, much to my rejoicing.
 
 Recently I resumed using Leo, but for other stuff. For Python programming I
 am sticking to Eric3. I have not gotten around to use its featureful
 support for version control, still using the command line for that, and the
 wonderful Meld for porting between trunk and branches.
 
 A suggestion: the View menu has two very useful folding commands, Toggle
 all folds and Toggle current fold. They are much more usable with
 keyboard shortcuts, so define them. I use Alt+A and Alt+C.
 
 A third command would be useful, to open only the first level folds (to
 open all classes but keep the method closed), but it looks like the
 underlying Scintilla editor does not support this. (In Leo you can
 instantly open the outline at one of ten different nesting level.)
 
If you haven't tried Wing IDE I'd encourage you to take a look. I've 
tried most debugging packages, and Wing is to my mind the most usable.

Further, they have a liberal policy with regard to open source projects, 
making the cost extremely reasonable if you aren't using the software 
for commercial development but do use it to develop and support open 
source works.

regards
  Steve
-- 
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: thread title's getting shorter...

2005-05-15 Thread James Stroud
On Sunday 15 May 2005 06:17 pm, Rolland rolland1 wrote:
 Johnny Gentile [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]

  .

 ?

Another instance of the extremely clever low content body email, AKA the LCBE. 
Let us bask in the cleverness, shall we? Boy that's clever! I can't get over 
how clever that is. Let's all just simultaneously acknowledge that the the 
author of the LCBE has proved his vast intellectual superiority by omitting 
content from the body, leaving others to wonder exactly what he meant. To the 
LCBE author, these people should wonder, as they are not smart enough to know 
that he really meant nothing except to make people wonder. Very Clever! What 
is even more clever is that the author of the LCBE is now making hundreds of 
people make a Johnny Gentile filter. Wow, I'm so impressed with this level 
of cleverness. Now, if the LCBE author will go take a crap on some canvas, we 
can call it art. How clever, indeed! Clever, clever, clever, clever, clever. 
W.
Clever.

(And Stupid.)

Dear LCBE author, please go fuck yourself.

James

-- 
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


Re: Range function

2005-05-15 Thread David Formosa (aka ? the Platypus)
On 15 May 2005 02:50:38 -0700, Xah Lee [EMAIL PROTECTED] wrote:
 Here's the Perl code.

Where did you learn to program?  Its highly unlikely that a Perl
programer would ever write a range function as there is a built in
Perl function that does the same thing.  If your intent is purely
accedemic then the first thing you should do is learn Perl to a much
higher grade.

 #! perl
 
 # http://xahlee.org/tree/tree.html
 # Xah Lee, 2005-05
 
 #_ Range _ _ _ _
 
=pod
 
 BRange

Its considered poor style to have function names with capital
letters.  The normal convention is to use all lower case.

 Range($iMax) generates the list [1, 2, ... , $iMax].
 
 Range($iMin, $iMax) generates the list [$iMin, ... , $iMax].
 
 Range($iMin, $iMax, $iStep) uses increment $iStep, with the last
 element in the result being less or equal to $iMax. $iStep cannot be 0.
 If $iStep is negative, then the role of $iMin and $iMax are reversed.
 
 If Range fails, 0 is returned.
 
 Example:
 
  Range(5); # returns [1,2,3,4,5]
 
  Range(5,10); # returns [5,6,7,8,9,10]
 
  Range( 5, 7, 0.3); # returns [5, 5.3, 5.6, 5.9, 6.2, 6.5, 6.8]
 
  Range( 5, -4, -2); # returns [5,3,1,-1,-3]
 
=cut

sub range {

  return [1..$_[0]] if (@_==1);

  return [$_[0]..$_[1]] if (@_==2);

  my $lowest= shift;
  my $greatest  = shift;
  my $increment = shift;

  my $steps = ($greatest - $lowest)/$increment;
  my @return= map { $_ * $increment + $lowest } (0..$steps);

  return [EMAIL PROTECTED];
}

This does as you wish but it far shorter and I would argue easyer for
the typical perl programer to read.

 sub Range ($;$$) {
 if (scalar @_ == 1) {return _rangeFullArgsWithErrorCheck(1,$_[0],1);};
 if (scalar @_ == 2) {return
 _rangeFullArgsWithErrorCheck($_[0],$_[1],1);};
 if (scalar @_ == 3) {return
 _rangeFullArgsWithErrorCheck($_[0],$_[1],$_[2]);};
};

I would suggest that If you have the case where your doing a one line
if stament then you should make use of the line modifing verent of
if.  Also since if produces a scalar context its not needed.

sub Range ($;$$) {
  return _rangeFullArgsWithErrorCheck(1,$_[0],1) if (@_ == 1);
  return _rangeFullArgsWithErrorCheck($_[0],$_[1],1) if (@_ == 2);
  return _rangeFullArgsWithErrorCheck($_[0],$_[1],$_[2]) if (@_ == 3);
}

See how much neater and more readable the code is after doing that.

 sub _rangeFullArgsWithErrorCheck ($$$) {
 my ($a1, $b1, $dx) = @_;
 
 if ($dx == 0) {print Range: increment cannot be zero.; return 0}
 elsif ($a1 == $b1) {return [$a1];}
 elsif ( ((($b1 - $a1)  0)  ($dx  0)) || ((($b1 - $a1)  0)  ($dx
 0)) ) {print Range: bad arguments. You have [$a1,$b1,$dx]; return
 0;}
 elsif ((($a1  $b1)  ($b1  ($a1 + $dx))) || (($a1  $b1)  ($b1 
 ($a1 + $dx {return [$a1];}
 else { return _rangeWithGoodArgs ($a1,$b1,$dx);};
};

This would be a great place to make use of die.  Throwing an exection for an 
error.

sub _rangeFullArgsWithErrorCheck ($$$) {
  my ($a1, $b1, $dx) = @_;

  die Range: increment cannot be zero. unless $dx;

  return [$a1] if ($a1 == $b1);

  if ( ((($b1 - $a1)  0)  ($dx  0))
|| 
   ((($b1 - $a1)  0)  ($dx0))) {
die Range: bad arguments. You have [$a1,$b1,$dx];
  }
}


 sub _rangeWithGoodArgs ($$$) {
 my ($a1, $b1, $dx) = @_;
 my @result;
 
 if ($a1  $b1) {for (my $i = $a1; $i = $b1; $i += $dx) { push
 (@result, $i);}; }
 else {for (my $i = $a1; $i = $b1; $i += $dx) { push (@result, $i);};
};
 return [EMAIL PROTECTED];
};

Personally I don't like the c style while loop.  I didn't like it in C
and I don't like it in perl.

-- 
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem uploading ZIP file tp PyPI

2005-05-15 Thread John Machin
richard wrote:
 John Machin wrote:
  Sorry in advance if this is not the correct forum ...

 Quite. The support link for PyPI is in the sidebar of the site.


Tried that, when I was trying to register and getting strange error
messages about the user name, like John Machin and John_Machin were
not ascii [it finally permitted sjmachin]. The response volume
could not be likened to that of a fire-hose.


  I'm trying to upload what appears to be a perfectly OK zip file as
a
  source file type to PyPI, and am getting this response:
 
  Error...
  There's been a problem with your request
  exceptions.ValueError: invalid distribution file

 The *only* valid (perfectly OK) source file to upload is a Source
 Distribution as generated by the sdist setup.py command.


Which is precisely how the file in question was generated:

setup.py sdist --format=zip

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


Re: 20050111: list basics

2005-05-15 Thread David Formosa (aka ? the Platypus)
On 12 Jan 2005 08:22:04 GMT, Abigail [EMAIL PROTECTED] wrote:

[...]

 Wrong. Perl functions don't take memory addresses. Perl doesn't allow
 the programmer to do direct memory access.

Perl's pack function will allow you to do direct memory access if you
ask it to via the p and P templates.

-- 
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
-- 
http://mail.python.org/mailman/listinfo/python-list


BLT with TCL/TK 8.4.9 and Python 2.4

2005-05-15 Thread Kenneth Miller
Has anyone acheived this?

Regards,
Ken


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


question about the id()

2005-05-15 Thread kyo guan
HI ALL:

Can someone explain why the id() return the same value, and why these 
values are changing? Thanks you.

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 class A(object):
... def f():
... pass
... def g():
... pass
...

 a=A()
 id(a.f)
11365872
 id(a.g)
11365872


 class B(object):
... def f():
... print 1
... def g():
... print 3
...
 b=B()
 id(b.f)
11365872
 id(b.g)
11365872
 id(a.f), id(a.g), id(b.f), id(b.g)
(11365872, 11365872, 11365872, 11365872)
 a.f is a.g
False
 id(a.f), id(a.g), id(b.f), id(b.g)
(11492408, 11492408, 11492408, 11492408)
 a.f is a.g
False
 id(a.f), id(a.g), id(b.f), id(b.g)
(11365872, 11365872, 11365872, 11365872)


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


Re: BLT with TCL/TK 8.4.9 and Python 2.4

2005-05-15 Thread Jeff Hobbs
Kenneth Miller wrote:
 Has anyone acheived this?

There is no reason why Tkinter couldn't load BLT (from the Tcl
side).  You could wrap it up into a Tkinter-style widget, or
just drive it through lower level evals.

-- 
   Jeff Hobbs, The Tcl Guy
   http://www.ActiveState.com/, a division of Sophos
-- 
http://mail.python.org/mailman/listinfo/python-list


Brad Pahlke is out of the office.

2005-05-15 Thread Bradley K Pahlke
I will be out of the office starting  05/11/2005 and will not return until
05/17/2005.

I will respond to your message when I return.

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


Re: question about the id()

2005-05-15 Thread Skip Montanaro

kyo Can someone explain why the id() return the same value, and why
kyo these values are changing?

Instance methods are created on-the-fly.  In your example the memory
associated with the a.f bound method (not the same as the unbound method
A.f) is freed before you reference a.g.  That chunk of memory just happens
to get reused for the bound method associated with a.g.  Here's a
demonstration:

% python
Python 2.5a0 (#77, May 14 2005, 14:47:06) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
Type help, copyright, credits or license for more information.
 class A(object):
...   def f(): pass
...   def g(): pass
... 
 a = A()
 x = a.f
 y = a.g
 id(x)
17969240
 id(y)
17969440
 id(a.f)
17969400
 id(a.g)
17969400

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


Re: Precision?

2005-05-15 Thread Facundo Batista
On 5/15/05, Ron Adam [EMAIL PROTECTED] wrote:


   x
 321.61
 
 Here the error has been kept to a minimum.  In most cases, it isn't a
 problem, but it is something to be aware of.  It does matter in banking
 and I beleive there are standard ways of dealing with it.

Yes, use Decimal:

http://docs.python.org/lib/module-decimal.html

Remember that you can also use it in Python 2.3.x:

http://www.taniquetil.com.ar/facundo/bdvfiles/get_decimal.html

.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: question about the id()

2005-05-15 Thread kyo guan
HI Skip:

I want to check is there any change in the instance 's methods.
 a=A()
 a2=A()
 a.f == a2.f
False
 a.f is a2.f
False
 a.f is a.f
False

If the instance methods are create on-the-fly, how to do that? Thanks.

Kyo
 

 -Original Message-
 From: Skip Montanaro [mailto:[EMAIL PROTECTED] 
 Sent: Monday, May 16, 2005 11:09 AM
 To: kyo guan
 Cc: python-list@python.org
 Subject: Re: question about the id()
 
 
 kyo Can someone explain why the id() return the same 
 value, and why
 kyo these values are changing?
 
 Instance methods are created on-the-fly.  In your example the 
 memory associated with the a.f bound method (not the same as 
 the unbound method
 A.f) is freed before you reference a.g.  That chunk of memory 
 just happens to get reused for the bound method associated 
 with a.g.  Here's a
 demonstration:
 
 % python
 Python 2.5a0 (#77, May 14 2005, 14:47:06) 
 [GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
 Type help, copyright, credits or license for more 
 information.
  class A(object):
 ...   def f(): pass
 ...   def g(): pass
 ... 
  a = A()
  x = a.f
  y = a.g
  id(x)
 17969240
  id(y)
 17969440
  id(a.f)
 17969400
  id(a.g)
 17969400
 
 Skip

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


Re: Quick Reference from module doc strings.

2005-05-15 Thread Scott David Daniels
Ron Adam wrote:
 John Machin wrote:
 
 Ron Adam wrote:

 Does anyone have suggestions on how to improve this further?

 Not functionally (from me, yet). However if you can bear a stylistic
 comment, do read on :-)

 elif (isinstance(object,str)
 or isinstance(object,int)
 or isinstance(object,bool)
 or isinstance(object,tuple)
 or isinstance(object,list)
 or isinstance(object,dict)):

 Since Python version 2.2, the 2nd arg of isinstance may be a tuple. You
 could define this up front, with a meaningful name:

 TYPES_WHICH_whatever = (str, int, bool, etc etc)
 
 Actually I'm begging for comments, it's the beginning of a project not 
 the end.  So thanks!  ;-)
 
 I changed it to:
 
if type(object)==str:

elif type(object) in (str,int,bool,tuple,list,dict):


Althought object is a horrible name for your own value (there is a builtin
object which you use for defining new-style classes), you probably want:

 if isinstance(object, (str,int,bool,tuple,list,dict)):
 ...
or (as John Machin was trying to suggest):

 if isinstance(object, TYPES_WHICH_whatever):
 ...

This allows you to use instances of those builtin types and any
user-defined subtypes.

 Thanks, I don't need the isinstance(), type works here just as well.

But the isinstance version is better than the type(...) in ... version.

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


Amy Redding/Tucson/IBM is out of the office.

2005-05-15 Thread Amy Redding

I will be out of the office starting  05/12/2005 and will not return until 05/16/2005.

I am out of the office until Mon. May 16
For assistance see Said Lamri x2374 -- 
http://mail.python.org/mailman/listinfo/python-list

PythonWin + Tkinter = broken relation with WindowsXP !?!?!

2005-05-15 Thread jean-marc
I read that Tkinter and Python IDEs (PythonWin and Idle at least) makes
for a bad mix in execution mode because they're fighting for the event
loop, but this mode is usefull to use the debugger.

But to the point of breaking something elsewhere than in memory ???
(Shutting down and rebooting the computer doesn't resolve the
problems... PythonWin becomes impossible to use if another window is
open (pdf files, winAmp music, browser et al...)

is this documented somewhere??? It's been happening quite a few times
to me (real bummer!).

NOTE: This situation seems to appear slowly...  Not like a works or
doesn't work situation but rather that corruption is progressive. This
is a complete mystery to me

Thanks in advance,

JMD
Python 2.3.5, WinXP Pro SP2
I've started using Python Scripter, which seems less problematic (at
this point)

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


  1   2   >