ANN: CherryPy 3.0.0 beta 2

2006-09-28 Thread Christian Wyglendowski
On behalf of the CherryPy team I'd like to announce the availability of
CherryPy 3.0.0 beta 2. There have been some significant bug fixes and
improvements since the first beta release a few weeks ago. Here are
some highlights: * All CherryPy exceptions now inherit from CherryPyException * The permission bug with the error log has been corrected.
 * Builtin SSL support! (requires PyOpenSSL). * New cherrypy.url() function replaces tree.url and request.url. * New builtin tools for basic and digest authentication. * Encoding bug fixes.For more details on 
3.0, see the following URLs: * http://www.cherrypy.org/wiki/WhatsNewIn30 * http://www.cherrypy.org/wiki/UpgradeTo30
Thanks
to the CherryPy community for all of the bug reports and comments on the
first beta. Please try out this latest release and let us know what
you think.
Christian WyglendowskiCherryPy Team
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: does anybody earn a living programming in python?

2006-09-28 Thread Hendrik van Rooyen

 Steven D'Aprano [EMAIL PROTECTED] Wrote:


 On Tue, 26 Sep 2006 22:00:55 +1000, Anthony Baxter wrote:

  This seems to be a very, very silly original post. I know of plenty of
  people who make a living programming Python. It's been the vast
  majority of the programming (for money) I've done in the last ten
  years, and there's countless other people I know here in Melbourne in
  the same position.

 Countless people? Are we talking aleph-zero people (countable infinity) or
 one of the uncountable infinities?


 --
 Steven.

Oh dont be so pedantic - countless - without count - probably just means that
nobody has bothered to count them...

- Hendrik






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


RE: Starting Win32 Service

2006-09-28 Thread Tim Golden
[placid]
|  Now i was trying to use service.ChangeStartMode but each 
| time i pass in
|  an argument i get the error;
| 
|  #TypeError: __call__() takes exactly 1 argument (2 given)
| 
|  but;
| 
|   print service.ChangeStartMode
|  function ChangeStartMode (StartMode) = (ReturnValue)
| 
|  ChangeStartMode needs an argument!
| 
|  What im i doing wrong here?
| 
| And to answer my own question, the way to pass in arguments is via the
| key=value way so;
| 
| service.ChangeStartMode(StartMode = Automatic)

Yes, sorry about that, it's a well-known (to me) gotcha.
Basically there's no way I can extract the params from
the COM interface in a way which implies order, so I
can't take them in positionally. (Corrections to this
statement will be gratefully received).

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: ctypes pointer to pointer

2006-09-28 Thread Gabriel Genellina

At Wednesday 27/9/2006 22:58, Podi wrote:


I have a C function in the dll does the following:

DLL_API int dll_foo(char **data, size_t *size)
{
strcpy(*data, hello);
*size = strlen(*data);

return 0;
}


So I would call the function as such,

char data[8];
size_t size;

int status = dll_foo(data, size);

I have tried the following in Python but not able to get it working...
Any help would be appreciated!

from ctypes import *
mydll = windll.mydll
array = c_char * 8
data = array()
size = c_long()
status = mydll.dll_foo(byref(data), byref(size))
Traceback (most recent call last):
  File interactive input, line 1, in ?
WindowsError: exception: access violation writing 0x


I'd use your last try. But since it didnt work, use a prototype and 
see what happens:


data = create_string_buffer('\000' * 8)
size = c_long()
dll_foo = mydll.dll_foo
dll_foo.argtypes = [POINTER(c_char_p), POINTER(c_long)]
status = dll_foo(byref(data), byref(size))

Are you sure your function is compiled using the stdcall calling 
convention? I'm not sure what means DLL_API.




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, George Sakkis [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:

 What bothers me a bit about the rejection of PEP 326 is that one of the
 reasons stated is:

   http://mail.python.org/pipermail/python-dev/2004-January/042306.html

   - it is easily implemented when you really need it

 Well I thought it would simplify some things for me, so I tried an
 implementation and then found that some of the things that I would
 want to do with it wont work. So the is easily implemented bit
 seems not to be correct.

 IIRC, the PEP proposed the Smallest and Largest singletons with the
 sole purpose of being used in comparisons. No numeric behavior was
 implied, i.e. Smallest and Largest are not negative and positive
 infinity in the math sense of the word.

That is true.

 So I guess the easily implemented refers to this case alone.

This doesn't follow. Take the example were I got stuck.

 lst = range(10)
 lst[:Top]

This doesn't need arithmetics done with Top. The only fact that
you need is: Top = len(lst). In a way this isn't that difficult
in itself, it becomes difficult because python doesn't allow
ducktyping for a lot of its builtins. I could write my own
function:

  def leftslice(lst, num):
return  [ tp[1] for tp in enumerate(lst) if tp[0]  num ]


This function works as expected if you substituted Top for num
and as you can see, no arithmetic is done on num, only comparisons.

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


Re: Difference between two dates in seconds

2006-09-28 Thread flupke
Fredrik Lundh schreef:
snip
 
 def get_seconds(td):
 ... return td.days * (24*60*60) + td.seconds
 ...
 import dis
 dis.dis(get_seconds)
   2   0 LOAD_FAST0 (td)
   3 LOAD_ATTR0 (days)
   6 LOAD_CONST   4 (86400)
   9 BINARY_MULTIPLY
  10 LOAD_FAST0 (td)
  13 LOAD_ATTR1 (seconds)
  16 BINARY_ADD
  17 RETURN_VALUE
 
 /F

Ha, i didn't know about the dis module.
Looks fun.
I get these results:

 def get_seconds(td):
...   return td.days * (24*60*60) + td.seconds
...
 dis.dis(get_seconds)
  2   0 LOAD_FAST0 (td)
  3 LOAD_ATTR1 (days)
  6 LOAD_CONST   1 (24)
  9 LOAD_CONST   2 (60)
 12 BINARY_MULTIPLY
 13 LOAD_CONST   2 (60)
 16 BINARY_MULTIPLY
 17 BINARY_MULTIPLY
 18 LOAD_FAST0 (td)
 21 LOAD_ATTR2 (seconds)
 24 BINARY_ADD
 25 RETURN_VALUE

 def get_seconds2(td):
...   return td.days * 86400 + td.seconds

 dis.dis(get_seconds2)
  2   0 LOAD_FAST0 (td)
  3 LOAD_ATTR1 (days)
  6 LOAD_CONST   1 (86400)
  9 BINARY_MULTIPLY
 10 LOAD_FAST0 (td)
 13 LOAD_ATTR2 (seconds)
 16 BINARY_ADD
 17 RETURN_VALUE

Using 86400 instead of (24*60*60) is faster

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


Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Michele Simionato
John J. Lee wrote:
 ISTM that there's a vast amount of mostly-tacit knowledge about the
 way things work, and they way they should work, good practices, design
 techniques, rules of thumb, Bad Ideas ;-), etc. etc. that good
 programmers do have and bad or inexperienced programmers don't.

Yep, I think that's the point. Worth repeating (and +1 for QOTW).

  Michele Simionato

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


Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread [EMAIL PROTECTED]
Hi,

String formatting can be used to converting an integer to its octal or 
hexadecimal form:
  a = 199
  %o % a
'307'
  %x % a
'c7'

But, can string formatting be used to convert an integer to its binary 
form ?


Thanks in advance.

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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, OKB (not okblacke) [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:

 To begin with this already fails:
 
 for i in xrange(Top):
 ...   print i

   What do you expect this to do?  Loop forever?

Yes that is what I would expect. If someone would ask me
to implement a function like xrange it would look something
like the following (*)

  def xrange(start=1, stop, step=1):

while start  stop:
  yield start
  start += step

Since Top is supposed to be bigger than any other value this would
indeed loop forever. The only reason that this doesn't work with
the builtin, is because the builtin xrange insist on its arguments
being ints instead of allowing duck typing.

(*) Yes I know this isn't legal python. I just wrote it like this
to make the intention clear instead of putting in the code that
would actually behave like xrange with regards to its defaults.
IMO that would just detract from the actual code.

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


Re: a query on sorting

2006-09-28 Thread Steve Holden
Paul McGuire wrote:
 Steve Holden [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 snip
 
[x for x in enumerate(a)]
 [(0, 9), (1, 4), (2, 3), (3, 5), (4, 2), (5, 6), (6, 7), (7, 1), (8, 2)]
 
 
 Just curious, Steve, but why do this list comprehension when:
 
 list(enumerate(a))
 
 works just as well?
 
Dumb stupidity would account for that. Knowing that enumerate(a) was an 
iterator I simply used the first iterative context that came to mind. 
List is somewhat more effective.

 In the interests of beating a dead horse into the ground (metaphor-mixing?), 
 I looked at using map to one-line the OP's request, and found an interesting 
 inconsistency.
 
 I tried using map(reversed, list(enumerate(a))), but got back a list of 
 iterators.  To create the list of tuples, I have to call the tuple 
 constructor on each one, as in:
 
 map(tuple,map(reversed,list(enumerate(a
 
 However, sorted returns a list, not a listsortediterator.  Why the 
 difference in these two builtins?
 
Ask the developers. Beats me ...

 I guess you can beat a dead horse into the ground, but you can't make him 
 drink.
 
I guess. Thanks for flogging this horse so effectively.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Michele Simionato
Ben Finney wrote:
 I submit that a programmer who knows *only* one programming language
 can never be an expert in that language; it is only exposure to
 multiple tools and ways of programming that can grow a one-trick pony
 into an expert.

Well, it all depends on the definition of expert. Python is written
in C, so if  by
expert of Python you mean somebody who knows its internal working, its
is clear
that that person must know C. However, even knowing Python only gives
you
a lot of multiple tools and ways of programming, much more than
knowing
Java or Visual Basic. That was my point.

Also, I believe that a person who knows Python has no reason to learn
Java or Visual Basic (except for pragmatic purposes). After Python I
learned Scheme and if I had time I would
give a look at Haskell, or some other different language. BTW I decided
not to learn
Ruby it is not really different from Python in terms of learning new
ways of programming.

 Michele Simionato

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


Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Michele Simionato
Roy Smith wrote:
 The problem is, if the complex features are there, people will use them.
 On any large project, there will always be some people who revel in using
 every obscure feature of a language.  That forces everybody else on the
 team (and all future members of the team) to know (or learn) those features
 in order to be able to use and maintain the code base.

Well, I am sympathetic with your point and I actually would have no
problem if metaclasses
and multiple inheritance were removed from the language. However my
point was a
different one. If you know all this stuff, you are likely to be able to
learn any language.
My point was that when hiring a programmer, one should also look at the
potential of the
person, not only at his/her present skills.

   Michele Simionato

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


Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread flupke
[EMAIL PROTECTED] schreef:
 Hi,
 
 String formatting can be used to converting an integer to its octal or
 hexadecimal form:
 a = 199
 %o % a
 '307'
 %x % a
 'c7'
 
 But, can string formatting be used to convert an integer to its binary
 form ?
 
 
 Thanks in advance.
 
 xiaojf

I don't actually know how to do it with string formatting but you can
create a simple function to do it.
Here's an example:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/219300

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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, Tim Chase [EMAIL PROTECTED] wrote:
 To begin with this already fails:

 for i in xrange(Top):
 ...   print i
 
  What do you expect this to do?  Loop forever?

 Perhaps the infinite loop should take half as long as

  for i in xrange(Bottom, Top): print i

 Though then the values when the loop first starts are kinda 
 ambiguous... :)

 Given the limits of xrange:

  for i in 
 xrange(10,19):
 ...   print i

 Traceback (most recent call last):
File stdin, line 1, in ?
 OverflowError: long int too large to convert to int

 I suspect one would have an overflow condition to help break you 
 out of the loop...

Sometime people want an infinite loop.

Personnaly I don't see why I should get an overflow error while
doing this:

  import sys
  for i in xrange(sys.maxint - 4, sys.maxint + 5):
pass

I remember in the days when longs and ints were being unified,
that some people complained, because without this unification,
a loop in which an int counter was incremented would necessarily
end when the counter overflowed and this was a good indication
there was a bug somewhere. The response to that was, that you
could never foresee how your algorithm would be used and that
maybe someday someone found a good way to use your algoritm
where the counter would go beyond sys.maxint.

Following this logic there is no reason why xrange should be
limited to ints.

  try:
 ...   for i in range(Top):
 ...   print i
 ... except OverflowError:
 ...   print 'done!'

 ...and then you time your instruction cycles and your disk reads 
 so they fall under the read-head at just the right time... [*]

 [*] http://www.catb.org/jargon/html/story-of-mel.html

There is no reason to compare what I propose to the story of melvin.
All behaviour of the objects would be well defined and could be
easily understood to those who would read the documentation.

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


Re: QuoteSQL

2006-09-28 Thread Duncan Booth
Lawrence D'Oliveiro [EMAIL PROTECTED] wrote:
 In message [EMAIL PROTECTED], Duncan Booth wrote:
 Deary me. Did you actually test out that bit of code before you
 posted it? 
 
 execfile(QuoteSQL.py)
 EscapeSQLWild(r\%)
 '%'
 SQLString(% + EscapeSQLWild(r\%) + %)
 '%%%'
 EscapeSQLWild(r\%) == r\\%
 True
 SQLString(% + EscapeSQLWild(r\%) + %) == r'%%%'
 True
 
Ah, so that's a 'no' then. I can't see any tests there. How do you know 
that those strings work correctly MySQL queries?

Please, open your mind to what I'm saying. I'm not trying to criticise your 
aims, just trying to point out the simple fact that your EscapeSQLWild 
function has a bug. If nothing else, the fact that you are finding this so 
hard to understand shows that there is a need for a correctly written 
function to do this.

The fix to EscapeSQLWild to get test_escapebackslashwild2 to work is a 
trivial change, and not suprisingly also makes the other failing test in my 
script (the one using parameterised queries and EscapeSQLWild) pass.

Again, please, try running the script I posted, and in particular 
test_escapebackslashwild2. It uses the SQL query you yourself created, and 
it fails because it matches something it shouldn't.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-27, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Wed, 27 Sep 2006 13:37:40 +, Paul McGuire wrote:

 Here's a little more refined version of my previous post:
 
 class StubbornInt(int):
 def invariantOp(self,other):
 return self
 __add__ = invariantOp
 __sub__ = invariantOp

 [snip rest of code]

 import sys
 Top = StubbornInt(sys.maxint)

 Top shouldn't need to depend on a specific integer value, but then it is
 easy enough to subclass StubbornInt.

 However, there is a more serious problem with your definition of Top:

 Top  sys.maxint+1
 False

 But Top is supposed to bigger than everything, right?

 Okay, let's fix it:

 class FixedTop(StubbornInt):
 def __init__(self):
 super(FixedTop, self).__init__(sys.maxint)
 self.name = 'Top'
 def _bigger(self, other):
 # Top is bigger than everything
 return True
 def _smaller(self, other):
 # Top is smaller than nothing
 return False
 __lt__ = __le__ = _smaller
 __gt__ = __ge__ = _bigger


 Let's test it out:

 Top = FixedTop()
 Top  45
 True
 Top  sys.maxint
 True
 Top  2L**512
 True
 Top  None
 True
 Top  hello
 True


 So far so good.

 However, the downside of rolling your own Top is the risk that one day
 you'll have something like this:

 class Funny:
 def __init__(self, name):
 self.name = name
 def __str__(self):
 return self.name
 def __gt__(self, other):
 return len(str(self))  len(str(other))

 and then you'll have problems:

 bottom = Funny(Bottom)
 Top  bottom
 True
 bottom  Top
 True

 As far as I can see, the only way to avoid edge cases like this is for Top
 (and Bottom) to be built-ins that are special-cased by Python.

An other problem is that if you roll your own, they wont be accepted in
a lot of buitins where they would make sense. Take itertools.repeat as
it is now and I understand correctly there are two possibilities.

1) Your extreme values are not a subclass of int, then you won't be able
to use them as a times arguments.

2) Your extreme values are a subclass of int, then they will somehow
have an int value and this int value will be used, so that the repeat
won't be an infinite loop.

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


Re: A critique of cgi.escape

2006-09-28 Thread Duncan Booth
Lawrence D'Oliveiro [EMAIL PROTECTED] wrote:

 Also, because Python has a 
 conservative policy on backwards incompatible changes, you are protected
 from some wanker going and changing the HTML safe mappings arbitrarily,
 say using numerical entity references instead of gt;, lt; and amp;.
 
 Why would that be wrong? It would still be consistent with the
 documentation.
 
It would be wrong as he said because Python has a conservative policy on 
backwards incompatible changes. In general (although they may not always 
succeed) Python's core developers try not to change functionality even when 
that functionality isn't clearly documented. Rather if it becomes an issue 
they would prefer to clarify the documentation.

Yes, there is a downside to this: a lot of the Python standard libraries 
aren't as good as they could be if incompatible changes were allowed, but 
it does reduce maintenance headaches.

The solution is usually that when the standard api is insufficient you wrap 
it in something else. cgi.escape is a good example: most people writing web 
applications never call it directly because they produce their html output 
using a templating language which does all the necessary quoting for them 
automatically (e.g. Zope's tal language). If you use tal then you have zero 
chance of forgetting to use quote; in a situation where it is required, 
but an incompatible change to cgi.escape could still break your existing 
code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XSLT speed comparisons

2006-09-28 Thread Damian
Sorted!

I installed msxml4 and then struggled for an hour or so with an
encoding error (UnicodeEncodeError: 'ascii' codec etc) which was
fixed by altering your code from:

return proc.output -- return proc.output.encode('utf-8')

The performance of MSXML over 4suite is substantial.
4suite: http://python.pointy.co.nz/test = 2.5s
MSXML: http://python.pointy.co.nz/test_msxml = 1.1s

I'd like to eventually break all ties with MS at some stage. It'll be
interesting to test this performance on a Linux server.

Thank you for your help.

Damian

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


Re: Difference between two dates in seconds

2006-09-28 Thread Duncan Booth
flupke [EMAIL PROTECTED] wrote:

 Using 86400 instead of (24*60*60) is faster

s/is/was/

upgrade to Python 2.5
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
efrat wrote:
   Hello,
 
   I'm planning to use Python in order to teach a DSA (data structures
 and algorithms) course in an academic institute. If you could help out
 with the following questions, I'd sure appreciate it:
(snip)
 2. Suppose I have some file example.py, and I'd like to incorporate it
 **into** part of an HTML page with nice syntax highlighting and all the
 shebang. Is there an easy way to do so?

I suppose this has more to do with the course presentation than with
it's content !-)

However, Trac's wiki is probably a good solution here.

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between two dates in seconds

2006-09-28 Thread flupke
Duncan Booth schreef:
 flupke [EMAIL PROTECTED] wrote:
 
 Using 86400 instead of (24*60*60) is faster
 
 s/is/was/
 
 upgrade to Python 2.5

Indeed, i'm still on 2.4.
I thought 2.5 might give a different result :)

Thanks for the info
Benedict
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
Antoon Pardon wrote:
 On 2006-09-27, George Sakkis [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:

 What bothers me a bit about the rejection of PEP 326 is that one of the
 reasons stated is:

   http://mail.python.org/pipermail/python-dev/2004-January/042306.html

   - it is easily implemented when you really need it

 Well I thought it would simplify some things for me, so I tried an
 implementation and then found that some of the things that I would
 want to do with it wont work. So the is easily implemented bit
 seems not to be correct.

 IIRC, the PEP proposed the Smallest and Largest singletons with the
 sole purpose of being used in comparisons. No numeric behavior was
 implied, i.e. Smallest and Largest are not negative and positive
 infinity in the math sense of the word.
 
 That is true.
 
 So I guess the easily implemented refers to this case alone.
 
 This doesn't follow. Take the example were I got stuck.
 
 lst = range(10)
 lst[:Top]

FWIW, this works with 2.5 and the __index__ slot:

  class Top(object):
...  def __index__(self):
...   return sys.maxint
...
  a=range(5)
  a[:Top()]
[0, 1, 2, 3, 4]
 

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


Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke [EMAIL PROTECTED] (on 2006-09-28 09:10):

 String formatting can be used to converting an integer to its octal or 
 hexadecimal form:
   a = 199
   %o % a
 '307'
   %x % a
 'c7'
 
 But, can string formatting be used to convert an integer to its binary 
 form ?

I didn't fell over this problem so far but
I *would* have expected to find something
like a 'pack' operator (as in Perl).

And voilá, there is (even basically identical to Perl):

  from struct import *

  a = 199
  a_bin_str = pack('L', a)



Regards

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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
Antoon Pardon wrote:
 On 2006-09-27, OKB (not okblacke) [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:

 To begin with this already fails:
 
 for i in xrange(Top):
 ...   print i

  What do you expect this to do?  Loop forever?
 
 Yes that is what I would expect.

For unterminating loops, use while 1:, and if you need the counter,
itertools.count().

 If someone would ask me
 to implement a function like xrange it would look something
 like the following (*)
 
   def xrange(start=1, stop, step=1):
 
 while start  stop:
   yield start
   start += step
 
 Since Top is supposed to be bigger than any other value this would
 indeed loop forever. The only reason that this doesn't work with
 the builtin, is because the builtin xrange insist on its arguments
 being ints instead of allowing duck typing.

xrange() *could* be implemented as shown above, but do you realize
that it would be a severe performance hit compared to the current
implementation, which doesn't give almost all users a benefit at all?

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


Re: windev vs python SOS

2006-09-28 Thread Bruno Desthuilliers
stéphane bard wrote:
 hello, my boss ask me to prefer windev to python.

Find another job.

(I'm serious. I've 2+ years of pain with Windev, and if your boss is
clueless enough to believe all the marketing crap from PCSoft's droids,
you really don't want to work for him).

 I have to argue
 
  - python work on multiple platform (linux, mac, windows)
 A good point but it didn't interest him. Because
 we want to choose a language for prototyping.

Python is far better at this than Windev - and the prototype is
usually quite usable.

 So multi platform is not enough.
 
  - python and windev are fast to develop

Nope. Windev lets you quickly have a barely usable DB-GUI pipeline, and
then trouble begins. Python, OTHO, really lets you do the job.

  - windev as a good IDE, python? boa-constructor is ok with wxpython

Aren't you confusing IDE with RAD ?

 
  - python is open source (that's not an argument for my boss, sorry
 it's a boss ...)

Python is free. And being a boss doesn't necessarily imply being stupid.

 any idea for a strong argument ?

My own argument would be it's Python or it's without me g

More seriously: since you're in a Window-only shop, portability may not
be a strong argument. But Python is also very good at Windows-specific
stuff (COM etc) - and is widely used by Windows programmers (at least in
France). FWIW, you may want to post this on fclpy too - there are some
hard-core Windows developpers there...


You can also point your boss to IronPython - if MS puts some money on
it, it can't be a bad tool, isn't it ?-)

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: windev vs python SOS

2006-09-28 Thread Bruno Desthuilliers
John Henry wrote:
 I don't know what windev is 

A french (highly proprietary) so-called CASE-Tool with a so-called
5th generation language (lol) that is mostly a dumbed-down mix of
basic and pascal. It's so bad that it makes you regret VB6.


-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: does anybody earn a living programming in python?

2006-09-28 Thread Magnus Lycka
Stuart Bishop wrote:
 My personal experience is that there is a shortage of good Python
 programmers. In Melbourne, Australia for example there is a continual need
 for about 2 more - one Python shop there just hires clueful developers and
 makes their first task 'learn Python'. We generally have a few positions
 open at any particular moment too - http://www.ubuntu.com/employment (but we
 are picky - it is hard to hand hold when the hand is several time zones away).

It's much easier to learn Python than it is to learn good general
software development skills, so I think that's a good approach. My
room mate here at work didn't know any Python programming before he
came, but he was fluent pretty soon. Like me, he's starting to make
stupid mistakes in C++, such as forgetting trailing ; after each line.
:)

We are fairly picky here when we employ people, but while we appreciate
that they already know Python, we don't see it as a major issue. It's
quick and easy to learn. Mentioning Python in job ads is maybe more a
way to attract people who take clever initiatives.

 On a slight tangent, one of the appealing things about Python (and other
 'non-mainstream' languages) in the past has been that the people who knew
 Python also tended to be the people you wanted to employ - they generally
 had experience in other languages but moved onto something they perceived as
 'better' either at work or home. It indicated a level of care and pride
 about their profession rather than someone who just treated cutting code as
 a day job. 

That depends if you are an employer who wants to lead
a team of skilled professionals or if you prefer a
herd of sheep that you lead around with a stick.

So, as someone who want to be employed, you influence
what kinds of job you tend to get with what you learn.
Do you prefer a job where you are just expected to do
exactly what you are told, or are you eager to take
initiatives and change your work place to something
better?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Gabriel Genellina

At Thursday 28/9/2006 05:22, Mirco Wahab wrote:


 String formatting can be used to converting an integer to its octal or
 hexadecimal form:
   a = 199
   %o % a
 '307'
   %x % a
 'c7'

 But, can string formatting be used to convert an integer to its binary
 form ?

  a = 199
  a_bin_str = pack('L', a)


Notice that the OP was looking for another thing, given the examples. 
Perhaps a better wording would have been how to convert an integer 
to its base-2 string representation.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-28, Georg Brandl [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:
 On 2006-09-27, OKB (not okblacke) [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:

 To begin with this already fails:
 
 for i in xrange(Top):
 ...   print i

 What do you expect this to do?  Loop forever?
 
 Yes that is what I would expect.

 For unterminating loops, use while 1:, and if you need the counter,
 itertools.count().

Neither of these will work if you want an easy way to choose
between repeating a specific number of times and an infinite
loop.

Of course you can include special tests in your code, but the
purpose of values like Top is to eliminate special case code
in a number of situations.

 If someone would ask me
 to implement a function like xrange it would look something
 like the following (*)
 
   def xrange(start=1, stop, step=1):
 
 while start  stop:
   yield start
   start += step
 
 Since Top is supposed to be bigger than any other value this would
 indeed loop forever. The only reason that this doesn't work with
 the builtin, is because the builtin xrange insist on its arguments
 being ints instead of allowing duck typing.

 xrange() *could* be implemented as shown above, but do you realize
 that it would be a severe performance hit compared to the current
 implementation, which doesn't give almost all users a benefit at all?

That code was just meant to illustrate behaviour, one could always
code as follows:

  def _xrange(start=1, stop, step=1):

# see implemantation above

  def xrange(start=1, stop, step=1):

if (type(start), type(stop), type(step)) == (int, int, int):
  return builtin.xrange(start, stop, step)
else:
  return _xrange(start, stop, step)
  
Just to show that with some thinking one could come up with
an implementation that was fast in most cases and yet would
allow for other types than ints if that would make sense.

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


Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-28 Thread Steve Holden
Stuart Bishop wrote:
[...]
 If you are using a modern PostgreSQL (8.1 for sure, maybe 8.0), this is
 better spelt:
 
 cur.execute(SELECT currval(pg_get_serial_sequence(%s, %s)) % (
 tableid, columnid))
 
 (Assuming of course your table name and column name don't contain odd
 characters like = or ' or ., in which case you need to properly quote them).
 
 The reason it is better is that in odd cases the sequence name will not
 always be %(tableid)s_%(columnid)s_seq, such as after you have renamed a 
 table.
 
Thank you! I've been looking for this for about six months - it helps to 
provide portability, and my current techniques relied on standard naming 
of the sequences.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: License / Registration key enabled software

2006-09-28 Thread Steve Holden
Ben Finney wrote:
 Mike Playle [EMAIL PROTECTED] writes:
 
 
License keys exist to make it easier for honest users to remain
honest.
 
 
 What doubletalk. If usage restrictions were in *any* way what end users
 wanted, they'd choose software that has it over software that does
 not.
 
 Usage restrictions serve *no* want of the end user.
 
No, but usage reporting is very important to large organisations with 
enterprise copies of their applications. They want to stay in 
compliance, and it's notoriously hard to track usage.
 
For instance a customer might want to buy a license to use your
software on up to 5 machines at once, but still have the software
installed on every machine in the company.
 
 
 This need is adequately served by not imposing usage restrictions. Any
 effective imposition of usage restrictions is hostile to the wants of
 the user.
 
 If usage restrictions are brought into the picture, it is to serve the
 wants of someone else, *not* the end user. It is disingenuous to
 suggest otherwise.
 
So you're suggesting that most people would rather be dishonest?

Otherwise you might as well say that any costs associated with using a 
piece of software (including purchase pricing) are hostile to the wants 
of the user.
 
License systems like FlexLM can work here, to make it easier for
them to ensure that they comply with the terms of the license.
 
 
 This is describing a want of the copyright holder, *not* the end user.
 
I think your view is a little biased here.
 
Forget about the people who'll crack your software. Ask yourself
whether a license key scheme offers anything to the people who won't
try to crack it. If it does, then actually implementing the scheme
becomes trivial; if it doesn't, then leave it out, because it won't
help against crackers.
 
 
 Very sound advice, I agree entirely.
 
As do I. The sad thing is that the people most concerned about 
protection of intellectual property are often the ones whose IP is least 
likely to need protection.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread sturlamolden
efrat wrote:

 1. What exactly is a Python list? If one writes a[n], then is the
 complexity Theta(n)? If this is O(1), then why was the name list
 chosen? If this is indeed Theta(n), then what alternative should be
 used? (array does not seem suited for teaching purposes.)

A Python list is an array of object references that has some empty
slots (or one empty slot?) for growing quickly to the right.

If you want to make a chained structure, then perhaps you know LISP?
This is what the basic machinery of LISP looks like in Python:

def cons(a,b)
   return [a,b]

def car(structure)
   return structure[0]

def cdr(structure)
   return structure[1]

Python lists are more powerful than you would think! You don't need
classes or OOP to create linked lists or tree structures in Python.

Remember that O(1) is not neccesarily faster than O(N)! Unless your
linked list is very big, you will get something called a 'cache miss'
inside your CPU. Thus it is usually more efficient to work with dynamic
arrays. Further, you can create hybrid array-list structures (e.g.
Java's ArrayList) that outperform lists and arrays with respect to
adding new elements. But they will have to be tuned to your particular
hardware architecture. Growing a linked list node by node is an
excercise for fools (and DSA students?) It may look good in DSA
textbooks, but it is extremely inefficient on real world computers.

Python's lists are implemented as dynamic arrays internally to be
efficient on the kind of data we normally work with. Not only do small
dynamic arrays grow faster than small lists, they also index much
faster. Why are they called lists then? Because Guido want you to
look at them conceptually as lists. That is what they are.

If you want real 'fixed size' arrays like Fortran and Matlab, then you
should add 'NumPy' to your Python (http://www.scipy.org). Your science
and engineering students will find NumPy, SciPy and Matplotlib
(http://matplotlib.sourceforge.net) valuable, so direct them to those
sources.

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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-28, Georg Brandl [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:
 On 2006-09-27, George Sakkis [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:

 What bothers me a bit about the rejection of PEP 326 is that one of the
 reasons stated is:

   http://mail.python.org/pipermail/python-dev/2004-January/042306.html

   - it is easily implemented when you really need it

 Well I thought it would simplify some things for me, so I tried an
 implementation and then found that some of the things that I would
 want to do with it wont work. So the is easily implemented bit
 seems not to be correct.

 IIRC, the PEP proposed the Smallest and Largest singletons with the
 sole purpose of being used in comparisons. No numeric behavior was
 implied, i.e. Smallest and Largest are not negative and positive
 infinity in the math sense of the word.
 
 That is true.
 
 So I guess the easily implemented refers to this case alone.
 
 This doesn't follow. Take the example were I got stuck.
 
 lst = range(10)
 lst[:Top]

 FWIW, this works with 2.5 and the __index__ slot:

  class Top(object):
 ...  def __index__(self):
 ...   return sys.maxint
 ...
  a=range(5)
  a[:Top()]
 [0, 1, 2, 3, 4]
 

It is something worth investigating, but I'm not sure it
will suite my purpose. You see I have a table module,
a table is like a list except the base index doesn't need
to be 0. So I could have a table that is indexable from
sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top]
would do what it is supposed to do in those circumstances.

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


Re: Auto color selection PIL

2006-09-28 Thread Leif K-Brooks
Gabriel Genellina wrote:
 Try this. It first chooses 0, 1/2, then 1/4, 3/4, then */8...
 It's the best I could make if you don't know the number of colors 
 beforehand. If you *do* know how many colors, your previous response is OK.

Um, that's the same thing my second suggestion does:

   h = hues()
   h.next()
  0.0
   h.next()
  0.5
   h.next()
  0.25
   h.next()
  0.75
   h.next()
  0.125

Your implementation is less terse than mine, though. And I suspect it 
runs faster, though I haven't checked that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Writing 2d array in an ascci file

2006-09-28 Thread [EMAIL PROTECTED]
Hi,

I want to write an 2d array in an ascii file using numpy. There's the -
tofile / fromfile - function but it doesn't work with nd array.

Thanks, 

CH.

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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Paul Rubin
Antoon Pardon [EMAIL PROTECTED] writes:
 It is something worth investigating, but I'm not sure it
 will suite my purpose. You see I have a table module,
 a table is like a list except the base index doesn't need
 to be 0. So I could have a table that is indexable from
 sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top]
 would do what it is supposed to do in those circumstances.

Top = object()

class Table(list):
   def __getitem__(self, n):
   get = super(Table, self).__getitem__
   if n is Top:
  return get(-1)
   return get(n - self.baseindex)

a=Table(range(9))
a.baseindex = 3

 print a[5], a[Top]
2 8

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
Some of your Lisp translations are subtly off...


 Date: 28 Sep 2006 02:49:50 -0700
 From: sturlamolden [EMAIL PROTECTED]
 Subject: Re: Questions on Using Python to Teach Data Structures and
   Algorithms
 To: python-list@python.org

 If you want to make a chained structure, then perhaps you know LISP?
 This is what the basic machinery of LISP looks like in Python:

 def cons(a,b)
return [a,b]

should be:
 return [a].extend(b)

 def car(structure)
return structure[0]

 def cdr(structure)
return structure[1]

should be:
 return structure[1:]

B.

--
Brendon Towle, Ph.D.   [EMAIL PROTECTED]  +1-412-362-1530
“Debugging is twice as hard as writing the code in the first place.  
Therefore,
if you write the code as cleverly as possible, you are, by  
definition, not
smart enough to debug it.” – Brian W. Kernighan


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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Paul Rubin
Paul Rubin http://[EMAIL PROTECTED] writes:
  sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top]
  would do what it is supposed to do in those circumstances.

 Top = object()
 class Table(list):
...

Oh wait, I missed the : in your tbl[:Top] example.  Yeah, you could
hair up Table to account for slices, I'll leave the exercise to you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread Mirco Wahab
Thus spoke Gabriel Genellina (on 2006-09-28 11:05):

 At Thursday 28/9/2006 05:22, Mirco Wahab wrote:
  But, can string formatting be used to convert an integer to its binary
  form ?

   a = 199
   a_bin_str = pack('L', a)

 
 Notice that the OP was looking for another thing, given the examples. 
 Perhaps a better wording would have been how to convert an integer 
 to its base-2 string representation.

Yes, you are right. The OP looks for a
'binary (bit) representation ...
I admit I didn't find out how to format
a value into a bit string in Python.

In Perl, this would be a no-brainer:

  $var = 199;
  $str = sprintf %0*b, 32, $var;

and str would contain 11000111
on a intel machine.

But where is the %b in Python?

Regards  Thanks

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


Re: Writing 2d array in an ascci file

2006-09-28 Thread Jeremy Sanders
[EMAIL PROTECTED] wrote:

 I want to write an 2d array in an ascii file using numpy. There's the -
 tofile / fromfile - function but it doesn't work with nd array.

Is this good enough?

x = numpy.zeros( (10, 10) )
f = open('out.txt', 'w')
print f, str(x).replace('[',' ').replace(']', ' ')
f.close()


Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Computer Language Popularity Trend

2006-09-28 Thread Steve Holden
Xah Lee wrote:
 Computer Language Popularity Trend
 
 This page gives a visual report of computer languages's popularity, as
 indicated by their traffic level in newsgroups. This is not a
 comprehensive or fair survey, but does give some indications of
 popularity trends.
 
 http://xahlee.org/lang_traf/index.html
 
   Xah
   [EMAIL PROTECTED]
 ∑ http://xahlee.org/
 
And not a single deletable expletive in sight. Good stuff!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote:
 Some of your Lisp translations are subtly off...

Seems correct to me. Lisp lists are linked lists, not arrays.

 
 Date: 28 Sep 2006 02:49:50 -0700
 From: sturlamolden [EMAIL PROTECTED]
 Subject: Re: Questions on Using Python to Teach Data Structures and
 Algorithms
 To: python-list@python.org

 If you want to make a chained structure, then perhaps you know LISP?
 This is what the basic machinery of LISP looks like in Python:

 def cons(a,b)
return [a,b]
 
 should be:
 return [a].extend(b)

A Lisp cons is made of a reference to it's content and a reference to
the rest of the list, so cons = lambda a, b : [a, b] seems the most
straightforward translation.

 def car(structure)
return structure[0]

 def cdr(structure)
return structure[1]
 
 should be:
 return structure[1:]

idem.

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Python and Win95B

2006-09-28 Thread Ciar�n � Duibh
I've just installed Python 2.5 under Win95B, and when run it says The
PYTHON25.DLL file is linked to missing export
KERNEL32.DLL.GetFileAttributesExA.

Does Python 2.5 not run under Win95?  If not, is there an earlier version of
Python which does?

Thanks,
Ciarán Ó Duibhín.



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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bryan Olson
efrat wrote:
   I'm planning to use Python in order to teach a DSA (data structures 
 and algorithms) course in an academic institute. If you could help out 
 with the following questions, I'd sure appreciate it:
 1. What exactly is a Python list?

It's almost exactly what the doc says (and exactly what the code
implements).

 If one writes a[n], then is the complexity Theta(n)?

No; as others have pointed out, it's O(1).

 If this is O(1), then why was the name list chosen?

Because it *is* a list: an ordered collection in which an
element might appear multiple times. It's also an extensible
array, but that's so more verbose.

 If this is indeed Theta(n), then what alternative should be 
 used? (array does not seem suited for teaching purposes.)

It's not Theta(n), and the array classes are fine for teaching.

 2. Suppose I have some file example.py, and I'd like to incorporate it 
 **into** part of an HTML page with nice syntax highlighting and all the 
 shebang. Is there an easy way to do so?

Yes. In fact its probably easier, or at least no harder, than
making sense of what you mean there.

 (Sorry, but any Google query involving Python and HTML (with any 
 other additional terms) led to Python HTML processing libraries.)

Don't be sorry about about getting the info you need (whether
or not you realize it is the info you need).

 3. Are there any useful links for Python/DSA education?

Yes, many. Python is fine for teaching data structures and algorithms.
Python's loosely-defined duck typing makes it pedagogically
inappropriate for some topics, but as far as you have described your
course, Python should work well.

 I found Data 
 Structures and Algorithms with Object Oriented Design Patterns 
 (http://www.brpreiss.com/books/opus7/html/book.html). It is a fine book, 
 but it is unsuitable: my students are electrical-engineers, and barely 
 know how to program; teaching them DSA, python, **and** stuff like the 
 visitor pattern seems impossible.

When I taught algorithms, I observed that my students arrived lacking
much of the background knowledge I would expect, but they more than
compensated by being so bright. The engineers did about as well as
comp-sci students. We all got blown away by a couple scary-smart math
majors.

You don't need to teach, or know, the visitor pattern. Deal with the
the fundamentals. There are two ways we describe specific computational
problems: output as a function of input, and abstract data type. Python
is great for both.


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


Re: does anybody earn a living programming in python?

2006-09-28 Thread rzed
Hendrik van Rooyen [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

[...]
 Oh dont be so pedantic - countless - without count - probably
 just means that nobody has bothered to count them...

Without being particularly pedantic: no, it doesn't. It means too 
many to count. Though I would have taken Anthony's usage (there's 
countless other people I know...) less than literally.

-- 
rzed

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


Re: Starting Win32 Service

2006-09-28 Thread Roger Upole

Tim Golden wrote:
...
 Yes, sorry about that, it's a well-known (to me) gotcha.
 Basically there's no way I can extract the params from
 the COM interface in a way which implies order, so I
 can't take them in positionally. (Corrections to this
 statement will be gratefully received).

 TJG

InParameters.Properties_ can be accessed by name or index,
so you should be able to map both *args and **kwargs.
(although you'd have to check for overlap yourself)

  Roger




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


RE: Starting Win32 Service

2006-09-28 Thread Tim Golden
| Tim Golden wrote:
| ...
|  Yes, sorry about that, it's a well-known (to me) gotcha.
|  Basically there's no way I can extract the params from
|  the COM interface in a way which implies order, so I
|  can't take them in positionally. (Corrections to this
|  statement will be gratefully received).
| 
|  TJG
| 
| InParameters.Properties_ can be accessed by name or index,
| so you should be able to map both *args and **kwargs.
| (although you'd have to check for overlap yourself)
| 
|   Roger

Thanks a lot, Roger. I thought I'd looked around this
one before, but obviously not hard enough! I'll have
another look.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Writing python extensions for libburn libisofs

2006-09-28 Thread mario . danic
Hello,

If there is anyone familiar with python C api, and would like to get
involved with writing python extensions for above two libs
(http://libburn.pykix.org) please contact me.

Kind regards,
Mario

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


Continuing after error

2006-09-28 Thread Sheldon
Hi,

Does anyone know if it is possible to resume the execution of a program
after it stops at an error in the code and the error was corrected?

Sincerely,
Sheldon

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


Re: Continuing after error

2006-09-28 Thread Georg Brandl
Sheldon wrote:
 Hi,
 
 Does anyone know if it is possible to resume the execution of a program
 after it stops at an error in the code and the error was corrected?

try:
 do something
except SomeException:
 correct the error

do something else

i.e. you handle the error in the except clause. If that's successful, your
program will continue normally.

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


Re: License / Registration key enabled software

2006-09-28 Thread Mike Playle
On Thu, 28 Sep 2006 10:19:37 +1000, Ben Finney wrote:
 For instance a customer might want to buy a license to use your
 software on up to 5 machines at once, but still have the software
 installed on every machine in the company.
 
 This need is adequately served by not imposing usage restrictions. Any
 effective imposition of usage restrictions is hostile to the wants of
 the user.

Who is the user? The person who uses the software isn't always
the same as the person who paid for it, or the person who'll be
in trouble if the license terms aren't adhered to.

Imagine you're an IT manager for a medium-to-large company who
wants to use some expensive piece of software. You talk to the
vendor and buy a licence to use the software on up to 5 machines
at once, but you don't know who in the company will want to use
it, so for convenience you want to install it on every PC in the
building.

Having installed it all over the shop, how can you be sure that
only 5 people are using it at any one time? Do you expect your
users to walk round the building asking everyone else if they're
using the software, or are they more likely to just start it up
and start working?

Of course this argument really applies only to large, expensive
commercial packages. I'd certainly agree that licence keys are
often used inappropriately in a way which doesn't really benefit
anyone, but this doesn't mean they don't have a place somewhere
in the grand scheme of things.

Mike

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


Resuming a program's execution after correcting error

2006-09-28 Thread Sheldon
Hi.

Does anyone know if one can resume a python script at the error point
after the error is corrected?
I have a large program that take forever if I have to restart from
scratch everytime. The error was the data writing a file so it seemed
such a waste if all the data was lost and must be recalculated again.

Sincerely,
Sheldon

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


Re: License / Registration key enabled software

2006-09-28 Thread Mike Playle
On Wed, 27 Sep 2006 12:21:08 -0500, Robert Kern wrote:

 Mike Playle wrote:
 For instance a customer might want to buy a license to
 use your software on up to 5 machines at once, but still
 have the software installed on every machine in the
 company. License systems like FlexLM can work here, to
 make it easier for them to ensure that they comply with
 the terms of the license.
 
 But then you must weigh that against the inconvenience that you impose upon 
 your 
 customers. Although you may make it easier for them to comply with your 
 license, 
 you are also making it harder for them to *use* your software.

This is certainly true.

As with any other software feature it's vital to weigh up the
advantages against the disadvantages, and not blindly add
features which don't provide a clear overall benefit.

 I do not know a single person who has used FlexLM-licensed software and does 
 not 
 hate FlexLM with a burning passion.

Yup, I can agree with that. From the POV of the guy who just
wants to get some work done, it's usually a real pain.

His boss may have a different view of the matter, though.
I've met people who've _bought_ FlexLM-licensed software
who think it's the best thing since sliced bread.

Mike

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


Re: a query on sorting

2006-09-28 Thread Steve Holden
Paul Rubin wrote:
 Gabriel Genellina [EMAIL PROTECTED] writes:
 
   sorted((x[1], x[0]) for x in enumerate(a))
[(1, 7), (2, 4), (2, 8), (3, 2), (4, 1), (5, 3), (6, 5), (7, 6), (9, 0)]

Why forcing to use enumerate if it doesn't fit? And a generator won't
help here since you have to access all the items.

sorted([(a[i],i) for i in range(len(a))])
 
 
 I think 
 
sorted((x,i) for i,x in enumerate(a))
 
 looks nicer than the above. 

Indeed it does: an excellent refinement of my rather crappily-expressed 
original idea.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote:

 From: Bruno Desthuilliers [EMAIL PROTECTED]
 Subject: Re: Questions on Using Python to Teach Data Structures and
   Algorithms
 To: python-list@python.org

 Brendon Towle wrote:
 Some of your Lisp translations are subtly off...

 Seems correct to me. Lisp lists are linked lists, not arrays.


 Date: 28 Sep 2006 02:49:50 -0700
 From: sturlamolden [EMAIL PROTECTED]
 Subject: Re: Questions on Using Python to Teach Data Structures and
 Algorithms
 To: python-list@python.org

 If you want to make a chained structure, then perhaps you know LISP?
 This is what the basic machinery of LISP looks like in Python:

 def cons(a,b)
return [a,b]

 should be:
 return [a].extend(b)

 A Lisp cons is made of a reference to it's content and a reference to
 the rest of the list, so cons = lambda a, b : [a, b] seems the most
 straightforward translation.

Yes, a lisp cons is a pair of references as you describe. However,  
the following lisp call:

? (cons item list)

returns a single level list, with item as its new first item, and  
the original contents of list as the remainder of the list. The  
OP's code doesn't do that; it returns a list of two items, with  
list as the second item.

To put it another way, the following code is always true in Lisp:

? (= (length (cons item list)) (1+ (length list)))

But the OP's code only allows that to be true when list is of  
length 1.


I suppose, of course, that you could claim that the following Lisp list:

   (1 2 3 4)

should translate into the following Python list:

   [1, [2, [3, [4

But, I think that's a bit silly.


 def car(structure)
return structure[0]

 def cdr(structure)
return structure[1]

 should be:
 return structure[1:]

 idem.

I should have pointed out, of course, that the original definition of  
CDR was correct given the original (incorrect) definition of cons.

B.

-- 
Brendon Towle, PhD
Cognitive Scientist
+1-412-690-2442x127
Carnegie Learning, Inc.
The Cognitive Tutor Company ®
Helping over 375,000 students in 1000 school districts succeed in math.


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


Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Antoon Pardon
On 2006-09-28, Paul Rubin http wrote:
 Paul Rubin http://[EMAIL PROTECTED] writes:
  sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top]
  would do what it is supposed to do in those circumstances.

 Top = object()
 class Table(list):
 ...

 Oh wait, I missed the : in your tbl[:Top] example.  Yeah, you could
 hair up Table to account for slices, I'll leave the exercise to you.

Yes, I could hair up Table, but that is missing the point somewhat.
The idea for provinding extreme values is that you don't have to
hair up the code.

In any case it seems I have my answer. I have some suggestions I can
try out, but writing up once own module for extreme values isn't as
easy as is suggested in the rejection of the PEP and there is probably
very little chance to get the PEP reopened.

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


Re: Extra Newby question - Trying to create md5 File Listing

2006-09-28 Thread Jim
Gabriel and Dennis, than you for all your help.  I ended up talking to
a friend a work about it and here's what we cam up with.  It's very
similar to your suggestions so again, thanks.  I just need to add a
machine name so I can get a md5 log from multiple machines and put it
in a database for version control monitoring.

Blessings, Jim.

#!/usr/bin/python
# Filename: md5makr.py

import sys
import os, os.path
import glob
import md5
import ConfigParser

config = ConfigParser.ConfigParser()
config.read('md5makr.ini')

outputfilname = config.get('general', 'outputfile')
f = file(outputfilname,'wt')
fileconfig = config.get('general', 'inputfiles')
# print 'fileconfig is ', fileconfig

fl = file(fileconfig,'r')
pathlist = [fli.strip() for fli in fl.readlines()]
# print 'fileData is ', fileData  # so far so good

for p in pathlist:
  filelist = glob.glob(p)
  for fn in filelist:
data = file(fn,'rb').read()
hexstring = md5.md5(data).hexdigest()
f.write(fn + '\t' + hexstring + '\n')

f.close()

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


Re: Resuming a program's execution after correcting error

2006-09-28 Thread Georg Brandl
Sheldon wrote:
 Hi.
 
 Does anyone know if one can resume a python script at the error point
 after the error is corrected?
 I have a large program that take forever if I have to restart from
 scratch everytime. The error was the data writing a file so it seemed
 such a waste if all the data was lost and must be recalculated again.

As I said before, this can be done by finding out where the error is raised,
what the cause is and by inserting an appropriate try-except-statement in
the code.

There's no way to do that without modifying the code, if the program itself
doesn't offer such an option.

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


Re: XSLT speed comparisons

2006-09-28 Thread Larry Bates
Damian wrote:
 Hi, I'm from an ASP.NET background an am considering making the switch
 to Python. I decided to develop my next project in tandem to test the
 waters and everything is working well, loving the language, etc.
 
 What I've got is:
 two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for
 XML/XSLT)
 both on the same box (Windows Server 2003)
 both using the same XML, XSLT, CSS
 
 The problem is, the Python version is (at a guess) about three times
 slower than the ASP one. I'm very new to the language and it's likely
 that I'm doing something wrong here:
 
 from os import environ
 from Ft.Lib.Uri import OsPathToUri
 from Ft.Xml import InputSource
 from Ft.Xml.Xslt import Processor
 
 def buildPage():
 try:
 xsluri = OsPathToUri('xsl/plainpage.xsl')
 xmluri = OsPathToUri('website.xml')
 
 xsl = InputSource.DefaultFactory.fromUri(xsluri)
 xml = InputSource.DefaultFactory.fromUri(xmluri)
 
 proc = Processor.Processor()
 proc.appendStylesheet(xsl)
 
 params = {url:environ['QUERY_STRING'].split(=)[1]}
 for i, v in enumerate(environ['QUERY_STRING'].split(/)[1:]):
 params[selected_section%s % (i + 1)] = / + v
 
 return proc.run(xml, topLevelParams=params)
 except:
 return Error blah blah
 
 print Content-Type: text/html\n\n
 print buildPage()
 
 You can compare the development sites here:
 asp: http://consultum.pointy.co.nz/about/team
 python: http://python.pointy.co.nz/about/team
 
 Cheers!
 
For max speed you might want to try pyrxp:

http://www.reportlab.org/pyrxp.html

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


Re: windev vs python SOS

2006-09-28 Thread Steve Holden
stéphane bard wrote:
 hello, my boss ask me to prefer windev to python.
 I have to argue
 
   - python work on multiple platform (linux, mac, windows)
   A good point but it didn't interest him. Because
   we want to choose a language for prototyping.
   So multi platform is not enough.
 
   - python and windev are fast to develop
 
   - windev as a good IDE, python? boa-constructor is ok with wxpython
 
   - python is open source (that's not an argument for my boss, sorry 
 it's  a boss ...)
 
 any idea for a strong argument ?
 
You might argue that Python allows much better integration with other 
Windows functionality: see Robinson  Hammond's Python Programming on 
Win32, and mention IronPython.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: OT: productivity and long computing delays

2006-09-28 Thread Steve Holden
Paul Rubin wrote:
 [EMAIL PROTECTED] writes:
 
Paul Anyway, I did the same build on a 2 ghz Athlon 64 and was
Paul surprised that the speedup was only 35% or so.  I'd have to get a
Paul multiprocessor box to obtain really substantial gains.

Maybe your build process is i/o bound.  If you're using GNU make and have
the make dependencies set up properly, the -jN flag (for N = 2 or 3) may
speed things up.
 
 
 It's almost all CPU-bound on both the Pentium M and the Athlon.  But I
 wasn't as much asking for technical approaches to speeding up
 calculation, as for general strategy about dealing with this downtime
 productively (I figured it was ok to ask this, given the other thread
 about RSI).  My workday is getting chopped up in a manner sort of like
 memory fragmentation in a program, where you end up with a lot of
 disjoint free regions that are individually too small to use.
 
 As for the technical part, the underlying problem has to do with the
 build system.  I should be able to edit a source file, type make and
 recompile just that file and maybe a few related ones.  But the
 results of doing that are often incorrect, and to make sure the right
 thing happens I have to rebuild.  I'm not in a position right now to
 start a side project to figure out what's wrong with the build system
 and fix it.

Well why not study it while the build system is running? Needn't be a 
full-blown project, but it sounds like you might save yourself a lot of 
pain for relatively little effort.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: sqlite3 error

2006-09-28 Thread John Salerno
John Machin wrote:
 John Salerno wrote:
 CREATE TABLE Researchers (
  researcherID varchar(9) PRIMARY KEY NOT NULL,
  birthYear int(4) DEFAULT NULL,
  birthMonth int(2) DEFAULT NULL,
  birthDay int(2) DEFAULT NULL,
  birthCountry varchar(50) DEFAULT NULL,
  birthState char(2) DEFAULT NULL,
  birthCity varchar(50) DEFAULT NULL,
  nameFirst varchar(50) NOT NULL,
  nameLast varchar(50) NOT NULL,
  nameGiven varchar(255) DEFAULT NULL,
 
 A bit OT, but one answer to the can you make a living with just
 Python question is Yup, tool of choice for rummaging in and fixing
 data that's been mangled by users cramming it into dodgy data models
 :-)
 
 (1) Consider that some countries have states/provinces with 3-letter
 abbreviations (e.g. Australia) or no abbreviation than I'm aware of in
 a Latin alphabet (e.g. China).

Good point. I guess since this program is for my own use, I just figured 
I could stick with the American style abbreviation. But it's not as if I 
actually considered that this wouldn't always work, so it's good to be 
aware of the issue.

 (2) It's not apparent how you would use the first, last, and given
 names columns, especially with two of them being not null. Consider
 how you would store e.g.:
 J Edgar Hoover
 DJ Delorie
 Sukarno
 35
 Maggie Cheung Man-Yuk
 Molnar Janos
 Fatimah binte Rahman
 Zhang Manyu

Not sure I follow you on some of these examples. In the case of J Edgar 
Hoover, I would just put the full name for his first name, or if J is 
entered, then just that, I suppose. Given name will be first name + 
middle name(s). (I took most of this schema from a baseball database, so 
maybe it's just something that worked better there.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 error

2006-09-28 Thread John Salerno
Dennis Lee Bieber wrote:
 On Wed, 27 Sep 2006 18:41:54 GMT, John Salerno
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 You're right! I think that must have been leftover from when it wasn't 
 the last line in the query. Thanks!
 
   You also, based upon the cutpaste, have a stray
 
 ) 
 
 (or something similar in the last line)

I don't see this. The code works now, though. Maybe it was something 
carried over by pasting.
-- 
http://mail.python.org/mailman/listinfo/python-list


startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread metaperl
I just finished answering a question in #python because someone tried
to match using ... well.. match()
but did not realize that match() is actually startswith() for regexps.

I suggest:
re.compile('blah').atstartof(string)
re.compile('blah').atendof(string)

But it will never happen.

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


remove the last character or the newline character?

2006-09-28 Thread Daniel Mark
Hello all:

I have the following snippet:

In [1]: fileName = 'Perfect Setup.txt\n'
In [2]: fileName = fileName[0:len(fileName)-1)]   # remove the '\n'
character
In [3]: fileName
Out[3]: 'Perfect Setup.txt'

Question one:
Does python provide any function that can remove the last character of
a string?
I don't know whether or not the method I used is efficient

Question two:
Does python provide any function that can remove the newline character
from a string if it exists?



Thank very much!
-Daniel

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 efrat:
[...]
 
then why was the name list chosen?
 
 
 I'd too love to know why the wrong list name was chosen for them,
 instead of array. (Maybe because list is shorter, or because ABC
 called them lists...)
 
I suspect it's because of their intrinsic one-dimensional nature.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: remove the last character or the newline character?

2006-09-28 Thread John Salerno
Daniel Mark wrote:

 Question one:
 Does python provide any function that can remove the last character of
 a string?
 I don't know whether or not the method I used is efficient

Doing fileName[-1] lets you access the last character, but I'm not sure 
about removing it since strings are immutable. It would still probably 
be something like you did.

 Question two:
 Does python provide any function that can remove the newline character
 from a string if it exists?

  fileName = 'Perfect Setup.txt\n'
  fileName.strip()
'Perfect Setup.txt'
 

Or you can use lstrip() or rstrip() to remove just the left or right side.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remove the last character or the newline character?

2006-09-28 Thread Georg Brandl
Daniel Mark wrote:
 Hello all:
 
 I have the following snippet:
 
 In [1]: fileName = 'Perfect Setup.txt\n'
 In [2]: fileName = fileName[0:len(fileName)-1)]   # remove the '\n'
 character
 In [3]: fileName
 Out[3]: 'Perfect Setup.txt'
 
 Question one:
 Does python provide any function that can remove the last character of
 a string?
 I don't know whether or not the method I used is efficient

fileName = fileName[:-1]

 Question two:
 Does python provide any function that can remove the newline character
 from a string if it exists?

fileName = fileName.rstrip(\n)

though this will remove more than one newline if present. If you only want
to remove one newline, use

if fileName[-1:] == '\n':
 fileName = fileName[:-1]

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


Re: remove the last character or the newline character?

2006-09-28 Thread Tim Chase
 In [1]: fileName = 'Perfect Setup.txt\n'
 In [2]: fileName = fileName[0:len(fileName)-1)]   # remove the '\n'
 character
 In [3]: fileName
 Out[3]: 'Perfect Setup.txt'
 
 Question one:
 Does python provide any function that can remove the last character of
 a string?
 I don't know whether or not the method I used is efficient

You're close...

fileName = fileName[0:-1]

which is the same as

fileName = fileName[:-1]

which will lop off the last character.  Much nicer than most 
other languages I've used where you have to use the len() trick 
you're using.  Also, it's a common python idiom you'll see 
frequently.

 Question two:
 Does python provide any function that can remove the newline character
 from a string if it exists?

In a discussion on this very matter a while back, I think the 
final verdict was something like

fileName = fileName.rstrip('\n')

which will strip off *all* the trailing newlines.  In most cases 
(such as for line in file('foo.txt'): code), there's only one 
to be stripped, so this works fine.

If you're ornary and want *only* the last '\n' lopped off, you'd 
have to test for it:

if fileName[-1] == '\n': fileName = fileName[:-1]

There were caveats regarding \n vs. \r\n line endings, but if 
the file comes in in ascii mode (rather than binary mode), Python 
more or less smart enough to do the translation for you, leaving 
the above code to work in the majority of cases.

-tkc




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


Re: remove the last character or the newline character?

2006-09-28 Thread Bruno Desthuilliers
Daniel Mark wrote:
 Hello all:
 
 I have the following snippet:
 
 In [1]: fileName = 'Perfect Setup.txt\n'
 In [2]: fileName = fileName[0:len(fileName)-1)]   # remove the '\n'

  fileName = fileName.rstrip('\n')
or just a plain:
  fileName = fileName.strip()

 character
 In [3]: fileName
 Out[3]: 'Perfect Setup.txt'
 
 Question one:
 Does python provide any function that can remove the last character of
 a string?

Not directly, since Python strings are immutable objects. If you want a
copy of the string without the last char *whatever it is*, you can just use
  somestr = somestr[0:-1]

But in your situation, it's usually safer to use [lr]?strip()

 
 Question two:
 Does python provide any function that can remove the newline character
 from a string if it exists?

Here again, you cannot *remove* anything from a string - you can just
have a modified copy copy of the string. (NB : answer is just above :
use str.strip())

HTH

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


best way to get data into a new instance?

2006-09-28 Thread John Salerno
Let's pretend I'm creating an Employee class, which I will later 
subclass for more specific jobs. Each instance will have stuff like a 
name, title, degrees held, etc. etc.

So I'm wondering, is the best way to get all this information into the 
object to just have a really long __init__ method that takes each argument?

Does a question like this depend on how the class will be used? I'm 
trying to construct it in a way that is independent of, say, the GUI 
interface that will be used, but I can't help but think that if all the 
data is entered into a GUI, then passed programmatically to the class, 
then it's no big deal because it happens behind the scenes. But if, for 
instance, someone manually created a new instance, they would have a ton 
of arguments to type in each time. Granted, even with the GUI they are 
basically typing in arguments, but in the manual case you'd have to type 
in the call to the class, the parentheses, commas, quotes around the 
strings, etc. (But still, I'm trying not to let a specific interface 
influence the construction of what should probably be a completely 
independent class implementation.)

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


Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread Bruno Desthuilliers
metaperl wrote:
 I just finished answering a question in #python because someone tried
 to match using ... well.. match()
 but did not realize that match() is actually startswith() for regexps.

Yet someone else that failed to read the Fine Manual(tm).

 I suggest:
 re.compile('blah').atstartof(string)
 re.compile('blah').atendof(string)

What's wrong with:
re.search(r'^blah', somestring)
re.search(r'blah$', somestring)


-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remove the last character or the newline character?

2006-09-28 Thread Duncan Booth
Daniel Mark [EMAIL PROTECTED] wrote:


 In [2]: fileName = fileName[0:len(fileName)-1)]   # remove the '\n'

To chop the last character regardless of what it is:

  fileName = fileName[:-1]

You don't need the 0 since thats the default, and you can use a negative 
index instead of subtracting from len(x). 

 Question two:
 Does python provide any function that can remove the newline character
 from a string if it exists?
 

To remove all trailing whitespace:

fileName = fileName.rstrip()

to just remove a newline:

fileName = fileName.rstrip('\n')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remove the last character or the newline character?

2006-09-28 Thread Tim Chase
 Does python provide any function that can remove the newline character
 from a string if it exists?
 
   fileName = 'Perfect Setup.txt\n'
   fileName.strip()
 'Perfect Setup.txt'
  
 
 Or you can use lstrip() or rstrip() to remove just the left or right side.

Just a caveat with the non-qualified strip/rstrip/lstrip...it 
will remove *all* whitespace, so if, for some reason, it's 
significant, and you only want to remove newlines, you have to 
specify it:

  s = ' some text \t\n'
  s.strip()
'some text'
  s.rstrip()
' some text'
  s.rstrip('\n')
' some text \t'

As the OP was talking about file-names, the use of 
initial/terminal spaces is allowable (albeit imprudent), 
depending on your platform, so one may or may not want to strip 
them off.

Fortunately, as in many other areas, Python offers the 
flexibility in an easy-to-use way, and comes with sensible defaults.

-tkc




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


Re: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread John Salerno
Bruno Desthuilliers wrote:
 metaperl wrote:
 I just finished answering a question in #python because someone tried
 to match using ... well.. match()
 but did not realize that match() is actually startswith() for regexps.
 
 Yet someone else that failed to read the Fine Manual(tm).
 
 I suggest:
 re.compile('blah').atstartof(string)
 re.compile('blah').atendof(string)
 
 What's wrong with:
 re.search(r'^blah', somestring)
 re.search(r'blah$', somestring)

I think, since he even said himself that match() is actually 
startswith() for regexps, that he isn't complaining about the lack of 
this feature, just that he wants a name change. Otherwise I'm not sure 
what he wants.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XSLT speed comparisons

2006-09-28 Thread Istvan Albert
Microsoft has put a lot of effort into their XML libraries as they are
(or will be) the foundation of most of their software suites. I think
you'll be hard pressed to find a library that exceeds it in both
breadth of functionality and performance. 

Istvan

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


Re: XSLT speed comparisons

2006-09-28 Thread Jan Dries
Larry Bates wrote:
 Damian wrote:
[...]
  What I've got is:
  two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for
  XML/XSLT)
  both on the same box (Windows Server 2003)
  both using the same XML, XSLT, CSS
 
  The problem is, the Python version is (at a guess) about three times
  slower than the ASP one. I'm very new to the language and it's likely
  that I'm doing something wrong here:
[...]
 
 For max speed you might want to try pyrxp:
 
 http://www.reportlab.org/pyrxp.html
 

Except that pyrxp, to the best of my knowledge, is an XML parser and 
doesn't support XSLT, which is a requirement for Damian.

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


Re: best way to get data into a new instance?

2006-09-28 Thread Diez B. Roggisch
John Salerno schrieb:
 Let's pretend I'm creating an Employee class, which I will later 
 subclass for more specific jobs. Each instance will have stuff like a 
 name, title, degrees held, etc. etc.
 
 So I'm wondering, is the best way to get all this information into the 
 object to just have a really long __init__ method that takes each argument?
 
 Does a question like this depend on how the class will be used? I'm 
 trying to construct it in a way that is independent of, say, the GUI 
 interface that will be used, but I can't help but think that if all the 
 data is entered into a GUI, then passed programmatically to the class, 
 then it's no big deal because it happens behind the scenes. But if, for 
 instance, someone manually created a new instance, they would have a ton 
 of arguments to type in each time. Granted, even with the GUI they are 
 basically typing in arguments, but in the manual case you'd have to type 
 in the call to the class, the parentheses, commas, quotes around the 
 strings, etc. (But still, I'm trying not to let a specific interface 
 influence the construction of what should probably be a completely 
 independent class implementation.)

Who is typing?

The programmer is responsible for the construction of new instances (or 
at least the code which will do that), and a constructor should contain 
parameters for at least the values you absolutely expect to be there - 
for example name and age or something like that in your example.

You can of course always add attributes later.

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


Re: Python and Win95B

2006-09-28 Thread Fredrik Lundh
Ciarán Ó Duibhín wrote:

 I've just installed Python 2.5 under Win95B, and when run it says The
 PYTHON25.DLL file is linked to missing export
 KERNEL32.DLL.GetFileAttributesExA.
 
 Does Python 2.5 not run under Win95?  If not, is there an earlier version of
 Python which does?

Windows 95 was end-of-lifed by Microsoft five years ago:

 http://www.microsoft.com/windows/lifecycle/default.mspx

I'm not sure that the last version that was officially tested with 
Windows 95 was, but Python 2.3 might work.

/F

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


Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread bearophileHUGS
Mirco Wahab:
 But where is the %b in Python?

Python doesn't have that. You can convert the number to a hex, and then
map the hex digitds to binary strings using a dictionary, like this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528

Bye,
bearophile

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


Re: How to update my web automatically by python?

2006-09-28 Thread tobiah
If you are in a dynamic web environment, then
please post the components of that environment.
If you only want to update your static web pages,
look at ftplib, or scripting scp commands.

[EMAIL PROTECTED] wrote:
 How to update my web automatically by python?
 
 I have one twiki web page
 https://twiki.cern.ch/twiki/bin/view/Atlas/CSC11DQ2ReplicateToCERNCAF
 In this page,the dates often need to be updated.Every time after I
 produce the dates ,I plaster the date to the web manual.The dates is
 produced by a python program.I want to write a python program to update
 my web automatically.I hope someone could help me.Tkanks!!
 

-- 
Posted via a free Usenet account from http://www.teranews.com

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


Re: Finding the file referred to in a Python traceback

2006-09-28 Thread Sion Arrowsmith
 [EMAIL PROTECTED] wrote:
In this traceback, the path to 3 different SQL Alchemy source files is
a relative directory. However, no such directory is below my current
working directory.

Traceback (most recent call last):
  File stdin, line 1, in ?
  File conf/__init__.py, line 34, in __init__
self.table = tables(self.metadata)
  File conf/__init__.py, line 38, in __init__
self.users = Table('Users', metadata, autoload=True)
  File build/bdist.darwin-8.7.1-i386/egg/sqlalchemy/schema.py, line
138, in __call__
[etc]
 print sys.path
['', '/sw/lib/python2.4/site-packages/Dabo-0.6.5s-py2.4.egg',
'/sw/lib/python2.4/site-packages/SQLAlchemy-0.2.8dev_r1898-py2.4.egg',
[etc]

Paths of files contained in eggs aren't always helpful (as was pointed
out to me recently). If you unzip the SQLAlchemy egg (eggs are just
zip files) (to somewhere other than site-packages if you want to avoid
confusion) you'll probably find schema.py etc. in there.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: best way to get data into a new instance?

2006-09-28 Thread tobiah

 So I'm wondering, is the best way to get all this information into the 
 object to just have a really long __init__ method that takes each argument?

As was pointed out, you might ask that absolutely essential information
be passed to the constructor such as employee id#, but other then
that, I think that it is more usual to do:

class Employee:

__init__(self, id):
self.id = id

e = Employee(32445)

... later


e.firstname = 'foo'
e.lastname = 'bar'

... more as the information comes about.

-- 
Posted via a free Usenet account from http://www.teranews.com

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


Re: Battlefield Weapon Popularity Trend

2006-09-28 Thread Chris Mattern
In article [EMAIL PROTECTED], Mirco Wahab wrote:
Thus spoke Chris Mattern (on 2006-09-27 19:09):
 In article [EMAIL PROTECTED], Mirco Wahab wrote:

When the Samurai of medieval Japan were confronted
with new 'battlefield language', e.g. early Shotguns,
 
 early Shotguns :D.  Your mastery of the history of
 firearms overwhelms me.

You want a fight? With a muzzle-loaded gun?
Three shots for everybody -- 5 minutes time?

BTW: (http://en.wikipedia.org/wiki/Musket)
The date of the origin of muskets remains
unknown, but they are mentioned as early as
the late 15th century, and they were primarily
designed for use by infantry. Muskets became
obsolete by the middle of the 19th century,
as rifles superseded them.


Muskets are not shotguns.

-- 
 Christopher Mattern

Which one you figure tracked us?
The ugly one, sir.
...Could you be more specific?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Ramon Diaz-Uriarte
Going back to the original question, a related question: does anybody
know why there are so few books on data structures and algorithms that
use Python?

I remember that, at least ~ 12 years ago there were many (and very
good) books that used Pascal for this topic. So when I did my own
search for one in Python (just for my own consumption and
enlightnment) and could only find the same one as the original poster
of this thread [1], I was very surprised. No publishers have felt the
need to fill this gap?



Best,

R.

[1] http://thread.gmane.org/gmane.comp.python.general/486698/focus=486698
 Data Structures and Algorithms with Object Oriented Design Patterns
(http://www.brpreiss.com/books/opus7/html/book.html) and was surprised.



-- 
Ramon Diaz-Uriarte
Bioinformatics Unit
Spanish National Cancer Centre (CNIO)
http://ligarto.org/rdiaz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Whither binary search?

2006-09-28 Thread Sion Arrowsmith
John Machin [EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
 well, people tend to use dictionaries when they need to look things up
 quickly...
... like those paper dictionaries with the words in alphabetical order
:-)

... where you'll notice that the really big ones are divided up into
buckets (which just happen to be keyed on initial letter).

Truth is that humans are lot better than computers at general
insertion sort, and its lookup equivalent, whereas computers are much
better at calculating hashes. So we each use a dictionary
implementation that plays to our strengths.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote:
 On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote:
 
 From: Bruno Desthuilliers [EMAIL PROTECTED]

 Brendon Towle wrote:
 Some of your Lisp translations are subtly off...

 Seems correct to me. Lisp lists are linked lists, not arrays.


 From: sturlamolden [EMAIL PROTECTED]

 If you want to make a chained structure, then perhaps you know LISP?
 This is what the basic machinery of LISP looks like in Python:

 def cons(a,b)
return [a,b]

 should be:
 return [a].extend(b)

 A Lisp cons is made of a reference to it's content and a reference to
 the rest of the list, so cons = lambda a, b : [a, b] seems the most
 straightforward translation.
 
 Yes, a lisp cons is a pair of references as you describe. However, the
 following lisp call:
 
 ? (cons item list)
 
 returns a single level list, 

returns a single level *Lisp* list - ie, a linked list.

 with item as its new first item, and the
 original contents of list as the remainder of the list. The OP's code
 doesn't do that; it returns a list of two items, with list as the
 second item.

It returns a structure made of a reference to the new item and a
reference to the original list. Which is exactly what Lisp's cons does
AFAIK.

 To put it another way, the following code is always true in Lisp:
 
 ? (= (length (cons item list)) (1+ (length list)))
 
 But the OP's code only allows that to be true when list is of length 1.

Not if you're writing the appropriate length function:

def length(linkedlist):
  return cdr(linkedlist) and  1 + length(cdr(linkedlist)) or 1

You obviously can't use the Python builtin len() here.

 
 I suppose, of course, that you could claim that the following Lisp list:
 
   (1 2 3 4)
 
 should translate into the following Python list:
 
   [1, [2, [3, [4

Should actually be
[1, [2, [3, [4, []

The internal representation of a Lisp list is really (1 (2 (3 (4 (),
not (1 2 3 4).

If it's the fact the proposed translation uses Python lists internally
that bother you, you could also implement it with a more heavyweight
solution:

class cons(object):
  def __init__(self, car, cdr=None):
self.car = car
self.cdr = cdr
  def __repr__(self):
return cons %s %s % (self.car, self.cdr)

def llist(*args):
alist = None
for item in reversed(args):
alist = cons(item, alist)
print alist
return alist

def cdr(acons):
  return acons.cdr

def car(acons):
  return acons.car

def length(llist):
  if cdr(llist) is None:
return 1
  return 1 + length(cdr(llist))


 But, I think that's a bit silly.

It's *of course* a bit silly[1] - Python is not Lisp. But it's a clear
illustration of the difference between Python lists and Lisp lists !-)

[1] OTHO, using this with tuples may be (or may have been) a more
efficient implementation for stacks than plain Python lists, cf Mark
Lutz, Programming Python, 2nd edition.

 
 def car(structure)
return structure[0]

 def cdr(structure)
return structure[1]

 should be:
 return structure[1:]

 idem.
 
 I should have pointed out, of course, that the original definition of
 CDR was correct given the original (incorrect) definition of cons.

The original definition of cons() was by no mean incorrect.

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best way to get data into a new instance?

2006-09-28 Thread Fredrik Lundh
John Salerno wrote:

 So I'm wondering, is the best way to get all this information into the 
 object to just have a really long __init__ method that takes each argument?

really long __init__ argument lists only work if most argument have 
reasonable defaults, and you're prepared to use keyword arguments when 
creating the objects.  and don't mind writing the field names over and 
over and over and over again.

really long positional argument lists are really bad; it's way too easy 
to mess up the order, and end up stuffing the wrong thing in the wrong 
field.

there's no need to use this if you're using the class as a record; 
just set the relevant attributes and be done with it.

(see the simulate UI part of my code example for how to do that).

/F

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


Re: XML parser that sorts elements?

2006-09-28 Thread jmike
Paul McGuire wrote:
  doc.childNodes[0].childNodes = sorted(
 ...   [n for n in doc.childNodes[0].childNodes
 ... if n.nodeType==doc.ELEMENT_NODE],
 ...   key=lambda n:n.nodeName)
  print doc.toprettyxml()
 ?xml version=1.0 ?
 booga bar=2 foo=1
 blah
 goodbye
 /blah
 well
 hello
 /well
 /booga

My requirements changed a bit, so now I'm sorting second level elements
by their values of a specific attribute (where the specific attribute
can be chosen).  But the solution is still mainly what you posted here.
 It was just a matter of supplying a different function for 'key'.
It's up and running live now and all is well.  Thanks again!

(A bonus side effect of this is that it let me sneak sorted() into
our test infrastructure, which gave me reason to get our IT guys to
upgrade a mismash of surprisingly old Python versions up to Python 2.5
everywhere.)

--JMike

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


Re: best way to get data into a new instance?

2006-09-28 Thread Bruno Desthuilliers
John Salerno wrote:
 Let's pretend I'm creating an Employee class, which I will later
 subclass for more specific jobs.

Let's pretend it might be a good design... g

 Each instance will have stuff like a
 name, title, degrees held, etc. etc.
 
 So I'm wondering, is the best way to get all this information into the
 object to just have a really long __init__ method that takes each argument?

what about optional arguments ?

class Employee(object):
  def __init__(self, id, name, **kw):
self.id = id
self.name = name
self.titles = kw.get('titles', [])
self.birthdate = kw.get(birthdate, None)
# etc

 Does a question like this depend on how the class will be used? 

I don't think it would make sens to design anything without any hint
about how it's supposed to be used.

My 2 cents
-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: for: else: - any practical uses for the else clause?

2006-09-28 Thread Sion Arrowsmith
Ben Sizer [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
 Yeah, I use it from time to time:

 for foo in bar:
 if foo matches some condition:
 print sail to tahiti!
 break
 else:
 print abandon ship!

As a C++ programmer (which I'm sure undermines my argument before
you've even read it...), this feels 'backwards' to me. Although I am no
purist, the 'else' typically implies failure of a previous explicit
condition, yet in this case, it's executed by default, when the
previous clause was successfully executed. It would seem more natural
if the else clause was triggered by 'bar' being empty, [ ... ]

It does:

 for foo in []:
... print foo
... else:
... print 'else'
...
else

I think it's clearer to see by comparing while with if:

if False:
do nothing
else:
do something

while False:
do nothing
else:
do something

and getting to the for behaviour from while is trivial.

That said, I've not had much call for it and was kind of surprised to
find myself writing a genuine for ... else the other week. But it was
the obvious way to do the task at hand, and I was happy it was there.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Fredrik Lundh
Ramon Diaz-Uriarte wrote:

 Going back to the original question, a related question: does anybody
 know why there are so few books on data structures and algorithms that
 use Python?

Probably because Python has better than textbook implementations of 
core structures, and better than textbook implementations of many core 
algorithms, so lots of things can be done more efficiently by combining 
existing structures and algorithms than by using textbook algorithms.

/F

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


Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Steve Holden enlightened us with:
 Otherwise you might as well say that any costs associated with using
 a piece of software (including purchase pricing) are hostile to the
 wants of the user.

It's true. People pay because they have to, but they'd rather not.

Sybren
-- 
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Steve Holden
Brendon Towle wrote:
 Some of your Lisp translations are subtly off...
 
 
 
Date: 28 Sep 2006 02:49:50 -0700
From: sturlamolden [EMAIL PROTECTED]
Subject: Re: Questions on Using Python to Teach Data Structures and
  Algorithms
To: python-list@python.org

If you want to make a chained structure, then perhaps you know LISP?
This is what the basic machinery of LISP looks like in Python:

def cons(a,b)
   return [a,b]
 
 
 should be:
  return [a].extend(b)
 
But surely this will return None?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Mike Playle enlightened us with:
 Imagine you're an IT manager for a medium-to-large company who wants
 to use some expensive piece of software. You talk to the vendor and
 buy a licence to use the software on up to 5 machines at once, but
 you don't know who in the company will want to use it, so for
 convenience you want to install it on every PC in the building.

 Having installed it all over the shop, how can you be sure that only
 5 people are using it at any one time?

Write the software in such a way that it needs a certificate on a
smartcard, then supply the company with five smartcards.

Sybren
-- 
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best way to get data into a new instance?

2006-09-28 Thread John Salerno
John Salerno wrote:
 Let's pretend I'm creating an Employee class, which I will later 
 subclass for more specific jobs. Each instance will have stuff like a 
 name, title, degrees held, etc. etc.
 
 So I'm wondering, is the best way to get all this information into the 
 object to just have a really long __init__ method that takes each argument?
 
 Does a question like this depend on how the class will be used? I'm 
 trying to construct it in a way that is independent of, say, the GUI 
 interface that will be used, but I can't help but think that if all the 
 data is entered into a GUI, then passed programmatically to the class, 
 then it's no big deal because it happens behind the scenes. But if, for 
 instance, someone manually created a new instance, they would have a ton 
 of arguments to type in each time. Granted, even with the GUI they are 
 basically typing in arguments, but in the manual case you'd have to type 
 in the call to the class, the parentheses, commas, quotes around the 
 strings, etc. (But still, I'm trying not to let a specific interface 
 influence the construction of what should probably be a completely 
 independent class implementation.)
 
 Thanks.

Thanks again guys! I guess I'm letting all these little getting 
started questions hang me up too much. I should just start coding like 
Fredrik suggested ages ago and find out the bad design ideas for myself. :)

Right now I started messing around with designing the GUI that will be 
used to input the data. It's much easier, I guess because it's just a 
matter of *doing* and not really figuring things out, but that's also 
why it gets tedious rather quickly!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Whither binary search?

2006-09-28 Thread Neil Cerutti
On 2006-09-28, Sion Arrowsmith [EMAIL PROTECTED] wrote:
 John Machin [EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
 well, people tend to use dictionaries when they need to look things up
 quickly...
... like those paper dictionaries with the words in alphabetical order
:-)

 ... where you'll notice that the really big ones are divided up
 into buckets (which just happen to be keyed on initial letter).

 Truth is that humans are lot better than computers at general
 insertion sort, and its lookup equivalent, whereas computers
 are much better at calculating hashes. So we each use a
 dictionary implementation that plays to our strengths.

Thanks all, for the help.

In the end, perhaps prophetically, it turned out my data wasn't
really fully sorted after all. I put together a short function to
translate my raw data into a dictionary, and that was the end of
my problem.

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


Re: License / Registration key enabled software

2006-09-28 Thread Steve Holden
Sybren Stuvel wrote:
 Mike Playle enlightened us with:
 
Imagine you're an IT manager for a medium-to-large company who wants
to use some expensive piece of software. You talk to the vendor and
buy a licence to use the software on up to 5 machines at once, but
you don't know who in the company will want to use it, so for
convenience you want to install it on every PC in the building.

Having installed it all over the shop, how can you be sure that only
5 people are using it at any one time?
 
 
 Write the software in such a way that it needs a certificate on a
 smartcard, then supply the company with five smartcards.
 
And you guarantee that the contents of the smartcard is only used by one 
user at a time by building a licensing system for the smartcards?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: windev vs python SOS

2006-09-28 Thread Sebastian Kaliszewski
stéphane bard wrote:
 hello, my boss ask me to prefer windev to python.
 I have to argue
 
  - python work on multiple platform (linux, mac, windows)
 A good point but it didn't interest him. Because
 we want to choose a language for prototyping.
 So multi platform is not enough.
 
  - python and windev are fast to develop
 
  - windev as a good IDE, python? boa-constructor is ok with wxpython
 
  - python is open source (that's not an argument for my boss, sorry 
 it's a boss ...)
 
 any idea for a strong argument ?

Python is widely known and tested, windev is not. Stuff not widely used (and 
thus not well verified by Real World(tm)) is a Big Business Risk(tm). Things 
looking pretty on marketing presentations might show its ugly head in Real 
Life(tm) where Real Money(tm) is at stake (and in fact they do in vast 
majority of cases).

Python is widely known and has Good Track Record(tm). Windev has not.

Python is known to integrate well into Windows. Is your boss really sure 
that windev is good there? How about various corner cases?

Does your boss know about .net? Tell him about IronPython (If Microsoft 
thinks its good, why your boss should not?). If your boss thinks .net is 
crap and Java rules, tell him about Jython.

It's relatively easy to find (hire) Python programmers. It's not true in 
case of windev programmers. If your boss needs more people or some people 
leave (and thus must be replaced), it's a Real Cost(tm) to train new people 
new windev tricks. Is your boss willing to take the risk that new people 
will need 1-2 months to get fluent with windev (as he may well forget about 
hiring trained windev developer in a reasonable amount of time, while hiring 
trained python developer is possible).


rgds
-- 
Sebastian Kaliszewski
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XSLT speed comparisons

2006-09-28 Thread Larry Bates
Jan Dries wrote:
 Larry Bates wrote:
 Damian wrote:
 [...]
  What I've got is:
  two websites, one in ASP.NET v2 and one in Python 2.5 (using 4suite for
  XML/XSLT)
  both on the same box (Windows Server 2003)
  both using the same XML, XSLT, CSS
 
  The problem is, the Python version is (at a guess) about three times
  slower than the ASP one. I'm very new to the language and it's likely
  that I'm doing something wrong here:
 [...]
 
 For max speed you might want to try pyrxp:

 http://www.reportlab.org/pyrxp.html

 
 Except that pyrxp, to the best of my knowledge, is an XML parser and
 doesn't support XSLT, which is a requirement for Damian.
 
 Regards,
 Jan
Oops, I should have read the OPs post closer.

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


  1   2   3   >